diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2003-05-12 15:17:21 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2003-05-12 15:17:21 +0000 |
commit | 8c1b9c134b5eaf5f8de2727be4618eeca22471d1 (patch) | |
tree | a88101354e995eae7f9d6f7b3df8241753ed64d4 | |
parent | ad7949faff548228842618c700a287786f3449c0 (diff) | |
download | urpmi-8c1b9c134b5eaf5f8de2727be4618eeca22471d1.tar urpmi-8c1b9c134b5eaf5f8de2727be4618eeca22471d1.tar.gz urpmi-8c1b9c134b5eaf5f8de2727be4618eeca22471d1.tar.bz2 urpmi-8c1b9c134b5eaf5f8de2727be4618eeca22471d1.tar.xz urpmi-8c1b9c134b5eaf5f8de2727be4618eeca22471d1.zip |
internalize grpmi in gurpm.pm so that we can share graphical
progression of download and installation between gurpmi and
rpmdrake
-rw-r--r-- | gurpm.pm | 59 | ||||
-rwxr-xr-x | urpmi | 151 | ||||
-rw-r--r-- | urpmi.spec | 13 |
3 files changed, 155 insertions, 68 deletions
diff --git a/gurpm.pm b/gurpm.pm new file mode 100644 index 00000000..e051f3a6 --- /dev/null +++ b/gurpm.pm @@ -0,0 +1,59 @@ +#***************************************************************************** +# +# Copyright (c) 2003 Guillaume Cottenceau (gc at mandrakesoft dot com) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +#***************************************************************************** + +package gurpm; + +use strict; +use lib qw(/usr/lib/libDrakX); +use ugtk2 qw(:all); +$::isStandalone = 1; + +our ($mainw, $label, $progressbar); + +sub init { + my ($title, $initializing) = @_; + $mainw = ugtk2->new($title); + $label = Gtk2::Label->new($initializing); + $progressbar = gtkset_size_request(Gtk2::ProgressBar->new, 400, 0); + gtkadd($mainw->{window}, gtkpack(gtkadd(create_vbox(), $label, $progressbar))); + $mainw->{rwindow}->set_position('center'); + $mainw->sync; +} + +sub sync { + $mainw->flush; +} + +sub label { + $label->set($_[0]); + select(undef, undef, undef, 0.1); #- hackish :-( + sync(); +} + +sub progress { + $progressbar->set_fraction($_[0]); + sync(); +} + +sub end { + $mainw and $mainw->destroy; + $mainw = undef; +} + +1; @@ -179,7 +179,7 @@ while (defined($_ = shift @ARGV)) { /^--X$/ and do { $X = 1; next }; /^--WID=(.*)$/ and do { $WID = $1; next }; /^--WID$/ and do { push @nextargv, \$WID; next }; - /^--best-output$/ and do { $X ||= $ENV{DISPLAY} && -x "/usr/sbin/grpmi" && system('/usr/X11R6/bin/xtest', '') == 0; + /^--best-output$/ and do { $X ||= $ENV{DISPLAY} && system('/usr/X11R6/bin/xtest', '') == 0; next }; /^--(no-)?verify-rpm$/ and do { $urpm->{options}{'verify-rpm'} = !$1; next }; /^--(no-)?test$/ and do { $test = !$1; next }; @@ -489,26 +489,41 @@ unless ($local_sources || $list) { $urpm->{fatal}(3, N("unable to get source packages, aborting")); } +if ($X) { + require gurpm; + gurpm::init(N("Package installation..."), N("Initializing...")); +} my %sources = $urpm->download_source_packages($local_sources, $list, verbose => $verbose > 0, limit_rate => $urpm->{options}{'limit-rate'}, callback => sub { my ($mode, $file, $percent, $total, $eta, $speed) = @_; - if ($mode eq 'start') { - print STDERR " $file\n"; #- allow pass-protected url to be logged. - } elsif ($mode eq 'progress') { - if (defined $total && defined $eta) { - print SAVEERR N(" %s%% of %s completed, ETA = %s, speed = %s", - $percent, $total, $eta, $speed) . "\r"; - } else { - print SAVEERR N(" %s%% completed, speed = %s", - $percent, $speed) . "\r"; - } - } elsif ($mode eq 'end') { - print SAVEERR " " x 79, "\r"; - } + if ($X) { + if ($mode eq 'start') { + $file =~ s|/*\s*$||; $file =~ s|.*/||; + gurpm::label(N("Downloading package `%s'...", $file)); + } elsif ($mode eq 'progress') { + gurpm::progress($percent/100); + } elsif ($mode eq 'end') { + gurpm::progress(1); + } + } else { + if ($mode eq 'start') { + print STDERR " $file\n"; #- allow pass-protected url to be logged. + } elsif ($mode eq 'progress') { + if (defined $total && defined $eta) { + print SAVEERR N(" %s%% of %s completed, ETA = %s, speed = %s", + $percent, $total, $eta, $speed) . "\r"; + } else { + print SAVEERR N(" %s%% completed, speed = %s", + $percent, $speed) . "\r"; + } + } elsif ($mode eq 'end') { + print SAVEERR " " x 79, "\r"; + } + } }, - force_local => !$X || $parallel, + force_local => 1, ask_for_medium => (!$auto || $allow_medium_change) && sub { my $msg = N("Please insert the medium named \"%s\" on device [%s]", @_); my $msg2 = N("Press Enter when ready..."); @@ -585,56 +600,62 @@ if (%sources_install || %sources) { message(N("installing %s\n", join(' ', values %sources_install, values %sources)), 'noX'); log_it(scalar localtime, " ", join(' ', values %sources_install, values %sources), "\n"); $urpm->{log}("starting installing packages"); - if ($X && !$root && !$test) { - system("rpm", "-e", "--nodeps", keys %{$state->{ask_remove} || {}}); - 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(N("Installation failed")); - exit(($? >> 8) + 32); #- forward grpmi error + 32 - } - } else { - my @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, - translate_message => 1, - oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, - test => $test, - excludepath => $urpm->{options}{excludepath}, excludedocs => $urpm->{options}{excludedocs}); - if (@l) { - message(N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); - - m|^/| && !-e $_ and exit 2 foreach values %sources_install, values %sources; #- missing local file - $auto || !$urpm->{options}{'allow-nodeps'} && !$urpm->{options}{'allow-force'} and exit 1; - - $noexpr = N("Nn"); - $yesexpr = N("Yy"); - message_input(N("Try installation without checking dependencies? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ - or exit 1; - $urpm->{log}("starting installing packages without deps"); - @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, - translate_message => 1, nodeps => 1, - oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, - test => $test, - excludepath => $urpm->{options}{excludepath}, excludedocs => $urpm->{options}{excludedocs}); - if (@l) { - message(N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); - !$urpm->{options}{'allow-force'} and exit 1; - message_input(N("Try installation even more strongly (--force)? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ - or exit 1; - $urpm->{log}("starting force installing packages without deps"); - @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, - translate_message => 1, nodeps => 1, force => 1, - oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, - test => $test, - excludepath => $urpm->{options}{excludepath}, - excludedocs => $urpm->{options}{excludedocs}); - @l and $urpm->fatal(2, N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); - } - } else { - $test and message(N("Installation is possible")); - } - } + my $progress_nb; + my $total_nb = grep { m|^/| } values %sources_install, values %sources; + my $callback_inst = $X && sub { + my ($urpm, $type, $id, $subtype, $amount, $total) = @_; + my $pkg = defined $id && $urpm->{depslist}[$id]; + + if ($subtype eq 'start') { + if ($type eq 'trans') { + gurpm::label(N("Preparing...")); + } else { + gurpm::label(N("Installing package `%s' (%s/%s)...", $pkg->name, ++$progress_nb, $total_nb)); + } + } elsif ($subtype eq 'progress') { + gurpm::progress($amount/$total); + } + }; + my @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, + translate_message => 1, + oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, + test => $test, + excludepath => $urpm->{options}{excludepath}, excludedocs => $urpm->{options}{excludedocs}, + callback_inst => $callback_inst, callback_trans => $callback_inst); + $X and gurpm::end(); + if (@l) { + message(N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); + + m|^/| && !-e $_ and exit 2 foreach values %sources_install, values %sources; #- missing local file + $auto || !$urpm->{options}{'allow-nodeps'} && !$urpm->{options}{'allow-force'} and exit 1; + + $noexpr = N("Nn"); + $yesexpr = N("Yy"); + message_input(N("Try installation without checking dependencies? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ + or exit 1; + $urpm->{log}("starting installing packages without deps"); + @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, + translate_message => 1, nodeps => 1, + oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, + test => $test, + excludepath => $urpm->{options}{excludepath}, excludedocs => $urpm->{options}{excludedocs}); + if (@l) { + message(N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); + !$urpm->{options}{'allow-force'} and exit 1; + message_input(N("Try installation even more strongly (--force)? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ + or exit 1; + $urpm->{log}("starting force installing packages without deps"); + @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, + translate_message => 1, nodeps => 1, force => 1, + oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, + test => $test, + excludepath => $urpm->{options}{excludepath}, + excludedocs => $urpm->{options}{excludedocs}); + @l and $urpm->fatal(2, N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); + } + } else { + $test and message(N("Installation is possible")); + } } } elsif ($test) { message(N("Installation is possible")); @@ -2,7 +2,7 @@ Name: urpmi Version: 4.3 -Release: 8mdk +Release: 9mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate @@ -22,8 +22,9 @@ You can compare rpm vs. urpmi with insmod vs. modprobe %package -n gurpmi Summary: User mode rpm GUI install -Requires: urpmi >= %{version}-%{release} grpmi gchooser gmessage usermode menu +Requires: urpmi >= %{version}-%{release} drakxtools gchooser gmessage usermode menu Group: %{group} +Obsoletes: grpmi %description -n gurpmi gurpmi is a graphical front-end to urpmi @@ -80,6 +81,7 @@ EOF mkdir -p $RPM_BUILD_ROOT%{perl_vendorlib} install -m 644 urpm.pm $RPM_BUILD_ROOT%{perl_vendorlib}/urpm.pm +install -m 644 gurpm.pm $RPM_BUILD_ROOT%{perl_vendorlib}/gurpm.pm mkdir -p $RPM_BUILD_ROOT%{perl_vendorlib}/urpm install -m 644 urpm/parallel_ka_run.pm $RPM_BUILD_ROOT%{perl_vendorlib}/urpm/parallel_ka_run.pm install -m 644 urpm/parallel_ssh.pm $RPM_BUILD_ROOT%{perl_vendorlib}/urpm/parallel_ssh.pm @@ -172,7 +174,7 @@ $urpm->update_media; %{_sbindir}/gurpmi %{_bindir}/gurpmi %{_menudir}/gurpmi - +%{perl_vendorlib}/gurpm.pm #%files -n autoirpm #%defattr(-,root,root) @@ -200,6 +202,11 @@ $urpm->update_media; %changelog +* Fri May 2 2003 Guillaume Cottenceau <gc@mandrakesoft.com> 4.3-9mdk +- internalize grpmi in gurpm.pm so that we can share graphical + progression of download and installation between gurpmi and + rpmdrake + * Fri Apr 25 2003 François Pons <fpons@mandrakesoft.com> 4.3-8mdk - added -i in urpmq --help (fix bug 3829). - fixed many urpmf options: --media, --synthesis, -e. |