summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-12-17 11:07:25 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-12-17 11:07:25 +0000
commit1c03ee6c6dcfd52bc84bb4cc3a7b0ed1a9276ed2 (patch)
tree496ca51281d8b1179678fcce660d4a263b4cdf45 /usr.sbin/pkg_add/OpenBSD
parentef49c30e17ef8b26757e4c46b5abf696e6ba0102 (diff)
add a callback to file creation, so that we get progress meter for huge
files in packages. Should affect emacs, chrome and the likes.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Add.pm8
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Ustar.pm7
2 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm
index acccea3603c..0e02e81fdb2 100644
--- a/usr.sbin/pkg_add/OpenBSD/Add.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Add.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Add.pm,v 1.98 2009/12/17 08:21:09 espie Exp $
+# $OpenBSD: Add.pm,v 1.99 2009/12/17 11:07:24 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -171,6 +171,10 @@ sub prepare_for_addition
sub install_and_progress
{
my ($self, $state, $donesize, $totsize) = @_;
+ $state->{callback} = sub {
+ my $done = shift;
+ $state->progress->show($$donesize + $done, $totsize);
+ };
unless ($state->{do_faked} && $state->{end_faked}) {
$self->install($state);
}
@@ -406,7 +410,7 @@ sub install
$state->{archive}->skip;
return;
} else {
- $file->create;
+ $file->create($state->{callback});
$self->may_check_digest($file, $state);
}
diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm
index 385b90f804e..ff7ba96435c 100644
--- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Ustar.pm,v 1.52 2009/11/10 11:36:56 espie Exp $
+# $OpenBSD: Ustar.pm,v 1.53 2009/12/17 11:07:24 espie Exp $
#
# Copyright (c) 2002-2007 Marc Espie <espie@openbsd.org>
#
@@ -629,7 +629,7 @@ sub new
sub create
{
- my $self = shift;
+ my ($self, $callback) = @_;
$self->make_basedir($self->name);
my $buffer;
my $out = OpenBSD::CompactWriter->new($self->{destdir}.$self->name);
@@ -654,6 +654,9 @@ sub create
}
$toread -= $actual;
+ if ($toread > 0 && defined $callback) {
+ &$callback($self->{size} - $toread);
+ }
}
$out->close or die "Error closing $self->{destdir}", $self->name,
": $!";