diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2004-01-12 17:16:18 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2004-01-12 17:16:18 +0000 |
commit | 787f95ee090fd373a85b0ea92c3b7cd1897d5ed6 (patch) | |
tree | 19f173ce4267295abeb7140ba4afc14ad6efd028 | |
parent | b34277345fb7338774c2faf60ba8f8d75ef868c6 (diff) | |
download | urpmi-787f95ee090fd373a85b0ea92c3b7cd1897d5ed6.tar urpmi-787f95ee090fd373a85b0ea92c3b7cd1897d5ed6.tar.gz urpmi-787f95ee090fd373a85b0ea92c3b7cd1897d5ed6.tar.bz2 urpmi-787f95ee090fd373a85b0ea92c3b7cd1897d5ed6.tar.xz urpmi-787f95ee090fd373a85b0ea92c3b7cd1897d5ed6.zip |
add ability to cancel packages downloads
-rw-r--r-- | gurpm.pm | 26 | ||||
-rw-r--r-- | urpm.pm | 20 | ||||
-rw-r--r-- | urpmi.spec | 10 |
3 files changed, 43 insertions, 13 deletions
@@ -24,14 +24,14 @@ use lib qw(/usr/lib/libDrakX); use ugtk2 qw(:all); $::isStandalone = 1; -our ($mainw, $label, $progressbar); +our ($mainw, $label, $progressbar, $vbox, $cancel, $hbox_cancel); sub init { - my ($title, $initializing) = @_; + my ($title, $initializing, $cancel_msg, $cancel_cb) = @_; $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))); + gtkadd($mainw->{window}, gtkpack($vbox = gtkadd(create_vbox(), $label, $progressbar))); $mainw->{rwindow}->set_position('center'); $mainw->sync; } @@ -54,6 +54,26 @@ sub progress { sub end { $mainw and $mainw->destroy; $mainw = undef; + $cancel = undef; #- in case we'll do another one later +} + +sub validate_cancel { + my ($cancel_msg, $cancel_cb) = @_; + if (!$cancel) { + gtkpack__($vbox, + $hbox_cancel = gtkpack__(create_hbox(), + $cancel = gtksignal_connect(Gtk2::Button->new($cancel_msg), clicked => \&$cancel_cb))); + } + $cancel->set_sensitive(1); + $cancel->show; +} + +sub invalidate_cancel { + $cancel and $cancel->set_sensitive(0); +} + +sub invalidate_cancel_forever { + $hbox_cancel and $hbox_cancel->destroy; } 1; @@ -154,9 +154,9 @@ sub propagate_sync_callback { if ($mode =~ /^(start|progress|end)$/) { my $file = shift @_; $file =~ s|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)|$1xxxx$2|; #- if needed... - $options->{callback}($mode, $file, @_); + return $options->{callback}($mode, $file, @_); } else { - $options->{callback}($mode, @_); + return $options->{callback}($mode, @_); } } } @@ -178,7 +178,7 @@ sub sync_wget { my $cwd = `pwd`; chomp $cwd; chdir(ref($options) ? $options->{dir} : $options); my ($buf, $total, $file) = ('', undef, undef); - open WGET, join(" ", map { "'$_'" } "/usr/bin/wget", + my $wget_pid = open WGET, join(" ", map { "'$_'" } "/usr/bin/wget", (ref($options) && $options->{limit_rate} ? "--limit-rate=$options->{limit_rate}" : ()), (ref($options) && $options->{proxy} ? set_proxy({ type => "wget", proxy => $options->{proxy} }) : ()), (ref($options) && $options->{callback} ? ("--progress=bar:force", "-o", "-") : @@ -198,7 +198,11 @@ sub sync_wget { } elsif (defined $total && $total eq '' && $buf =~ /^[^:]*:\s+(\d\S*)/) { $total = $1; } elsif (my ($percent, $speed, $eta) = $buf =~ /^\s*(\d+)%.*\s+(\S+)\s+ETA\s+(\S+)\s*[\r\n]$/ms) { - propagate_sync_callback($options, 'progress', $file, $percent, $total, $eta, $speed); + if (propagate_sync_callback($options, 'progress', $file, $percent, $total, $eta, $speed) eq 'canceled') { + kill 15, $wget_pid; + close WGET; + return; + } if ($_ eq "\n") { propagate_sync_callback($options, 'end', $file); ($total, $file) = (undef, undef); @@ -275,7 +279,7 @@ sub sync_curl { if (my @all_files = ((map { ("-O", $_) } @ftp_files), (map { /\/([^\/]*)$/ ? ("-z", $1, "-O", $_) : @{[]} } @other_files))) { my @l = (@ftp_files, @other_files); my ($buf, $file) = ('', undef); - open CURL, join(" ", map { "'$_'" } "/usr/bin/curl", + my $curl_pid = open CURL, join(" ", map { "'$_'" } "/usr/bin/curl", (ref($options) && $options->{limit_rate} ? ("--limit-rate", $options->{limit_rate}) : ()), (ref($options) && $options->{proxy} ? set_proxy({ type => "curl", proxy => $options->{proxy} }) : ()), (ref($options) && $options->{quiet} && !$options->{verbose} ? "-s" : @{[]}), @@ -292,7 +296,11 @@ sub sync_curl { propagate_sync_callback($options, 'start', $file); } if (my ($percent, $total, $eta, $speed) = $buf =~ /^\s*(\d+)\s+(\S+)[^\r\n]*\s+(\S+)\s+(\S+)[\r\n]$/ms) { - propagate_sync_callback($options, 'progress', $file, $percent, $total, $eta, $speed); + if (propagate_sync_callback($options, 'progress', $file, $percent, $total, $eta, $speed) eq 'canceled') { + kill 15, $curl_pid; + close CURL; + return; + } if ($_ eq "\n") { propagate_sync_callback($options, 'end', $file); $file = undef; @@ -7,8 +7,8 @@ ################################################################## %define name urpmi -%define version 4.4 -%define release 52mdk +%define version 4.4.1 +%define release 1mdk %define group %(perl -e 'printf "%%s\\n", "%_vendor" =~ /mandrake/i ? "System/Configuration/Packaging" : "System Environment/Base"') @@ -30,7 +30,6 @@ Source0: %{name}.tar.bz2 Summary: User mode rpm install URL: http://cvs.mandrakesoft.com/cgi-bin/cvsweb.cgi/soft/urpmi Requires: %{req_webfetch} eject gnupg -Provides: perl(urpm) PreReq: perl-Locale-gettext >= 1.01-7 gettext rpmtools >= 4.5 perl-URPM >= 0.94 BuildRequires: %{buildreq_locale} bzip2-devel rpm-devel >= 4.0.3 BuildRoot: %{_tmppath}/%{name}-buildroot @@ -47,7 +46,6 @@ Summary: User mode rpm GUI install Group: %{group} Requires: urpmi >= %{version}-%{release} drakxtools gchooser gmessage usermode menu Obsoletes: grpmi -Provides: perl(gurpm) %description -n gurpmi gurpmi is a graphical front-end to urpmi @@ -238,6 +236,10 @@ $urpm->update_media(nolock => 1, nopubkey => 1); %{compat_perl_vendorlib}/urpm/parallel_ssh.pm %changelog +* Mon Jan 12 2004 Guillaume Cottenceau <gc@mandrakesoft.com> 4.4.1-1mdk +- add ability to cancel packages downloads (subsubversion increase) +- don't explicitely provide perl(urpm) and perl(gurpm), it's unneeded + * Fri Jan 09 2004 Warly <warly@mandrakesoft.com> 4.4-52mdk - provides perl(gurpm) in gurpmi |