diff options
-rw-r--r-- | urpm.pm | 70 | ||||
-rwxr-xr-x | urpmi | 80 | ||||
-rw-r--r-- | urpmi.spec | 11 | ||||
-rwxr-xr-x | urpmq | 10 |
4 files changed, 111 insertions, 60 deletions
@@ -3,7 +3,7 @@ package urpm; use strict; use vars qw($VERSION @ISA); -$VERSION = '3.6'; +$VERSION = '3.7'; @ISA = qw(URPM); =head1 NAME @@ -295,10 +295,10 @@ sub read_config { my (%hdlists, %lists); foreach (@{$urpm->{media}}) { exists $hdlists{$_->{hdlist}} and - $_->{ignore} = 1, $urpm->{error}(_("medium \"%s\" tries to use an already used hdlist, medium ignored", $_->{name})); + $_->{ignore} = 1, $urpm->{error}(_("medium \"%s\" trying to use an already used hdlist, medium ignored", $_->{name})); $hdlists{$_->{hdlist}} = undef; exists $lists{$_->{list}} and - $_->{ignore} = 1, $urpm->{error}(_("medium \"%s\" tries to use an already used list, medium ignored", $_->{name})); + $_->{ignore} = 1, $urpm->{error}(_("medium \"%s\" trying to use an already used list, medium ignored", $_->{name})); $lists{$_->{list}} = undef; } @@ -627,7 +627,7 @@ sub select_media { } elsif (@found == 0 && @foundi == 0) { $urpm->{error}(_("trying to select inexistent medium \"%s\"", $_)); } else { #- multiple element in found or foundi list. - $urpm->{error}(_("trying to select multiple medium: %s", join(", ", map { _("\"%s\"", $_->{name}) } + $urpm->{error}(_("trying to select multiple media: %s", join(", ", map { _("\"%s\"", $_->{name}) } (@found ? @found : @foundi)))); } } @@ -1532,7 +1532,7 @@ sub get_source_packages { } else { chomp; $error = 1; - $urpm->{error}(_("unable to parse correctly [%s] on value \"%s\"", "$urpm->{statedir}/$medium->{list}", $_)); + $urpm->{error}(_("unable to correctly parse [%s] on value \"%s\"", "$urpm->{statedir}/$medium->{list}", $_)); last; } } @@ -1716,4 +1716,64 @@ sub extract_packages_to_install { \%inst; } +#- install logger (ala rpm) +sub install_logger { + my ($urpm, $type, $id, $subtype, $amount, $total) = @_; + my $pkg = defined $id && $urpm->{depslist}[$id]; + my $progress_size = 50; + + open FF, ">>/tmp/rpm_install"; + print FF join(':', ($pkg && $pkg->name), $type, $subtype, $amount, $total) . "\n"; + + if ($subtype eq 'start') { + $urpm->{logger_progress} = 0; + printf "%-28s", $type eq 'trans' ? _("Preparing...") : ($pkg && $pkg->name); + } elsif ($subtype eq 'stop') { + if ($urpm->{logger_progress} < $progress_size) { + print '#' x ($progress_size - $urpm->{logger_progress}); + print "\n"; + } + } elsif ($subtype eq 'progress') { + my $new_progress = $total > 0 ? int($progress_size * $amount / $total) : $progress_size; + if ($new_progress > $urpm->{logger_progress}) { + print FF "logging " . ($new_progress - $urpm->{logger_progress}) . "#\n"; + print '#' x ($new_progress - $urpm->{logger_progress}); + $urpm->{logger_progress} = $new_progress; + $urpm->{logger_progress} == $progress_size and print "\n"; + } + } + close FF; +} + +#- install packages according to each hashes (install or upgrade). +sub install { + my ($urpm, $prefix, $install, $upgrade, %options) = @_; + my $db = URPM::DB::open($prefix, 1); #- open in read/write mode. + my $trans = $db->create_transaction($prefix); + my @l; + local *F; + + foreach (keys %$install) { + my $pkg = $urpm->{depslist}[$_]; + $pkg->update_header($install->{$_}); + $trans->add($pkg, 0) or $urpm->{error}(_("unable to install package %s", $install->{$_})); + } + foreach (keys %$upgrade) { + my $pkg = $urpm->{depslist}[$_]; + $pkg->update_header($upgrade->{$_}); + $trans->add($pkg, 1) or $urpm->{error}(_("unable to install package %s", $upgrade->{$_})); + } + !$options{nodeps} and @l = $trans->check and return @l; + !$options{noorder} and @l = $trans->order and return @l; + @l = $trans->run($urpm, force => $options{force}, nosize => $options{nosize}, delta => 1000, callback_open => sub { + my ($data, $type, $id) = @_; + open F, $install->{$id} || $upgrade->{$id} or + $urpm->{error}(_("unable to access rpm file [%s]", $install->{$id} || $upgrade->{$id})); + return fileno F; + }, callback_close => sub { + my ($data, $type, $id) = @_; + close F; + }, callback_inst => \&install_logger, callback_trans => \&install_logger); +} + 1; @@ -47,8 +47,6 @@ my $log = ''; my $uid; my @files; my @src_files; -my @rpms_install; -my @rpms_upgrade; my @names; my @src_names; @@ -65,8 +63,8 @@ usage: ", $urpm::VERSION) . _(" --help - print this help message. ") . _(" --update - use only update media. ") . _(" --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. +") . _(" --auto - automatically select a package in choices. +") . _(" --auto-select - automatically select packages to upgrade 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. @@ -183,7 +181,11 @@ if ($env) { @names || @files and $urpm->{fatal}(1, _("Only superuser is allowed to install packages")); #- allow installation. - @rpms_install = @src_files; + if (@src_files) { + system("rpm", "-i$rpm_opt", @src_files, ($root ? ("--root", $root) : ())); + $? and message(_("Installation failed")), exit 1; + } + exit 0; } else { #- allow log if not defined. $log ||= "/var/log/urpmi.log"; @@ -417,7 +419,7 @@ unless ($noclean) { 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..."); + my $msg2 = _("Press Enter when ready..."); if ($X) { my $ok = _("Ok"); my $cancel = _("Cancel"); @@ -428,55 +430,39 @@ my %sources = $urpm->download_source_packages($local_sources, $list, ($X ? '' : defined message_input("$msg\n$msg2 "); } }); +my %sources_install = %{$urpm->extract_packages_to_install(\%sources) || {}}; -#- install package. -if ($uid == 0) { - @rpms_install = grep { $_ !~ /\.src\.rpm$/ } values %{$urpm->extract_packages_to_install(\%sources) || {}}; - @rpms_upgrade = grep { $_ !~ /\.src\.rpm$/ } values %sources; -} -if (@rpms_install || @rpms_upgrade) { - message(_("installing %s\n", join(' ', @rpms_install, @rpms_upgrade))); - log_it(scalar localtime, " ", join(' ', @rpms_install, @rpms_upgrade), "\n"); +if (%sources_install || %sources) { + message(_("installing %s\n", join(' ', values %sources_install, values %sources))); + log_it(scalar localtime, " ", join(' ', values %sources_install, values %sources), "\n"); #- check for local files. - foreach (@rpms_install, @rpms_upgrade) { + foreach (values %sources_install, values %sources) { m|^/| && ! -e $_ or next; message(_("Installation failed, some files are missing.\nYou may want to update your urpmi database")); exit 2; } $urpm->{log}("starting installing packages"); - if ($X && !$root) { - system("grpmi", $WID ? ("--WID=$WID") : (), - (map { ("-noupgrade", $_) } @rpms_install), @rpms_upgrade); - if ($?) { - #- grpmi handles --nodeps and --force by itself, - #- and $WID is defined when integrated in rpminst. - $WID or message(_("Installation failed")); - exit(($? >> 8) + 32); #- forward grpmi error + 32 - } + if ($uid > 0) { + system("rpm", "-i$rpm_opt", values %sources_install, values %sources, ($root ? ("--root", $root) : ())); + $? and message(_("Installation failed")), exit 1; + exit 0; } else { - if (@rpms_install) { - system("rpm", "-i$rpm_opt", "--nodeps", @rpms_install, ($root ? ("--root", $root) : ())); - if (@$_) { - message(_("Installation failed")); - - m|^/| && !-e $_ and exit 2 foreach @rpms_install; #- missing local file - $auto and exit 1; #- if auto has been set, avoid asking user. - - $noexpr = _("Nn"); - $yesexpr = _("Yy"); - message_input(_("Try installation even more strongly (--force)? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ - or exit 1; - $urpm->{log}("starting force installing packages without deps"); - system("rpm", "-i$rpm_opt", "--nodeps", "--force", @rpms_install, ($root ? ("--root", $root) : ())); - } - } - if (@rpms_upgrade) { - system("rpm", "-U$rpm_opt", @rpms_upgrade, ($root ? ("--root", $root) : ())); + if ($X && !$root) { + system("grpmi", $WID ? ("--WID=$WID") : (), + (map { ("-noupgrade", $_) } values %sources_install), values %sources); if ($?) { + #- grpmi handles --nodeps and --force by itself, + #- and $WID is defined when integrated in rpminst. + $WID or message(_("Installation failed")); + exit(($? >> 8) + 32); #- forward grpmi error + 32 + } + } else { + my @l = $urpm->install($root, \%sources_install, \%sources); + if (@l) { message(_("Installation failed")); - m|^/| && !-e $_ and exit 2 foreach @rpms_upgrade; #- missing local file + m|^/| && !-e $_ and exit 2 foreach values %sources_install, values %sources; #- missing local file $auto and exit 1; #- if auto has been set, avoid asking user. $noexpr = _("Nn"); @@ -484,14 +470,14 @@ if (@rpms_install || @rpms_upgrade) { message_input(_("Try installation without checking dependencies? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ or exit 1; $urpm->{log}("starting installing packages without deps"); - system("rpm", "-U$rpm_opt", "--nodeps", @rpms_upgrade, ($root ? ("--root", $root) : ())); - - if ($?) { + @l = $urpm->install($root, \%sources_install, \%sources, nodeps => 1); + if (@l) { message(_("Installation failed")); message_input(_("Try installation even more strongly (--force)? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ or exit 1; $urpm->{log}("starting force installing packages without deps"); - system("rpm", "-U$rpm_opt", "--nodeps", "--force", @rpms_upgrade, ($root ? ("--root", $root) : ())); + @l = $urpm->install($root, \%sources_install, \%sources, nodeps => 1, force => 1); + @l and $urpm->fatal(2, _("Installation failed") . ":\n" . join("\n", @l)); } } } @@ -1,14 +1,14 @@ %define group System/Configuration/Packaging Name: urpmi -Version: 3.6 -Release: 5mdk +Version: 3.7 +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-Locale-gettext rpmtools >= 4.3-2mdk perl-URPM >= 0.05-1mdk +PreReq: perl-Locale-gettext rpmtools >= 4.3-2mdk perl-URPM >= 0.08-1mdk BuildRequires: bzip2-devel gcc-c++ gettext rpm-devel rpmtools BuildRoot: %{_tmppath}/%{name}-buildroot BuildArch: noarch @@ -144,6 +144,11 @@ fi %changelog +* Mon Jul 8 2002 François Pons <fpons@mandrakesoft.com> 3.7-1mdk +- added new methods to handle directly installation of package (no + more rpm binary needed). +- fixed some english typo (thanks to Mark Walker). + * Tue Jul 2 2002 Pixel <pixel@mandrakesoft.com> 3.6-5mdk - use perl-Locale-gettext instead of perl-gettext (ie. Locale::gettext instead of Locale::GetText) @@ -40,19 +40,19 @@ usage: ") . _(" -h - print this help message. ") . _(" -v - verbose mode. ") . _(" -d - extend query to package dependencies. -") . _(" -u - remove package if a better version is already installed. +") . _(" -u - remove package if a more recent version is already installed. ") . _(" -c - choose complete method for resolving requires closure. ") . _(" -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). -") . _(" -g - print groups too with name. -") . _(" -r - print version and release too with name. +") . _(" -g - print groups with name also. +") . _(" -r - print version and release with name also. ") . _(" -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. +") . _(" --auto-select - automatically select packages to upgrade the system. ") . _(" --fuzzy - impose fuzzy search (same as -y). -") . _(" --list - list package available. +") . _(" --list - list available packages. ") . _(" --src - next package is a source package (same as -s). ") . _(" --headers - extract headers for package listed from urpmi db to stdout (root only). |