summaryrefslogtreecommitdiffstats
path: root/urpmi.addmedia
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-04-11 14:10:59 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-04-11 14:10:59 +0000
commit074e96fcc7db23d842f1558ca2b841454d952471 (patch)
treeb1ab342d3d1ec108c399a44435adf87e112340f9 /urpmi.addmedia
parent94dfae1c5dd5ca4e85f9e3b9a5d5c8ba6c6158bf (diff)
downloadurpmi-074e96fcc7db23d842f1558ca2b841454d952471.tar
urpmi-074e96fcc7db23d842f1558ca2b841454d952471.tar.gz
urpmi-074e96fcc7db23d842f1558ca2b841454d952471.tar.bz2
urpmi-074e96fcc7db23d842f1558ca2b841454d952471.tar.xz
urpmi-074e96fcc7db23d842f1558ca2b841454d952471.zip
Code factorization
Diffstat (limited to 'urpmi.addmedia')
-rwxr-xr-xurpmi.addmedia31
1 files changed, 15 insertions, 16 deletions
diff --git a/urpmi.addmedia b/urpmi.addmedia
index 82c0e1db..9cb57822 100755
--- a/urpmi.addmedia
+++ b/urpmi.addmedia
@@ -76,6 +76,17 @@ and [options] are from
exit 0;
}
+#- 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->remove_selected_media;
+ $urpm->update_media(%options, callback => \&urpm::download::sync_logger);
+ }
+}
+
#- parse /etc/urpmi/mirror.config if present, or use default mdk mirror.
#- the --from option overrides this setting.
if ($options{mirrors_url}) {
@@ -114,14 +125,8 @@ if ($options{distrib}) {
$urpm->add_distrib_media($name, $url, virtual => $options{virtual}, update => $options{update}, probe_with => $options{probe_with});
$urpm->update_media(%options, callback => \&urpm::download::sync_logger);
+ remove_failed($urpm, grep { $_->{modified} } @{$urpm->{media}});
- if (my @unsynced_media = grep { $_->{modified} } @{$urpm->{media}}) {
- print STDERR join("\n", map { N("unable to update medium \"%s\"\n", $_->{name}) } @unsynced_media);
- #- remove quietly the failing media.
- $urpm->{log} = sub {};
- $urpm->remove_selected_media;
- $urpm->update_media(%options, callback => \&urpm::download::sync_logger);
- }
} else {
$name or usage;
@@ -139,23 +144,17 @@ if ($options{distrib}) {
);
urpm::download::copy_cmd_line_proxy($name);
if ($options{raw}) {
- $urpm->write_config();
+ $urpm->write_config;
} else {
$urpm->update_media(%options, callback => \&urpm::download::sync_logger);
#- check creation of media
my ($medium) = grep { $_->{name} eq $name } @{$urpm->{media}};
$medium or die N("unable to create medium \"%s\"\n", $name);
- if ($medium->{modified}) {
- print STDERR N("unable to update medium \"%s\"\n", $name);
- #- remove quietly the failing media.
- $urpm->{log} = sub {};
- $urpm->remove_selected_media;
- $urpm->update_media(%options, callback => \&urpm::download::sync_logger);
- }
+ remove_failed($urpm, $medium) if $medium->{modified};
}
}
#- try to umount removable devices which may have been mounted.
$urpm->try_umounting_removables;
-=for vim:ts=8:sts=4:sw=4
+# vim:ts=8:sts=4:sw=4