From f407ed64ddf4070d54f0e631b0eee6ce070933a9 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Thu, 15 Jan 2004 18:51:32 +0000 Subject: more graphical feedback in urpmi --parallel --X (status, progress, etc) --- urpm.pm | 6 +++++- urpm/parallel_ka_run.pm | 10 +++++----- urpm/parallel_ssh.pm | 33 ++++++++++++++++++++++++++------- urpmi | 8 +++++++- urpmi.spec | 18 ++++++++++-------- 5 files changed, 53 insertions(+), 22 deletions(-) diff --git a/urpm.pm b/urpm.pm index 6cbea321..490dff02 100644 --- a/urpm.pm +++ b/urpm.pm @@ -29,7 +29,8 @@ sub basename { local $_ = shift; s|/*\s*$||; s|.*/||; $_ } #- create a new urpm object. sub new { my ($class) = @_; - bless { + my $self; + $self = bless { config => "/etc/urpmi/urpmi.cfg", skiplist => "/etc/urpmi/skip.list", instlist => "/etc/urpmi/inst.list", @@ -47,6 +48,9 @@ sub new { fatal => sub { printf STDERR "%s\n", $_[1]; exit($_[0]) }, error => sub { printf STDERR "%s\n", $_[0] }, log => sub { printf STDERR "%s\n", $_[0] }, + + ui_msg => sub { $self->{log}($_[0]); $self->{ui} and $self->{ui}{msg}->($_[1]); }, + }, $class; } diff --git a/urpm/parallel_ka_run.pm b/urpm/parallel_ka_run.pm index 2d3039eb..8961a65f 100644 --- a/urpm/parallel_ka_run.pm +++ b/urpm/parallel_ka_run.pm @@ -98,7 +98,7 @@ sub parallel_resolve_dependencies { my (%avoided, %requested); #- first propagate the synthesis file to all machine. - $urpm->{log}("parallel_ka_run: mput $parallel->{options} -- '$synthesis' '$synthesis'"); + $urpm->{ui_msg}("parallel_ka_run: mput $parallel->{options} -- '$synthesis' '$synthesis'", urpm::N("Propagating synthesis to nodes...")); system "mput $parallel->{options} -- '$synthesis' '$synthesis'"; $? == 0 || $? == 256 or $urpm->{fatal}(1, urpm::N("mput failed, maybe a node is unreacheable")); $parallel->{synthesis} = $synthesis; @@ -149,7 +149,7 @@ sub parallel_resolve_dependencies { #- the following state should be cleaned for each iteration. delete $state->{selected}; #- now try an iteration of urpmq. - $urpm->{log}("parallel_ka_run: rshp -v $parallel->{options} -- urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen)); + $urpm->{ui_msg}("parallel_ka_run: rshp -v $parallel->{options} -- urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen), urpm::N("Resolving dependencies on nodes...")); open F, "rshp -v $parallel->{options} -- urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen)." |"; while (defined ($_ = )) { chomp; @@ -192,13 +192,13 @@ sub parallel_resolve_dependencies { sub parallel_install { my ($parallel, $urpm, $remove, $install, $upgrade, %options) = @_; - $urpm->{log}("parallel_ka_run: mput $parallel->{options} -- ".join(' ', values %$install, values %$upgrade)." $urpm->{cachedir}/rpms/"); + $urpm->{ui_msg}("parallel_ka_run: mput $parallel->{options} -- ".join(' ', values %$install, values %$upgrade)." $urpm->{cachedir}/rpms/", urpm::N("Distributing files to nodes...")); system "mput", split(' ', $parallel->{options}), '--', values %$install, values %$upgrade, "$urpm->{cachedir}/rpms/"; $? == 0 || $? == 256 or $urpm->{fatal}(1, urpm::N("mput failed, maybe a node is unreacheable")); local (*F, $_); my ($node, %bad_nodes); - $urpm->{log}("parallel_ka_run: rshp -v $parallel->{options} -- urpmi --pre-clean --no-locales --test --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line}"); + $urpm->{ui_msg}("parallel_ka_run: rshp -v $parallel->{options} -- urpmi --pre-clean --no-locales --test --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line}", urpm::N("Verifying if install is possible on nodes...")); open F, "rshp -v $parallel->{options} -- urpmi --pre-clean --no-locales --test --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line} |"; while (defined ($_ = )) { chomp; @@ -222,7 +222,7 @@ sub parallel_install { } else { my $line = $parallel->{line} . ($options{excludepath} ? " --excludepath '$options{excludepath}'" : ""); #- continue installation. - $urpm->{log}("parallel_ka_run: rshp $parallel->{options} -- urpmi --no-locales --no-verify-rpm --auto --synthesis $parallel->{synthesis} $line"); + $urpm->{ui_msg}("parallel_ka_run: rshp $parallel->{options} -- urpmi --no-locales --no-verify-rpm --auto --synthesis $parallel->{synthesis} $line", urpm::N("Installing packages on nodes...")); system("rshp $parallel->{options} -- urpmi --no-locales --no-verify-rpm --auto --synthesis $parallel->{synthesis} $line") == 0; } } diff --git a/urpm/parallel_ssh.pm b/urpm/parallel_ssh.pm index 5d885e1b..e1ede130 100644 --- a/urpm/parallel_ssh.pm +++ b/urpm/parallel_ssh.pm @@ -1,4 +1,5 @@ package urpm::parallel_ssh; +use Time::HiRes qw(gettimeofday); #- parallel copy sub parallel_register_rpms { @@ -39,7 +40,7 @@ sub parallel_find_remove { #- now try an iteration of urpme. foreach my $node (keys %{$parallel->{nodes}}) { - $urpm->{log}("parallel_ssh: ssh $node urpme --no-locales --auto $test".(join ' ', map { "'$_'" } @$l)); + $urpm->{log}("parallel_ssh: ssh $node urpme --no-locales --auto $test".(join ' ', map { "'$_'" } @$l)); open F, "ssh 2>&1 $node urpme --no-locales --auto $test".(join ' ', map { "'$_'" } @$l)." |"; while (defined ($_ = )) { chomp; @@ -102,7 +103,7 @@ sub parallel_resolve_dependencies { #- first propagate the synthesis file to all machine. foreach (keys %{$parallel->{nodes}}) { - $urpm->{log}("parallel_ssh: scp -q '$synthesis' '$_:$synthesis'"); + $urpm->{ui_msg}("parallel_ssh: scp -q '$synthesis' '$_:$synthesis'", urpm::N("Propagating synthesis to %s...", $_)); system "scp -q '$synthesis' '$_:$synthesis'"; $? == 0 or $urpm->{fatal}(1, urpm::N("scp failed on host %s", $_)); } @@ -154,7 +155,7 @@ sub parallel_resolve_dependencies { delete $state->{selected}; #- now try an iteration of urpmq. foreach my $node (keys %{$parallel->{nodes}}) { - $urpm->{log}("parallel_ssh: ssh $node urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen)); + $urpm->{ui_msg}("parallel_ssh: ssh $node urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen), urpm::N("Resolving dependencies on %s...", $node)); open F, "ssh $node urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen)." |"; while (defined ($_ = )) { chomp; @@ -199,7 +200,7 @@ sub parallel_install { foreach (keys %{$parallel->{nodes}}) { my $sources = join ' ', map { "'$_'" } values %$install, values %$upgrade; - $urpm->{log}("parallel_ssh: scp $sources $_:$urpm->{cachedir}/rpms"); + $urpm->{ui_msg}("parallel_ssh: scp $sources $_:$urpm->{cachedir}/rpms", urpm::N("Distributing files to %s...", $_)); system "scp $sources $_:$urpm->{cachedir}/rpms"; $? == 0 or $urpm->{fatal}(1, urpm::N("scp failed on host %s", $_)); } @@ -207,7 +208,7 @@ sub parallel_install { my %bad_nodes; foreach my $node (keys %{$parallel->{nodes}}) { local (*F, $_); - $urpm->{log}("parallel_ssh: ssh $node urpmi --pre-clean --no-locales --test --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line}"); + $urpm->{ui_msg}("parallel_ssh: ssh $node urpmi --pre-clean --no-locales --test --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line}", urpm::N("Verifying if install is possible on %s...", $node)); open F, "ssh $node urpmi --pre-clean --no-locales --test --no-verify-rpm --auto --synthesis $parallel->{synthesis} $parallel->{line} |"; while ($_ = ) { $bad_nodes{$node} .= $_; @@ -229,8 +230,26 @@ sub parallel_install { my $line = $parallel->{line} . ($options{excludepath} ? " --excludepath $options{excludepath}" : ""); #- continue installation on each nodes. foreach my $node (keys %{$parallel->{nodes}}) { - $urpm->{log}("parallel_ssh: ssh $node urpmi --no-locales --no-verify-rpm --auto --synthesis $parallel->{synthesis} $line"); - system split " ", "ssh $node urpmi --no-locales --no-verify-rpm --auto --synthesis $parallel->{synthesis} $line"; + $urpm->{ui_msg}("parallel_ssh: ssh $node urpmi --no-locales --no-verify-rpm --auto --synthesis $parallel->{synthesis} $line", urpm::N("Performing install on %s...", $node)); + $urpm->{ui}{progress}->(0); + open F, "ssh $node urpmi --no-locales --no-verify-rpm --auto --synthesis $parallel->{synthesis} $line |"; + local $/ = \1; + my $log; + my $last_time; + while ($_ = ) { + print; + $log .= $_; + /\n/ and $log = ''; + if (my ($msg, $progress) = $log =~ /^\s*(\S+)\s+(#+)/) { + if ($urpm->{ui} && (gettimeofday() - $last_time > 0.15 || length($progress) == 50)) { + $urpm->{ui}{msg}->($msg =~ /\d+:(\S+)/ ? urpm::N("Installing %s on %s...", $1, $node) + : urpm::N("Preparing install on %s...", $node)); + $urpm->{ui}{progress}->(length($progress)/50); + $last_time = gettimeofday(); + } + } + } + close F; } } } diff --git a/urpmi b/urpmi index 3432f034..99e5bc4a 100755 --- a/urpmi +++ b/urpmi @@ -417,6 +417,12 @@ sub ask_choice { $choices->[$n - 1]; }; +if ($parallel && $X) { #- do it early, we'll have ui outputs while resolving deps + require gurpm; + gurpm::init(N("Package installation..."), N("Initializing...")); + $urpm->{ui} = { msg => sub { gurpm::label($_[0]) }, progress => sub { gurpm::progress($_[0]) } }; +} + #- do the resolution of dependencies between requested package (and auto selection if any). #- handle parallel option if any. #- return value is true if program should be restarted (in order to take care of important @@ -528,7 +534,7 @@ unless ($local_sources || $list) { $urpm->{fatal}(3, N("unable to get source packages, aborting")); } -if ($X) { +if ($X && !$parallel) { #- for $parallel, already done require gurpm; gurpm::init(N("Package installation..."), N("Initializing...")); } diff --git a/urpmi.spec b/urpmi.spec index 6c2722a3..89f312bb 100644 --- a/urpmi.spec +++ b/urpmi.spec @@ -70,7 +70,7 @@ distributed installation using ka-run tools. %package -n urpmi-parallel-ssh Summary: Parallel extensions to urpmi using ssh and scp -Requires: urpmi >= %{version}-%{release} openssh-clients +Requires: urpmi >= %{version}-%{release} openssh-clients perl Group: %{group} %description -n urpmi-parallel-ssh @@ -236,13 +236,15 @@ $urpm->update_media(nolock => 1, nopubkey => 1); %{compat_perl_vendorlib}/urpm/parallel_ssh.pm %changelog -* Thu Jan 15 2004 Olivier Blin 4.4.2-1mdk -- enhance urpmq -i for non root user -- fix urpmq --sources for non root user (do not give a wrong url) -- fix urpme --root -- urpmi, urpme, urpmq: / can be used as root, it's not a particular case -- urpm.pm: lock rpm db in chroot, and urpmi db in / -- urpmi: ask to be root to install binary rpms in chroot +* Thu Jan 15 2004 Guillaume Cottenceau 4.4.2-1mdk +- more graphical feedback in urpmi --parallel --X (status, progress, etc) +- Olivier Blin : + - enhance urpmq -i for non root user + - fix urpmq --sources for non root user (do not give a wrong url) + - fix urpme --root + - urpmi, urpme, urpmq: / can be used as root, it's not a particular case + - urpm.pm: lock rpm db in chroot, and urpmi db in / + - urpmi: ask to be root to install binary rpms in chroot - From Pascal Terjan : - $root =~ s!/*!! to avoid root detection issue - From Olivier Thauvin : -- cgit v1.2.1