diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-06-20 13:44:41 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-06-20 13:44:41 +0000 |
commit | 9d2c36d6f220ce9faf8df6efe2377724f9b02197 (patch) | |
tree | c47d4ac5f24e1e30149345d82aa8afe2963a585a | |
parent | 2c65e007f49588715f8ed6d9791487a8e8975a73 (diff) |
sprinkle code to deal gracefully with absent packing-lists.
makes it easier for people to recover after a disk crash that
leaves /var/db/pkg half-empty.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/CollisionReport.pm | 3 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingList.pm | 13 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/SharedItems.pm | 3 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/SharedLibs.pm | 7 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_info | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_mklocatedb | 1 |
6 files changed, 20 insertions, 13 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm index 5f58b0a9f52..4022f9c5d97 100644 --- a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm +++ b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: CollisionReport.pm,v 1.14 2007/06/09 11:16:54 espie Exp $ +# $OpenBSD: CollisionReport.pm,v 1.15 2007/06/20 13:44:39 espie Exp $ # # Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org> # @@ -56,6 +56,7 @@ sub collision_report($$) print "Looking for collisions in $pkg\n" if $state->{verbose}; my $plist = OpenBSD::PackingList->from_installation($pkg, \&OpenBSD::PackingList::FilesOnly); + next if !defined $plist; for my $item (@{$plist->{items}}) { next unless $item->IsFile; my $name = $item->fullname; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm index 8ed4d30ae91..43518ddbf22 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.79 2007/06/19 10:47:28 espie Exp $ +# $OpenBSD: PackingList.pm,v 1.80 2007/06/20 13:44:39 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -419,15 +419,20 @@ sub from_installation if ($code == \&DependOnly && defined $plist_cache->{$pkgname}) { return $plist_cache->{$pkgname}; } - my $plist = - $o->fromfile(OpenBSD::PackageInfo::installed_contents($pkgname), - $code); + my $filename = OpenBSD::PackageInfo::installed_contents($pkgname); + my $plist = $o->fromfile($filename, $code); if (defined $plist && $code == \&DependOnly) { $plist_cache->{$pkgname} = $plist; } if (defined $plist) { $plist->set_infodir(OpenBSD::PackageInfo::installed_info($pkgname)); } + if (!defined $plist) { + print STDERR "Warning: couldn't read packing-list from installed package $pkgname\n"; + unless (-e $filename) { + print STDERR "File $filename does not exist\n"; + } + } return $plist; } diff --git a/usr.sbin/pkg_add/OpenBSD/SharedItems.pm b/usr.sbin/pkg_add/OpenBSD/SharedItems.pm index 960defa5c6e..fcc01e43fc5 100644 --- a/usr.sbin/pkg_add/OpenBSD/SharedItems.pm +++ b/usr.sbin/pkg_add/OpenBSD/SharedItems.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: SharedItems.pm,v 1.12 2007/06/16 09:29:37 espie Exp $ +# $OpenBSD: SharedItems.pm,v 1.13 2007/06/20 13:44:40 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org> # @@ -36,6 +36,7 @@ sub find_items_in_installed_packages $progress->show($done, $total); my $plist = OpenBSD::PackingList->from_installation($e, \&OpenBSD::PackingList::SharedItemsOnly) or next; + next if !defined $plist; $plist->record_shared($db, $e); $done++; } diff --git a/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm index 6db12a41263..92d4a414c9a 100644 --- a/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm +++ b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: SharedLibs.pm,v 1.28 2007/06/16 09:29:37 espie Exp $ +# $OpenBSD: SharedLibs.pm,v 1.29 2007/06/20 13:44:40 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> # @@ -124,10 +124,7 @@ sub add_libs_from_installed_package $done_plist->{$pkgname} = 1; my $plist = OpenBSD::PackingList->from_installation($pkgname, \&OpenBSD::PackingList::LibraryOnly); - if (!defined $plist) { - Warn "Can't read plist for $pkgname\n"; - return; - } + next if !defined $plist; $plist->mark_available_lib($pkgname); } diff --git a/usr.sbin/pkg_add/pkg_info b/usr.sbin/pkg_add/pkg_info index 33b659f3ccd..e51dd170ae4 100644 --- a/usr.sbin/pkg_add/pkg_info +++ b/usr.sbin/pkg_add/pkg_info @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_info,v 1.61 2007/06/17 12:34:02 espie Exp $ +# $OpenBSD: pkg_info,v 1.62 2007/06/20 13:44:39 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -190,6 +190,7 @@ sub find_by_path my $plist = OpenBSD::PackingList->from_installation($pkg, \&OpenBSD::PackingList::ExtraInfoOnly); + next if !defined $plist; add_to_path_info($plist->{extrainfo}->{subdir}, $plist->pkgname); if ($plist->has('pkgpath')) { @@ -296,7 +297,8 @@ sub print_info } else { $plist = $handle->plist(\&OpenBSD::PackingList::FilesOnly); } - Fatal "Bad packing list" unless defined $plist; + Fatal "Bad packing list for", $handle->url + unless defined $plist; } if ($opt_L) { just_in_time_header($pkg, $handle ,\$done); diff --git a/usr.sbin/pkg_add/pkg_mklocatedb b/usr.sbin/pkg_add/pkg_mklocatedb index 652a2ee441a..8034ecab89b 100644 --- a/usr.sbin/pkg_add/pkg_mklocatedb +++ b/usr.sbin/pkg_add/pkg_mklocatedb @@ -163,6 +163,7 @@ if ($opt_p) { elsif (@ARGV==0) { for my $pkgname (installed_packages()) { my $plist = OpenBSD::PackingList->from_installation($pkgname); + next unless defined $plist; $plist->print_name($fh, info($plist)); } } else { |