From 5bb188d99416f16b21a34f706a410eaff4a994b3 Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Mon, 27 Jan 2003 17:36:54 +0000 Subject: 4.2-14mdk --- urpm.pm | 15 +++++++++++++-- urpmi | 56 ++++++++++++++++++++++++++------------------------------ urpmi.spec | 7 ++++++- 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/urpm.pm b/urpm.pm index 66f432e7..ff46799c 100644 --- a/urpm.pm +++ b/urpm.pm @@ -471,8 +471,19 @@ sub read_config { while () { chomp; s/#.*$//; s/^\s*//; s/\s*$//; $_ eq '}' and last; - /^(\S+)\s*:(.*)$/ and $urpm->{options}{$1} = $2, next; - /^(\S+)$/ and $urpm->{options}{$1} = undef, next; + #- check for boolean variables first, and after that valued variables. + if (my ($no, $k, $v) = /^(no-)?(verify-rpm|fuzzy|allow-(?:force|nodeps)|(?:pre|post)-clean)(?:\s*:\s*(.*))?$/) { + unless (exists $urpm->{options}{$k}) { + $urpm->{options}{$k} = $v eq '' || $v =~ /^(yes|on|1)$/i; + $no and $urpm->{options}{$k} = ! $urpm->{options}{$k}; + } + next; + } elsif (my ($k, $v) = /^(limit-rate|excludepath)\s*:\s*(.*)$/) { + unless (exists $urpm->{options}{$k}) { + $v =~ /^'([^']*)'$/ and $v = $1; $v =~ /^"([^"]*)"$/ and $v = $1; + $urpm->{options}{$k} = $v; + } + } $_ and $urpm->{error}(_("syntax error in config file at line %s", $.)); } next; }; diff --git a/urpmi b/urpmi index 72bf1782..cf0e6926 100755 --- a/urpmi +++ b/urpmi @@ -22,6 +22,9 @@ use urpm; #- get I18N translation method. import urpm _; +#- contains informations to parse installed system. +my $urpm = new urpm; + #- default options. my $update = 0; my $media = ''; @@ -30,31 +33,23 @@ my $auto = 0; my $allow_medium_change = 0; my $auto_select = 0; my $force = 0; -my $allow_nodeps = undef; #0; -my $allow_force = undef; #0; my $parallel = ''; my $sync = undef; -my $limit_rate = undef; #0; my $X = 0; my $WID = 0; my $all = 0; my $rpm_opt = "vh"; my $use_provides = 1; -my $fuzzy = undef; #0; my $src = 0; my $install_src = 0; my $clean = 0; my $noclean = 0; -my $pre_clean_cache = 0; -my $post_clean_cache = 1; my $verbose = 0; my $root = ''; my $bug = ''; my $env = ''; my $log = ''; -my $verify_rpm = undef; #1; my $test = 0; -my $excludepath = undef; #0; my $uid; my @files; @@ -121,9 +116,6 @@ usage: exit(0); } -#- params contains informations to parse installed system. -my $urpm = new urpm; - #- parse arguments list. my @nextargv; my $command_line = join " ", @ARGV; @@ -138,23 +130,23 @@ while (defined($_ = shift @ARGV)) { /^--auto$/ and do { $auto = 1; next }; /^--allow-medium-change$/ and do { $allow_medium_change = 1; next }; /^--auto-select$/ and do { $auto_select = 1; next }; - /^--fuzzy$/ and do { $fuzzy = 1; next }; + /^--(no-)?fuzzy$/ and do { $urpm->{options}{fuzzy} = !$1; next }; /^--src$/ and do { $src = 1; next }; /^--install-src$/ and do { $install_src = 1; next }; /^--clean$/ and do { $clean = 1; $noclean = 0; next }; - /^--noclean$/ and do { $clean = $pre_clean_cache = $post_clean_cache = 0; $noclean = 1; next }; - /^--(no-)?pre-clean$/ and do { $pre_clean_cache = !$1; next }; - /^--(no-)?post-clean$/ and do { $post_clean_cache = !$1; next }; + /^--noclean$/ and do { $clean = $urpm->{options}{'pre-clean'} = $urpm->{options}{'post-clean'} = 0; $noclean = 1; next }; + /^--(no-)?pre-clean$/ and do { $urpm->{options}{'pre-clean'} = !$1; next }; + /^--(no-)?post-clean$/ and do { $urpm->{options}{'post-clean'} = !$1; next }; /^--force$/ and do { $force = 1; next }; - /^--allow-nodeps$/ and do { $allow_nodeps = 1; next }; - /^--allow-force$/ and do { $allow_force = 1; next }; + /^--allow-nodeps$/ and do { $urpm->{options}{'allow-nodeps'} = 1; next }; + /^--allow-force$/ and do { $urpm->{options}{'allow-force'} = 1; next }; /^--parallel$/ and do { push @nextargv, \$parallel; next }; /^--wget$/ and do { $sync = sub { my $options = shift @_; if (ref $options) { $options->{prefer} = 'wget' } else { $options = { dir => $options, prefer => 'wget' } } urpm::sync_webfetch($options, @_) }; next }; /^--curl$/ and do { $sync = \&urpm::sync_webfetch; next }; - /^--limit-rate$/ and do { push @nextargv, \$limit_rate; next }; + /^--limit-rate$/ and do { $urpm->{options}{'limit-rate'} = undef; push @nextargv, \$urpm->{options}{'limit-rate'}; next }; /^--proxy$/ and do { my ($proxy, $port) = ($_ = shift @ARGV) =~ m,^(?:http://)?([^:]+(:\d+)?)/*$, or die _("bad proxy declaration on command line\n"); @@ -176,11 +168,11 @@ while (defined($_ = shift @ARGV)) { /^--WID$/ and do { push @nextargv, \$WID; next }; /^--best-output$/ and do { $X ||= $ENV{DISPLAY} && -x "/usr/sbin/grpmi" && system('/usr/X11R6/bin/xtest', '') == 0; next }; - /^--(no-)?verify-rpm$/ and do { $verify_rpm = !$1; next }; + /^--(no-)?verify-rpm$/ and do { $urpm->{options}{'verify-rpm'} = !$1; next }; /^--(no-)?test$/ and do { $test = !$1; next }; /^--comment$/ and do { push @nextargv, undef; next }; /^--root$/ and do { push @nextargv, \$root; next }; - /^--excludepath$/ and do { push @nextargv, \$excludepath; next }; + /^--excludepath$/ and do { $urpm->{options}{excludepath} = undef; push @nextargv, \$urpm->{options}{excludepath}; next }; /^-(.*)$/ and do { foreach (split //, $1) { /[\?h]/ and do { usage; next }; /a/ and do { $all = 1; next }; @@ -190,7 +182,7 @@ while (defined($_ = shift @ARGV)) { /q/ and do { --$verbose; $rpm_opt = ""; next }; /p/ and do { $use_provides = 1; next }; /P/ and do { $use_provides = 0; next }; - /y/ and do { $fuzzy = 1; next }; + /y/ and do { $urpm->{options}{fuzzy} = 1; next }; /s/ and do { $src = 1; next }; /v/ and do { ++$verbose; $rpm_opt = "vh"; next }; die _("urpmi: unknown option \"-%s\", check usage with --help\n", $1); } next }; @@ -210,6 +202,10 @@ while (defined($_ = shift @ARGV)) { } $src = 0; #- reset switch for next package. } +#- get back activated default values of boolean options. +foreach (qw(post-clean use-provides verify-rpm)) { + exists $urpm->{options}{$_} or $urpm->{options}{$_} = 1; +} #- use install_src to promote all names as src package. if ($install_src) { @@ -332,14 +328,14 @@ if (@names) { $urpm->search_packages(\%requested, [ @names ], all => $all, use_provides => $use_provides, - fuzzy => $fuzzy) + fuzzy => $urpm->{options}{fuzzy}) or $force or exit 1; } if (@src_names) { $urpm->search_packages(\%requested, [ @src_names ], all => $all, use_provides => $use_provides, - fuzzy => $fuzzy, + fuzzy => $urpm->{options}{fuzzy}, src => 1) or $force or exit 1; } @@ -491,14 +487,14 @@ if (@root_only) { #- if not root, the list become invisible and no download will be possible. my ($local_sources, $list) = $urpm->get_source_packages($state->{selected}, - clean_all => $clean, clean_other => !$noclean && $pre_clean_cache); + clean_all => $clean, clean_other => !$noclean && $urpm->{options}{'pre-clean'}); unless ($local_sources || $list) { $urpm->{fatal}(3, _("unable to get source packages, aborting")); } my %sources = $urpm->download_source_packages($local_sources, $list, verbose => $verbose > 0, - limit_rate => $limit_rate, + limit_rate => $urpm->{options}{'limit-rate'}, callback => sub { my ($mode, $file, $percent, $total, $eta, $speed) = @_; if ($mode eq 'start') { @@ -608,13 +604,13 @@ if (%sources_install || %sources) { } else { my @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, translate_message => 1, - oldpackage => $state->{oldpackage}, post_clean_cache => $post_clean_cache, + oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, test => $test, excludepath => $excludepath); if (@l) { message(_("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); m|^/| && !-e $_ and exit 2 foreach values %sources_install, values %sources; #- missing local file - $auto || !$allow_nodeps && !$allow_force and exit 1; #- if auto has been set, avoid asking user. + $auto || !$urpm->{options}{'allow-nodeps'} && !$urpm->{options}{'allow-force'} and exit 1; $noexpr = _("Nn"); $yesexpr = _("Yy"); @@ -623,17 +619,17 @@ if (%sources_install || %sources) { $urpm->{log}("starting installing packages without deps"); @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, translate_message => 1, nodeps => 1, - oldpackage => $state->{oldpackage}, post_clean_cache => $post_clean_cache, + oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, test => $test, excludepath => $excludepath); if (@l) { message(_("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); - !$allow_force and exit 1; + !$urpm->{options}{'allow-force'} and exit 1; message_input(_("Try installation even more strongly (--force)? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ or exit 1; $urpm->{log}("starting force installing packages without deps"); @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, translate_message => 1, nodeps => 1, force => 1, - oldpackage => $state->{oldpackage}, post_clean_cache => $post_clean_cache, + oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, test => $test, excludepath => $excludepath); @l and $urpm->fatal(2, _("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); } diff --git a/urpmi.spec b/urpmi.spec index 4f494ef8..30a0b7bc 100644 --- a/urpmi.spec +++ b/urpmi.spec @@ -2,7 +2,7 @@ Name: urpmi Version: 4.2 -Release: 13mdk +Release: 14mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate @@ -205,6 +205,11 @@ fi %changelog +* Mon Jan 27 2003 François Pons 4.2-14mdk +- added more global options to urpmi.cfg: verify-rpm, fuzzy, + allow-force, allow-nodeps, pre-clean, post-clean, limit-rate, + excludepath. + * Mon Jan 27 2003 François Pons 4.2-13mdk - simplified portage to perl 5.6.1, because the following open F, "-|", "/usr/bin/wget", ... are 5.8.0 restrictive. -- cgit v1.2.1