aboutsummaryrefslogtreecommitdiffstats
path: root/gurpmi.addmedia
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2006-03-07 17:23:48 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2006-03-07 17:23:48 +0000
commitfb0b431ddf11ca2d50580d957c375f22cae829b7 (patch)
tree3b5488f6db33a5558f2c41e176c5085ca63a6fc9 /gurpmi.addmedia
parenta1beaa11767db24ff2f7c23976774ee1331b1754 (diff)
downloadrpmdrake-fb0b431ddf11ca2d50580d957c375f22cae829b7.tar
rpmdrake-fb0b431ddf11ca2d50580d957c375f22cae829b7.tar.gz
rpmdrake-fb0b431ddf11ca2d50580d957c375f22cae829b7.tar.bz2
rpmdrake-fb0b431ddf11ca2d50580d957c375f22cae829b7.tar.xz
rpmdrake-fb0b431ddf11ca2d50580d957c375f22cae829b7.zip
Let gurpmi.addmedia be able to add several media at once
Diffstat (limited to 'gurpmi.addmedia')
-rwxr-xr-xgurpmi.addmedia57
1 files changed, 45 insertions, 12 deletions
diff --git a/gurpmi.addmedia b/gurpmi.addmedia
index 7a5691ca..3372e8e3 100755
--- a/gurpmi.addmedia
+++ b/gurpmi.addmedia
@@ -73,27 +73,60 @@ if ($ARGV[0] =~ /^-?-update/) {
$update = 1;
shift @ARGV;
}
-my ($name, $url, $with, $with_hdlist) = @ARGV;
-if ($url !~ m,^(file://|ftp://|http://|removable://), || $with && !$with_hdlist) {
- interactive_msg('gurpmi.addmedia',
- N("Unable to add medium, wrong or missing arguments"));
- myexit(-1);
+
+my @addmedia_args;
+my @names;
+
+while (@ARGV) {
+ my ($name, $url, $with, $with_hdlist) = @ARGV;
+ $with eq 'with' or ($with, $with_hdlist) = (undef, undef);
+ if ($url !~ m,^(file://|ftp://|http://|removable://), || $with && !$with_hdlist) {
+ interactive_msg('gurpmi.addmedia',
+ N("Unable to add medium, wrong or missing arguments"));
+ myexit(-1);
+ }
+ push @addmedia_args, [ $name, $url, $with, $with_hdlist ];
+ push @names, $name;
+ shift @ARGV for 1 .. ($with ? 4 : 2);
}
-$fromfile and do { interactive_msg('gurpmi.addmedia',
+$fromfile and do {
+ interactive_msg('gurpmi.addmedia',
N("%s
Is it ok to continue?",
-N("You are about to add a new packages medium, `%s'.
+@names > 1
+? N("You are about to add new packages media, %s.
+That means you will be able to add new software packages
+to your system from these new media.", join ", ", @names)
+: N("You are about to add a new packages medium, `%s'.
That means you will be able to add new software packages
-to your system from that new medium.", $name)),
- yesno => 1) or myexit(-1) };
+to your system from that new medium.", $names[0])
+),
+ yesno => 1) or myexit(-1);
+};
my $urpm = urpm->new;
$urpm->read_config;
-if (add_medium_and_check($urpm, { probe_with => !$with }, $name, $url, $with_hdlist, update => $update)) {
- interactive_msg('gurpmi.addmedia',
- N("Successfully added medium `%s'.", $name)) if !$silent_success;
+my $success = 1;
+for (@addmedia_args) {
+ #- NB: that short circuits
+ $success = $success && add_medium_and_check(
+ $urpm,
+ { probe_with => !$_->[2] },
+ $_->[0],
+ $_->[1],
+ $_->[3],
+ update => $update,
+ );
+}
+if ($success) {
+ interactive_msg(
+ 'gurpmi.addmedia',
+ @names > 1
+ ? N("Successfully added media %s.", join ", ", @names)
+ : N("Successfully added medium `%s'.", $names[0])
+ ) if !$silent_success;
myexit(0);
} else {
myexit(-1);