aboutsummaryrefslogtreecommitdiffstats
path: root/URPM/Resolve.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2003-07-10 16:02:50 +0000
committerFrancois Pons <fpons@mandriva.com>2003-07-10 16:02:50 +0000
commit217f438aaf8ffc92f75afe56ecd90d03f43ee658 (patch)
treea84ffe77334def35dfe5b27d1644c9a13a7e899f /URPM/Resolve.pm
parent64797c37406f2dcf3b5ae5dd4c77a40bba97cc06 (diff)
downloadperl-URPM-217f438aaf8ffc92f75afe56ecd90d03f43ee658.tar
perl-URPM-217f438aaf8ffc92f75afe56ecd90d03f43ee658.tar.gz
perl-URPM-217f438aaf8ffc92f75afe56ecd90d03f43ee658.tar.bz2
perl-URPM-217f438aaf8ffc92f75afe56ecd90d03f43ee658.tar.xz
perl-URPM-217f438aaf8ffc92f75afe56ecd90d03f43ee658.zip
optimized URPM::compute_flags method by an almost unlimited factor.
Diffstat (limited to 'URPM/Resolve.pm')
-rw-r--r--URPM/Resolve.pm63
1 files changed, 37 insertions, 26 deletions
diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm
index c9eba62..0ba8ff1 100644
--- a/URPM/Resolve.pm
+++ b/URPM/Resolve.pm
@@ -811,37 +811,48 @@ sub compute_installed_flags {
#- callback : sub to be called for each package with skip flag activated,
sub compute_flags {
my ($urpm, $val, %options) = @_;
+ my %regex;
- #- avoid losing our time.
- %$val or return;
-
- foreach my $pkg (@{$urpm->{depslist}}) {
- #- check if fullname is matching a regexp.
- if (grep { exists($val->{$_}{''}) && /^\/(.*)\/$/ && $pkg->fullname =~ /$1/ } keys %$val) {
- #- a single selection on fullname using a regular expression.
- foreach (qw(skip disable_obsolete)) {
- if ($options{$_} && !$pkg->flag($_)) {
- $pkg->set_flag($_, 1);
- $options{callback} and $options{callback}->($urpm, $pkg, %options);
- }
- }
+ #- perform the fastest possible, unless a regular expression is given,
+ #- the operation matches only according to provides.
+ while (my ($name, $sense) = each %$val) {
+ if ($name =~ /^\/(.*)\/$/) {
+ $regex{$1} = $sense;
} else {
- #- check if a provides match at least one package.
- foreach ($pkg->provides) {
- if (my ($n, $s) = /^([^\s\[]*)(?:\[\*\])?\[?([^\s\]]*\s*[^\s\]]*)/) {
- foreach my $sn ($n, grep { /^\/(.*)\/$/ && $n =~ /$1/ } keys %$val) {
- foreach (keys %{$val->{$sn} || {}}) {
- if (URPM::ranges_overlap($_, $s)) {
- foreach (qw(skip disable_obsolete)) {
- if ($options{$_} && !$pkg->flag($_)) {
- $pkg->set_flag($_, 1);
- $options{callback} and $options{callback}->($urpm, $pkg, %options);
- }
- }
- }
+ foreach (keys %{$urpm->{provides}{$name} || {}}) {
+ my $pkg = $urpm->{depslist}[$_];
+ my $satisfied = exists($sense->{''}) || !$urpm->{provides}{$name}{$_};
+ unless ($satisfied) {
+ foreach my $s (keys %$sense) {
+ foreach ($pkg->provides) {
+ ranges_overlap($_, $name.$s) and ++$satisfied, last;
}
}
}
+ if ($satisfied) {
+ foreach (qw(skip disable_obsolete)) {
+ if ($options{$_} && !$pkg->flag($_)) {
+ $pkg->set_flag($_, 1);
+ $options{callback} and $options{callback}->($urpm, $pkg, %options);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #- now perform regular matches but only on fullname.
+ if (%regex) {
+ foreach my $pkg (@{$urpm->{depslist}}) {
+ #- check if fullname is matching a regexp.
+ if (grep { exists($regex{$_}{''}) && $pkg->fullname =~ /$1/ } keys %regex) {
+ #- a single selection on fullname using a regular expression.
+ foreach (qw(skip disable_obsolete)) {
+ if ($options{$_} && !$pkg->flag($_)) {
+ $pkg->set_flag($_, 1);
+ $options{callback} and $options{callback}->($urpm, $pkg, %options);
+ }
+ }
}
}
}