From a3d672d23de228cb2955f5825869154b77a7f5e0 Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Thu, 6 Jun 2002 15:44:27 +0000 Subject: 0.03-2mdk --- URPM.pm | 119 ++++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 70 insertions(+), 49 deletions(-) (limited to 'URPM.pm') diff --git a/URPM.pm b/URPM.pm index 5d712cf..2d6bb85 100644 --- a/URPM.pm +++ b/URPM.pm @@ -18,55 +18,6 @@ sub new { }, $class; } -#- relocate depslist array id to use only the most recent packages, -#- reorder info hashes to give only access to best packages. -sub relocate_depslist { - my ($urpm, %options) = @_; - my $relocated_entries = 0; - - #- reset names hash now, will be filled after. - $urpm->{names} = {}; - - foreach (@{$urpm->{depslist} || []}) { - #- remove access to info if arch is incompatible and only - #- take into account compatible arch to examine. - #- set names hash by prefering first better version, - #- then better release, then better arch. - if ($_->is_arch_compat) { - my $p = $urpm->{names}{$_->name}; - if ($p) { - if ($_->compare_pkg($p) > 0) { - $urpm->{names}{$_->name} = $_; - ++$relocated_entries; - } - } else { - $urpm->{names}{$_->name} = $_; - } - } elsif ($_->arch ne 'src') { - #- the package is removed, make it invisible (remove id). - my $id = $_->set_id; - - #- the architecture is not compatible, this means the package is dropped. - #- we have to remove its reference in provides. - foreach ($_->provides) { - delete $urpm->{provides}{$_}{$id}; - } - } - } - - #- relocate id used in depslist array, delete id if the package - #- should NOT be used. - #- if no entries have been relocated, we can safely avoid this computation. - if ($relocated_entries) { - foreach (@{$urpm->{depslist}}) { - my $p = $urpm->{names}{$_->name} or next; - $_->set_id($p->id); - } - } - - $relocated_entries; -} - sub traverse { my ($urpm, $callback) = @_; @@ -127,3 +78,73 @@ sub traverse_tag { $count; } + +#- relocate depslist array id to use only the most recent packages, +#- reorder info hashes to give only access to best packages. +sub relocate_depslist { + my ($urpm, %options) = @_; + my $relocated_entries = 0; + + #- reset names hash now, will be filled after. + $urpm->{names} = {}; + + foreach (@{$urpm->{depslist} || []}) { + #- remove access to info if arch is incompatible and only + #- take into account compatible arch to examine. + #- set names hash by prefering first better version, + #- then better release, then better arch. + if ($_->is_arch_compat) { + my $p = $urpm->{names}{$_->name}; + if ($p) { + if ($_->compare_pkg($p) > 0) { + $urpm->{names}{$_->name} = $_; + ++$relocated_entries; + } + } else { + $urpm->{names}{$_->name} = $_; + } + } elsif ($_->arch ne 'src') { + #- the package is removed, make it invisible (remove id). + my $id = $_->set_id; + + #- the architecture is not compatible, this means the package is dropped. + #- we have to remove its reference in provides. + foreach ($_->provides) { + delete $urpm->{provides}{$_}{$id}; + } + } + } + + #- relocate id used in depslist array, delete id if the package + #- should NOT be used. + #- if no entries have been relocated, we can safely avoid this computation. + if ($relocated_entries) { + foreach (@{$urpm->{depslist}}) { + my $p = $urpm->{names}{$_->name} or next; + $_->set_id($p->id); + } + } + + $relocated_entries; +} + +#- resolve requires using requested tag, keep resolution state to speed process. +#- a requested package is marked to be installed, once done, a upgrade flag or +#- installed flag is set according to needs of package. +#- other required package will have required flag set along with upgrade flag or +#- installed flag. +#- base flag should always been installed or upgraded. +#- the following options are recognized : +#- check : check requires of installed packages. +sub resolve_requires { + my ($urpm, $db, $state, %options); + my (@packages); + + #- get package that need to be evaluated. + foreach (0 .. $#{$urpm->{depslist}}) { + my $pkg = $urpm->{depslist}[$_]; + $pkg->flag_requested && !($pkg->flag_installed || $pkg->flag_upgrade) and push @packages, $_; + } + #TODO +} + -- cgit v1.2.1