From ac0461f24d4583e2f0dcaa15bc1574a22b3249e6 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Mon, 23 Dec 2013 16:50:30 +0000 Subject: move ntogo code, so it can be used while copying packages in pkg_create. add the few lines necessary for that to work. --- usr.sbin/pkg_add/OpenBSD/PkgCreate.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'usr.sbin/pkg_add/OpenBSD/PkgCreate.pm') diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm index 2c00f34ed06..765a8952387 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgCreate.pm,v 1.71 2013/12/23 16:34:51 espie Exp $ +# $OpenBSD: PkgCreate.pm,v 1.72 2013/12/23 16:50:29 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie # @@ -65,6 +65,12 @@ sub set_status } } +sub todo +{ + my ($self, $offset) = @_; + return sprintf("%u/%u", $self->{done}-$offset, $self->{total}); +} + sub end_status { my $self = shift; @@ -1063,7 +1069,8 @@ sub sign_existing_package unlink($plist->pkgname.".tgz") if $state->{output}; rename($tmp, $output.'/'.$plist->pkgname.".tgz") or $state->fatal("Can't create final signed package: #1", $!); - $state->end_status; + $state->{done}++; + $state->progress->next($state->ntogo); } sub sign_existing_pkgname @@ -1081,7 +1088,10 @@ sub sign_existing_repository my ($self, $state, $source, $cert, $privkey) = @_; require OpenBSD::PackageRepository; my $repo = OpenBSD::PackageRepository->new($source, $state); - for my $name (@{$repo->list}) { + my @list = @{$repo->list}; + $state->{total} = scalar @list; + $state->{done} = 0; + for my $name (@list) { my $pkg = $repo->find($name); $self->sign_existing_package($state, $pkg, $cert, $privkey); } @@ -1363,10 +1373,13 @@ sub parse_and_run if ($state->not) { $state->fatal("can't pretend to sign existing packages"); } + $state->{wantntogo} = $state->config->istrue("ntogo"); if (defined $state->{source}) { $self->sign_existing_repository($state, $state->{source}, $cert, $privkey); } + $state->{total} = scalar @ARGV; + $state->{done} = 0; for my $pkgname (@ARGV) { $self->sign_existing_pkgname($state, $pkgname, $cert, $privkey); -- cgit v1.2.3