summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-09-13 09:30:56 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-09-13 09:30:56 +0000
commitf986061e816ef447245fa37bf82e46b6f3a069cf (patch)
treef3874d31a856e276d51a096f8e024d70caa1c6d5 /usr.sbin
parent80f0523bc1ea57dd89d0ddeb1269f8ab57ec3a80 (diff)
allows grabbing a packing-list directly, without needing to go through
a temporary file, by using perl's new-fangled open my $fh, '<', \$scalar
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageLocator.pm42
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Ustar.pm15
2 files changed, 55 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
index a0df004b049..5cca2519a92 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.22 2005/09/13 09:21:01 espie Exp $
+# $OpenBSD: PackageLocator.pm,v 1.23 2005/09/13 09:30:55 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -107,6 +107,14 @@ sub openPackage
return $self->openPackage($name, $arch);
}
+sub grabPlist
+{
+ my ($repository, $name, $arch, $code) = @_;
+ my $self = OpenBSD::PackageLocation->new($repository, $name);
+
+ return $self->grabPlist($name, $arch, $code);
+}
+
package OpenBSD::PackageRepository::SCP;
our @ISA=qw(OpenBSD::PackageRepository OpenBSD::PackageRepository::FTPorSCP);
@@ -339,6 +347,38 @@ sub grabInfoFiles
return 1;
}
+sub grabPlist
+{
+ my ($self, $pkgname, $arch, $code) = @_;
+ if (!$self->openArchive()) {
+ return undef;
+ }
+
+ # maybe it's a fat package.
+ while (my $e = $self->next()) {
+ unless ($e->{name} eq CONTENTS or $e->{name} =~ m/\/\+CONTENTS$/) {
+ last;
+ }
+ my $prefix = $`;
+ my $value = $e->contents();
+ open my $fh, '<', \$value or next;
+ require OpenBSD::PackingList;
+ $pkgname =~ s/\.tgz$//;
+ my $plist = OpenBSD::PackingList->read($fh, $code);
+ close $fh;
+ next if defined $pkgname and $plist->pkgname() ne $pkgname;
+ if ($plist->has('arch')) {
+ if ($plist->{arch}->check($arch)) {
+ return $plist;
+ }
+ }
+ }
+ # hopeless
+ $self->close();
+
+ return undef;
+}
+
sub openPackage
{
my ($self, $pkgname, $arch) = @_;
diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm
index 4ecbfc8fb4c..26a89209bec 100644
--- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Ustar.pm,v 1.35 2005/08/10 14:02:22 espie Exp $
+# $OpenBSD: Ustar.pm,v 1.36 2005/09/13 09:30:55 espie Exp $
#
# Copyright (c) 2002-2004 Marc Espie <espie@openbsd.org>
#
@@ -599,6 +599,19 @@ sub create
$self->SUPER::set_modes();
}
+sub contents
+{
+ my $self = shift;
+ my $toread = $self->{size};
+ my $buffer;
+
+ if (!defined read($self->{archive}->{fh}, $buffer, $toread)) {
+ die "Error reading from archive: $!";
+ }
+ $self->{archive}->{swallow} -= $toread;
+ return $buffer;
+}
+
sub write_contents
{
my ($self, $arc) = @_;