diff options
-rw-r--r-- | urpm.pm | 71 | ||||
-rw-r--r-- | urpmi.spec | 6 | ||||
-rwxr-xr-x | urpmq | 67 |
3 files changed, 126 insertions, 18 deletions
@@ -935,6 +935,22 @@ sub update_media { -s "$urpm->{cachedir}/partial/$medium->{hdlist}" > 32 or $error = 1, $urpm->{error}(_("copy of [%s] failed", "$with_hdlist_dir")); + #- examine if a local MD5SUM file is available. + if (!$options{force} && -s reduce_pathname("$dir/$with_hdlist_dir/../MD5SUM")) { + my ($basename) = $with_hdlist_dir =~ /^.*\/([^\/]+)$/; + $urpm->{log}(_("examining MD5SUM file")); + local (*F, $_); + open F, reduce_pathname("$dir/$with_hdlist_dir/../MD5SUM"); + while (<F>) { + my ($md5sum, $file) = /(\S+)\s+(\S+)/ or next; + if ($file eq $basename) { + $options{force} ||= (split ' ', `md5sum '$urpm->{cachedir}/partial/$medium->{hdlist}'`)[0] ne $md5sum; + last; + } + } + close F; + } + #- check if the file are equals... and no force copy... unless ($error || $options{force} || ! -e "$urpm->{statedir}/synthesis.$medium->{hdlist}") { my @sstat = stat "$urpm->{cachedir}/partial/$medium->{hdlist}"; @@ -958,9 +974,9 @@ sub update_media { #- examine if a local list file is available (always probed according to with_hdlist #- and check hdlist has not be named very strangely... if ($medium->{hdlist} ne 'list') { - unlink "$urpm->{cachedir}/partial/list"; my $local_list = $medium->{with_hdlist} =~ /hd(list.*)\.cz$/ ? $1 : 'list'; if (-s "$dir/$local_list") { + unlink "$urpm->{cachedir}/partial/list"; $urpm->{log}(_("copying source list of \"%s\"...", $medium->{name})); system("cp", "-pR", "$dir/$local_list", "$urpm->{cachedir}/partial/list") ? $urpm->{log}(_("...copying failed")) : $urpm->{log}(_("...copying done")); @@ -1041,7 +1057,8 @@ sub update_media { unlink "$urpm->{cachedir}/partial/$basename"; eval { - $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy} }, reduce_pathname("$medium->{url}/$_")); + $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy} }, + reduce_pathname("$medium->{url}/$_")); }; if (!$@ && -s "$urpm->{cachedir}/partial/$basename" > 32) { $medium->{with_hdlist} = $_; @@ -1073,21 +1090,43 @@ sub update_media { $urpm->{log}(_("...retrieving done")); unless ($options{force}) { - my @sstat = stat "$urpm->{cachedir}/partial/$basename"; - my @lstat = stat "$urpm->{statedir}/$medium->{hdlist}"; - if ($sstat[7] == $lstat[7] && $sstat[9] == $lstat[9]) { - #- the two files are considered equal here, the medium is so not modified. - $medium->{modified} = 0; - unlink "$urpm->{cachedir}/partial/$basename"; - #- as previously done, just read synthesis file here, this is enough. - $urpm->{log}(_("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$medium->{hdlist}")); - eval { ($medium->{start}, $medium->{end}) = - $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}") }; - unless (defined $medium->{start} && defined $medium->{end}) { - $urpm->{error}(_("problem reading synthesis file of medium \"%s\"", $medium->{name})); - $medium->{ignore} = 1; + #- examine if a distant MD5SUM file is available. + unlink "$urpm->{cachedir}/partial/MD5SUM"; + eval { + $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy} }, + reduce_pathname("$medium->{url}/$medium->{with_hdlist}/../MD5SUM")); + }; + if (!$@ && -s "$urpm->{cachedir}/partial/MD5SUM" > 32) { + $urpm->{log}(_("examining MD5SUM file")); + local (*F, $_); + open F, "$urpm->{cachedir}/partial/MD5SUM"; + while (<F>) { + my ($md5sum, $file) = /(\S+)\s+(\S+)/ or next; + if ($file eq $basename) { + $options{force} ||= (split ' ', `md5sum '$urpm->{cachedir}/partial/$basename'`)[0] ne $md5sum; + last; + } + } + close F; + } + + unless ($options{force}) { + my @sstat = stat "$urpm->{cachedir}/partial/$basename"; + my @lstat = stat "$urpm->{statedir}/$medium->{hdlist}"; + if ($sstat[7] == $lstat[7] && $sstat[9] == $lstat[9]) { + #- the two files are considered equal here, the medium is so not modified. + $medium->{modified} = 0; + unlink "$urpm->{cachedir}/partial/$basename"; + #- as previously done, just read synthesis file here, this is enough. + $urpm->{log}(_("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$medium->{hdlist}")); + eval { ($medium->{start}, $medium->{end}) = + $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}") }; + unless (defined $medium->{start} && defined $medium->{end}) { + $urpm->{error}(_("problem reading synthesis file of medium \"%s\"", $medium->{name})); + $medium->{ignore} = 1; + } + next; } - next; } } @@ -2,7 +2,7 @@ Name: urpmi Version: 4.0 -Release: 22mdk +Release: 23mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate @@ -204,6 +204,10 @@ fi %changelog +* Tue Oct 29 2002 François Pons <fpons@mandrakesoft.com> 4.0-23mdk +- added MD5SUM file support for downloading hdlist/synthesis. +- added -R option to urpmq to search what may provide packages. + * Thu Oct 24 2002 François Pons <fpons@mandrakesoft.com> 4.0-22mdk - fixed online help of tools to be more consistent. - added some times missing --help options. @@ -64,6 +64,7 @@ usage: ") . _(" -u - remove package if a more recent version is already installed. ") . _(" -c - choose complete method for resolving requires closure. ") . _(" -P - do not search in provides to find package. +") . _(" -R - reverse search to what requires package. ") . _(" -y - impose fuzzy search (same as --fuzzy). ") . _(" -s - next package is a source package (same as --src). ") . _(" -g - print groups with name also. @@ -126,6 +127,7 @@ for (@ARGV) { /g/ and do { $query->{group} = 1; next }; /p/ and do { $query->{use_provides} = 1; next }; /P/ and do { $query->{use_provides} = 0; next }; + /R/ and do { $query->{what_requires} = 1; next }; /y/ and do { $query->{fuzzy} = 1; next }; /s/ and do { $query->{src} = 1; next }; /v/ and do { $query->{verbose} = 1; next }; @@ -208,7 +210,70 @@ if ($query->{list_aliases}) { }; #- open/close of database should be moved here, in order to allow testing #- some bogus case and check for integrity. (note auto_select implies upgrade). - if ($query->{auto_select} || $query->{upgrade}) { + if ($query->{what_requires}) { + #- search for packages that requires on of the package proposed. + my (@properties, %requires, %properties, $dep); + + #- keep in mind the requested id (if given) in order to prefer these packages + #- on choices instead of anything other one. + @properties = keys %requested; + + if (@properties) { + require URPM::Resolve; + + #- build a requires to packages id hash. + foreach my $pkg (@{$urpm->{depslist}}) { + foreach ($pkg->requires_nosense) { + $requires{$_}{$pkg->id} = undef; + } + } + + #- for each dep property evaluated, examine which package will be obsoleted on $db, + #- then examine provides that will be removed (which need to be satisfied by another + #- package present or by a new package to upgrade), then requires not satisfied and + #- finally conflicts that will force a new upgrade or a remove. + while (defined ($dep = shift @properties)) { + #- take the best package for each choices of same name. + my $packages = $urpm->find_candidate_packages($dep); + foreach (values %$packages) { + my ($best_requested, $best); + foreach (@$_) { + if ($best_requested || exists $requested{$_->id}) { + if ($best_requested && $best_requested != $_) { + $_->compare_pkg($best_requested) > 0 and $best_requested = $_; + } else { + $best_requested = $_; + } + } elsif ($best && $best != $_) { + $_->compare_pkg($best) > 0 and $best = $_; + } else { + $best = $_; + } + } + + #- examine all choice proposed. + my $pkg = $best_requested || $best or next; + exists $state->{selected}{$pkg->id} and next; + $state->{selected}{$pkg->id} = undef; + + #- for all provides of package, look of what is requiring them. + foreach ($pkg->provides) { + if (my ($n, $s) = /^([^\s\[]*)(?:\[\*\])?\[?([^\s\]]*\s*[^\s\]]*)/) { + foreach (map { $urpm->{depslist}[$_] } + grep { ! exists $state->{selected}{$_} && ! exists $properties{$_} } + keys %{$requires{$n} || {}}) { + print "examining ".$_->fullname." from $n $s\n"; + if (grep { URPM::ranges_overlap("$n $s", $_) } $_->requires) { + push @properties, $_->id; + $properties{$_->id} = undef; + } + } + } + } + } + } + } + } elsif ($query->{auto_select} || $query->{upgrade}) { $urpm->resolve_dependencies($state, \%requested, auto_select => $query->{auto_select}, callback_choices => $stop_on_choices); |