summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-07-24 10:41:15 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-07-24 10:41:15 +0000
commit27bf10dd2c87d87fb27302da0ad92960e6634083 (patch)
treefa19f49ca613eb7cc41cb808a49090020449cdab /usr.sbin
parent59143c170a048575757d1539bc8035ed7c534bd8 (diff)
deal with a special case, where we are replacing files with changed md5:
in which case, we need to rename the files for the partial package, so the renaming phase won't fuck up.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Delete.pm25
1 files changed, 22 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm
index 91fc9c84583..efc995f8fe8 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.21 2005/02/09 11:07:13 espie Exp $
+# $OpenBSD: Delete.pm,v 1.22 2005/07/24 10:41:14 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -22,10 +22,11 @@ use OpenBSD::Error;
use OpenBSD::Vstat;
use OpenBSD::PackageInfo;
use OpenBSD::RequiredBy;
+use File::Basename;
sub keep_old_files
{
- my ($plist, $dir) = @_;
+ my ($state, $plist, $dir) = @_;
my $p = new OpenBSD::PackingList;
for my $i (qw(cvstags name no-default-conflict pkgcfl conflict) ) {
if (defined $plist->{$i}) {
@@ -40,6 +41,24 @@ sub keep_old_files
next unless $i->IsFile();
if (defined $i->{stillaround}) {
delete $i->{stillaround};
+ if ($state->{replacing}) {
+ require File::Temp;
+
+ my $n = $i->fullname();
+
+ my ($fh, $j) = File::Temp::mkstemp("$n.XXXXXXXX");
+ close $fh;
+ if (rename($n, $j)) {
+ print "Renaming $n to $j\n";
+ if ($i->{name} !~ m|^/| && $i->cwd() ne '.') {
+ my $c = $i->cwd();
+ $j =~ s|^\Q$c\E/||;
+ }
+ $i->{name} = $j;
+ } else {
+ print "Bad rename $n to $j: $!\n";
+ }
+ }
push(@{$p->{items}}, $i);
}
}
@@ -187,7 +206,7 @@ sub delete_plist
return if $state->{not};
if ($state->{baddelete}) {
- my $borked = keep_old_files($plist, $dir);
+ my $borked = keep_old_files($state, $plist, $dir);
$state->print("Files kept as $borked package\n");
delete $state->{baddelete};
}