diff options
-rw-r--r-- | urpm/args.pm | 44 | ||||
-rwxr-xr-x | urpmi.addmedia | 18 | ||||
-rwxr-xr-x | urpmi.update | 4 |
3 files changed, 39 insertions, 27 deletions
diff --git a/urpm/args.pm b/urpm/args.pm index f9062727..36e84b79 100644 --- a/urpm/args.pm +++ b/urpm/args.pm @@ -21,6 +21,14 @@ my $urpm; # stores the values of the command-line options our %options; +sub import { + if ($_[1] eq 'options') { + # export the %options hash + no strict 'refs'; + *{caller().'::options'} = \%options; + } +} + # options specifications for Getopt::Long my %options_spec = ( @@ -218,30 +226,30 @@ my %options_spec = ( }, 'urpmi.update' => { - a => \$::options{all}, - c => sub { $::options{noclean} = 0 }, - f => sub { ++$::options{force} }, - z => sub { ++$::options{compress} }, - update => \$::options{update}, - 'force-key' => \$::options{forcekey}, - 'limit-rate=s' => \$::options{limit_rate}, - 'no-md5sum' => \$::options{nomd5sum}, + a => \$options{all}, + c => sub { $options{noclean} = 0 }, + f => sub { ++$options{force} }, + z => sub { ++$options{compress} }, + update => \$options{update}, + 'force-key' => \$options{forcekey}, + 'limit-rate=s' => \$options{limit_rate}, + 'no-md5sum' => \$options{nomd5sum}, 'noa|d' => \my $dummy, # default, keeped for compatibility '<>' => sub { push @::toupdates, $_[0] }, }, 'urpmi.addmedia' => { - 'probe-synthesis' => sub { $::options{probe_with} = 'synthesis' }, - 'probe-hdlist' => sub { $::options{probe_with} = 'hdlist' }, - 'no-probe' => sub { $::options{probe_with} = undef }, - distrib => sub { $::options{distrib} = undef }, - 'from=s' => \$::options{mirrors_url}, - 'version=s' => \$::options{version}, - 'arch=s' => \$::options{arch}, - virtual => \$::options{virtual}, + 'probe-synthesis' => sub { $options{probe_with} = 'synthesis' }, + 'probe-hdlist' => sub { $options{probe_with} = 'hdlist' }, + 'no-probe' => sub { $options{probe_with} = undef }, + distrib => sub { $options{distrib} = undef }, + 'from=s' => \$options{mirrors_url}, + 'version=s' => \$options{version}, + 'arch=s' => \$options{arch}, + virtual => \$options{virtual}, '<>' => sub { if ($_[0] =~ /^--distrib-(.*)$/) { - $::options{distrib} = $1; + $options{distrib} = $1; } else { push @::cmdline, $_[0]; @@ -297,6 +305,8 @@ urpm::args - command-line argument parser for the urpm* tools =head1 SYNOPSIS + urpm::args::parse_cmdline(); + =head1 DESCRIPTION =cut diff --git a/urpmi.addmedia b/urpmi.addmedia index 803dca8c..8157db01 100755 --- a/urpmi.addmedia +++ b/urpmi.addmedia @@ -22,7 +22,7 @@ use strict; use urpm; -use urpm::args; +use urpm::args 'options'; use urpm::msg; # Default mirror list @@ -79,16 +79,19 @@ and [options] are from } sub main { - our %options; #- parse /etc/urpmi/mirror.config if present, or use default mandrake mirror. - if (-e "/etc/urpmi/mirror.config") { - local (*F, $_); - open F, "/etc/urpmi/mirror.config"; - while (<F>) { + # the --from option overrides this setting. + if ($options{mirrors_url}) { + $mirrors = $options{$mirrors_url}; + } + elsif (-e "/etc/urpmi/mirror.config") { + local $_; + open my $fh, "/etc/urpmi/mirror.config"; + while (<$fh>) { chomp; s/#.*$//; s/^\s*//; s/\s*$//; /^url\s*=\s*(.*)/ and $mirrors = $1; } - close F; + close $fh; } $options{force} = 0; $options{noclean} = 1; @@ -111,7 +114,6 @@ sub main { #- -h always set, updates should allow setting update flag. $options{distrib} eq 'updates' and $options{update} = 1; #- official site by default. - $options{from} ||= $mirrors; #- get default value unless already provided. unless ($options{version} && $options{arch}) { my $db = URPM::DB::open; diff --git a/urpmi.update b/urpmi.update index 2a591329..5a5abc7f 100755 --- a/urpmi.update +++ b/urpmi.update @@ -20,7 +20,7 @@ use strict; use urpm; -use urpm::args; +use urpm::args 'options'; use urpm::msg; sub usage { @@ -45,7 +45,7 @@ where <name> is a medium name to update. } sub main { - our (@toupdates, %options); + our @toupdates; my $urpm = new urpm; $options{force} = 0; |