aboutsummaryrefslogtreecommitdiffstats
path: root/URPM
diff options
context:
space:
mode:
Diffstat (limited to 'URPM')
-rw-r--r--URPM/Query.pm45
-rw-r--r--URPM/Resolve.pm22
2 files changed, 60 insertions, 7 deletions
diff --git a/URPM/Query.pm b/URPM/Query.pm
new file mode 100644
index 0000000..02e911e
--- /dev/null
+++ b/URPM/Query.pm
@@ -0,0 +1,45 @@
+package URPM;
+
+use strict;
+use warnings;
+
+# perl_checker: require URPM
+
+# Olivier Thauvin <thauvin@aerov.jussieu.fr>
+# This package extend URPM functions to permit
+# URPM low level query on rpm header
+# $Id: Query.pm 270395 2010-07-30 00:55:59Z nanardon $
+#
+# UNUSED BY ANYTHING IN THE DISTRO
+#
+
+# tag2id
+# INPUT array of rpm tag name
+# Return an array of ID tag
+
+sub tag2id {
+ my @l = @_;
+ my %taglist = URPM::list_rpm_tag();
+ map { $taglist{uc($_)} || undef } @l;
+}
+
+sub query_pkg {
+ my (undef, $pkg, $query) = @_;
+ my @tags = map {
+ [ $pkg->get_tag(tag2id($_)) ];
+ } $query =~ m/\%\{([^{}]*)\}*/g;
+
+ $query =~ s/\%\{[^{}]*\}/%s/g;
+ $query =~ s/\\n/\n/g;
+ $query =~ s/\\t/\t/g;
+ my ($max, @res) = 0;
+
+ foreach (@tags) { $max < $#{$_} and $max = $#{$_} }
+
+ foreach my $i (0 .. $max) {
+ push @res, sprintf($query, map { ${$_}[ $#{$_} < $i ? $#{$_} : $i] } @tags);
+ }
+ @res;
+}
+
+1;
diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm
index f79c438..e0eaf9d 100644
--- a/URPM/Resolve.pm
+++ b/URPM/Resolve.pm
@@ -82,7 +82,7 @@ sub find_candidate_packages_ {
$pkg->is_arch_compat or next;
$o_rejected && exists $o_rejected->{$pkg->fullname} and next;
#- check if at least one provide of the package overlap the property.
- !$urpm->{provides}{$name}{$_} || $pkg->provides_overlap($property)
+ !$urpm->{provides}{$name}{$_} || $pkg->provides_overlap($property, 1)
and push @packages, $pkg;
}
}
@@ -287,7 +287,7 @@ sub _find_required_package__sort {
my @chosen = map { $_->[0] } @chosen_with_score;
#- return immediately if there is only one chosen package
- return \@chosen if @chosen == 1;
+ if (@chosen == 1) { return \@chosen }
#- if several packages were selected to match a requested installation,
#- and if --more-choices wasn't given, trim the choices to the first one.
@@ -490,7 +490,7 @@ sub unsatisfied_requires {
#- check on the selected package if a provide is satisfying the resolution (need to do the ops).
foreach (grep { exists $state->{selected}{$_} } keys %{$urpm->{provides}{$n} || {}}) {
my $p = $urpm->{depslist}[$_];
- !$urpm->{provides}{$n}{$_} || $p->provides_overlap($prop) and next REQUIRES;
+ !$urpm->{provides}{$n}{$_} || $p->provides_overlap($prop, 1) and next REQUIRES;
}
#- check if the package itself provides what is necessary.
@@ -513,7 +513,7 @@ sub unsatisfied_requires {
if (my ($pn, $ps) = property2name_range($_)) {
$ps or $state->{cached_installed}{$pn}{$p->fullname} = undef;
$pn eq $n or next;
- URPM::ranges_overlap($ps, $s) and ++$satisfied;
+ URPM::ranges_overlap($ps, $s, 1) and ++$satisfied;
}
}
});
@@ -1487,7 +1487,9 @@ sub disable_selected_and_unrequested_dependencies {
#- keep in the packages that had to be unselected.
@all_unselected or push @all_unselected, @unselected;
- last if $urpm->{keep_unrequested_dependencies};
+ if ($urpm->{keep_unrequested_dependencies}) {
+ last;
+ }
#- search for unrequested required packages.
foreach (@unselected) {
@@ -1552,7 +1554,11 @@ sub _selected_size_filesize {
foreach (values %{$state->{rejected} || {}}) {
$_->{removed} || $_->{obsoleted} or next;
- $size -= abs($_->{size});
+ if ($_->{size} < 0) {
+ $size += $_->{size};
+ } else {
+ $size -= $_->{size};
+ }
}
foreach (@{$state->{orphans_to_remove} || []}) {
@@ -1643,7 +1649,9 @@ sub compute_flags {
sub _choose_best_pkg {
my ($urpm, $pkg_installed, @pkgs) = @_;
- _choose_best_pkg_($urpm, $pkg_installed, grep { $_->compare_pkg($pkg_installed) > 0 } @pkgs);
+ _choose_best_pkg_($urpm, $pkg_installed, grep {
+ $_->compare_pkg($pkg_installed) > 0;
+ } @pkgs);
}
#- side-effects: none