diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-12-12 11:17:16 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-12-12 11:17:16 +0000 |
commit | df23d1acfe8752f339f9f69d212cfa240f578796 (patch) | |
tree | 104a01fc795255b3434f1adb915aa621f116d612 | |
parent | 15c0d5414fbeb5b6e2fa65e30cbe99e33b00df20 (diff) | |
download | urpmi-df23d1acfe8752f339f9f69d212cfa240f578796.tar urpmi-df23d1acfe8752f339f9f69d212cfa240f578796.tar.gz urpmi-df23d1acfe8752f339f9f69d212cfa240f578796.tar.bz2 urpmi-df23d1acfe8752f339f9f69d212cfa240f578796.tar.xz urpmi-df23d1acfe8752f339f9f69d212cfa240f578796.zip |
create urpm->new_parse_cmdline and use it
(it may be a little stricter for urpmi since we exit(1) on parse_cmdline error)
-rw-r--r-- | urpm.pm | 7 | ||||
-rw-r--r-- | urpme | 3 | ||||
-rwxr-xr-x | urpmf | 3 | ||||
-rwxr-xr-x | urpmi | 5 | ||||
-rwxr-xr-x | urpmi.addmedia | 3 | ||||
-rwxr-xr-x | urpmi.removemedia | 4 | ||||
-rwxr-xr-x | urpmi.update | 3 | ||||
-rwxr-xr-x | urpmq | 3 |
8 files changed, 14 insertions, 17 deletions
@@ -61,6 +61,13 @@ sub new { $self; } +sub new_parse_cmdline { + my ($class) = @_; + my $urpm = $class->new; + urpm::args::parse_cmdline(urpm => $urpm); + $urpm; +} + sub prefer_rooted { my ($root, $file) = @_; -e "$root$file" ? "$root$file" : $file; @@ -63,8 +63,7 @@ usage: @ARGV or usage(); my @origARGV = @ARGV; -my $urpm = new urpm; -urpm::args::parse_cmdline(urpm => $urpm) or exit(1); +my $urpm = urpm->new_parse_cmdline or exit(1); @l = @ARGV; my $state = {}; @@ -106,8 +106,7 @@ our $expr; # regexp to match against our %uniq; #- parse arguments list. -my $urpm = new urpm; -urpm::args::parse_cmdline(urpm => $urpm) or exit(1); +my $urpm = urpm->new_parse_cmdline or exit(1); defined $expr or usage(); if ($qf eq '%default') { @@ -28,8 +28,6 @@ use urpm::select; use urpm::util qw(untaint difference2 member partition); use urpm::main_loop; -#- contains informations to parse installed system. -my $urpm = new urpm; #URPM::setVerbosity(7); #- default options. @@ -177,8 +175,7 @@ if (member('--restricted', @ARGV)) { @ARGV = @ARGVcopy; } -# Parse command line options -urpm::args::parse_cmdline(urpm => $urpm); +my $urpm = urpm->new_parse_cmdline or exit(1); if (@ARGV && $auto_select) { print STDERR N("Error: can't use --auto-select along with package list.\n"); diff --git a/urpmi.addmedia b/urpmi.addmedia index 988c39a8..6b057e2d 100755 --- a/urpmi.addmedia +++ b/urpmi.addmedia @@ -87,8 +87,7 @@ if ($options{mirrors_url}) { } $options{force} = 0; $options{noclean} = 1; -my $urpm = new urpm; -urpm::args::parse_cmdline(urpm => $urpm) or usage(); +my $urpm = urpm->new_parse_cmdline or usage(); our ($name, $url, $with, $relative_hdlist) = our @cmdline; $options{quiet} = 1 if $options{verbose} < 0; diff --git a/urpmi.removemedia b/urpmi.removemedia index 88e9a823..35f98081 100755 --- a/urpmi.removemedia +++ b/urpmi.removemedia @@ -53,11 +53,9 @@ where <name> is a medium name to remove. $options{noclean} = 1; $options{strict_match} = 1; -my $urpm = new urpm; - our @cmdline; #- set by urpm::args -urpm::args::parse_cmdline(urpm => $urpm) or exit(1); +my $urpm = urpm->new_parse_cmdline or exit(1); if ($< != 0) { $urpm->{fatal}(1, N("Only superuser is allowed to remove media")); diff --git a/urpmi.update b/urpmi.update index ad9d7e01..2e3f3aa8 100755 --- a/urpmi.update +++ b/urpmi.update @@ -59,12 +59,11 @@ $ENV{PATH} = "/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"; delete @ENV{qw(ENV BASH_ENV IFS CDPATH)}; our @cmdline; #- set by urpm::args -my $urpm = new urpm; $options{force} = 0; $options{noclean} = 1; -urpm::args::parse_cmdline(urpm => $urpm) or exit(1); +my $urpm = urpm->new_parse_cmdline or exit(1); if ($< != 0) { $urpm->{fatal}(1, N("Only superuser is allowed to update media")); @@ -117,8 +117,7 @@ sub escape_shell ($) { #- parse arguments list. @ARGV or usage(); -my $urpm = new urpm; -urpm::args::parse_cmdline(urpm => $urpm) or exit(1); +my $urpm = urpm->new_parse_cmdline or exit(1); #- we really don't want logs on stdout, and remove verbose if not asked. $urpm->{info} = sub { print STDERR "$_[0]\n" }; |