summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-12-09 18:46:01 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-12-09 18:46:01 +0000
commit877d6b209818d669ea266633e357c362f1ee9311 (patch)
tree5bfac174ebd493a5494a4163e5d3b900b09303a2
parentf067bfe4f1b2ff364dd668f0eab9b004efb40294 (diff)
while upgrading, protect deletion in an eval: we've got an extract
package that should be registered as borked if something should go wrong (which can happen if -f update, as I just witnessed with firefox).
-rw-r--r--usr.sbin/pkg_add/pkg_add16
1 files changed, 14 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index dc447ec16db..f0c39661bb6 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.136 2004/12/07 19:09:04 espie Exp $
+# $OpenBSD: pkg_add,v 1.137 2004/12/09 18:46:00 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -328,7 +328,19 @@ sub really_add($$)
OpenBSD::ProgressMeter::set_header($plist->{replacing}->pkgname()." (deleting)");
$state->set_pkgname($plist->{replacing}->pkgname());
require OpenBSD::Delete;
- OpenBSD::Delete::delete_plist($plist->{replacing}, $state);
+ eval {
+ OpenBSD::Delete::delete_plist($plist->{replacing}, $state);
+ };
+ if ($@) {
+ Warn $@;
+ if ($not) {
+ Fatal "Deinstallation of ",
+ $plist->{replacing}->pkgname(), " failed";
+ } else {
+ OpenBSD::Add::borked_installation($plist, $dir);
+ }
+ }
+
delete_installed($plist->{replacing}->pkgname());
OpenBSD::ProgressMeter::set_header("$pkgname (installing)");