summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2008-03-03 15:08:40 +0000
committerThierry Vignaud <tv@mandriva.org>2008-03-03 15:08:40 +0000
commit6ecb1b70b2b7410995a52b4f7fd010f5be0da525 (patch)
treef6ae56b4ec8a42c6ba676c64c21f4a7dc158d38a
parent05ca1f54f8aea97462a1265f3d151a792b838296 (diff)
downloadurpmi-6ecb1b70b2b7410995a52b4f7fd010f5be0da525.tar
urpmi-6ecb1b70b2b7410995a52b4f7fd010f5be0da525.tar.gz
urpmi-6ecb1b70b2b7410995a52b4f7fd010f5be0da525.tar.bz2
urpmi-6ecb1b70b2b7410995a52b4f7fd010f5be0da525.tar.xz
urpmi-6ecb1b70b2b7410995a52b4f7fd010f5be0da525.zip
(gurpmi::parse_command_line) reuse common shared code of urpm::args,
thus fixing --root option
-rw-r--r--NEWS2
-rw-r--r--gurpmi.pm23
-rw-r--r--urpm/args.pm13
3 files changed, 24 insertions, 14 deletions
diff --git a/NEWS b/NEWS
index a499dd1f..6ae7f8c9 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@
o fix download progression using wget
- gurpmi:
o exit immediately on success in automatic mode
+ o fix --root option
+ o reuse common shared code of urpmi
- urpmf, urpmq:
o never display raw downloader output, otherwise output is very messy (#38125)
o do not try to download xml-info if it's not available (#38125)
diff --git a/gurpmi.pm b/gurpmi.pm
index 5660989e..66899af1 100644
--- a/gurpmi.pm
+++ b/gurpmi.pm
@@ -22,6 +22,7 @@ use strict;
use Gtk2;
use urpm::util;
use urpm::msg;
+use urpm::args;
use Exporter;
our @ISA = qw(Exporter);
@@ -53,6 +54,13 @@ sub parse_command_line() {
my @all_rpms;
our %options;
our @names;
+
+ # keep a copy for gurpmi2
+ {
+ local @ARGV = @ARGV;
+ urpm::args::parse_cmdline(urpm => { options => \%options});
+ }
+
# Expand *.urpmi arguments
my @ARGV_expanded;
foreach my $a (@ARGV) {
@@ -64,21 +72,8 @@ sub parse_command_line() {
push @ARGV_expanded, $a;
}
}
- my $nextopt;
foreach (@ARGV_expanded) {
- if ($nextopt) { $options{$nextopt} = $_; undef $nextopt; next }
- if (/^-/) {
- if (/^--(no-verify-rpm|auto-select|auto)$/) {
- $options{$1} = 1;
- next;
- }
- if (/^--(media|searchmedia|root)$/) {
- $nextopt = $1;
- next;
- }
- /^--?[hv?]/ and usage();
- fatal(N("Unknown option %s", $_));
- }
+ next if /^-/;
if (-f $_) {
push @all_rpms, $_;
} else {
diff --git a/urpm/args.pm b/urpm/args.pm
index e5aeec01..759db946 100644
--- a/urpm/args.pm
+++ b/urpm/args.pm
@@ -59,6 +59,16 @@ my %options_spec_all = (
my %options_spec = (
+ gurpmi => {
+ auto => sub { $urpm->{options}{auto} = 1 },
+ 'auto-select' => sub { $urpm->{options}{auto_select} = 1 },
+ 'media|mediums=s' => sub { $urpm->{options}{media} = 1 },
+ "help|h" => sub { gurpmi::usage() },
+ 'root=s' => sub { set_root($urpm, $_[1]) },
+ 'searchmedia|search-media=s' => sub { $urpm->{options}{searchmedia} = 1 },
+ 'verify-rpm!' => sub { $urpm->{options}{'verify-rpm'} = $_[1] },
+ },
+
urpmi => {
"version" => sub { require urpm; print "$tool $urpm::VERSION\n"; exit(0) },
"help|h" => sub {
@@ -338,6 +348,9 @@ my %options_spec = (
);
+$options_spec{gurpmi2} = $options_spec{gurpmi};
+
+
# generate urpmf options callbacks
sub add_urpmf_cmdline_tags {
foreach my $k (@_) {