in case we run delete_first (not enough room), delay the unlink of
authorespie <espie@openbsd.org>
Sat, 27 Aug 2016 18:17:46 +0000 (18:17 +0000)
committerespie <espie@openbsd.org>
Sat, 27 Aug 2016 18:17:46 +0000 (18:17 +0000)
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
usr.sbin/pkg_add/OpenBSD/Delete.pm
usr.sbin/pkg_add/OpenBSD/PkgAdd.pm

index 9b7f174..530f23e 100644 (file)
@@ -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;
index dc83d25..af94e56 100644 (file)
@@ -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, $!);
+               }
        }
 }
 
index e18f1a1..f179826 100644 (file)
@@ -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);
        }