summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-11-22 14:08:22 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-11-22 14:08:22 +0000
commitccc027bb2ba3e9fb45f59ef7ce17214694d0f665 (patch)
tree52d7b19b8a58e28cc4273672e84763496ea17b7f /usr.sbin/pkg_add
parent3ac57f843d6c794fc0552f3c05c72ee083482eb8 (diff)
tweak completion messages: do the next only during the next iteration, so
that at end, we can show a full completion message for the whole set. pass the number of packages still to-do through, so that the last complete also says (n to go) during installs...
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm6
-rw-r--r--usr.sbin/pkg_add/pkg_add19
2 files changed, 16 insertions, 9 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm b/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm
index 9ba34c138d6..664812359f7 100644
--- a/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm
+++ b/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: ProgressMeter.pm,v 1.19 2009/11/22 13:32:50 espie Exp $
+# $OpenBSD: ProgressMeter.pm,v 1.20 2009/11/22 14:08:21 espie Exp $
#
# Copyright (c) 2004-2007 Marc Espie <espie@openbsd.org>
#
@@ -154,7 +154,9 @@ sub next
my ($self, $todo) = @_;
return unless $isatty;
$self->clear;
- print "$header: complete ", defined $todo ? "($todo to go)\n" : "\n";
+
+ $todo //= 0;
+ print "$header: complete ", $todo ? "($todo to go)" : "", "\n";
}
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 13b1a84c07b..3d004ce6490 100644
--- a/usr.sbin/pkg_add/pkg_add
+++ b/usr.sbin/pkg_add/pkg_add
@@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_add,v 1.391 2009/11/22 09:18:55 espie Exp $
+# $OpenBSD: pkg_add,v 1.392 2009/11/22 14:08:21 espie Exp $
#
# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org>
#
@@ -298,7 +298,7 @@ sub partial_install
sub really_add
{
- my ($set, $state) = @_;
+ my ($set, $state, $todo) = @_;
for my $h ($set->newer) {
$h->plist->set_infodir($h->location->info);
@@ -407,9 +407,13 @@ sub really_add
# Here there should be code to handle old libs
}
+ my $first = 1;
for my $handle ($set->newer) {
+ if (!$first) {
+ $state->progress->next;
+ $first = 0;
+ }
my $pkgname = $handle->pkgname;
- my $header = $state->deptree_header($set).$pkgname;
my $plist = $handle->plist;
$set->setup_header($state, $handle,
$replacing ? "installing" : undef);
@@ -426,7 +430,6 @@ sub really_add
$errors++;
}
};
- $state->progress->next;
unlink($plist->infodir.CONTENTS);
if ($state->{interrupted} || $errors) {
@@ -434,6 +437,8 @@ sub really_add
$set, $state);
}
}
+ $set->setup_header($state, undef, $replacing ? "installing" : undef);
+ $state->progress->next($todo);
for my $handle ($set->newer) {
my $pkgname = $handle->pkgname;
my $plist = $handle->plist;
@@ -457,7 +462,7 @@ sub really_add
sub install_set
{
- my ($set, $state) = @_;
+ my ($set, $state, $todo) = @_;
if ($set->{finished}) {
return ();
@@ -534,7 +539,7 @@ sub install_set
# return ();
# }
# }
- really_add($set, $state);
+ really_add($set, $state, $todo);
for my $handle ($set->newer) {
$handle->cleanup;
}
@@ -723,7 +728,7 @@ sub {
inform_user_of_pending_update($state);
# This is the actual very small loop that adds all packages
while (my $set = shift @todo2) {
- unshift(@todo2, install_set($set, $state));
+ unshift(@todo2, install_set($set, $state, scalar @todo2));
}
});