summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xurpmi.removemedia56
1 files changed, 29 insertions, 27 deletions
diff --git a/urpmi.removemedia b/urpmi.removemedia
index 1630b162..b29e53ef 100755
--- a/urpmi.removemedia
+++ b/urpmi.removemedia
@@ -3,7 +3,7 @@
# $Id$
#- Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 MandrakeSoft SA
-#- Copyright (C) 2005 Mandriva SA
+#- Copyright (C) 2005, 2006 Mandriva SA
#-
#- This program is free software; you can redistribute it and/or modify
#- it under the terms of the GNU General Public License as published by
@@ -29,14 +29,18 @@ use urpm::download;
$ENV{PATH} = "/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin";
delete @ENV{qw(ENV BASH_ENV IFS CDPATH)};
-sub main {
- my (@toremoves, %options);
+my @toremove;
- $options{noclean} = 1;
- $options{strict_match} = 1;
- $options{verbose} = 1;
+#- default option values
+my %options = (
+ noclean => 1,
+ strict_match => 1,
+ verbose => 1,
+);
+
+{
my $options_end = 0;
- foreach (@_) {
+ foreach (@ARGV) {
$_ eq '--' and $options_end = 1, next;
unless ($options_end) {
/^--?a$/ and $options{all} = 1, next;
@@ -57,30 +61,28 @@ where <name> is a medium name to remove.
exit 0;
};
}
- push @toremoves, $_;
- }
-
- my $urpm = new urpm;
- if ($< != 0) {
- $urpm->{fatal}(1, N("Only superuser is allowed to remove media"));
+ push @toremove, $_;
}
+}
- $options{verbose} > 0 or $urpm->{log} = sub {};
-
- $urpm->read_config;
- urpm::download::set_cmdline_proxy();
- my @entries = map { $_->{name} } @{$urpm->{media}};
+my $urpm = new urpm;
+if ($< != 0) {
+ $urpm->{fatal}(1, N("Only superuser is allowed to remove media"));
+}
- if ($options{all}) {
- @toremoves = @entries;
- @toremoves == 0 and die N("nothing to remove (use urpmi.addmedia to add a media)\n");
- }
- @toremoves == 0 and die N("the entry to remove is missing\n(one of %s)\n", join(", ", @entries));
+$options{verbose} > 0 or $urpm->{log} = sub {};
- $urpm->select_media({ strict_match => $options{strict_match} }, @toremoves);
- $urpm->remove_selected_media;
+$urpm->read_config;
+urpm::download::set_cmdline_proxy();
+my @entries = map { $_->{name} } @{$urpm->{media}};
- $urpm->update_media(noclean => $options{noclean});
+if ($options{all}) {
+ @toremove = @entries;
+ @toremove == 0 and die N("nothing to remove (use urpmi.addmedia to add a media)\n");
}
+@toremove == 0 and die N("the entry to remove is missing\n(one of %s)\n", join(", ", @entries));
+
+$urpm->select_media({ strict_match => $options{strict_match} }, @toremove);
+$urpm->remove_selected_media;
-main(@ARGV);
+$urpm->update_media(noclean => $options{noclean});