From 74bd206ac50bfef14c9cbfb22087a288acd3d823 Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Fri, 24 Jan 2003 16:42:12 +0000 Subject: 4.2-11mdk --- urpm.pm | 19 ++++++++++++++++++- urpmi | 31 +++++++++++++++++++++---------- urpmi.spec | 13 ++++++++++++- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/urpm.pm b/urpm.pm index b990a2d9..135ebdcc 100644 --- a/urpm.pm +++ b/urpm.pm @@ -120,6 +120,7 @@ sub new { sync => \&sync_webfetch, #- first argument is directory, others are url to fetch. proxy => get_proxy(), + options => {}, fatal => sub { printf STDERR "%s\n", $_[1]; exit($_[0]) }, error => sub { printf STDERR "%s\n", $_[0] }, @@ -466,10 +467,20 @@ sub read_config { open F, $urpm->{config}; #- no filename can be allowed on some case while () { chomp; s/#.*$//; s/^\s*//; s/\s*$//; + $_ eq '{' and do { #- urpmi.cfg global options extension + 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; + $_ and $urpm->{error}(_("syntax error in config file at line %s", $.)); + } + next; }; /^(.*?[^\\])\s+(?:(.*?[^\\])\s+)?{$/ and do { #- urpmi.cfg format extention my $medium = { name => unquotespace($1), clear_url => unquotespace($2) }; while () { chomp; s/#.*$//; s/^\s*//; s/\s*$//; + $_ eq '}' and last; /^hdlist\s*:\s*(.*)$/ and $medium->{hdlist} = $1, next; /^with_hdlist\s*:\s*(.*)$/ and $medium->{with_hdlist} = $1, next; /^list\s*:\s*(.*)$/ and $medium->{list} = $1, next; @@ -478,7 +489,6 @@ sub read_config { /^ignore\s*$/ and $medium->{ignore} = 1, next; /^synthesis\s*$/ and $medium->{synthesis} = 1, next; /^modified\s*$/ and next; # IGNORED TO AVOID EXCESIVE REMOVE $medium->{modified} = 1, next; - $_ eq '}' and last; $_ and $urpm->{error}(_("syntax error in config file at line %s", $.)); } $urpm->probe_medium($medium, %options) and push @{$urpm->{media}}, $medium; @@ -663,6 +673,13 @@ sub write_config { local *F; open F, ">$urpm->{config}" or $urpm->{fatal}(6, _("unable to write config file [%s]", $urpm->{config})); + if (%{$urpm->{options} || {}}) { + printf F "{\n"; + while (my ($k,$v) = each %{$urpm->{options}}) { + printf F " %s: %s\n", $k, $v; + } + printf F "}\n"; + } foreach my $medium (@{$urpm->{media}}) { printf F "%s %s {\n", quotespace($medium->{name}), quotespace($medium->{clear_url}); foreach (qw(hdlist with_hdlist list removable)) { diff --git a/urpmi b/urpmi index f8b6cac9..8f15ede9 100755 --- a/urpmi +++ b/urpmi @@ -30,17 +30,17 @@ my $auto = 0; my $allow_medium_change = 0; my $auto_select = 0; my $force = 0; -my $allow_nodeps = 0; -my $allow_force = 0; +my $allow_nodeps = undef; #0; +my $allow_force = undef; #0; my $parallel = ''; my $sync = undef; -my $limit_rate = 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 = 0; +my $fuzzy = undef; #0; my $src = 0; my $install_src = 0; my $clean = 0; @@ -52,9 +52,9 @@ my $root = ''; my $bug = ''; my $env = ''; my $log = ''; -my $verify_rpm = 1; +my $verify_rpm = undef; #1; my $test = 0; -my $excludepath = 0; +my $excludepath = undef; #0; my $uid; my @files; @@ -121,6 +121,9 @@ usage: exit(0); } +#- params contains informations to parse installed system. +my $urpm = new urpm; + #- parse arguments list. my @nextargv; my $command_line = join " ", @ARGV; @@ -208,10 +211,6 @@ while (defined($_ = shift @ARGV)) { $src = 0; #- reset switch for next package. } -#- params contains informations to parse installed system. -my $urpm = new urpm; -my ($pid_out, $pid_err); - #- use install_src to promote all names as src package. if ($install_src) { @files and $urpm->{fatal}(1, _("What can be done with binary rpm files when using --install-src")); @@ -253,6 +252,7 @@ if ($env) { } } +my ($pid_out, $pid_err); if ($log) { #- log only at this point in case of query usage. log_it(scalar localtime, " urpmi called with $command_line\n"); @@ -309,6 +309,17 @@ $urpm->configure(nocheck_access => $env || $uid > 0, bug => $bug, parallel => $parallel, ); +#- handle options directly here according to values in configuration file. +foreach (keys %{$urpm->{options} || {}}) { + my $v = $urpm->{options}{$_}; + /^(no-)?verify-rpm$/ and do { + unless (defined $verify_rpm) { + $verify_rpm = defined $v && $v =~ /^(yes|on)$/i; $1 and $verify_rpm = ! $verify_rpm; + } next }; + $urpm->{error}(_("ignoring option \"$_\" not used")); +} +#- get default, this should be reworked to be more useable internally TODO. +defined $verify_rpm or $verify_rpm = 1; my $state = {}; my %requested = $urpm->register_rpms(@files, @src_files); diff --git a/urpmi.spec b/urpmi.spec index d82263eb..3abd8bac 100644 --- a/urpmi.spec +++ b/urpmi.spec @@ -2,7 +2,7 @@ Name: urpmi Version: 4.2 -Release: 10mdk +Release: 11mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate @@ -205,6 +205,17 @@ fi %changelog +* Fri Jan 24 2003 François Pons 4.2-11mdk +- add --limit-rate option to urpmi, urpmi.addmedia and + urpmi.update. +- add preliminary support for options in urpmi.cfg, only + verify-rpm is supported yet, format is as follow + { + verify-rpm : on|yes + verify-rpm + no-verify-rpm + } + * Thu Jan 23 2003 François Pons 4.2-10mdk - added download log support for rsync and ssh protocol. - make log not visible in log file instead url. -- cgit v1.2.1