summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-11-09 10:17:53 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-11-09 10:17:53 +0000
commit0d54b6753087a536e4886327faab98283098e9a4 (patch)
treedbb06796c11226c1f69e67bed3869002ed5f6ebc /usr.sbin
parent5fc97f2b9cf140a3cddfc7dba07a6a2abce857fe (diff)
save dir in plist, not state (unconfuse script operations when several
plists are present). Encapsulate `extract' operation in `extract_with_pm' to allow progress meter to do something sensible when replacing packages.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm15
-rw-r--r--usr.sbin/pkg_add/pkg_add17
2 files changed, 27 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index 6a07b725e42..a61cf1db79d 100644
--- a/usr.sbin/pkg_add/OpenBSD/Update.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Update.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Update.pm,v 1.15 2004/11/09 09:58:56 espie Exp $
+# $OpenBSD: Update.pm,v 1.16 2004/11/09 10:17:52 espie Exp $
#
# Copyright (c) 2004 Marc Espie <espie@openbsd.org>
#
@@ -48,6 +48,19 @@ sub unmark_lib
{
}
+sub extract_with_pm
+{
+ require OpenBSD::ProgressMeter;
+
+ my ($self, $state) = @_;
+
+ $self->extract($state);
+ if (defined $self->{size}) {
+ $state->{donesize} += $self->{size};
+ OpenBSD::ProgressMeter::show($state->{donesize}, $state->{totsize});
+ }
+}
+
package OpenBSD::PackingElement::FileBase;
use File::Temp qw/tempfile/;
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 9845dcd93c8..de4a198cd74 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.96 2004/11/09 09:32:17 espie Exp $
+# $OpenBSD: pkg_add,v 1.97 2004/11/09 10:17:51 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -87,6 +87,7 @@ sub can_install($$)
my $plist = OpenBSD::Update::can_do($l[0], $pkgname, $state);
if ($plist) {
+ $plist->{dir} = installed_info($l[0]);
return $plist;
} else {
print "Can't update $l[0] into $pkgname\n";
@@ -389,6 +390,7 @@ sub validate_plist($$)
sub do_script
{
my ($plist, $name, $state, $args) = @_;
+ $state->{dir} = $plist->{dir};
return unless $plist->has($name);
$plist->get($name)->run($state, $args);
}
@@ -419,7 +421,7 @@ sub really_add($$)
my $dir = $handle->info();
my $pkgname = $plist->pkgname();
$state->{archive} = $handle;
- $state->{dir} = $dir;
+ $plist->{dir} = $dir;
$state->set_pkgname($pkgname);
if (defined $plist->{replacing}) {
$state->{replacing} = 1;
@@ -459,11 +461,18 @@ sub really_add($$)
if (defined $plist->{replacing}) {
require OpenBSD::Update;
+ OpenBSD::ProgressMeter::set_header("$pkgname (extracting)");
OpenBSD::Update::save_old_libraries($plist, $state);
- $plist->visit('extract', $state);
-
+ $state->{totsize} = $totsize;
+ $state->{donesize} = 0;
+ $plist->visit('extract_with_pm', $state);
+ OpenBSD::ProgressMeter::next();
+
+ OpenBSD::ProgressMeter::set_header($plist->{replacing}->pkgname()." (deleting)");
require OpenBSD::Delete;
OpenBSD::Delete::delete_plist($plist->{replacing}, $state);
+
+ OpenBSD::ProgressMeter::set_header("$pkgname (installing)");
}
do_script($plist, REQUIRE, $state, "INSTALL");