diff options
author | Francois Pons <fpons@mandriva.com> | 2001-11-26 15:40:55 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2001-11-26 15:40:55 +0000 |
commit | 948c59848688dff57de58dec0dd75d6ec32ed4a4 (patch) | |
tree | 8c16fbfffec2d89529b30b782a1cbf21b7aef69f | |
parent | c6ab03bfd880e1969ecb4e54ea390384ba7a6cd1 (diff) | |
download | urpmi-948c59848688dff57de58dec0dd75d6ec32ed4a4.tar urpmi-948c59848688dff57de58dec0dd75d6ec32ed4a4.tar.gz urpmi-948c59848688dff57de58dec0dd75d6ec32ed4a4.tar.bz2 urpmi-948c59848688dff57de58dec0dd75d6ec32ed4a4.tar.xz urpmi-948c59848688dff57de58dec0dd75d6ec32ed4a4.zip |
first 2.1.
-rw-r--r-- | urpm.pm | 192 | ||||
-rwxr-xr-x | urpmi | 33 | ||||
-rw-r--r-- | urpmi.spec | 14 | ||||
-rwxr-xr-x | urpmq | 25 |
4 files changed, 58 insertions, 206 deletions
@@ -1131,159 +1131,6 @@ sub search_packages { $result; } -#- compute the closure of a list, mostly internal function for filter_packages_to_upgrade. -#- limited to values in packages which should not be a reference. -#- package are identified by their id. -sub compute_closure { - my ($urpm, $packages, $installed, $select_choices) = @_; - my ($id, @packages) = (undef, keys %$packages); - - #- at this level, compute global closure of what is requested, regardless of - #- choices for which all package in the choices are taken and their dependencies. - #- allow iteration over a modifying list. - while (defined($id = shift @packages)) { - #- get a relocated id if possible, by this way. - $id = $urpm->{params}{depslist}[$id]{id}; - defined $id or next; #- this means we have an incompatible arch only (uggly and test it?) - - #- avoid a package if it has already been dropped in the sense of - #- selected directly by another way. - foreach ($id, split ' ', $urpm->{params}{depslist}[$id]{deps}) { - if (/\|/) { - my ($follow_id, @upgradable_choices, %choices_id); - @choices_id{grep { defined $_ } map { $urpm->{params}{depslist}[$_]{id} } split /\|/, $_} = (); - my @choices = sort { $a <=> $b } keys(%choices_id); - foreach (@choices) { - $installed && $installed->{$_} and $follow_id = -1, last; - exists $packages->{$_} && ! ref $packages->{$_} and $follow_id = $_, last; - $installed && exists $installed->{$_} and push @upgradable_choices, $_; - } - unless (defined $follow_id) { - #- if there are at least one upgradable choice, use it instead - #- of asking the user to chose among a list. - if (@upgradable_choices == 1) { - push @packages, $upgradable_choices[0]; - } else { - @upgradable_choices > 1 and @choices = @upgradable_choices; - #- propose the choice to the user now, or select the best one (as it is supposed to be). - my @selection = $select_choices ? ($select_choices->($urpm, $id, @choices)) : (); - if (@selection) { - foreach (@selection) { - unshift @packages, $_; - exists $packages->{$_} or $packages->{$_} = 1; - } - } else { - foreach (@choices) { - push @{$packages->{$_} ||= []}, \@choices; - } - } - } - } - } else { - local $_ = $urpm->{params}{depslist}[$_]{id}; - if (ref $packages->{$_}) { - #- all the choices associated here have to be dropped, need to copy else - #- there could be problem with foreach on a modifying list. - foreach my $choices (@{$packages->{$id}}) { - foreach (@$choices) { - $packages->{$_} = [ grep { $_ != $choices } @{$packages->{$_}} ]; - @{$packages->{$_}} > 0 or delete $packages->{$_}; - } - } - } - if ($installed && $installed->{$_}) { - delete $packages->{$_}; - } else { - exists $packages->{$_} or $packages->{$_} = $installed && ! exists $installed->{$_}; - } - } - } - } -} - -#- filter the packages list (assuming only the key is registered, so undefined -#- value stored) to keep only packages that need to be upgraded, -#- additionnal packages will be stored using non null values, -#- choice will have a list of other choices as values, -#- initial packages will have a 0 stored as values. -#- options allow changing some behaviour of the algorithms: -#- complete -> perform a complete closure before trying to look for upgrade. -sub filter_packages_to_upgrade { - my ($urpm, $packages, $select_choices, %options) = @_; - my ($id, %closures, %installed, @packages_installed); - my $db = rpmtools::db_open(''); #- keep it open for all operation that could be done. - - #- request the primary list to rpmlib if complete mode is not activated. - if (!$options{complete}) { - #- there are not too many packages selected here to allow - #- take care of package up-to-date at this point, - #- so check version and if the package does not need to - #- updated, ignore it and his dependencies. - rpmtools::db_traverse_tag($db, "name", [ map { $urpm->{params}{depslist}[$_]{name} } keys %$packages ], - [ qw(name version release serial) ], sub { - my ($p) = @_; - my $pkg = $urpm->{params}{info}{$p->{name}}; - if ($pkg) { - my $cmp = rpmtools::version_compare($pkg->{version}, $p->{version}); - $installed{$pkg->{id}} = !($pkg->{serial} > $p->{serial} || - $pkg->{serial} == $p->{serial} && - ($cmp > 0 || $cmp == 0 && - rpmtools::version_compare($pkg->{release}, - $p->{release}) > 0)) - and delete $packages->{$pkg->{id}}; - } - }); - } - - #- select first level of packages, as in packages list will only be - #- examined deps of each. - #- at this level, compute global closure of what is requested, regardless of - #- choices for which all package in the choices are taken and their dependencies. - #- allow iteration over a modifying list. - @closures{keys %$packages} = (); - $urpm->compute_closure(\%closures, undef, sub { my ($urpm, @l) = @_; @l }); - - #- closures has been done so that its keys are the package that may be examined. - #- according to number of keys, get all package installed or only the necessary - #- packages. - my $examine_installed_packages = sub { - my ($p) = @_; - my $pkg = $urpm->{params}{names}{$p->{name}}; - if ($pkg && exists $closures{$pkg->{id}}) { - my $cmp = rpmtools::version_compare($pkg->{version}, $p->{version}); - $installed{$pkg->{id}} = !($pkg->{serial} > $p->{serial} || $pkg->{serial} == $p->{serial} && - ($cmp > 0 || $cmp == 0 && rpmtools::version_compare($pkg->{release}, $p->{release}) > 0)) - and delete $packages->{$pkg->{id}}; - } - }; - #- do not take care of already examined packages. - delete @closures{keys %installed}; - if (scalar(keys %closures) < 100) { - rpmtools::db_traverse_tag($db, "name", [ map { $urpm->{params}{depslist}[$_]{name} } keys %closures ], - [ qw(name version release serial) ], $examine_installed_packages); - } else { - rpmtools::db_traverse($db, [ qw(name version release serial) ], $examine_installed_packages); - } - rpmtools::db_close($db); - - #- recompute closure but ask for which package to select on a choices. - #- this is necessary to have the result before the end else some dependency may - #- be losed or added. - #- accept no choice allow to browse list, and to compute it with more iteration. - %closures = (); @closures{keys %$packages} = (); - $urpm->compute_closure(\%closures, \%installed, $select_choices); - - #- restore package to match selection done, update the values according to - #- need upgrade (0), requested (undef), already installed (not present) or - #- newly added (1). - #- choices if not chosen are present as ref. - foreach (keys %closures) { - exists $packages->{$_} or $packages->{$_} = $closures{$_}; - } - - $packages; -} - #- parse synthesis file to retrieve information stored inside. sub parse_synthesis { my ($urpm, $synthesis) = @_; @@ -1480,6 +1327,7 @@ sub filter_minimal_packages_to_upgrade { #- it will be resolved by searching the rpm database. $provides{$n} ||= undef; my $check_pkg = sub { + $options{keep_alldeps} and return; $v and eval(rpmtools::version_compare($_[0]{version}, $v) . $o . 0) || return; $r and eval(rpmtools::version_compare($_[0]{release}, $r) . $o . 0) || return; $provides{$n} = "$_[0]{name}-$_[0]{version}-$_[0]{release}"; @@ -1521,13 +1369,16 @@ sub filter_minimal_packages_to_upgrade { foreach my $pkg (@pre_choices) { push @choices, $pkg; - rpmtools::db_traverse_tag($db, - 'name', [ $_ ], - [ qw(name version release serial) ], sub { - my ($p) = @_; - my $cmp = rpmtools::version_compare($pkg->{version}, $p->{version}); - $installed{$pkg->{id}} ||= !($pkg->{serial} > $p->{serial} || $pkg->{serial} == $p->{serial} && ($cmp > 0 || $cmp == 0 && rpmtools::version_compare($pkg->{release}, $p->{release}) > 0)); - }); + unless ($options{keep_alldeps}) { + rpmtools::db_traverse_tag($db, + 'name', [ $_ ], + [ qw(name version release serial) ], sub { + my ($p) = @_; + my $cmp = rpmtools::version_compare($pkg->{version}, + $p->{version}); + $installed{$pkg->{id}} ||= !($pkg->{serial} > $p->{serial} || $pkg->{serial} == $p->{serial} && ($cmp > 0 || $cmp == 0 && rpmtools::version_compare($pkg->{release}, $p->{release}) > 0)); + }); + } $installed{$pkg->{id}} and delete $packages->{$pkg->{id}}; if (exists $packages->{$pkg->{id}} || $installed{$pkg->{id}}) { #- the package is already selected, or installed with a better version and release. @@ -1924,8 +1775,8 @@ sub select_packages_to_upgrade { }); } - #- mark all files which are not in /dev or /etc/rc.d/ for packages which are already installed but which - #- are not in the packages list to upgrade. + #- mark all files which are not in /dev or /etc/rc.d/ for packages which are already installed + #- but which are not in the packages list to upgrade. #- the 'installed' property will make a package unable to be selected, look at select. rpmtools::db_traverse($db, [ qw(name version release serial files) ], sub { my ($p) = @_; @@ -1936,11 +1787,13 @@ sub select_packages_to_upgrade { my $version_cmp = rpmtools::version_compare($p->{version}, $pkg->{version}); if ($p->{serial} > $pkg->{serial} || $p->{serial} == $pkg->{serial} && ($version_cmp > 0 || - $version_cmp == 0 && rpmtools::version_compare($p->{release}, $pkg->{release}) >= 0)) { + $version_cmp == 0 && + rpmtools::version_compare($p->{release}, $pkg->{release}) >= 0)) { if ($otherPackage && $version_cmp <= 0) { $toRemove{$otherPackage} = 0; $pkg->{selected} = 1; - $urpm->{log}(_("removing %s to upgrade ...\n to %s since it will not be updated otherwise", $otherPackage, "$pkg->{name}-$pkg->{version}-$pkg->{release}")); + $urpm->{log}(_("removing %s to upgrade to %s ... + since it will not be updated otherwise", $otherPackage, "$pkg->{name}-$pkg->{version}-$pkg->{release}")); } else { $pkg->{installed} = 1; } @@ -1948,10 +1801,11 @@ sub select_packages_to_upgrade { my $otherPackage = "$p->{name}-$p->{version}-$p->{release}"; $toRemove{$otherPackage} = 0; $pkg->{selected} = 1; - $urpm->{log}(_("removing %s to upgrade ...\n to %s since it will not upgrade correctly!", $otherPackage, "$pkg->{name}-$pkg->{version}-$pkg->{release}")); + $urpm->{log}(_("removing %s to upgrade to %s ... + since it will not upgrade correctly!", $otherPackage, "$pkg->{name}-$pkg->{version}-$pkg->{release}")); } } else { - if (! exists $obsoletedPackages{$p->{name}}) { + if (exists $obsoletedPackages{$p->{name}}) { @installedFilesForUpgrade{grep { ($_ !~ m|^/dev/| && $_ !~ m|^/etc/rc.d/| && $_ !~ m|\.la$| && ! -d "$prefix/$_" && ! -l "$prefix/$_") } @@ -2021,13 +1875,15 @@ sub select_packages_to_upgrade { }); if ($toSelect) { if ($toSelect <= 1 && $pkg->{name} =~ /-devel/) { - $urpm->{log}(_("avoid selecting %s as not enough files will be updated", "$pkg->{name}-$pkg->{version}-$pkg->{release}")); + $urpm->{log}(_("avoid selecting %s as not enough files will be updated", + "$pkg->{name}-$pkg->{version}-$pkg->{release}")); } else { #- default case is assumed to allow upgrade. my @deps = map { /\|/ and next; #- do not inspect choice my $p = $urpm->{params}{depslist}[$_]; $p && $p->{name} =~ /locales-/ ? ($p) : () } split ' ', $pkg->{deps}; - if (@deps == 0 || @deps > 0 && (grep { !$_->{selected} && !$_->{installed} } @deps) == 0) { + if (@deps == 0 || + @deps > 0 && (grep { !$_->{selected} && !$_->{installed} } @deps) == 0) { $urpm->{log}(_("selecting %s by selection on files", $pkg->{name})); $pkg->{selected} = 1; } else { @@ -31,8 +31,6 @@ my $force = 0; my $X = 0; my $WID = 0; my $all = 0; -my $complete = 0; -my $minimal = 1; my $rpm_opt = "vh"; my $use_provides = 0; my $verbose = 0; @@ -60,9 +58,6 @@ usage: ") . _(" --best-output - choose best interface according to the environment: X or text mode. ") . _(" -a - select all matches on command line. -") . _(" -m - choose minimum closure of requires (default). -") . _(" -M - ignored, kept for compability. -") . _(" -c - choose complete method for resolving requires closure. ") . _(" -p - allow search in provides to find package. ") . _(" -q - quiet mode. ") . _(" -v - verbose mode. @@ -89,8 +84,8 @@ for (@ARGV) { /^-(.*)$/ and do { foreach (split //, $1) { /[\?h]/ and do { usage; next }; /a/ and do { $all = 1; next }; - /c/ and do { $complete = 1; next }; - /m/ and do { $minimal = 1; next }; + /c/ and do { next }; + /m/ and do { next }; /M/ and do { next }; #- nop /q/ and do { $rpm_opt = ""; next }; /p/ and do { $use_provides = 1; next }; @@ -156,7 +151,7 @@ if (@files) { $use_provides or $urpm->read_provides; #- build closure with local package and return list of names. - push @names, $urpm->register_local_packages($minimal, @files); + push @names, $urpm->register_local_packages('minimal', @files); } #- reparse whole internal depslist to match against newer packages only. @@ -173,9 +168,10 @@ $urpm->relocate_depslist_provides(use_active => $update); #- all its dependency will be updated too. #- make sure basesystem exists before. my %packages; -$urpm->search_packages(\%packages, - [ ($minimal || !$urpm->{params}{info}{basesystem} ? () : ('basesystem')), @names], - all => $all, use_provides => $use_provides, use_active => $update) or $force or exit 1; +$urpm->search_packages(\%packages, [ @names], + all => $all, + use_provides => $use_provides, + use_active => $update) or $force or exit 1; #- filter to add in packages selected required packages. my $ask_choice = sub { @@ -218,13 +214,9 @@ if ($auto_select) { } } -if ($minimal) { - $use_provides || @files or $urpm->read_provides; - $update || $auto_select or $urpm->read_config; - $urpm->filter_minimal_packages_to_upgrade(\%packages, $ask_choice); -} else { - $urpm->filter_packages_to_upgrade(\%packages, $ask_choice, complete => $complete); -} +$use_provides || @files or $urpm->read_provides; +$update || $auto_select or $urpm->read_config; +$urpm->filter_minimal_packages_to_upgrade(\%packages, $ask_choice); #- get out of package that should not be upgraded. $urpm->deselect_unwanted_packages(\%packages); @@ -261,8 +253,6 @@ if (!$auto) { } } -$minimal or $urpm->read_config; - my ($local_sources, $list, $local_to_removes) = $urpm->get_source_packages(\%packages); unless ($local_sources || $list) { $urpm->{fatal}(3, _("unable to get source packages, aborting")); @@ -303,7 +293,8 @@ if (@rpms_install || @rpms_upgrade) { } $urpm->{log}("starting installing packages"); if ($X) { - system("grpmi", $WID ? ("--WID=$WID") : (), map { ("-noupgrade", $_) } @rpms_install, @rpms_upgrade); + system("grpmi", $WID ? ("--WID=$WID") : (), + (map { ("-noupgrade", $_) } @rpms_install), @rpms_upgrade); if ($?) { message(_("Installation failed")); #- grpmi handles --nodeps and --force by itself, exit(($? >> 8) + 32); #- forward grpmi error + 32 @@ -1,8 +1,8 @@ %define group System/Configuration/Packaging Name: urpmi -Version: 2.0 -Release: 7mdk +Version: 2.1 +Release: 1mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate @@ -126,6 +126,16 @@ rm -f /var/lib/urpmi/depslist %changelog +* Mon Nov 26 2001 François Pons <fpons@mandrakesoft.com> 2.1-1mdk +- removed obsoleted code in urpm module. +- ignore -m, -M and -c flag of urpmi/urpmq. +- fixed group display of urpmq. +- added -f for urpmq to display full package name. +- fixed -d of urpmq. +- fixed --auto-select and files of package not obsoleted but + present in other registered package (no more selected). +- fixed call to grpmi (no more only installation). + * Wed Nov 21 2001 François Pons <fpons@mandrakesoft.com> 2.0-7mdk - fixed missing urpmi configuration file not read. - fixed bad output of rpm files to be installed or upgraded. @@ -40,14 +40,11 @@ usage: ") . _(" -v - verbose mode. ") . _(" -d - extend query to package dependencies. ") . _(" -u - remove package if a better version is already installed. -") . _(" -m - extend query to package dependencies, remove already - installed package that provide what is necessary, add - packages that may be block the upgrade. -") . _(" -M - same as -m mode, see above. ") . _(" -c - choose complete method for resolving requires closure. ") . _(" -p - allow search in provides to find package. ") . _(" -g - print groups too with name. ") . _(" -r - print version and release too with name. +") . _(" -f - print version, release and arch with name. ") . "\n" . _(" --update - use only update media. ") . _(" --auto-select - automatically select packages for upgrading the system. ") . _(" --headers - extract headers for package listed from urpmi db to @@ -72,13 +69,14 @@ for (@ARGV) { /[\?h]/ and do { usage; next }; /d/ and do { $query->{deps} = 1; next }; /u/ and do { $query->{upgrade} = 1; next }; - /m/ and do { $query->{minimal} = 1; next }; - /M/ and do { $query->{minimal} = 1; next }; #- nop same as -m + /m/ and do { next }; + /M/ and do { next }; /c/ and do { $query->{complete} = 1; next }; /g/ and do { $query->{group} = 1; next }; /p/ and do { $query->{use_provides} = 1; next }; /v/ and do { $query->{verbose} = 1; next }; /r/ and do { $query->{version} = $query->{release} = 1; next }; + /f/ and do { $query->{version} = $query->{release} = $query->{arch} = 1; next }; print STDERR _("urpmq: unknown option \"-%s\", check usage with --help\n", $1); exit(1) } next }; @nextargv and do { my $r = shift @nextargv; $r and $$r = $_; next }; /\.rpm$/ and do { if (-r $_) { push @files, $_; } @@ -103,7 +101,7 @@ if (@files) { $query->{use_provides} or $urpm->read_provides; #- build closure with local package and return list of names. - push @names, $urpm->register_local_packages($query->{minimal}, @files); + push @names, $urpm->register_local_packages('minimal', @files); } #- reparse whole internal depslist to match against newer packages only. @@ -133,14 +131,10 @@ if ($query->{auto_select}) { } #- filter to add in packages selected required packages. -if ($query->{minimal}) { - $query->{use_provides} || @files or $urpm->read_provides; - $query->{update} || $query->{auto_select} or $urpm->read_config(nocheck_access => 1); - $urpm->filter_minimal_packages_to_upgrade(\%packages, undef); -} else { - $query->{deps} && !$query->{upgrade} and $urpm->compute_closure(\%packages); - $query->{upgrade} and $urpm->filter_packages_to_upgrade(\%packages, undef, complete => $query->{complete}); -} +$query->{use_provides} || @files or $urpm->read_provides; +$query->{update} || $query->{auto_select} or $urpm->read_config(nocheck_access => 1); +$urpm->filter_minimal_packages_to_upgrade(\%packages, undef, + keep_alldeps => $query->{deps} && !$query->{upgrade}); #- get out of package that should not be upgraded. $urpm->deselect_unwanted_packages(\%packages); @@ -185,6 +179,7 @@ my $query_sub = sub { $str .= $info->{name}; $query->{version} and $str .= '-' . $info->{version}; $query->{release} and $str .= '-' . $info->{release}; + $query->{arch} and $str .= '.' . $info->{arch}; $str; }; |