From 02254ccd1c05bf1f17a6c1abd6d121602e166f5d Mon Sep 17 00:00:00 2001 From: espie Date: Sat, 27 Aug 2016 18:17:46 +0000 Subject: [PATCH] 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. --- usr.sbin/pkg_add/OpenBSD/Add.pm | 5 ++--- usr.sbin/pkg_add/OpenBSD/Delete.pm | 13 +++++++++---- usr.sbin/pkg_add/OpenBSD/PkgAdd.pm | 19 +++++++++++++++++-- 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 # @@ -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 # @@ -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 # @@ -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); } -- 2.20.1