summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--urpm.pm20
-rwxr-xr-xurpmi57
-rw-r--r--urpmi.spec9
-rwxr-xr-xurpmq35
4 files changed, 59 insertions, 62 deletions
diff --git a/urpm.pm b/urpm.pm
index ae13f39e..d75a2246 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -3,7 +3,7 @@ package urpm;
use strict;
use vars qw($VERSION @ISA);
-$VERSION = '3.4';
+$VERSION = '3.5';
@ISA = qw(URPM);
=head1 NAME
@@ -1132,7 +1132,6 @@ sub clean {
$urpm->{depslist} = [];
$urpm->{provides} = {};
- $urpm->{names} = {};
foreach (@{$urpm->{media} || []}) {
delete $_->{start};
@@ -1304,17 +1303,6 @@ sub search_packages {
my (%exact, %exact_a, %exact_ra, %found, %foundi);
foreach my $v (@$names) {
- #- it is a way of speedup, providing the name of a package directly help
- #- to find the package.
- #- this is necessary if providing a name list of package to upgrade.
- unless ($options{fuzzy}) {
- my $pkg = $urpm->{names}{$v};
- if ($pkg && defined $pkg->id && ($options{src} ? $pkg->arch eq 'src' : $pkg->arch ne 'src')) {
- $exact{$v} = $pkg->id;
- next;
- }
- }
-
my $qv = quotemeta $v;
if ($options{use_provides}) {
@@ -1381,7 +1369,7 @@ sub search_packages {
my $result = 1;
foreach (@$names) {
if (defined $exact{$_}) {
- $packages->{$exact{$_}} = undef;
+ $packages->{$exact{$_}} = 1;
} else {
#- at this level, we need to search the best package given for a given name,
#- always prefer already found package.
@@ -1406,7 +1394,7 @@ sub search_packages {
$best = $_;
}
}
- $packages->{$best->id} = undef;
+ $packages->{$best->id} = 1;
}
}
}
@@ -1703,7 +1691,7 @@ sub deselect_unwanted_packages {
foreach (keys %{$urpm->{provides}{$_} || {}}) {
my $pkg = $urpm->{depslist}[$_] or next;
$pkg->arch eq 'src' and next; #- never ignore source package.
- $options{force} || (exists $packages->{$_} && defined $packages->{$_})
+ $options{force} || (exists $packages->{$_} && ! defined $packages->{$_})
and delete $packages->{$_};
}
}
diff --git a/urpmi b/urpmi
index dd9f286d..4ef37921 100755
--- a/urpmi
+++ b/urpmi
@@ -236,26 +236,23 @@ $urpm->configure(nocheck_access => $uid > 0,
my ($start, $end) = $urpm->register_rpms(@files, @src_files);
-#- relocate depslist.
-$urpm->relocate_depslist_provides();
-
#- select individual files.
-my %packages;
-defined $start && defined $end and @packages{($start .. $end)} = ();
+my $state = { requested => {} };
+defined $start && defined $end and @{$state->{requested}}{($start .. $end)} = ();
#- search the packages according the selection given by the user,
#- basesystem is added to the list so if it need to be upgraded,
#- all its dependency will be updated too.
#- make sure basesystem exists before.
if (@names) {
- $urpm->search_packages(\%packages, [ @names ],
+ $urpm->search_packages($state->{requested}, [ @names ],
all => $all,
use_provides => $use_provides,
fuzzy => $fuzzy)
or $force or exit 1;
}
if (@src_names) {
- $urpm->search_packages(\%packages, [ @src_names ],
+ $urpm->search_packages($state->{requested}, [ @src_names ],
all => $all,
use_provides => $use_provides,
fuzzy => $fuzzy,
@@ -264,13 +261,14 @@ if (@src_names) {
}
#- filter to add in packages selected required packages.
-my $ask_choice = sub {
- my ($urpm, $from_id, @choices_id) = @_;
+sub ask_choice {
+ my ($urpm, $db, $state, $choices) = @_;
my $n = 1; #- default value.
- my ($from, @l) = map { my $pkg = $urpm->{depslist}[$_]; scalar $pkg->fullname } ($from_id, @choices_id);
+ my (@l) = map { scalar $_->fullname } @$choices;
+ my $from = undef; #TODO
if (@l > 1 && !$auto) {
- my $msg = (defined $from_id ?
+ my $msg = (defined $from ?
_("One of the following packages is needed to install %s:", $from) :
_("One of the following packages is needed:"));
if ($X) {
@@ -288,7 +286,7 @@ my $ask_choice = sub {
}
}
- $choices_id[$n - 1];
+ $choices->[$n - 1];
};
#- open/close of database should be moved here, in order to allow testing
@@ -299,38 +297,36 @@ my $ask_choice = sub {
local $SIG{INT} = $sig_handler;
local $SIG{QUIT} = $sig_handler;
+ require URPM::Resolve;
#- auto select package for upgrading the distribution.
if ($auto_select) {
my (%to_remove, %keep_files);
- $urpm->select_packages_to_upgrade($db, \%packages, \%to_remove, \%keep_files);
+ $urpm->resolve_packages_to_upgrade($db, $state, requested => 0);
- if (keys(%to_remove) > 0) {
+ if (%{$state->{ask_remove}} || %{$state->{ask_unselect}}) {
$urpm->{error}(_("some packages have to be removed for being upgraded, this is not supported yet\n"));
}
}
- $urpm->filter_packages_to_upgrade($db, \%packages, $ask_choice);
- #- my $track = $urpm->filter_packages_to_upgrade(\%packages, $ask_choice, track => 1);
- #- require Data::Dumper;
- #- print STDERR Data::Dumper->Dump([$track], ['$track']);
+ $urpm->resolve_requested($db, $state, callback_choices => \&ask_choice);
}
#- get out of package that should not be upgraded.
-$urpm->deselect_unwanted_packages(\%packages);
+$urpm->deselect_unwanted_packages($state->{selected});
#- package to install as a array of strings.
my @to_install;
#- check if there is at least one package to install that
#- has not been given by the user.
-my $ask_user = $auto_select && scalar(keys %packages);
+my $ask_user = $auto_select;
my $sum = 0;
my @root_only;
-foreach (keys %packages) {
- defined $packages{$_} and $ask_user = 1;
- my $pkg = $urpm->{depslist}[$_];
+foreach my $pkg (sort { $a->name cmp $b->name } @{$urpm->{depslist}}[keys %{$state->{selected}}]) {
+ $ask_user ||= $pkg->flag_required;
+
my $fullname = $pkg->fullname;
if ($uid > 0 && $pkg->arch ne 'src') {
push @root_only, $fullname;
@@ -359,7 +355,7 @@ if (@root_only) {
}
#- if not root, the list become invisible and no download will be possible.
-my ($local_sources, $list, $local_to_removes) = $urpm->get_source_packages(\%packages);
+my ($local_sources, $list, $local_to_removes) = $urpm->get_source_packages($state->{selected});
unless ($local_sources || $list) {
$urpm->{fatal}(3, _("unable to get source packages, aborting"));
}
@@ -495,9 +491,18 @@ sub message {
sub message_input {
my ($msg, $default_input) = @_;
- message($msg, $default_value); #- if a default value is given, the user doesn't have to choose (and being asked).
+ if ($X && !default_input) { #- if a default input is given, the user doesn't have to choose (and being asked).
+ `gmessage -default Ok -buttons Ok "$msg"`;
+ $bug and log_it($msg);
+ } else {
+ if ($bug) {
+ print STDOUT "$msg";
+ } else {
+ print SAVEOUT "$msg";
+ }
+ }
- my $input = $default_value || <STDIN>;
+ my $input = $default_input || <STDIN>;
$bug and log_it($input);
return $input;
}
diff --git a/urpmi.spec b/urpmi.spec
index e9ca655e..249780fc 100644
--- a/urpmi.spec
+++ b/urpmi.spec
@@ -1,14 +1,14 @@
%define group System/Configuration/Packaging
Name: urpmi
-Version: 3.4
-Release: 9mdk
+Version: 3.5
+Release: 1mdk
License: GPL
Source0: %{name}.tar.bz2
Source1: %{name}.logrotate
Summary: User mode rpm install
Requires: eject webfetch perl-DateManip >= 5.40
-PreReq: perl-gettext rpmtools >= 4.3-2mdk perl-URPM >= 0.03-2mdk
+PreReq: perl-gettext rpmtools >= 4.3-2mdk perl-URPM >= 0.04-1mdk
BuildRequires: bzip2-devel gcc-c++ gettext rpm-devel rpmtools
BuildRoot: %{_tmppath}/%{name}-buildroot
BuildArch: noarch
@@ -144,6 +144,9 @@ fi
%changelog
+* Thu Jun 13 2002 François Pons <fpons@mandrakesoft.com> 3.5-1mdk
+- use perl-URPM >= 0.04 for new require resolution algorithms.
+
* Mon Jun 10 2002 François Pons <fpons@mandrakesoft.com> 3.4-9mdk
- fixed no output if root.
- use message function as most as possible. (why it wasn't used ?)
diff --git a/urpmq b/urpmq
index 03215e09..a3ba2d07 100755
--- a/urpmq
+++ b/urpmq
@@ -25,7 +25,7 @@ use urpm;
import urpm _;
#- default options.
-my $query = {};
+my $query = { use_provides => 1, };
my @files;
my @names;
@@ -42,7 +42,6 @@ usage:
") . _(" -d - extend query to package dependencies.
") . _(" -u - remove package if a better version is already installed.
") . _(" -c - choose complete method for resolving requires closure.
-") . _(" -p - allow search in provides to find package.
") . _(" -P - do not search in provides to find package.
") . _(" -y - impose fuzzy search (same as --fuzzy).
") . _(" -s - next package is a source package (same as --src).
@@ -121,24 +120,21 @@ $urpm->configure(nocheck_access => 1,
my ($start, $end) = $urpm->register_rpms(@files);
-#- relocate depslist.
-$urpm->relocate_depslist_provides();
-
#- select individual files.
-my %packages;
-defined $start && defined $end and @packages{($start .. $end)} = ();
+my $state = { requested => {} };
+defined $start && defined $end and @{$state->{requested}}{($start .. $end)} = ();
#- search the packages according the selection given by the user,
#- basesystem is added to the list so if it need to be upgraded, all its dependency
#- will be updated too.
if (@names) {
- $urpm->search_packages(\%packages, [ @names ],
+ $urpm->search_packages($state->{requested}, [ @names ],
use_provides => $query->{use_provides},
fuzzy => $query->{fuzzy})
or $query->{force} or exit 1;
}
if (@src_names) {
- $urpm->search_packages(\%packages, [ @src_names ],
+ $urpm->search_packages($state->{requested}, [ @src_names ],
use_provides => $query->{use_provides},
fuzzy => $query->{fuzzy},
src => 1)
@@ -153,26 +149,31 @@ if ($query->{auto_select} || $query->{deps}) {
local $SIG{INT} = $sig_handler;
local $SIG{QUIT} = $sig_handler;
+ require URPM::Resolve;
#- auto select package for upgrading the distribution.
if ($query->{auto_select}) {
my (%to_remove, %keep_files);
- $urpm->select_packages_to_upgrade($db, \%packages, \%to_remove, \%keep_files);
+ $urpm->resolve_packages_to_upgrade($db, $state, requested => 0);
- if (keys(%to_remove) > 0) {
+ if (%{$state->{ask_remove}} || %{$state->{ask_unselect}}) {
$urpm->{error}(_("some packages have to be removed for being upgraded, this is not supported yet\n"));
}
}
#- filter to add in packages selected required packages.
- $query->{deps} and $urpm->filter_packages_to_upgrade($db, \%packages, undef, keep_alldeps => !$query->{upgrade});
+ if ($query->{upgrade}) {
+ $query->{deps} and $urpm->resolve_requested($db, $state);
+ } else { #TODO fallback tempory...
+ $urpm->filter_packages_to_upgrade($db, $state->{requested}, undef, keep_alldeps => 1);
+ }
}
#- get out of package that should not be upgraded.
-$urpm->deselect_unwanted_packages(\%packages);
+$urpm->deselect_unwanted_packages($state->{selected});
if ($query->{headers} || $query->{sources}) {
- my ($local_sources, $list) = $urpm->get_source_packages(\%packages);
+ my ($local_sources, $list) = $urpm->get_source_packages($state->{selected});
unless ($local_sources || $list) {
$urpm->{fatal}(1, _("unable to get source packages, aborting"));
}
@@ -221,8 +222,8 @@ my $query_sub = sub {
};
my %hack_only_one;
-foreach my $id (keys %packages) {
- my $class = $packages{$id};
+foreach my $id ($state->{selected} ? keys %{$state->{selected}} : keys %{$state->{requested}}) {
+ my $class = $state->{selected}{$id} || $state->{requested}{$id};
if (ref $class) {
foreach my $choices (@{$class || []}) {
exists $hack_only_one{$choices} and next;
@@ -230,7 +231,7 @@ foreach my $id (keys %packages) {
$hack_only_one{$choices} = undef;
}
} else {
- exists $packages{$id} and print join('|', map { $query_sub->($_) } split '\|', $id), "\n";
+ print join('|', map { $query_sub->($_) } split '\|', $id), "\n";
}
}