summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-03-18 18:48:21 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-03-18 18:48:21 +0000
commit3cba6545b7a1b9bb7d048e3d4e3003a1ccbeebb9 (patch)
tree956fa03f6d262e0a54b7cf977ff5e521cf583883
parentec35b38281ffda50d5320508459596ab5cbf8de5 (diff)
handle more errors during package creation.
- if archiving discovers issues, then go into high speed mode where stuff doesn't get written. - in case of errors or fatal signals, make sure to remove a partially written archive.
-rw-r--r--usr.sbin/pkg_add/pkg_create24
1 files changed, 20 insertions, 4 deletions
diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create
index d522677d868..67053c880db 100644
--- a/usr.sbin/pkg_add/pkg_create
+++ b/usr.sbin/pkg_add/pkg_create
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_create,v 1.50 2006/12/10 23:15:00 steven Exp $
+# $OpenBSD: pkg_create,v 1.51 2007/03/18 18:48:20 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -45,17 +45,16 @@ sub archive
if (defined $arc) {
my $o = $arc->prepare_long($self);
- $o->write();
if (!defined $self->{owner} && !$o->isSymLink()) {
if ($o->{uname} ne 'root' && $o->{uname} ne 'bin') {
print STDERR "Warning: no \@owner for ",
- $self->fullname(), " (", $o->{uname}, ")\n";
+ $self->fullname(), " (", $o->{uname}, ")\n";
}
}
if (!defined $self->{group} && !$o->isSymLink()) {
if ($o->{gname} ne 'bin' && $o->{gname} ne 'wheel') {
print STDERR "Warning: no \@group for ",
- $self->fullname(), " (", $o->{gname}, ")\n";
+ $self->fullname(), " (", $o->{gname}, ")\n";
}
}
if (!defined $self->{mode} && $o->isFile()) {
@@ -65,6 +64,7 @@ sub archive
sprintf("%4o", $o->{mode} & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID)), "\n";
}
}
+ $o->write() unless $main::errors;
}
if ($verbose) {
print "Adding ", $self->{name}, "\n";
@@ -592,6 +592,18 @@ if ($opt_n) {
$plist->archive(undef, $base, 1);
} else {
print "Creating gzip'd tar ball in '$wname'\n" if $opt_v;
+ my $h = sub {
+ unlink $wname;
+ my $caught = shift;
+ $SIG{$caught} = 'DEFAULT';
+ kill $caught, $$;
+ };
+
+ local $SIG{'INT'} = $h;
+ local $SIG{'QUIT'} = $h;
+ local $SIG{'HUP'} = $h;
+ local $SIG{'KILL'} = $h;
+ local $SIG{'TERM'} = $h;
open(my $fh, "|gzip >$wname");
my $wrarc = OpenBSD::Ustar->new($fh, $dir);
for my $special (@extra_files) {
@@ -603,6 +615,10 @@ if ($opt_n) {
$plist->archive($wrarc, $base, $opt_v);
$wrarc->pad();
close($fh);
+ if ($errors) {
+ unlink($wname);
+ exit(1);
+ }
}
} catch {
print STDERR "$0: $_\n";