From f4f538e70ddeaf9683dd4c077fe6abd6af96b883 Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Fri, 25 Apr 2003 16:36:10 +0000 Subject: 4.3-8mdk --- urpm.pm | 156 ++++++++++++++++++++++++++++++++----------------------------- urpmf | 17 +++++-- urpmi.spec | 12 ++++- urpmq | 8 +++- 4 files changed, 112 insertions(+), 81 deletions(-) diff --git a/urpm.pm b/urpm.pm index 1b9877fd..bea56bd0 100644 --- a/urpm.pm +++ b/urpm.pm @@ -733,7 +733,7 @@ sub configure { delete $_->{modified} foreach @{$urpm->{media} || []}; my @oldmedia = @{$urpm->{media} || []}; my @newmedia; - foreach (split ',', $options{excludemedia}) { + foreach (split ',', $options{sortmedia}) { $urpm->select_media($_); push @newmedia, grep { $_->{modified} } @oldmedia; @oldmedia = grep { !$_->{modified} } @oldmedia; @@ -743,44 +743,46 @@ sub configure { #- clean remaining modified flag. delete $_->{modified} foreach @{$urpm->{media} || []}; } - foreach (grep { !$_->{ignore} && (!$options{update} || $_->{update}) } @{$urpm->{media} || []}) { - delete @{$_}{qw(start end)}; - if ($options{callback}) { - if ($options{hdlist} && -s "$urpm->{statedir}/$_->{hdlist}" > 32) { - $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$_->{hdlist}")); - eval { ($_->{start}, $_->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$_->{hdlist}", - packing => 1, callback => $options{callback}) }; - } else { - $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$_->{hdlist}")); - eval { ($_->{start}, $_->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$_->{hdlist}", - callback => $options{callback}) }; - unless (defined $_->{start} && defined $_->{end}) { + unless ($options{nodepslist}) { + foreach (grep { !$_->{ignore} && (!$options{update} || $_->{update}) } @{$urpm->{media} || []}) { + delete @{$_}{qw(start end)}; + if ($options{callback}) { + if ($options{hdlist} && -s "$urpm->{statedir}/$_->{hdlist}" > 32) { $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$_->{hdlist}")); eval { ($_->{start}, $_->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$_->{hdlist}", packing => 1, callback => $options{callback}) }; + } else { + $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$_->{hdlist}")); + eval { ($_->{start}, $_->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$_->{hdlist}", + callback => $options{callback}) }; + unless (defined $_->{start} && defined $_->{end}) { + $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$_->{hdlist}")); + eval { ($_->{start}, $_->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$_->{hdlist}", + packing => 1, callback => $options{callback}) }; + } } - } - unless (defined $_->{start} && defined $_->{end}) { - $urpm->{error}(N("problem reading hdlist file of medium \"%s\"", $_->{name})); - $_->{ignore} = 1; - } - } else { - if (-s "$urpm->{statedir}/synthesis.$_->{hdlist}" > 32) { - $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$_->{hdlist}")); - eval { ($_->{start}, $_->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$_->{hdlist}") }; - } - unless (defined $_->{start} && defined $_->{end}) { - $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$_->{hdlist}")); - eval { ($_->{start}, $_->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$_->{hdlist}", packing => 1) }; unless (defined $_->{start} && defined $_->{end}) { - $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $_->{name})); + $urpm->{error}(N("problem reading hdlist file of medium \"%s\"", $_->{name})); $_->{ignore} = 1; } + } else { + if (-s "$urpm->{statedir}/synthesis.$_->{hdlist}" > 32) { + $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$_->{hdlist}")); + eval { ($_->{start}, $_->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$_->{hdlist}") }; + } + unless (defined $_->{start} && defined $_->{end}) { + $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$_->{hdlist}")); + eval { ($_->{start}, $_->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$_->{hdlist}", packing => 1) }; + unless (defined $_->{start} && defined $_->{end}) { + $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $_->{name})); + $_->{ignore} = 1; + } + } } } } } - #- determine package to withdraw (from skip.list file). + #- determine package to withdraw (from skip.list file) only if something should be withdrawn. unless ($options{noskipping}) { $urpm->compute_skip_flags($urpm->get_unwanted_packages($options{skip}), callback => sub { my ($urpm, $pkg) = @_; @@ -2183,7 +2185,7 @@ sub get_unwanted_packages { #- have a null list. sub get_source_packages { my ($urpm, $packages, %options) = @_; - my ($id, $error, %local_sources, @list, %fullname2id, %usefull_files, %file2fullnames, %examined); + my ($id, $error, %local_sources, @list, %fullname2id, %file2fullnames, %examined); local (*D, *F, $_); #- build association hash to retrieve id and examine all list files. @@ -2194,8 +2196,6 @@ sub get_source_packages { } else { $fullname2id{$p->fullname} = $_.''; } - #- keep track of related files to avoid scanning all the cache (very long when cache is big). - $usefull_files{$p->filename} = undef; } #- examine each medium to search for packages. @@ -2210,39 +2210,33 @@ sub get_source_packages { if (my ($filename) = /^([^\/]*\.rpm)$/) { my $filepath = "$urpm->{cachedir}/rpms/$filename"; if (!$options{clean_all} && -s $filepath) { - if (exists $usefull_files{$filename}) { - if (URPM::verify_rpm($filepath, nogpg => 1, nopgp => 1) =~ /md5 OK/) { - if (keys(%{$file2fullnames{$filename} || {}}) > 1) { - $urpm->{error}(N("there are multiple packages with the same rpm filename \"%s\""), $filename); - next; - } elsif (keys(%{$file2fullnames{$filename} || {}}) == 1) { - my ($fullname) = keys(%{$file2fullnames{$filename} || {}}); - if (defined($id = delete $fullname2id{$fullname})) { - $local_sources{$id} = $filepath; - } else { - $options{clean_other} and unlink $filepath; - } - } else { - $options{clean_other} and unlink $filepath; - } + if (keys(%{$file2fullnames{$filename} || {}}) > 1) { + $urpm->{error}(N("there are multiple packages with the same rpm filename \"%s\""), $filename); + next; + } elsif (keys(%{$file2fullnames{$filename} || {}}) == 1) { + my ($fullname) = keys(%{$file2fullnames{$filename} || {}}); + if (defined($id = delete $fullname2id{$fullname})) { + $local_sources{$id} = $filepath; } else { - #- this is an invalid file in cache, remove it and ignore it. - #- or clean options has been given meaning ignore any file in cache - #- remove it too. - #- if a continue to download feature is used, the file should not be - #- removed and the transfer should continue, if it fails again, try - #- again from beginning ? - unlink $filepath; + $options{clean_other} and unlink $filepath; } - } #- do not examine rpm file in cache that will not be used. + } else { + $options{clean_other} and unlink $filepath; + } } else { #- this file should be removed or is already empty. unlink $filepath; } - } #- no error on unknown filename located in cache (because .listing) + } #- no error on unknown filename located in cache (because .listing) inherited from old urpmi } closedir D; + #- clean download directory, do it here even if this is not the best moment. + if ($options{clean_all}) { + system("rm", "-rf", "$urpm->{cachedir}/partial"); + mkdir "$urpm->{cachedir}/partial"; + } + foreach my $medium (@{$urpm->{media} || []}) { my (%sources, %list_examined, $list_warning); @@ -2286,7 +2280,8 @@ sub get_source_packages { } } $list_warning && $medium->{list} && -r "$urpm->{statedir}/$medium->{list}" and - $urpm->{error}(N("medium \"%s\" uses an invalid list file (mirror is problably not up-to-date, trying to use alternate method)", $medium->{name})); + $urpm->{error}(N("medium \"%s\" uses an invalid list file: + mirror is problably not up-to-date, trying to use alternate method", $medium->{name})); } elsif (!%list_examined) { $error = 1; $urpm->{error}(N("medium \"%s\" does not define any location for rpm files", $medium->{name})); @@ -2299,7 +2294,7 @@ sub get_source_packages { foreach (grep { ! exists($examined{$_}) } keys %fullname2id) { $error = 1; $urpm->{error}(N("package %s is not found.", $_)); - } + } $error ? @{[]} : (\%local_sources, \@list); } @@ -2352,23 +2347,30 @@ sub download_source_packages { $urpm->{fatal}(4, N("medium \"%s\" is not selected", $medium->{name})); } if (-e $dir) { - my @removable_sources; while (my ($i, $url) = each %{$list->[$id]}) { chomp $url; - $url =~ /^(removable[^:]*|file):\/(.*\/([^\/]*))/ or next; - if (-r $2) { + my ($filepath, $filename) = $url =~ /^(?:removable[^:]*|file):\/(.*\/([^\/]*))/ or next; + if (-r $filepath) { if ($copy) { - push @removable_sources, $2; - $sources{$i} = "$urpm->{cachedir}/rpms/$3"; + #- we should assume a possible buggy removable device... + #- first copy in cache, and if the package is still good, transfert it + #- to the great rpms cache. + unlink "$urpm->{cachedir}/partial/$filename"; + if (system("cp", "--preserve=mode,timestamps", "-R", $filepath, "$urpm->{cachedir}/partial") && + URPM::verify_rpm("$urpm->{cachedir}/partial/$filename", nogpg => 1, nopgp => 1) =~ /md5 OK/) { + #- now we can consider the file to be fine. + unlink "$urpm->{cachedir}/rpms/$filename"; + rename "$urpm->{cachedir}/partial/$filename", "$urpm->{cachedir}/rpms/$filename"; + -r "$urpm->{cachedir}/rpms/$filename" and $sources{$i} = "$urpm->{cachedir}/rpms/$filename"; + } } else { - $sources{$i} = $2; + $sources{$i} = $filepath; } - } else { - $urpm->{error}(N("unable to read rpm file [%s] from medium \"%s\"", $2, $medium->{name})); } - } - if (@removable_sources) { - system("cp", "--preserve=mode,timestamps", "-R", @removable_sources, "$urpm->{cachedir}/rpms"); + unless ($sources{$i}) { + #- fallback to use other method for retrieving the file later. + $urpm->{error}(N("unable to read rpm file [%s] from medium \"%s\"", $filepath, $medium->{name})); + } } } else { $urpm->{error}(N("medium \"%s\" is not selected", $medium->{name})); @@ -2446,7 +2448,6 @@ sub download_source_packages { } } elsif ($url =~ /^([^:]*):\/(.*\/([^\/]*\.rpm))$/) { if ($options{force_local} || $1 ne 'ftp' && $1 ne 'http') { #- only ftp and http protocol supported by grpmi. - $sources{$i} = "$urpm->{cachedir}/rpms/$3"; $distant_sources{$i} = "$1:/$2"; } else { $sources{$i} = "$1:/$2"; @@ -2460,7 +2461,7 @@ sub download_source_packages { if (%distant_sources) { eval { $urpm->{log}(N("retrieving rpm files from medium \"%s\"...", $urpm->{media}[$_]{name})); - $urpm->{sync}({ dir => "$urpm->{cachedir}/rpms", + $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 0, verbose => $options{verbose}, limit_rate => $options{limit_rate}, @@ -2476,9 +2477,18 @@ sub download_source_packages { #- has been problem downloading them at least once, this is #- necessary to keep track of failing download in order to #- present the error to the user. - foreach (keys %distant_sources) { - -s $sources{$_} && URPM::verify_rpm($sources{$_}, nogpg => 1, nopgp => 1) =~ /md5 OK/ or - $error_sources{$_} = delete $sources{$_}; + foreach my $i (keys %distant_sources) { + my ($filename) = $distant_sources{$i} =~ /\/([^\/]*\.rpm)$/; + if ($filename && -s "$urpm->{cachedir}/partial/$filename" && + URPM::verify_rpm("$urpm->{cachedir}/partial/$filename", nogpg => 1, nopgp => 1) =~ /md5 OK/) { + #- it seems the the file has been downloaded correctly and has been checked to be valid. + unlink "$urpm->{cachedir}/rpms/$filename"; + rename "$urpm->{cachedir}/partial/$filename", "$urpm->{cachedir}/rpms/$filename"; + -r "$urpm->{cachedir}/rpms/$filename" and $sources{$i} = "$urpm->{cachedir}/rpms/$filename"; + } + unless ($sources{$i}) { + $error_sources{$i} = $distant_sources{$i}; + } } } } diff --git a/urpmf b/urpmf index 28863d27..30fcbb15 100755 --- a/urpmf +++ b/urpmf @@ -28,6 +28,8 @@ usage: ", $urpm::VERSION) . N(" --help - print this help message. ") . N(" --update - use only update media. ") . N(" --media - use only the given media, separated by comma. +") . N(" --excludemedia - do not use the given media, separated by comma. +") . N(" --sortmedia - sort media according to substrings separated by comma. ") . N(" --synthesis - use the synthesis given instead of urpmi db. ") . N(" --verbose - verbose mode. ") . N(" --quiet - do not print tag name (default if no tag given on command @@ -65,6 +67,8 @@ usage: #- default options. my $update = 0; my $media = ''; +my $excludemedia = ''; +my $sortmedia = ''; my $synthesis = ''; my $verbose = 0; my $quiet; @@ -75,14 +79,15 @@ my (%params, %uniq); #- parse arguments list. my $expr; -my @nextargv; while (defined($_ = shift @ARGV)) { /^--help$/ and do { usage; next }; /^--no-locales$/ and do { undef *N; undef *urpm::N; *N = *urpm::N = sub { sprintf(shift @_, @_) }; next }; /^--update$/ and do { $update = 1; next }; - /^--media$/ and do { push @nextargv, \$media; next }; - /^--mediums$/ and do { push @nextargv, \$media; next }; - /^--synthesis$/ and do { push @nextargv, \$synthesis; next }; + /^--media$/ and do { $media = shift @ARGV; next }; + /^--mediums$/ and do { $media = shift @ARGV; next }; + /^--exclude-?media$/ and do { $excludemedia = shift @ARGV; next }; + /^--sort-?media$/ and do { $sortmedia = shift @ARGV; next }; + /^--synthesis$/ and do { $synthesis = shift @ARGV; next }; /^--verbose$/ and do { $verbose = 1; next }; /^--quiet$/ and do { $quiet = 1; next }; /^--uniq$/ and do { $uniq = 1; next }; @@ -97,7 +102,7 @@ while (defined($_ = shift @ARGV)) { /^-u$/ and do { $uniq = 1; next }; /^-i$/ and do { $pattern = 'i'; next }; /^-f$/ and do { $full = 'full'; next }; - /^-e$/ and do { $expr .= '('.$_.')'; next }; + /^-e$/ and do { $expr .= '('.(shift @ARGV).')'; next }; /^-a$/ and do { $expr .= ' && '; next }; /^-o$/ and do { $expr .= ' || '; next }; /^[!\(\)]$/ and do { $expr .= $_; next }; @@ -136,6 +141,8 @@ $@ and usage; $urpm->configure(nocheck_access => 1, noskipping => 1, media => $media, + excludemedia => $excludemedia, + sortmedia => $sortmedia, synthesis => $synthesis, update => $update, callback => $callback, diff --git a/urpmi.spec b/urpmi.spec index 99385ed2..1fbd011e 100644 --- a/urpmi.spec +++ b/urpmi.spec @@ -2,7 +2,7 @@ Name: urpmi Version: 4.3 -Release: 7mdk +Release: 8mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate @@ -199,7 +199,15 @@ $urpm->update_media; %changelog -- fixed bad file in cache not cleaned. +* Fri Apr 25 2003 François Pons 4.3-8mdk +- added -i in urpmq --help (fix bug 3829). +- fixed many urpmf options: --media, --synthesis, -e. +- added --excludemedia and --sortmedia to urpmf. +- fixed --sortmedia not working properly. +- slightly modified cache management for rpms, not always use + partial subdirectory before transfering to rpms directory. +- improved --list-aliases, --list-nodes and --list-media to be + much faster than before. * Thu Apr 24 2003 François Pons 4.3-7mdk - added -v to urpme and removed default log. diff --git a/urpmq b/urpmq index 6a5a4f21..cbd6fd60 100755 --- a/urpmq +++ b/urpmq @@ -66,6 +66,7 @@ usage: ") . N(" -R - reverse search to what requires package. ") . N(" -y - impose fuzzy search (same as --fuzzy). ") . N(" -s - next package is a source package (same as --src). +") . N(" -i - print usefull information in human readeable form. ") . N(" -g - print groups with name also. ") . N(" -r - print version and release with name also. ") . N(" -f - print version, release and arch with name. @@ -85,6 +86,7 @@ while (defined($_ = shift @ARGV)) { /^--update$/ and do { $query->{update} = 1; next }; /^--media$/ and do { push @nextargv, \$query->{media}; next }; /^--exclude-?media$/ and do { push @nextargv, \$query->{excludemedia}; next }; + /^--sort-?media$/ and do { push @nextargv, \$query->{sortmedia}; next }; /^--mediums$/ and do { push @nextargv, \$query->{media}; next }; /^--synthesis$/ and do { push @nextargv, \$query->{synthesis}; next }; /^--auto-select$/ and do { $query->{deps} = $query->{upgrade} = $query->{auto_select} = 1; next }; @@ -152,9 +154,13 @@ while (defined($_ = shift @ARGV)) { #- remove verbose if not asked. $query->{verbose} or $urpm->{log} = sub {}; -$urpm->configure(nocheck_access => 1, +#- improve speed if using any list_... options. +$query->{nodepslist} = $query->{list_aliases} || $query->{list_nodes} || $query->{list_media}; + +$urpm->configure(nocheck_access => 1, noskipping => $query->{nodepslist}, nodepslist => $query->{nodepslist}, media => $query->{media}, excludemedia => $query->{excludemedia}, + sortmedia => $query->{sortmedia}, synthesis => $query->{synthesis}, update => $query->{update}, skip => $query->{skip}, -- cgit v1.2.1