From 3b15f4893480acf473e276c571a1eda577621c72 Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Tue, 17 Dec 2002 13:46:47 +0000 Subject: 0.81-1mdk --- URPM.pm | 64 ++++++++++++++++++++++++++++++--------------------------- URPM/Resolve.pm | 27 +++++++++++++++++------- perl-URPM.spec | 9 ++++++-- 3 files changed, 61 insertions(+), 39 deletions(-) diff --git a/URPM.pm b/URPM.pm index 02f2b15..4e3b90f 100644 --- a/URPM.pm +++ b/URPM.pm @@ -6,7 +6,7 @@ use vars qw($VERSION @ISA); require DynaLoader; @ISA = qw(DynaLoader); -$VERSION = '0.80'; +$VERSION = '0.81'; bootstrap URPM $VERSION; @@ -80,11 +80,12 @@ sub traverse_tag { my ($count, %names) = (0); if (@{$names || []}) { - @names{@$names} = (); if ($tag eq 'name') { - foreach (@{$urpm->{depslist} || []}) { - if (exists $names{$_->name}) { - $callback and $callback->($_); + foreach my $n (@$names) { + foreach (keys %{$urpm->{provides}{$n} || {}}) { + my $p = $urpm->{depslist}[$_]; + $p->name eq $n or next; + $callback and $callback->($p); ++$count; } } @@ -95,36 +96,39 @@ sub traverse_tag { ++$count; } } - } elsif ($tag eq 'whatrequires') { - foreach (@{$urpm->{depslist} || []}) { - if (grep { /^([^ \[]*)/ && exists $names{$1} } $_->requires) { - $callback and $callback->($_); - ++$count; + } else { + @names{@$names} = (); + if ($tag eq 'whatrequires') { + foreach (@{$urpm->{depslist} || []}) { + if (grep { /^([^ \[]*)/ && exists $names{$1} } $_->requires) { + $callback and $callback->($_); + ++$count; + } } - } - } elsif ($tag eq 'whatconflicts') { - foreach (@{$urpm->{depslist} || []}) { - if (grep { /^([^ \[]*)/ && exists $names{$1} } $_->conflicts) { - $callback and $callback->($_); - ++$count; + } elsif ($tag eq 'whatconflicts') { + foreach (@{$urpm->{depslist} || []}) { + if (grep { /^([^ \[]*)/ && exists $names{$1} } $_->conflicts) { + $callback and $callback->($_); + ++$count; + } } - } - } elsif ($tag eq 'group') { - foreach (@{$urpm->{depslist} || []}) { - if (exists $names{$_->group}) { - $callback and $callback->($_); - ++$count; + } elsif ($tag eq 'group') { + foreach (@{$urpm->{depslist} || []}) { + if (exists $names{$_->group}) { + $callback and $callback->($_); + ++$count; + } } - } - } elsif ($tag eq 'triggeredby' || $tag eq 'path') { - foreach (@{$urpm->{depslist} || []}) { - if (grep { exists $names{$_} } $_->files, grep { /^\// } $_->provides_nosense) { - $callback and $callback->($_); - ++$count; + } elsif ($tag eq 'triggeredby' || $tag eq 'path') { + foreach (@{$urpm->{depslist} || []}) { + if (grep { exists $names{$_} } $_->files, grep { /^\// } $_->provides_nosense) { + $callback and $callback->($_); + ++$count; + } } + } else { + die "unknown tag"; } - } else { - die "unknown tag"; } } diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm index fd479fa..adb12b9 100644 --- a/URPM/Resolve.pm +++ b/URPM/Resolve.pm @@ -5,18 +5,20 @@ use strict; #- find candidates packages from a require string (or id), #- take care of direct choices using | sepatator. sub find_candidate_packages { - my ($urpm, $dep) = @_; + my ($urpm, $dep, $avoided) = @_; my %packages; foreach (split '\|', $dep) { if (/^\d+$/) { my $pkg = $urpm->{depslist}[$_]; $pkg->arch eq 'src' || $pkg->is_arch_compat or next; + $avoided && exists $avoided->{$pkg->fullname} and next; push @{$packages{$pkg->name}}, $pkg; } elsif (my ($property, $name) = /^(([^\s\[]*).*)/) { foreach (keys %{$urpm->{provides}{$name} || {}}) { my $pkg = $urpm->{depslist}[$_]; $pkg->is_arch_compat or next; + $avoided && exists $avoided->{$pkg->fullname} and next; #- check if at least one provide of the package overlap the property. my $satisfied = 0; foreach ($pkg->provides) { @@ -169,7 +171,7 @@ sub resolve_requested { my ($best_requested, $best); foreach (@$_) { exists $state->{selected}{$_->id} and $best_requested = $_, last; - exists $avoided{$_->name} and next; + exists $avoided{$_->fullname} and next; if ($best_requested || exists $requested{$_->id}) { if ($best_requested && $best_requested != $_) { $_->compare_pkg($best_requested) > 0 and $best_requested = $_; @@ -290,8 +292,6 @@ sub resolve_requested { #- this means required dependencies have undef value in selected hash. #- requested flag is set only for requested package where value is not false. $state->{selected}{$pkg->id} = delete $requested->{$dep}; - #- mark package of this name to be avoided if possible. - $avoided{$pkg->name} = undef; $options{no_flag_update} or $state->{selected}{$pkg->id} ? $pkg->set_flag_requested : $pkg->set_flag_required; @@ -305,6 +305,19 @@ sub resolve_requested { foreach ($pkg->name." < ".$pkg->epoch.":".$pkg->version."-".$pkg->release, $pkg->obsoletes) { if (my ($n, $o, $v) = /^([^\s\[]*)(?:\[\*\])?\s*\[?([^\s\]]*)\s*([^\s\]]*)/) { + #- populate avoided entries according to what is selected. + foreach (keys %{$urpm->{provides}{$n} || {}}) { + my $p = $urpm->{depslist}[$_]; + if ($p->name eq $pkg->name) { + #- all package with the same name should now be avoided except what is chosen. + $p->fullname eq $pkg->fullname or $avoided{$p->fullname} = $pkg->fullname; + } else { + #- in case of obsoletes, keep track of what should be avoided. + !$o || eval($p->compare($v) . $o . 0) or next; + $avoided{$p->fullname} = $pkg->fullname; + } + } + #- examine rpm db too. $db->traverse_tag('name', [ $n ], sub { my ($p) = @_; !$o || eval($p->compare($v) . $o . 0) or return; @@ -336,7 +349,7 @@ sub resolve_requested { if (my @l = $urpm->unsatisfied_requires($db, $state, $p)) { #- try if upgrading the package will be satisfying all the requires #- else it will be necessary to ask the user for removing it. - my $packages = $urpm->find_candidate_packages($p->name); + my $packages = $urpm->find_candidate_packages($p->name, \%avoided); my $best = join '|', map { $_->id } grep { $urpm->unsatisfied_requires($db, $state, $_, name => $n) == 0 } @{$packages->{$p->name}}; @@ -348,7 +361,7 @@ sub resolve_requested { #- there exists a package that provided the unsatisfied requires. my @best; foreach (@l) { - $packages = $urpm->find_candidate_packages($_); + $packages = $urpm->find_candidate_packages($_, \%avoided); $best = join('|', map { $_->id } map { @{$_ || []} } values %$packages); $best and push @best, $best; } @@ -391,7 +404,7 @@ sub resolve_requested { if (grep { ranges_overlap($_, $property) } $p->provides) { #- the existing package will conflicts with selection, check if a newer #- version will be ok, else ask to remove the old. - my $packages = $urpm->find_candidate_packages($p->name); + my $packages = $urpm->find_candidate_packages($p->name, \%avoided); my $best = join '|', map { $_->id } grep { ! grep { ranges_overlap($_, $property) } $_->provides } @{$packages->{$p->name}}; diff --git a/perl-URPM.spec b/perl-URPM.spec index 7dfd8e6..7b2ecc2 100644 --- a/perl-URPM.spec +++ b/perl-URPM.spec @@ -1,7 +1,7 @@ %define name perl-URPM %define real_name URPM -%define version 0.80 -%define release 2mdk +%define version 0.81 +%define release 1mdk %{expand:%%define rpm_version %(rpm -q --queryformat '%{VERSION}-%{RELEASE}' rpm)} @@ -49,6 +49,11 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Dec 17 2002 François Pons 0.81-1mdk +- little improve on traverse_tag with tag name when env. +- fixed dependencies resolution when various different version + of a package are available. + * Wed Dec 11 2002 François Pons 0.80-2mdk - removed dSP in XS (sound like perl doesn't like them a lot), this fixes urpmf problem of reading first hdlist. -- cgit v1.2.1