summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2016-08-27 18:17:47 +0000
committerMarc Espie <espie@cvs.openbsd.org>2016-08-27 18:17:47 +0000
commit475bdb8d1b45896067adf3915fe85ba6a87851f0 (patch)
treed02ac48639c9f5b6ad73fd534995a3a7a6bc76a8 /usr.sbin
parent17ac3b3a3f214e3820023a9678d34a09dacd079b (diff)
in case we run delete_first (not enough room), delay the unlink of
tied items so we can still skip extracting them. better than the stopgap measure I committed a few weeks ago.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Add.pm5
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Delete.pm13
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgAdd.pm19
3 files changed, 28 insertions, 9 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm
index 9b7f174dfcc..530f23ec8f1 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.171 2016/08/12 11:17:37 espie Exp $
+# $OpenBSD: Add.pm,v 1.172 2016/08/27 18:17:46 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
@@ -420,8 +420,7 @@ use OpenBSD::Temp;
sub find_extractible
{
my ($self, $state, $wanted, $tied) = @_;
- if ($self->{tieto} && !$state->{delete_first}
- || $self->{link} || $self->{symlink}) {
+ if ($self->{tieto} || $self->{link} || $self->{symlink}) {
$tied->{$self->name} = $self;
} else {
$wanted->{$self->name} = $self;
diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm
index dc83d25ca18..af94e56ed4d 100644
--- a/usr.sbin/pkg_add/OpenBSD/Delete.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Delete.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Delete.pm,v 1.145 2016/02/03 18:30:15 robert Exp $
+# $OpenBSD: Delete.pm,v 1.146 2016/08/27 18:17:46 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
@@ -451,9 +451,14 @@ sub delete
$state->say("deleting: #1", $realname);
}
return if $state->{not};
- if (!unlink $realname) {
- $state->errsay("Problem deleting #1: #2", $realname, $!);
- $state->log("deleting #1 failed: #2", $realname, $!);
+ if ($state->{delete_first} && $self->{tied}) {
+ push(@{$state->{delayed}}, $realname);
+ } else {
+ if (!unlink $realname) {
+ $state->errsay("Problem deleting #1: #2", $realname,
+ $!);
+ $state->log("deleting #1 failed: #2", $realname, $!);
+ }
}
}
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm
index e18f1a14d67..f1798267f4a 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm
@@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgAdd.pm,v 1.88 2015/10/07 17:52:38 jmc Exp $
+# $OpenBSD: PkgAdd.pm,v 1.89 2016/08/27 18:17:46 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
@@ -751,6 +751,19 @@ sub delete_old_packages
# Here there should be code to handle old libs
}
+sub delayed_delete
+{
+ my $state = shift;
+ for my $realname (@{$state->{delayed}}) {
+ if (!unlink $realname) {
+ $state->errsay("Problem deleting #1: #2", $realname,
+ $!);
+ $state->log("deleting #1 failed: #2", $realname, $!);
+ }
+ }
+ delete $state->{delayed};
+}
+
sub really_add
{
my ($set, $state) = @_;
@@ -819,7 +832,9 @@ sub really_add
$handle->pkgname." failed", $set, $state));
}
}
- if (!$state->{delete_first}) {
+ if ($state->{delete_first}) {
+ delayed_delete($state);
+ } else {
$state->{hardkill} = 1;
delete_old_packages($set, $state);
}