summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-09-13 10:00:49 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-09-13 10:00:49 +0000
commit6ff6c6d1e5f6dac2095610a623fd02d46d453a97 (patch)
tree9660d13e3a8d2ca78cdc8b7caf27ae88ddb977d9 /usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
parentf986061e816ef447245fa37bf82e46b6f3a069cf (diff)
make grabPlist slightly smarter so that we can still open the package
afterwards.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/PackageLocator.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageLocator.pm30
1 files changed, 25 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
index 5cca2519a92..ba70d6fe084 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageLocator.pm,v 1.23 2005/09/13 09:30:55 espie Exp $
+# $OpenBSD: PackageLocator.pm,v 1.24 2005/09/13 10:00:48 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -329,6 +329,18 @@ sub grabInfoFiles
my $self = shift;
my $dir = $self->{dir};
+ if (defined $self->{plist}) {
+ require OpenBSD::PackingList;
+
+ $self->{plist}->tofile($dir.CONTENTS);
+ delete $self->{plist};
+ } elsif (defined $self->{contents}) {
+ open my $fh, '>', $dir.CONTENTS or die "Permission denied";
+ print $fh $self->{contents};
+ close $fh;
+ delete $self->{contents};
+ }
+
while (my $e = $self->next()) {
if ($e->isFile() && is_info_name($e->{name})) {
$e->{name}=$dir.$e->{name};
@@ -354,12 +366,15 @@ sub grabPlist
return undef;
}
- # maybe it's a fat package.
while (my $e = $self->next()) {
- unless ($e->{name} eq CONTENTS or $e->{name} =~ m/\/\+CONTENTS$/) {
- last;
+ if ($e->{name} ne CONTENTS) {
+ if ($e->{name} =~ m/\/\+CONTENTS$/) {
+ $self->{prefix} = $';
+ bless $self, "OpenBSD:FatPackageLocation";
+ } else {
+ last;
+ }
}
- my $prefix = $`;
my $value = $e->contents();
open my $fh, '<', \$value or next;
require OpenBSD::PackingList;
@@ -369,6 +384,11 @@ sub grabPlist
next if defined $pkgname and $plist->pkgname() ne $pkgname;
if ($plist->has('arch')) {
if ($plist->{arch}->check($arch)) {
+ if (!defined $code) {
+ $self->{plist} = $plist;
+ } else {
+ $self->{contents} = $value;
+ }
return $plist;
}
}