From 2884d491b2e47f393085cebcdc8bcab92937f8b2 Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Mon, 26 Aug 2002 21:24:02 +0000 Subject: 4.0-4mdk --- urpm.pm | 43 ++++++++++++++++++++++++++++++------------- urpm/parallel_ka_run.pm | 25 ++++++++++++++++++++++--- urpm/parallel_ssh.pm | 23 +++++++++++++++++++++-- urpmi | 33 ++++++++++++++++++++++----------- urpmi.spec | 12 +++++++++++- 5 files changed, 106 insertions(+), 30 deletions(-) diff --git a/urpm.pm b/urpm.pm index 2ce9d9d1..1a41432e 100644 --- a/urpm.pm +++ b/urpm.pm @@ -174,7 +174,6 @@ sub set_proxy { } last; }; -# Translator: the %s here is a program name die _("Unknown webfetch `%s' !!!\n",$proxy->{type}); } } @@ -818,7 +817,7 @@ sub remove_selected_media { #- computational of base files. #- allow options : #- all -> all medium are rebuilded. -#- force -> try to force rebuilding base files (1) or hdlist from rpms files (2). +#- force -> try to force rebuilding base files (1) or hdlist from rpm files (2). #- probe_with_hdlist -> probe synthesis or hdlist. #- ratio -> use compression ratio (with gzip, default is 4) #- noclean -> keep header directory cleaned. @@ -845,7 +844,7 @@ sub update_media { #- examine each medium to see if one of them need to be updated. #- if this is the case and if not forced, try to use a pre-calculated - #- hdlist file else build it from rpms files. + #- hdlist file else build it from rpm files. $urpm->clean; foreach my $medium (@{$urpm->{media}}) { #- take care of modified medium only or all if all have to be recomputed. @@ -976,7 +975,7 @@ sub update_media { if (@files > 0) { #- we need to rebuild from rpm files the hdlist. eval { - $urpm->{log}(_("reading rpms files from [%s]", $dir)); + $urpm->{log}(_("reading rpm files from [%s]", $dir)); my @unresolved_before = grep { ! defined $urpm->{provides}{$_} } keys %{$urpm->{provides} || {}}; $medium->{start} = @{$urpm->{depslist}}; $medium->{headers} = [ $urpm->parse_rpms_build_headers(dir => "$urpm->{cachedir}/headers", @@ -995,7 +994,7 @@ sub update_media { @unresolved_before == @unresolved_after or $urpm->{second_pass} = 1; } }; - $@ and $error = 1, $urpm->{error}(_("unable to read rpms files from [%s]: %s", $dir, $@)); + $@ and $error = 1, $urpm->{error}(_("unable to read rpm files from [%s]: %s", $dir, $@)); $error and delete $medium->{headers}; #- do not propagate these. $error or delete $medium->{synthesis}; #- when building hdlist by ourself, drop synthesis property. } else { @@ -1445,7 +1444,6 @@ sub reduce_pathname { #- remove any multiple /s or trailing /. #- then split all components of pathname. $dir =~ s/\/+/\//g; $dir =~ s/\/$//; - $dir =~ s/([^:]+:\/)?\/+/$1\//g; $dir =~ s/\/$//; my @paths = split '/', $dir; #- reset $dir, recompose it, and clean trailing / added by algorithm. @@ -1659,19 +1657,38 @@ sub resolve_dependencies { #- get out of package that should not be upgraded. sub deselect_unwanted_packages { my ($urpm, $packages, %options) = @_; + my (%skip, %remove); local ($_, *F); open F, $urpm->{skiplist}; while () { chomp; s/#.*$//; s/^\s*//; s/\s*$//; - foreach (keys %{$urpm->{provides}{$_} || {}}) { - my $pkg = $urpm->{depslist}[$_] or next; - $pkg->arch eq 'src' and next; #- never ignore source package. - $options{force} || (exists $packages->{$_} && ! defined $packages->{$_}) - and delete $packages->{$_}; + if (my ($n, $s) = /^([^\s\[]*)(?:\[\*\])?\[?([^\s\]]*\s*[^\s\]]*)/) { + $skip{$n}{$s} = undef; } } close F; + + %skip and return; + foreach (grep { $options{force} || (exists $packages->{$_} && ! defined $packages->{$_}) } keys %$packages) { + my $pkg = $urpm->{depslist}[$_] or next; + my $remove_it; + + #- find skiped entry that match the package fullname. + foreach (keys %skip) { + exists $skip{$_}{''} && $pkg->fullname =~ /$_/ and delete $packages->{$pkg->id}; + } + + #- check if a provides match at least one package. + foreach ($pkg->provides) { + if (my ($n, $s) = /^([^\s\[]*)(?:\[\*\])?\[?([^\s\]]*\s*[^\s\]]*)/) { + foreach (keys %{$skip{$n} || {}}) { + range_overlap($_, $s) and delete $packages->{$pkg->id}; + } + } + } + } + 1; } #- select source for package selected. @@ -1843,7 +1860,7 @@ sub download_source_packages { foreach my $device (keys %removables) { #- here we have only removable device. #- if more than one media use this device, we have to sort - #- needed package to copy first the needed rpms files. + #- needed package to copy first the needed rpm files. if (@{$removables{$device}} > 1) { my @sorted_media = sort { values %{$list->[$a]} <=> values %{$list->[$b]} } @{$removables{$device}}; @@ -1888,7 +1905,7 @@ sub download_source_packages { } } @distant_sources and eval { - $urpm->{log}(_("retrieving rpms files...")); + $urpm->{log}(_("retrieving rpm files...")); foreach (map { m|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)| ? "$1xxxx$2" : $_ } @distant_sources) { $urpm->{log}(" $_") ; } diff --git a/urpm/parallel_ka_run.pm b/urpm/parallel_ka_run.pm index dacc1056..ef806b6b 100644 --- a/urpm/parallel_ka_run.pm +++ b/urpm/parallel_ka_run.pm @@ -52,7 +52,7 @@ sub parallel_resolve_dependencies { $state->{selected}{$pkg->id}{$node} = $_; } } - close F or $urpm->{fatal}(1, _("host %s does not have a good version of urpmi", $node)); + close F or $urpm->{fatal}(1, _("rshp failed")); #- check for internal error of resolution. $cont == 1 and die "internal distant urpmq error on choice not taken"; } while ($cont); @@ -74,8 +74,27 @@ sub parallel_install { system "mput $parallel->{options} -- '$_' $urpm->{cachedir}/rpms/$basename"; } - $urpm->{log}("parallel_ka_run: rshp -v $parallel->{options} -- urpmi --synthesis $parallel->{synthesis} $parallel->{line}"); - system "rshp -v $parallel->{options} -- urpmi --auto --synthesis $parallel->{synthesis} $parallel->{line}"; + local (*F, $_); + my ($node, %good_nodes, $bad); + $urpm->{log}("parallel_ka_run: rshp -v $parallel->{options} -- urpmi --no-locales --test --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line}"); + open F, "rshp -v $parallel->{options} -- urpmi --no-locales --test --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line} |"; + while ($_ = ) { + chomp; + s/<([^>]*)>.*:->:(.*)/$2/ and $node = $1; + /Installation is possible/ and $good_nodes{$node} = undef; + } + close F or $urpm->{fatal}(1, _("rshp failed")); + + foreach (keys %{$parallel->{nodes}}) { + exists $good_nodes{$_} and next; + $urpm->{error}(_("Installation failed on node %s", $_) . ":\n" . ""); #TODO + $bad = 1; + } + unless ($bad) { + #- continue installation. + $urpm->{log}("parallel_ka_run: rshp $parallel->{options} -- urpmi --no-locales --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line}"); + system "rshp $parallel->{options} -- urpmi --no-locales --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line}"; + } } diff --git a/urpm/parallel_ssh.pm b/urpm/parallel_ssh.pm index 5d0c3ea3..46a21b34 100644 --- a/urpm/parallel_ssh.pm +++ b/urpm/parallel_ssh.pm @@ -77,9 +77,28 @@ sub parallel_install { system "scp $sources $_:$urpm->{cachedir}/rpms"; } + my (%good_nodes, $bad); + foreach my $node (keys %{$parallel->{nodes}}) { + local (*F, $_); + $urpm->{log}("parallel_ssh: ssh $node urpmi --no-locales --test --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line}"); + open F, "ssh $node urpmi --no-locales --test --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line} |"; + while ($_ = ) { + chomp; + /Installation is possible/ and $good_nodes{$node} = undef; + } + close F; + } foreach (keys %{$parallel->{nodes}}) { - $urpm->{log}("parallel_ssh: ssh $_ urpmi --auto --synthesis $parallel->{synthesis} $parallel->{line}"); - system "ssh $_ urpmi --auto --synthesis $parallel->{synthesis} $parallel->{line}"; + exists $good_nodes{$_} and next; + $urpm->{error}(_("Installation failed on node %s", $_) . ":\n" . ""); #TODO + $bad = 1; + } + unless ($bad) { + foreach my $node (keys %{$parallel->{nodes}}) { + #- continue installation. + $urpm->{log}("parallel_ssh: ssh $node urpmi --no-locales --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line}"); + system "ssh $node urpmi --no-locales --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line}"; + } } } diff --git a/urpmi b/urpmi index 6dc07801..04f43a36 100755 --- a/urpmi +++ b/urpmi @@ -47,7 +47,8 @@ my $root = ''; my $bug = ''; my $env = ''; my $log = ''; -my $verify_rpm = ''; +my $verify_rpm = 1; +my $test = 0; my $uid; my @files; @@ -86,12 +87,16 @@ usage: to be 1080 by default (format is ). ") . _(" --proxy-user - specify user and password to use for proxy authentication (format is ). -") . _(" --bug - output a bug report in directory indicated by next arg. -") . _(" --env - use specific environment (typically a bug report). +") . _(" --bug - output a bug report in directory indicated by + next arg. +") . _(" --env - use specific environment (typically a bug + report). ") . _(" --X - use X interface. ") . _(" --best-output - choose best interface according to the environment: X or text mode. -") . _(" --verify-rpm - verify rpm signature before installation. +") . _(" --verify-rpm - verify rpm signature before installation + (--no-verify-rpm disable it, default is enabled). +") . _(" --test - verify if the installation can be achieved correctly. ") . _(" -a - select all matches on command line. ") . _(" -p - allow search in provides to find package. ") . _(" -P - do not search in provides to find package. @@ -106,8 +111,10 @@ usage: #- parse arguments list. my @nextargv; +my $command_line = join " ", @ARGV; while (defined($_ = shift @ARGV)) { /^--help$/ and do { usage; next }; + /^--no-locales$/ and do { undef *_; undef *urpm::_; *_ = *urpm::_ = sub { sprintf(shift @_, @_) }; next }; /^--update$/ and do { $update = 1; next }; /^--media$/ and do { push @nextargv, \$media; next }; /^--mediums$/ and do { push @nextargv, \$media; next }; @@ -148,7 +155,8 @@ 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 }; - /^--verify-rpm$/ and do { $verify_rpm = 1; next }; + /^--(no-)?verify-rpm$/ and do { $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 }; /^-(.*)$/ and do { foreach (split //, $1) { @@ -229,7 +237,7 @@ if ($env) { if ($log) { #- log only at this point in case of query usage. - log_it(scalar localtime, " urpmi called with @ARGV\n"); + log_it(scalar localtime, " urpmi called with $command_line\n"); open SAVEOUT, ">&STDOUT"; select SAVEOUT; $| = 1; open SAVEERR, ">&STDERR"; select SAVEERR; $| = 1; @@ -496,12 +504,13 @@ if (%sources_install || %sources) { log_it(scalar localtime, " ", join(' ', values %sources_install, values %sources), "\n"); $urpm->{log}("starting installing packages"); if ($uid > 0) { - system("rpm", "-i$rpm_opt", values %sources_install, values %sources, ($root ? ("--root", $root) : ())); + system("rpm", "-i$rpm_opt", values %sources_install, values %sources, + ($root ? ("--root", $root) : ()), ($test ? ("--test", $test) : ())); $? and message(_("Installation failed")), exit 1; exit 0; } else { - if ($X && !$root) { - system("rpm", "-e", "--nodeps", keys %{$state->{ask_remove} || {}}, ($root ? ("--root", $root) : ())); + if ($X && !$root && !$test) { + system("rpm", "-e", "--nodeps", keys %{$state->{ask_remove} || {}}); system("grpmi", $WID ? ("--WID=$WID") : (), (map { ("-noupgrade", $_) } values %sources_install), values %sources); if ($?) { @@ -512,7 +521,7 @@ if (%sources_install || %sources) { } } else { my @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, - translate_message => 1); + translate_message => 1, test => $test); if (@l) { message(_("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); @@ -536,6 +545,8 @@ if (%sources_install || %sources) { translate_message => 1, nodeps => 1, force => 1); @l and $urpm->fatal(2, _("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); } + } else { + $test and message(_("Installation is possible")); } } } @@ -569,7 +580,7 @@ sub log_it { #- message functions. sub message { my ($msg, $noX) = @_; - if ($X && !$noX) { + if ($X && !$noX && !$auto) { `gmessage -default Ok -buttons Ok "$msg"`; $bug and log_it($msg); } else { diff --git a/urpmi.spec b/urpmi.spec index 79e4d9c4..72de6043 100644 --- a/urpmi.spec +++ b/urpmi.spec @@ -2,7 +2,7 @@ Name: urpmi Version: 4.0 -Release: 3mdk +Release: 4mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate @@ -177,6 +177,16 @@ fi %changelog +* Mon Aug 26 2002 François Pons 4.0-4mdk +- english typo fixed. +- improved skip.list contents to provides using sense and regexp + on package fullname. +- added --test options to urpmi to test installation. +- made --verify-rpm the default (use --no-verify-rpm to avoid). +- fixed command line not seen in log. +- improved parallel module to check installation on all nodes before + doing it effectively. + * Fri Aug 23 2002 Warly 4.0-3mdk - fix urpme '/' pb -- cgit v1.2.1