From 5a6bdbc17631cb7ac32dbfe7e0b6dfa21feb4646 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Wed, 3 Sep 2003 18:23:07 +0000 Subject: fix not reporting any error when updating of media fail (#5212) --- edit-urpm-sources.pl | 4 ++-- rpmdrake | 2 +- rpmdrake.pm | 33 +++++++++++++++++++++------------ rpmdrake.spec | 2 ++ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/edit-urpm-sources.pl b/edit-urpm-sources.pl index aaef7e43..6b80e3da 100755 --- a/edit-urpm-sources.pl +++ b/edit-urpm-sources.pl @@ -163,7 +163,7 @@ really want to replace it?"), yesno => 1) or return 0; $urpm->select_media($i{name}); $urpm->remove_selected_media; } - add_medium_and_check($urpm, N("Please wait, adding medium..."), + add_medium_and_check($urpm, { probe_with => $probe }, $i{name}, $make_url{$type}, $i{hdlist}, update => $type eq 'security'); return 1; @@ -212,7 +212,7 @@ sub edit_callback { standalone::explanations("Removing medium $name"); $urpm->select_media($name); $urpm->remove_selected_media; - add_medium_and_check($urpm, N("Please wait, updating medium..."), {}, $name, $url, $with_hdlist, update => $update); + add_medium_and_check($urpm, {}, $name, $url, $with_hdlist, update => $update); return 1; } return 0; diff --git a/rpmdrake b/rpmdrake index 00dc8f0c..1fd044fb 100755 --- a/rpmdrake +++ b/rpmdrake @@ -930,7 +930,7 @@ launch the Software Media Manager, and then add a `Security updates' medium. Then, restart MandrakeUpdate.", $update_name)), myexit(-1); - add_medium_and_check($urpm, N("Please wait, adding medium..."), {}, + add_medium_and_check($urpm, {}, $update_name, make_url_mirror($m), '../base/hdlist.cz', update => 1); @update_medias = { name => $update_name }; #- hack to simulate a medium for parsing of descriptions } diff --git a/rpmdrake.pm b/rpmdrake.pm index c7ae0dfe..7888cac8 100644 --- a/rpmdrake.pm +++ b/rpmdrake.pm @@ -408,10 +408,24 @@ sub update_sources { remove_wait_msg($w); } +sub update_sources_check { + my ($urpm, $options, @media) = @_; + my @error_msgs; + local $urpm->{fatal} = sub { push @error_msgs, $_[1] }; + local $urpm->{error} = sub { push @error_msgs, $_[0] }; + update_sources($urpm, %$options, noclean => 1); + if (any { member($_->{name}, @media) && $_->{modified} } @{$urpm->{media}}) { + interactive_msg('rpmdrake', + N("Unable to update medium; it will be automatically disabled.\n\nErrors:\n%s", + join("\n", @error_msgs))); + } +} + sub update_sources_interactive { my ($urpm, %opts) = @_; my $w = ugtk2->new(N("Update media"), grab => 1, center => 1, %opts); my @buttons; + my @media; gtkadd($w->{window}, gtkpack__(Gtk2::VBox->new(0,5), Gtk2::Label->new(N("Select the media you wish to update:")), @@ -420,7 +434,7 @@ sub update_sources_interactive { gtkpack(create_hbox(), gtksignal_connect(Gtk2::Button->new(N("Update")), clicked => sub { $w->{retval} = any { $_->get_active } @buttons; - each_index { $_->get_active and $urpm->select_media($urpm->{media}[$::i]{name}) } @buttons; + @media = map_index { if_($_->get_active, $urpm->{media}[$::i]{name}) } @buttons; Gtk2->main_quit; }), gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => sub { $w->{retval} = 0; Gtk2->main_quit })))); @@ -428,26 +442,21 @@ sub update_sources_interactive { foreach (@{$urpm->{media}}) { #- force ignored media to be returned alive (forked from urpmi.updatemedia...) $_->{modified} and delete $_->{ignore}; } - update_sources($urpm, noclean => 1); + standalone::explanations("Updating media @media"); + $urpm->select_media(@media); + update_sources_check($urpm, {}, @media); return 1; } return 0; } sub add_medium_and_check { - my ($urpm, $msg, $options) = splice @_, 0, 3; + my ($urpm, $options) = splice @_, 0, 2; standalone::explanations("Adding medium @_"); - my $wait = wait_msg($msg); $urpm->add_medium(@_); - my @error_msgs; - local $urpm->{fatal} = sub { push @error_msgs, $_[1] }; - local $urpm->{error} = sub { push @error_msgs, $_[0] }; - update_sources($urpm, %$options, noclean => 1); - remove_wait_msg($wait); + update_sources_check($urpm, $options, $_[0]); my ($medium) = grep { $_->{name} eq $_[0] } @{$urpm->{media}}; $medium or interactive_msg('rpmdrake', N("Unable to create medium.")); - $medium->{modified} and interactive_msg('rpmdrake', - N("Unable to update medium; it will be automatically disabled.\n\nErrors:\n%s", - join("\n", @error_msgs))); $urpm->write_config; } + diff --git a/rpmdrake.spec b/rpmdrake.spec index c74d4810..af1c454b 100644 --- a/rpmdrake.spec +++ b/rpmdrake.spec @@ -107,6 +107,8 @@ rm -rf $RPM_BUILD_ROOT - use --id - launch the good sub-chapter - add an help button to the Media Editor +- edit-urpm-media: fix not reporting any error when updating of + media fail (#5212) * Tue Sep 02 2003 David Baudens 2.1-33mdk - Update banners -- cgit v1.2.1