aboutsummaryrefslogtreecommitdiffstats
path: root/URPM
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-01-09 13:22:36 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-01-09 13:22:36 +0000
commit9204f244a730b828802035fa659eb6773d8851b6 (patch)
treec538c7c4fa9572b05ea0a10d49f9e6647f0f7708 /URPM
parent5375c0872a928a3e99b7e24c2944d2aa9902605c (diff)
downloadperl-URPM-9204f244a730b828802035fa659eb6773d8851b6.tar
perl-URPM-9204f244a730b828802035fa659eb6773d8851b6.tar.gz
perl-URPM-9204f244a730b828802035fa659eb6773d8851b6.tar.bz2
perl-URPM-9204f244a730b828802035fa659eb6773d8851b6.tar.xz
perl-URPM-9204f244a730b828802035fa659eb6773d8851b6.zip
factorize code into _set_flag_installed_and_upgrade_if_no_newer()
Diffstat (limited to 'URPM')
-rw-r--r--URPM/Resolve.pm52
1 files changed, 21 insertions, 31 deletions
diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm
index bbbff30..3b915af 100644
--- a/URPM/Resolve.pm
+++ b/URPM/Resolve.pm
@@ -116,15 +116,8 @@ sub find_chosen_packages {
#- Packages with more compatibles architectures are always preferred.
#- Puts the results in @chosen. Other are left unordered.
foreach my $p (values(%packages)) {
- unless ($p->flag_upgrade || $p->flag_installed) {
- #- assume for this small algorithm package to be upgradable.
- $p->set_flag_upgrade;
- $db->traverse_tag('name', [ $p->name ], sub {
- my ($pp) = @_;
- $p->set_flag_installed;
- $p->flag_upgrade and $p->set_flag_upgrade($p->compare_pkg($pp) > 0);
- });
- }
+ _set_flag_installed_and_upgrade_if_no_newer($db, $p);
+
my $arch_score = ($p->is_arch_compat < min map { $_->is_arch_compat } @chosen) ? 10 : 0;
if ($p->flag_requested && $p->flag_installed) {
$mode < 3 + $arch_score and @chosen = ();
@@ -542,17 +535,8 @@ sub resolve_requested {
if ($pkg->arch eq 'src') {
$pkg->set_flag_upgrade;
} else {
- if (!$pkg->flag_upgrade && !$pkg->flag_installed) {
- #- assume for this small algorithm package to be upgradable.
- my $upgrade = 1;
- $db->traverse_tag('name', [ $pkg->name ], sub {
- my ($p) = @_;
- #- there is at least one package installed (whatever its version).
- $pkg->set_flag_installed;
- $upgrade &&= $pkg->compare_pkg($p) > 0;
- });
- $pkg->set_flag_upgrade($upgrade);
- }
+ _set_flag_installed_and_upgrade_if_no_newer($db, $pkg);
+
if ($pkg->flag_installed && !$pkg->flag_upgrade) {
_no_more_recent_installed_and_providing($urpm, $db, $pkg, $dep->{required}) or next;
}
@@ -840,6 +824,20 @@ sub _id_to_name {
}
}
+sub _set_flag_installed_and_upgrade_if_no_newer {
+ my ($db, $pkg) = @_;
+
+ !$pkg->flag_upgrade && !$pkg->flag_installed or return;
+
+ my $upgrade = 1;
+ $db->traverse_tag('name', [ $pkg->name ], sub {
+ my ($p) = @_;
+ $pkg->set_flag_installed;
+ $upgrade &&= $pkg->compare_pkg($p) > 0;
+ });
+ $pkg->set_flag_upgrade($upgrade);
+}
+
sub _no_more_recent_installed_and_providing {
my ($urpm, $db, $pkg, $required) = @_;
@@ -1153,17 +1151,9 @@ sub request_packages_to_upgrade {
#- examine all obsoleter packages, compute installer and upgrade flag if needed.
foreach my $pkg (@obsoleters) {
next if !$names{$pkg->name};
- unless ($pkg->flag_upgrade || $pkg->flag_installed) {
- #- assume for this small algorithm package to be upgradable.
- $pkg->set_flag_upgrade;
- $db->traverse_tag(
- 'name', [ $pkg->name ], sub {
- my ($p) = @_;
- $pkg->set_flag_installed; #- there is at least one package installed (whatever its version).
- $pkg->flag_upgrade and $pkg->set_flag_upgrade($pkg->compare_pkg($p) > 0);
- },
- );
- }
+
+ _set_flag_installed_and_upgrade_if_no_newer($db, $pkg);
+
if ($pkg->flag_installed && !$pkg->flag_upgrade) {
delete $names{$pkg->name};
} else {