diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-11-06 12:19:18 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-11-06 12:19:18 +0000 |
commit | 34617830694d282bd732b97b341d8023d88e9512 (patch) | |
tree | 146675fd8293c2ad0bc1b41463bd9e3697335f5b | |
parent | 7165c756e826b4e22c30cc30c52fe0808aba618e (diff) |
mark whole state for `replacing' so that only file entries get tempname
markers. Explain about tempname to PackingElement, so that we become
able to save temporary packing-lists (e.g, borking during replace will
now work).
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Add.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 25 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Update.pm | 3 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 7 |
4 files changed, 32 insertions, 7 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index 005526587f2..9b9dcb94716 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.5 2004/11/01 19:21:58 espie Exp $ +# $OpenBSD: Add.pm,v 1.6 2004/11/06 12:19:17 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -162,7 +162,7 @@ sub install my $fullname = $self->fullname(); my $destdir = $state->{destdir}; - if (defined $self->{tempname}) { + if (defined $state->{replacing}) { if (defined $self->{link}) { link($destdir.$self->{link}, $destdir.$fullname); diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 1a08817f35f..9b85a061da0 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.60 2004/10/31 11:33:51 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.61 2004/11/06 12:19:17 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -243,7 +243,7 @@ our @ISA=qw(OpenBSD::PackingElement::Meta); package OpenBSD::PackingElement::FileBase; our @ISA=qw(OpenBSD::PackingElement::FileObject); -use File::Spec; +use File::Basename; sub write { @@ -263,6 +263,9 @@ sub write if (defined $self->{link}) { print $fh "\@link ", $self->{link}, "\n"; } + if (defined $self->{tempname}) { + print $fh "\@temp ", basename($self->{tempname}), "\n"; + } } sub destate @@ -308,6 +311,12 @@ sub make_hardlink $self->{link} = $linkname; } +sub set_tempname +{ + my ($self, $tempname) = @_; + $self->{temp} = $tempname; +} + sub IsFile() { 1 } @@ -538,6 +547,18 @@ sub add return undef; } +package OpenBSD::PackingElement::temp; +our @ISA=qw(OpenBSD::PackingElement::Annotation); + +__PACKAGE__->setKeyword('temp'); + +sub add +{ + my ($class, $plist, @args) = @_; + $plist->{state}->{lastfile}->set_tempname(@args); + return undef; +} + package OpenBSD::PackingElement::size; our @ISA=qw(OpenBSD::PackingElement::Annotation); diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm index 86f026f2e73..8d125fef743 100644 --- a/usr.sbin/pkg_add/OpenBSD/Update.pm +++ b/usr.sbin/pkg_add/OpenBSD/Update.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Update.pm,v 1.9 2004/11/02 23:53:21 espie Exp $ +# $OpenBSD: Update.pm,v 1.10 2004/11/06 12:19:17 espie Exp $ # # Copyright (c) 2004 Marc Espie <espie@openbsd.org> # @@ -54,7 +54,6 @@ sub extract my $file = $self->prepare_to_extract($state); if (defined $self->{link} || defined $self->{symlink}) { - $self->{tempname} = 1; return; } my ($fh, $tempname) = tempfile(DIR => dirname($file->{destdir}.$file->{name})); diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 542774ababa..3c0b814ef8d 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.93 2004/11/02 23:53:20 espie Exp $ +# $OpenBSD: pkg_add,v 1.94 2004/11/06 12:19:16 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -424,6 +424,11 @@ sub really_add($$) $state->{archive} = $handle; $state->{dir} = $dir; $state->set_pkgname($pkgname); + if (defined $plist->{replacing}) { + $state->{replacing} = 1; + } else { + $state->{replacing} = 0; + } my $header = $pkgname; |