summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--urpm.pm7
-rw-r--r--urpme3
-rwxr-xr-xurpmf3
-rwxr-xr-xurpmi5
-rwxr-xr-xurpmi.addmedia3
-rwxr-xr-xurpmi.removemedia4
-rwxr-xr-xurpmi.update3
-rwxr-xr-xurpmq3
8 files changed, 14 insertions, 17 deletions
diff --git a/urpm.pm b/urpm.pm
index 9416e4eb..11a3aec9 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -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;
diff --git a/urpme b/urpme
index 71d2ea33..cb0afeb4 100644
--- a/urpme
+++ b/urpme
@@ -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 = {};
diff --git a/urpmf b/urpmf
index 3db657e2..d8d375fb 100755
--- a/urpmf
+++ b/urpmf
@@ -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') {
diff --git a/urpmi b/urpmi
index 1d0e0095..775dc4c7 100755
--- a/urpmi
+++ b/urpmi
@@ -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"));
diff --git a/urpmq b/urpmq
index 0c6fe0cf..5f9176b6 100755
--- a/urpmq
+++ b/urpmq
@@ -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" };