diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-12-05 16:30:45 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-12-05 16:30:45 +0000 |
commit | a1e68ff6761fe316671e760785ce27e376053991 (patch) | |
tree | c4213d176fab48220e7a1964fd876f42549da4dc | |
parent | 1a26f8e97d214ae49dda536b8b27a3175e174fae (diff) | |
download | urpmi-a1e68ff6761fe316671e760785ce27e376053991.tar urpmi-a1e68ff6761fe316671e760785ce27e376053991.tar.gz urpmi-a1e68ff6761fe316671e760785ce27e376053991.tar.bz2 urpmi-a1e68ff6761fe316671e760785ce27e376053991.tar.xz urpmi-a1e68ff6761fe316671e760785ce27e376053991.zip |
- urpmi.addmedia:
o exit code 1 when a medium can't be added
and simplifies a mess in urpmi.addmedia: this mess is not needed anymore since
update_media() will exit on error
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | urpm/media.pm | 3 | ||||
-rwxr-xr-x | urpmi.addmedia | 28 |
3 files changed, 9 insertions, 23 deletions
@@ -3,6 +3,7 @@ o leave early with error if no medium were successfull updated - drop translated man pages (they are too old) - urpmi.addmedia: + o exit code 1 when a medium can't be added o enhance parsing of urls with login:password for logins with "@" so that password doesn't end up in urpmi.cfg diff --git a/urpm/media.pm b/urpm/media.pm index c262900d..363fe860 100644 --- a/urpm/media.pm +++ b/urpm/media.pm @@ -1808,8 +1808,11 @@ sub update_media { $rc or _update_medium_first_pass_failed($urpm, $medium); } + $urpm->{debug} and $urpm->{debug}('update_medium: ' . join(' ', map { "$_=$updates_result{$_}" } keys %updates_result)); + if ($updates_result{1} == 0) { #- only errors/unmodified, leave now + #- (this ensures buggy added medium is not added to urpmi.cfg) return $updates_result{error} == 0; } diff --git a/urpmi.addmedia b/urpmi.addmedia index 0ef5b807..988c39a8 100755 --- a/urpmi.addmedia +++ b/urpmi.addmedia @@ -75,18 +75,6 @@ and [options] are from exit 1; } -#- remove quietly the failing media. -sub remove_failed { - my ($urpm, @media) = @_; - if (@media) { - print STDERR join("\n", map { N("unable to update medium \"%s\"\n", $_->{name}) } @media); - local $urpm->{log} = sub {}; - urpm::media::remove_selected_media($urpm); - urpm::media::update_media($urpm, %options, quiet => 1); - exit(1); - } -} - $ENV{PATH} = "/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"; delete @ENV{qw(ENV BASH_ENV IFS CDPATH)}; @@ -118,6 +106,7 @@ if (!-e $urpm->{config}) { my $_urpmi_lock = urpm::lock::urpmi_db($urpm, 'exclusive', wait => $options{wait_lock}); urpm::media::read_config($urpm); +my $ok = 1; if ($options{distrib}) { $with || $relative_hdlist and usage N("no need to give <relative path of hdlist> with --distrib"); @@ -145,15 +134,9 @@ if ($options{distrib}) { nolock => $options{nolock}, ask_media => $add_media_callback, ); - local $SIG{INT} = sub { - remove_failed($urpm, grep { $_->{modified} } @{$urpm->{media}}); - exit(1); - }; - urpm::media::update_media($urpm, %options, + $ok = urpm::media::update_media($urpm, %options, quiet => $options{verbose} < 0, callback => \&urpm::download::sync_logger); - remove_failed($urpm, grep { $_->{modified} } @{$urpm->{media}}); - } else { $name or usage(); @@ -180,16 +163,15 @@ if ($options{distrib}) { remove_failed($urpm, $medium) if $medium && $medium->{modified}; exit(1); }; - urpm::media::update_media($urpm, %options, + $ok = urpm::media::update_media($urpm, %options, quiet => $options{verbose} < 0, callback => \&urpm::download::sync_logger); - #- check creation of media - my $medium = urpm::media::name2medium($urpm, $name) or die N("unable to create medium \"%s\"\n", $name); - remove_failed($urpm, $medium) if $medium->{modified}; } } #- try to umount removable devices which may have been mounted. urpm::removable::try_umounting_removables($urpm); +exit($ok ? 0 : 1); + # vim:ts=8:sts=4:sw=4 |