summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-11-01 11:48:04 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-11-01 11:48:04 +0000
commit1039de13029f757ee6b357412bdb28937b5eb8af (patch)
tree78fd4643ad4f26d150f8581fa5c6d27b28110707
parent75d25b331314d248a45225333c6e11a8e567446e (diff)
separate `extract' routine that can put an archive in temporary files
next to their final locations. XXX: doesn't work with hard links, yet.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Add.pm36
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm57
2 files changed, 76 insertions, 17 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm
index 857d827e97e..9985d3ab376 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.1 2004/11/01 11:27:50 espie Exp $
+# $OpenBSD: Add.pm,v 1.2 2004/11/01 11:48:03 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -160,24 +160,28 @@ sub install
{
my ($self, $state) = @_;
my $fullname = $self->fullname();
-
- my $file=$state->{archive}->next();
- if ($file->{name} ne $self->{name}) {
- Fatal "Error: archive does not match", $file->{name}, "!=",
- $self->{name}, "\n";
- }
my $destdir = $state->{destdir};
- print "extracting $destdir$fullname\n" if $state->{very_verbose};
- return if $state->{not};
- $file->{name} = $fullname;
- $file->{cwd} = $self->{cwd};
- $file->{destdir} = $destdir;
- # faked installation are VERY weird
- if (defined $self->{symlink} && $state->{do_faked}) {
- $file->{linkname} = $destdir.$file->{linkname};
+ if (defined $self->{tempname}) {
+ rename($self->{tempname}, $destdir.$fullname);
+ } else {
+ my $file=$state->{archive}->next();
+ if ($file->{name} ne $self->{name}) {
+ Fatal "Error: archive does not match", $file->{name}, "!=",
+ $self->{name}, "\n";
+ }
+
+ print "extracting $destdir$fullname\n" if $state->{very_verbose};
+ return if $state->{not};
+ $file->{name} = $fullname;
+ $file->{cwd} = $self->{cwd};
+ $file->{destdir} = $destdir;
+ # faked installation are VERY weird
+ if (defined $self->{symlink} && $state->{do_faked}) {
+ $file->{linkname} = $destdir.$file->{linkname};
+ }
+ $file->create();
}
- $file->create();
$self->set_modes($destdir.$fullname);
}
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index df6c2dcaa19..d4341e48c27 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.2 2004/10/31 12:40:01 espie Exp $
+# $OpenBSD: Update.pm,v 1.3 2004/11/01 11:48:03 espie Exp $
#
# Copyright (c) 2004 Marc Espie <espie@openbsd.org>
#
@@ -33,6 +33,61 @@ sub validate_depend
}
sub updatable() { 1 }
+sub extract
+{
+}
+
+package OpenBSD::PackingElement::FileBase;
+use File::Temp qw/tempfile/;
+
+sub extract
+{
+ my ($self, $state) = @_;
+ my $fullname = $self->fullname();
+
+ my $file=$state->{archive}->next();
+ if ($file->{name} ne $self->{name}) {
+ Fatal "Error: archive does not match", $file->{name}, "!=",
+ $self->{name}, "\n";
+ }
+ my $destdir = $state->{destdir};
+
+ my ($fh, $tempname) = tempfile(DIR => dirname($destdir.$fullname));
+
+ print "extracting $tempname\n";
+ $file->{name} = $tempname;
+ $file->{cwd} = $self->{cwd};
+ $file->{destdir} = $destdir;
+ # faked installation are VERY weird
+ if (defined $self->{symlink} && $state->{do_faked}) {
+ $file->{linkname} = $destdir.$file->{linkname};
+ }
+ $file->create();
+ $self->{tempname} = $tempname;
+}
+
+package OpenBSD::PackingElement::Dir;
+sub extract
+{
+ my ($self, $state) = @_;
+ my $fullname = $self->fullname();
+ my $destdir = $state->{destdir};
+
+ print "new directory ", $destdir, $fullname, "\n" if $state->{very_verbose};
+ return if $state->{not};
+ File::Path::mkpath($destdir.$fullname);
+}
+
+package OpenBSD::PackingElement::Sample;
+sub extract
+{
+}
+
+package OpenBSD::PackingElement::Sampledir;
+sub extract
+{
+}
+
package OpenBSD::PackingElement::ScriptFile;
sub updatable() { 0 }