diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-06-12 09:53:37 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-06-12 09:53:37 +0000 |
commit | f5ea31f35648f76e28be8218284ea696380dec74 (patch) | |
tree | 0280077a655a023ec2ab4dd1ac8554eaa7d41c92 /usr.sbin/pkg_add | |
parent | 5d44a7a1991e292bfc38c019d99817638bc703fa (diff) |
tidy error messages: uses $! more consistently, do not append \n on die,
do append \n on warn.
Fix the two cases where the temp dir vanished too soon: not copying +DESC
should have been apparent. Not finding a +DISPLAY file is not a reason for
burping all over the place.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Add.pm | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/ArcCheck.pm | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 17 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingList.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgCfl.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Ustar.pm | 20 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg | 6 |
8 files changed, 36 insertions, 31 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index 99ca49ef26b..a2885f3e54b 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.76 2007/06/09 13:39:31 espie Exp $ +# $OpenBSD: Add.pm,v 1.77 2007/06/12 09:53:36 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -662,7 +662,9 @@ sub copy_info my ($self, $dest) = @_; require File::Copy; - File::Copy::move($self->fullname, $dest); + File::Copy::move($self->fullname, $dest) or + print STDERR "Problem while moving ", $self->fullname, + " into $dest: $!\n"; } package OpenBSD::PackingElement::FINSTALL; diff --git a/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm b/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm index eddf5c28f11..cf73f6dca00 100644 --- a/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm +++ b/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: ArcCheck.pm,v 1.9 2007/06/04 14:40:39 espie Exp $ +# $OpenBSD: ArcCheck.pm,v 1.10 2007/06/12 09:53:36 espie Exp $ # # Copyright (c) 2005-2006 Marc Espie <espie@openbsd.org> # @@ -117,10 +117,10 @@ sub prepare_long my $filename = $item->{name}; my $entry = $self->prepare($filename); if (!defined $entry->{uname}) { - die "No user name for ", $entry->{name}, " (uid ", $entry->{uid}, ")\n"; + die "No user name for ", $entry->{name}, " (uid ", $entry->{uid}, ")"; } if (!defined $entry->{gname}) { - die "No group name for ", $entry->{name}, " (gid ", $entry->{gid}. "\n"; + die "No group name for ", $entry->{name}, " (gid ", $entry->{gid}. ")"; } my ($prefix, $name) = split_name($entry->{name}); if (length($name) > MAXFILENAME || length($prefix) > MAXPREFIX) { diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index 1bb91809786..9aea21681a2 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.44 2007/06/10 14:25:18 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.45 2007/06/12 09:53:36 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -326,7 +326,7 @@ sub pkg_copy do { $n = sysread($in, $buffer, $buffsize); if (!defined $n) { - die "Error reading\n"; + die "Error reading: $!"; } if ($n > 0) { $nonempty = 1; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index fdf55b3e006..c09de9eb3f5 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.133 2007/06/06 12:32:09 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.134 2007/06/12 09:53:36 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -1327,12 +1327,15 @@ sub prepare { my ($self, $state) = @_; my $fname = $self->fullname; - open(my $src, '<', $fname) or Warn "Can't open $fname: $!"; - while (<$src>) { - next if m/^\+\-+\s*$/o; - s/^[+-] //o; - $state->print($_); - } + if (open(my $src, '<', $fname)) { + while (<$src>) { + next if m/^\+\-+\s*$/o; + s/^[+-] //o; + $state->print($_); + } + } else { + Warn "Can't open $fname: $!\n"; + } } package OpenBSD::PackingElement::FDISPLAY; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm index cde7c0be3db..e4d29a8ce06 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingList.pm,v 1.77 2007/06/06 12:32:09 espie Exp $ +# $OpenBSD: PackingList.pm,v 1.78 2007/06/12 09:53:36 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -320,7 +320,7 @@ sub addunique my ($plist, $object) = @_; my $category = $object->category; if (defined $plist->{$category}) { - die "Duplicate $category in plist\n"; + die "Duplicate $category in plist"; } $plist->{$category} = $object; } diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm b/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm index 36cf357524a..c60762f2fd0 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgCfl.pm,v 1.23 2007/05/29 10:40:20 espie Exp $ +# $OpenBSD: PkgCfl.pm,v 1.24 2007/06/12 09:53:36 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> # @@ -100,7 +100,7 @@ sub find($$) while (my ($name, $l) = each %{$state->{conflict_list}}) { next if $name eq $pkgname; if (!defined $l) { - die "Error: $name has no definition\n"; + die "Error: $name has no definition"; } if ($l->conflicts_with($pkgname)) { push(@bad, $name); diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm index a11c58399b1..5f7e8167815 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.48 2007/06/04 14:40:39 espie Exp $ +# $OpenBSD: Ustar.pm,v 1.49 2007/06/12 09:53:36 espie Exp $ # # Copyright (c) 2002-2007 Marc Espie <espie@openbsd.org> # @@ -73,10 +73,10 @@ sub skip } my $actual = read($self->{fh}, $temp, $toread); if (!defined $actual) { - die "Error while skipping archive: $!\n"; + die "Error while skipping archive: $!"; } if ($actual == 0) { - die "Premature end of archive in header: $!\n"; + die "Premature end of archive in header: $!"; } $self->{swallow} -= $actual; } @@ -222,19 +222,19 @@ sub mkheader $linkname = ''; } if (length $prefix > MAXPREFIX) { - die "Prefix too long $prefix\n"; + die "Prefix too long $prefix"; } if (length $name > MAXFILENAME) { - die "Name too long $name\n"; + die "Name too long $name"; } if (length $linkname > MAXLINKNAME) { - die "Linkname too long $linkname\n"; + die "Linkname too long $linkname"; } if (length $uname > MAXUSERNAME) { - die "Username too long $uname\n"; + die "Username too long $uname"; } if (length $gname > MAXGROUPNAME) { - die "Groupname too long $gname\n"; + die "Groupname too long $gname"; } my $header; my $cksum = ' 'x8; @@ -343,7 +343,7 @@ sub new my ($class, $object) = @_; if ($object->{size} != 0) { - die "Bad archive: non null size for arbitrary entry\n"; + die "Bad archive: non null size for arbitrary entry"; } bless $object, $class; } @@ -462,7 +462,7 @@ sub resolve_links $self->{linkname} = $arc->{key}->{$k}; } else { print join("\n", keys(%{$arc->{key}})), "\n"; - die "Can't copy link over: original for $k NOT available\n"; + die "Can't copy link over: original for $k NOT available"; } } diff --git a/usr.sbin/pkg_add/pkg b/usr.sbin/pkg_add/pkg index 74efca62cf1..82e21372f91 100644 --- a/usr.sbin/pkg_add/pkg +++ b/usr.sbin/pkg_add/pkg @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg,v 1.8 2007/05/14 11:02:14 espie Exp $ +# $OpenBSD: pkg,v 1.9 2007/06/12 09:53:36 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -34,7 +34,7 @@ sub check_dependencies($) my %opts; my %legacy = map +($_, 1), qw{add info delete create}; if (@ARGV == 0) { - die "needs arguments\n"; + die "needs arguments"; } getopts('v', \%opts); @@ -56,4 +56,4 @@ if (defined $legacy{$cmd}) { } } } -die "Bad command $cmd\n"; +die "Bad command $cmd"; |