diff options
author | Francois Pons <fpons@mandriva.com> | 2002-02-11 13:31:21 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2002-02-11 13:31:21 +0000 |
commit | a6bddac94bf0364258dafd6feef3a775ea16900f (patch) | |
tree | c4f0a6b4fca24d47110ca65adac5660a1544aa8b | |
parent | 612f8aa481385da4a8468d793afcaa7dd0bc2458 (diff) | |
download | urpmi-a6bddac94bf0364258dafd6feef3a775ea16900f.tar urpmi-a6bddac94bf0364258dafd6feef3a775ea16900f.tar.gz urpmi-a6bddac94bf0364258dafd6feef3a775ea16900f.tar.bz2 urpmi-a6bddac94bf0364258dafd6feef3a775ea16900f.tar.xz urpmi-a6bddac94bf0364258dafd6feef3a775ea16900f.zip |
3.3-1mdk
-rw-r--r-- | urpm.pm | 127 | ||||
-rwxr-xr-x | urpmi | 268 | ||||
-rw-r--r-- | urpmi.spec | 11 | ||||
-rwxr-xr-x | urpmq | 33 |
4 files changed, 256 insertions, 183 deletions
@@ -4,7 +4,7 @@ use strict; use vars qw($VERSION @ISA); use Fcntl ':flock'; -$VERSION = '3.2'; +$VERSION = '3.3'; =head1 NAME @@ -143,7 +143,7 @@ sub sync_curl { } } } - #- http files (and other files) are correctly managed by curl to conditionnal upload. + #- http files (and other files) are correctly managed by curl to conditionnal download. #- options for ftp files, -R (-O <file>)* #- options for http files, -R (-z file -O <file>)* if (my @all_files = ((map { ("-O", $_ ) } @ftp_files), (map { /\/([^\/]*)$/ ? ("-z", $1, "-O", $_) : () } @other_files))) { @@ -704,7 +704,7 @@ sub update_media { #- is a symlink to a directory. #- make sure rpm filename format is correct and is not a source rpm #- which are not well managed by urpmi. - @files = grep { $_ !~ /\.src\.rpm/ } split "\n", `find '$dir/' -name "*.rpm" -print`; + @files = split "\n", `find '$dir/' -name "*.rpm" -print`; #- check files contains something good! if (@files > 0) { @@ -952,7 +952,7 @@ sub update_media { foreach my $file (keys %{$urpm->{params}{provides}}) { $file =~ /^\// or next; foreach (keys %{$urpm->{params}{provides}{$file} || {}}) { - push @{$urpm->{params}{info}{$_}{provides}}, $file; + eval { push @{$urpm->{params}{info}{$_}{provides}}, $file }; } } @@ -1162,7 +1162,7 @@ sub relocate_depslist_provides { } else { $urpm->{params}{names}{$_->{name}} = $_; } - } else { + } elsif ($_->{arch} ne 'src') { #- the package is removed, make it invisible (remove id). delete $_->{id}; @@ -1227,9 +1227,12 @@ sub search_packages { #- 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. - if (!$options{fuzzy} && $urpm->{params}{names}{$v} && defined $urpm->{params}{names}{$v}{id}) { - $exact{$v} = $urpm->{params}{names}{$v}{id}; - next; + unless ($options{fuzzy}) { + my $pkg = $urpm->{params}{names}{$v}; + if (defined $pkg->{id} && ($options{src} ? $pkg->{arch} eq 'src' : $pkg->{arch} ne 'src')) { + $exact{$v} = $pkg->{id}; + next; + } } my $qv = quotemeta $v; @@ -1237,7 +1240,8 @@ sub search_packages { if ($options{use_provides}) { unless ($options{fuzzy}) { #- try to search through provides. - if (my @l = grep { defined $_ } map { $_ && $_->{id} } map { $urpm->{params}{info}{$_} } + if (my @l = grep { defined $_ } map { $_ && ($options{src} ? $_->{arch} eq 'src' : $_->{arch} ne 'src') && + $_->{id} || undef } map { $urpm->{params}{info}{$_} } keys %{$urpm->{params}{provides}{$v} || {}}) { #- we assume that if the there is at least one package providing the resource exactly, #- this should be the best ones that is described. @@ -1251,16 +1255,20 @@ sub search_packages { #- but manages choices correctly (as a provides may be virtual or #- multiply defined. /$qv/ and push @{$found{$v}}, join '|', grep { defined $_ } - map { $urpm->{params}{info}{$_}{id} } keys %{$urpm->{params}{provides}{$_}}; + map { my $pkg = $urpm->{params}{info}{$_}; + $pkg && ($options{src} ? $pkg->{arch} eq 'src' : $pkg->{arch} ne 'src') && $pkg->{id} || undef } + keys %{$urpm->{params}{provides}{$_}}; /$qv/i and push @{$found{$v}}, join '|', grep { defined $_ } - map { $urpm->{params}{info}{$_}{id} } keys %{$urpm->{params}{provides}{$_}}; + map { my $pkg = $urpm->{params}{info}{$_}; + $pkg && ($options{src} ? $pkg->{arch} eq 'src' : $pkg->{arch} ne 'src') && $pkg->{id} || undef } + keys %{$urpm->{params}{provides}{$_}}; } } foreach my $id (0 .. $#{$urpm->{params}{depslist}}) { my $info = $urpm->{params}{depslist}[$id]; - rpmtools::compat_arch($info->{arch}) or next; + ($options{src} ? $info->{arch} eq 'src' : rpmtools::compat_arch($info->{arch})) or next; my $pack_ra = "$info->{name}-$info->{version}"; my $pack_a = "$pack_ra-$info->{release}"; @@ -1281,8 +1289,6 @@ sub search_packages { $pack =~ /$qv/ and push @{$found{$v}}, $id; $pack =~ /$qv/i and push @{$foundi{$v}}, $id; - - ++$id; } } @@ -1438,6 +1444,7 @@ sub filter_packages_to_upgrade { #- common routines that are called at different points. my $check_installed = sub { my ($pkg) = @_; + $pkg->{src} eq 'src' and return; $options{keep_alldeps} || exists $installed{$pkg->{id}} and return 0; rpmtools::db_traverse_tag($db, 'name', [ $pkg->{name} ], [ qw(name version release serial) ], sub { @@ -1495,50 +1502,54 @@ sub filter_packages_to_upgrade { #- installed. my (%diff_provides, %provides); - rpmtools::db_traverse_tag($db, - 'name', [ $pkg->{name}, @{$pkg->{obsoletes} || []} ], - [ qw(name version release sense provides) ], sub { - my ($p) = @_; - foreach (@{$p->{provides}}) { - s/\[\*\]//; - s/\[([^\]]*)\]/ $1/; - $diff_provides{$_} = "$p->{name}-$p->{version}-$p->{release}"; - } - }); + if ($pkg->{arch} ne 'src') { + rpmtools::db_traverse_tag($db, + 'name', [ $pkg->{name}, @{$pkg->{obsoletes} || []} ], + [ qw(name version release sense provides) ], sub { + my ($p) = @_; + foreach (@{$p->{provides}}) { + s/\[\*\]//; + s/\[([^\]]*)\]/ $1/; + $diff_provides{$_} = "$p->{name}-$p->{version}-$p->{release}"; + } + }); - foreach (@{$pkg->{provides} || []}) { - s/\[\*\]//; - s/\[([^\]]*)\]/ $1/; - delete $diff_provides{$_}; - } + foreach (@{$pkg->{provides} || []}) { + s/\[\*\]//; + s/\[([^\]]*)\]/ $1/; + delete $diff_provides{$_}; + } - foreach (keys %diff_provides) { - #- analyse the difference in provide and select other package. - if (my ($n, $o, $e, $v, $r) = /^(\S*)\s*(\S*)\s*(\d+:)?([^\s-]*)-?(\S*)/) { - my $check = sub { - my ($p) = @_; - my ($needed, $satisfied) = (0, 0); - foreach (@{$p->{requires}}) { - if (my ($pn, $po, $pv, $pr) = /^([^\s\[]*)(?:\[\*\])?(?:\s+|\[)?([^\s\]]*)\s*([^\s\-\]]*)-?([^\s\]]*)/) { - $pn eq $n && $pn eq $pkg->{name} or next; - ++$needed; - (!$pv || eval(rpmtools::version_compare($pkg->{version}, $pv) . $po . 0)) && - (!$pr || rpmtools::version_compare($pkg->{version}, $pv) != 0 || - eval(rpmtools::version_compare($pkg->{release}, $pr) . $po . 0)) or next; - #- an existing provides (propably the one examined) is satisfying the underlying. - ++$satisfied; + foreach (keys %diff_provides) { + #- analyse the difference in provide and select other package. + if (my ($n, $o, $e, $v, $r) = /^(\S*)\s*(\S*)\s*(\d+:)?([^\s-]*)-?(\S*)/) { + my $check = sub { + my ($p) = @_; + my ($needed, $satisfied) = (0, 0); + foreach (@{$p->{requires}}) { + if (my ($pn, $po, $pv, $pr) = + /^([^\s\[]*)(?:\[\*\])?(?:\s+|\[)?([^\s\]]*)\s*([^\s\-\]]*)-?([^\s\]]*)/) { + $pn eq $n && $pn eq $pkg->{name} or next; + ++$needed; + (!$pv || eval(rpmtools::version_compare($pkg->{version}, $pv) . $po . 0)) && + (!$pr || rpmtools::version_compare($pkg->{version}, $pv) != 0 || + eval(rpmtools::version_compare($pkg->{release}, $pr) . $po . 0)) or next; + #- an existing provides (propably the one examined) is satisfying the underlying. + ++$satisfied; + } } - } - #- check if the package need to be updated because it - #- losts some of its requires regarding the current diff_provides. - $needed > $satisfied and $selected{$p->{name}} ||= undef; - }; - rpmtools::db_traverse_tag($db, 'whatrequires', [ $n ], [ qw(name version release sense requires) ], $check); + #- check if the package need to be updated because it + #- losts some of its requires regarding the current diff_provides. + $needed > $satisfied and $selected{$p->{name}} ||= undef; + }; + rpmtools::db_traverse_tag($db, 'whatrequires', [ $n ], [ qw(name version release sense requires) ], $check); + } } + + $provides{$pkg->{name}} = undef; #"$pkg->{name}-$pkg->{version}-$pkg->{release}"; } #- iterate over requires of the packages, register them. - $provides{$pkg->{name}} = undef; #"$pkg->{name}-$pkg->{version}-$pkg->{release}"; foreach (@{$pkg->{requires} || []}) { if (my ($n, $o, $v, $r) = /^([^\s\[]*)(?:\[\*\])?(?:\s+|\[)?([^\s\]]*)\s*([^\s\-\]]*)-?([^\s\]]*)/) { exists $provides{$_} and next; @@ -1575,6 +1586,7 @@ sub filter_packages_to_upgrade { [ qw (name version release) ], $check_pkg); foreach my $fullname (keys %{$urpm->{params}{provides}{$n} || {}}) { my $pkg = $urpm->{params}{info}{$fullname}; + $pkg->{arch} eq 'src' and next; $o and $n eq $pkg->{name} || next; (!$v || eval(rpmtools::version_compare($pkg->{version}, $v) . $o . 0)) && (!$r || rpmtools::version_compare($pkg->{version}, $v) != 0 || @@ -1586,7 +1598,7 @@ sub filter_packages_to_upgrade { #- at this point, all unresolved provides (requires) should be fixed by #- provides files, try to minimize choice at this level. - foreach (keys %provides, keys %selected) { + foreach (keys %provides, grep { !$selected{$_} } keys %selected) { my (%pre_choices, @pre_choices, @choices, @upgradable_choices, %choices_id); if (my ($n, $o, $v, $r) = /^([^\s\[]*)(?:\[\*\])?(?:\s+|\[)?([^\s\]]*)\s*([^\s\-\]]*)-?([^\s\]]*)/) { $provides{$_} and next; @@ -1594,6 +1606,7 @@ sub filter_packages_to_upgrade { foreach my $fullname (keys %{$urpm->{params}{provides}{$n} || {}}) { exists $conflicts{$fullname} and next; my $pkg = $urpm->{params}{info}{$fullname}; + $pkg->{arch} eq 'src' and next; $selected{$n} || $selected{$pkg->{name}} and %pre_choices=(), last; #- check if a unsatisfied selection on a package is needed, #- which need a obsolete on a package with different name or @@ -1682,6 +1695,7 @@ sub deselect_unwanted_packages { chomp; s/#.*$//; s/^\s*//; s/\s*$//; foreach (keys %{$urpm->{params}{provides}{$_} || {}}) { my $pkg = $urpm->{params}{info}{$_} or next; + $pkg->{arch} eq 'src' and next; #- never ignore source package. $options{force} || (exists $packages->{$pkg->{id}} && defined $packages->{$pkg->{id}}) and delete $packages->{$pkg->{id}}; } @@ -1777,13 +1791,13 @@ sub get_source_packages { $error ? () : ( \%local_sources, \@list, \@local_to_removes ); } -#- upload package that may need to be uploaded. +#- download package that may need to be downloaded. #- make sure header are available in the appropriate directory. #- change location to find the right package in the local #- filesystem for only one transaction. #- try to mount/eject removable media here. #- return a list of package ready for rpm. -sub upload_source_packages { +sub download_source_packages { my ($urpm, $local_sources, $list, $force_local, $ask_for_medium) = @_; my (%sources, @distant_sources, %media, %removables); @@ -2001,6 +2015,7 @@ sub select_packages_to_upgrade { #- select packages which obseletes other package, obselete package are not removed, #- should we remove them ? this could be dangerous ! foreach my $pkg (values %{$urpm->{params}{info}}) { + defined $pkg->{id} && $pkg->{arch} ne 'src' or next; $ask_child->("$pkg->{name}-$pkg->{version}-$pkg->{release}.$pkg->{arch}", "obsoletes", sub { #- take care of flags and version and release if present if ($_[0] =~ /^(\S*)\s*(\S*)\s*([^\s-]*)-?(\S*)/ && @@ -2056,6 +2071,8 @@ sub select_packages_to_upgrade { #- find new packages to upgrade. foreach my $pkg (values %{$urpm->{params}{info}}) { + defined $pkg->{id} && $pkg->{arch} ne 'src' or next; + my $skipThis = 0; my $count = rpmtools::db_traverse_tag($db, "name", [ $pkg->{name} ], [ 'name' ], sub { $skipThis ||= $pkg->{installed}; @@ -2090,6 +2107,7 @@ sub select_packages_to_upgrade { #- unmark all files for all packages marked for upgrade. it may not have been done above #- since some packages may have been selected by depsList. foreach my $pkg (values %{$urpm->{params}{info}}) { + defined $pkg->{id} && $pkg->{arch} ne 'src' or next; if ($pkg->{selected}) { $ask_child->("$pkg->{name}-$pkg->{version}-$pkg->{release}.$pkg->{arch}", "files", sub { delete $installedFilesForUpgrade{$_[0]}; @@ -2104,6 +2122,7 @@ sub select_packages_to_upgrade { #- made some files moving between the normal package and its devel couterpart. #- if only one file is affected, no devel package is selected. foreach my $pkg (values %{$urpm->{params}{info}}) { + defined $pkg->{id} && $pkg->{arch} ne 'src' or next; unless ($pkg->{selected}) { my $toSelect = 0; $ask_child->("$pkg->{name}-$pkg->{version}-$pkg->{release}.$pkg->{arch}", "files", sub { @@ -37,6 +37,8 @@ my $all = 0; my $rpm_opt = "vh"; my $use_provides = 1; my $fuzzy = 0; +my $src = 0; +my $noclean = 0; my $verbose = 0; my $uid; @@ -45,6 +47,7 @@ my @src_files; my @rpms_install; my @rpms_upgrade; my @names; +my @src_names; $ENV{PATH} = "/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"; delete @ENV{qw(ENV BASH_ENV IFS CDPATH)}; @@ -61,6 +64,9 @@ usage: ") . _(" --media - use only the media listed by comma. ") . _(" --auto - automatically select a good package in choices. ") . _(" --auto-select - automatically select packages for upgrading the system. +") . _(" --fuzzy - impose fuzzy search (same as -y). +") . _(" --src - next package is a source package (same as -s). +") . _(" --noclean - keep rpm not used in cache. ") . _(" --complete - use parsehdlist server to complete selection. ") . _(" --force - force invocation even if some packages do not exist. ") . _(" --wget - use wget to retrieve distant files. @@ -71,7 +77,8 @@ usage: ") . _(" -a - select all matches on command line. ") . _(" -p - allow search in provides to find package. ") . _(" -P - do not search in provides to find package. -") . _(" -y - impose fuzzy search. +") . _(" -y - impose fuzzy search (same as --fuzzy). +") . _(" -s - next package is a source package (same as --src). ") . _(" -q - quiet mode. ") . _(" -v - verbose mode. ") . "\n" . _(" names or rpm files given on command line are installed. @@ -89,6 +96,9 @@ for (@ARGV) { /^--auto$/ and do { $auto = 1; next }; /^--allow-medium-change$/ and do { $allow_medium_change = 1; next }; /^--auto-select$/ and do { $auto_select = 1; next }; + /^--fuzzy$/ and do { $fuzzy = 1; next }; + /^--src$/ and do { $src = 1; next }; + /^--noclean$/ and do { $noclean = 1; next }; /^--complete$/ and do { $complete = 1; next }; /^--force$/ and do { $force = 1; next }; /^--wget$/ and do { $sync = \&urpm::sync_wget; next }; @@ -109,6 +119,7 @@ for (@ARGV) { /p/ and do { $use_provides = 1; next }; /P/ and do { $use_provides = 0; next }; /y/ and do { $fuzzy = 1; next }; + /s/ and do { $src = 1; next }; /v/ and do { $verbose = 1; next }; die _("urpmi: unknown option \"-%s\", check usage with --help\n", $1); } next }; @nextargv and do { my $r = shift @nextargv; $r and $$r = $_; next }; @@ -119,7 +130,12 @@ for (@ARGV) { push @files, untaint($_); next; } - push @names, $_; + if ($src) { + push @src_names, $_; + } else { + push @names, $_; + } + $src = 0; #- reset switch for next package. } #- params contains informations to parse installed system. @@ -128,7 +144,7 @@ my ($pid_out, $pid_err); if ($uid) { #- only src files are installable using urpmi. - @src_files or $urpm->{fatal}(1, _("Only superuser is allowed to install packages")); + @names || @files and $urpm->{fatal}(1, _("Only superuser is allowed to install packages")); #- allow installation. @rpms_install = @src_files; @@ -162,156 +178,166 @@ if ($uid) { } select STDERR; $| = 1; # make unbuffered select STDOUT; $| = 1; # make unbuffered +} - #- use specific sync routine. - $sync and $urpm->{sync} = $sync; +#- use specific sync routine. +$sync and $urpm->{sync} = $sync; - #- remove verbose if not asked. - $verbose or $urpm->{log} = sub {}; +#- remove verbose if not asked. +$verbose or $urpm->{log} = sub {}; - $urpm->read_config; - if ($media) { - $urpm->select_media(split ',', $media); - foreach (grep { !$_->{modified} } @{$urpm->{media} || []}) { - #- this is only a local ignore that will not be saved. - $_->{ignore} = 1; - } - } - foreach (grep { !$_->{ignore} && (!$update || $_->{update}) } @{$urpm->{media} || []}) { - $urpm->parse_synthesis($_); +$urpm->read_config(nocheck_access => $uid > 0); +if ($media) { + $urpm->select_media(split ',', $media); + foreach (grep { !$_->{modified} } @{$urpm->{media} || []}) { + #- this is only a local ignore that will not be saved. + $_->{ignore} = 1; } +} +foreach (grep { !$_->{ignore} && (!$update || $_->{update}) } @{$urpm->{media} || []}) { + $urpm->parse_synthesis($_); +} - if (@files) { - #- sanity check of pathname. - m|^/| or $_ = "./$_" foreach @files; +if (@files) { + #- sanity check of pathname. + m|^/| or $_ = "./$_" foreach @files; - #- build closure with local package and return list of names. - push @names, $urpm->register_local_packages(@files); - } + #- build closure with local package and return list of names. + push @names, $urpm->register_local_packages(@files); +} - #- relocate depslist. - $urpm->relocate_depslist_provides(); +#- relocate depslist. +$urpm->relocate_depslist_provides(); - #- 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. - my %packages; +#- 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. +my %packages; +if (@names) { $urpm->search_packages(\%packages, [ @names], all => $all, use_provides => $use_provides, fuzzy => $fuzzy) or $force or exit 1; +} +if (@src_names) { + $urpm->search_packages(\%packages, [ @src_names], + all => $all, + use_provides => $use_provides, + fuzzy => $fuzzy, + src => 1) + or $force or exit 1; +} - #- filter to add in packages selected required packages. - my $ask_choice = sub { - my ($urpm, $from_id, @choices_id) = @_; - my $n = 1; #- default value. - my ($from, @l) = map { my $info = $urpm->{params}{depslist}[$_]; - "$info->{name}-$info->{version}-$info->{release}" } ($from_id, @choices_id); - - if (@l > 1 && !$auto) { - my $msg = (defined $from_id ? - _("One of the following packages is needed to install %s:", $from) : - _("One of the following packages is needed:")); - if ($X) { - `gchooser "$msg" @l`; - $n = $? >> 8 || die; - } else { - print SAVEOUT "$msg\n"; - my $i = 0; foreach (@l) { print SAVEOUT " ", ++$i, "- $_\n"; } - while (1) { - printf SAVEOUT _("What is your choice? (1-%d) ", $i); - $n = <STDIN>; - 1 <= $n && $n <= $i and last; - print SAVEOUT _("Sorry, bad choice, try again\n"); - } +#- filter to add in packages selected required packages. +my $ask_choice = sub { + my ($urpm, $from_id, @choices_id) = @_; + my $n = 1; #- default value. + my ($from, @l) = map { my $info = $urpm->{params}{depslist}[$_]; + "$info->{name}-$info->{version}-$info->{release}.$info->{arch}" } ($from_id, @choices_id); + + if (@l > 1 && !$auto) { + my $msg = (defined $from_id ? + _("One of the following packages is needed to install %s:", $from) : + _("One of the following packages is needed:")); + if ($X) { + `gchooser "$msg" @l`; + $n = $? >> 8 || die; + } else { + print SAVEOUT "$msg\n"; + my $i = 0; foreach (@l) { print SAVEOUT " ", ++$i, "- $_\n"; } + while (1) { + printf SAVEOUT _("What is your choice? (1-%d) ", $i); + $n = <STDIN>; + 1 <= $n && $n <= $i and last; + print SAVEOUT _("Sorry, bad choice, try again\n"); } } + } - $choices_id[$n - 1]; - }; + $choices_id[$n - 1]; +}; - #- auto select package for upgrading the distribution. - if ($auto_select) { - my (%to_remove, %keep_files); +#- auto select package for upgrading the distribution. +if ($auto_select) { + my (%to_remove, %keep_files); - $urpm->select_packages_to_upgrade('', \%packages, \%to_remove, \%keep_files, use_parsehdlist => $complete); + $urpm->select_packages_to_upgrade('', \%packages, \%to_remove, \%keep_files, use_parsehdlist => $complete); - if (keys(%to_remove) > 0) { - print STDERR "some packages have to be removed for being upgraded, this is not supported yet\n"; - } - } +#- if (keys(%to_remove) > 0) { +#- print STDERR "some packages have to be removed for being upgraded, this is not supported yet\n"; +#- } +} - $urpm->filter_packages_to_upgrade(\%packages, $ask_choice); +$urpm->filter_packages_to_upgrade(\%packages, $ask_choice); - #- get out of package that should not be upgraded. - $urpm->deselect_unwanted_packages(\%packages); +#- get out of package that should not be upgraded. +$urpm->deselect_unwanted_packages(\%packages); - #- package to install as a array of strings. - my @to_install; +#- 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 $sum = 0; - foreach (keys %packages) { - defined $packages{$_} and $ask_user = 1; - my $info = $urpm->{params}{depslist}[$_]; - $sum += $info->{size}; - push @to_install, "$info->{name}-$info->{version}-$info->{release}"; - } - if (!$auto) { - if ($ask_user) { - my $msg = _("To satisfy dependencies, the following packages are going to be installed (%d MB)", toMb($sum)); - my $msg2 = _("Is it OK?"); - if ($X) { - my $p = join "\n", @to_install; - my $ok = _("Ok"); - my $cancel = _("Cancel"); - `gmessage -default $ok -buttons "$ok:0,$cancel:2" "$msg:\n$p\n\n$msg2"`; - $? and exit 0; - } else { - $noexpr = _("Nn"); - $yesexpr = _("Yy"); - print SAVEOUT "$msg:\n@to_install\n$msg2" . _(" (Y/n) "); - <STDIN> =~ /[$noexpr]/ and exit 0; - } - } +#- 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 $sum = 0; +foreach (keys %packages) { + defined $packages{$_} and $ask_user = 1; + my $info = $urpm->{params}{depslist}[$_]; + $sum += $info->{size}; + push @to_install, "$info->{name}-$info->{version}-$info->{release}.$info->{arch}"; +} +if (!$auto && $ask_user) { + my $msg = _("To satisfy dependencies, the following packages are going to be installed (%d MB)", toMb($sum)); + my $msg2 = _("Is it OK?"); + if ($X) { + my $p = join "\n", @to_install; + my $ok = _("Ok"); + my $cancel = _("Cancel"); + `gmessage -default $ok -buttons "$ok:0,$cancel:2" "$msg:\n$p\n\n$msg2"`; + $? and exit 0; + } else { + $noexpr = _("Nn"); + $yesexpr = _("Yy"); + print SAVEOUT "$msg:\n@to_install\n$msg2" . _(" (Y/n) "); + <STDIN> =~ /[$noexpr]/ and exit 0; } +} - 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")); - } - #- clean cache with file that are not necessary with this transaction. - #- TODO check not another urpmi is doing the same... +#- 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); +unless ($local_sources || $list) { + $urpm->{fatal}(3, _("unable to get source packages, aborting")); +} +#- clean cache with file that are not necessary with this transaction. +unless ($noclean) { foreach (@$local_to_removes) { unlink $_; } - - my %sources = $urpm->upload_source_packages($local_sources, $list, ($X ? '' : 'force_local'), - (!$auto || $allow_medium_change) && sub { - my $msg = _("Please insert the medium named \"%s\" on device [%s]", @_); - my $msg2 = _("Press Enter when it's done..."); - if ($X) { - my $ok = _("Ok"); - my $cancel = _("Cancel"); - $msg =~ s/"/\\"/g; - `gmessage -default $ok -buttons "$ok:0,$cancel:2" "$msg"`; - !$?; - } else { - print SAVEOUT "$msg\n$msg2 "; - <STDIN>; 1; - } - }); - - #- install package. - @rpms_install = grep { $_ !~ /\.src.\.rpm/ } values %{$urpm->extract_packages_to_install(\%sources) || {}}; - @rpms_upgrade = grep { $_ !~ /\.src.\.rpm/ } values %sources; } +my %sources = $urpm->download_source_packages($local_sources, $list, ($X ? '' : 'force_local'), + (!$auto || $allow_medium_change) && sub { + my $msg = _("Please insert the medium named \"%s\" on device [%s]", @_); + my $msg2 = _("Press Enter when it's done..."); + if ($X) { + my $ok = _("Ok"); + my $cancel = _("Cancel"); + $msg =~ s/"/\\"/g; + `gmessage -default $ok -buttons "$ok:0,$cancel:2" "$msg"`; + !$?; + } else { + print SAVEOUT "$msg\n$msg2 "; + <STDIN>; 1; + } + }); + +#- install package. +@rpms_install = grep { $_ !~ /\.src.\.rpm/ } values %{$urpm->extract_packages_to_install(\%sources) || {}}; +@rpms_upgrade = grep { $_ !~ /\.src.\.rpm/ } values %sources; + if (@rpms_install || @rpms_upgrade) { printf SAVEOUT _("installing %s\n", join(' ', @rpms_install, @rpms_upgrade)); log_it(scalar localtime, " @_\n"); @@ -1,8 +1,8 @@ %define group System/Configuration/Packaging Name: urpmi -Version: 3.2 -Release: 8mdk +Version: 3.3 +Release: 1mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate @@ -144,6 +144,13 @@ fi %changelog +* Mon Feb 11 2002 François Pons <fpons@mandrakesoft.com> 3.3-1mdk +- added --fuzzy as alias to -y (sorry Andrej to be late on this). +- added --src (aliased to -s) to handle src rpm in medium. +- added --noclean (only urpmi) to avoid cleaning the cache of rpm. +- try handling src in medium (there is still weirdness for access + right, need to be root first and user after). + * Thu Feb 7 2002 François Pons <fpons@mandrakesoft.com> 3.2-8mdk - fixed a requires resolution when a package C is upgraded which need a package A with a specific version and release, but a @@ -29,6 +29,7 @@ my $query = {}; my @files; my @names; +my @src_names; sub usage { print STDERR _("urpmq version %s @@ -43,13 +44,16 @@ usage: ") . _(" -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. +") . _(" -y - impose fuzzy search (same as --fuzzy). +") . _(" -s - next package is a source package (same as --src). ") . _(" -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. ") . _(" --media - use only the media listed by comma. ") . _(" --auto-select - automatically select packages for upgrading the system. +") . _(" --fuzzy - impose fuzzy search (same as -y). +") . _(" --src - next package is a source package (same as -s). ") . _(" --headers - extract headers for package listed from urpmi db to stdout (root only). ") . _(" --sources - give all source packages before downloading (root only). @@ -67,6 +71,8 @@ for (@ARGV) { /^--media$/ and do { push @nextargv, \$query->{media}; next }; /^--mediums$/ and do { push @nextargv, \$query->{media}; next }; /^--auto-select$/ and do { $query->{auto_select} = 1; next }; + /^--fuzzy$/ and do { $query->{fuzzy} = 1; next }; + /^--src$/ and do { $query->{src} = 1; next }; /^--headers$/ and do { $query->{headers} = 1; next }; /^--sources$/ and do { $query->{sources} = 1; next }; /^--force$/ and do { $query->{force} = 1; next }; @@ -81,6 +87,7 @@ for (@ARGV) { /p/ and do { $query->{use_provides} = 1; next }; /P/ and do { $query->{use_provides} = 0; next }; /y/ and do { $query->{fuzzy} = 1; next }; + /s/ and do { $query->{src} = 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 }; @@ -89,7 +96,12 @@ for (@ARGV) { /\.rpm$/ and do { if (-r $_) { push @files, $_; } else { print STDERR _("urpmq: cannot read rpm file \"%s\"\n", $_); } next }; - push @names, $_; + if ($query->{src}) { + push @src_names, $_; + } else { + push @names, $_; + } + $query->{src} = 0; #- reset switch for next package. } #- params contains informations to parse installed system. @@ -122,10 +134,19 @@ $urpm->relocate_depslist_provides(); #- basesystem is added to the list so if it need to be upgraded, all its dependency #- will be updated too. my %packages; -$urpm->search_packages(\%packages, [ @names ], - use_provides => $query->{use_provides}, - fuzzy => $query->{fuzzy}) - or $query->{force} or exit 1; +if (@names) { + $urpm->search_packages(\%packages, [ @names ], + use_provides => $query->{use_provides}, + fuzzy => $query->{fuzzy}) + or $query->{force} or exit 1; +} +if (@src_names) { + $urpm->search_packages(\%packages, [ @src_names ], + use_provides => $query->{use_provides}, + fuzzy => $query->{fuzzy}, + src => 1) + or $query->{force} or exit 1; +} #- auto select package for upgrading the distribution. if ($query->{auto_select}) { |