summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2014-01-17 13:41:48 +0000
committerMarc Espie <espie@cvs.openbsd.org>2014-01-17 13:41:48 +0000
commitbe134824c24f0f92722509953c17c816133d86ba (patch)
tree4a694fad2eed936a5fe5c37a4e96761736dfe58d /usr.sbin/pkg_add
parentea5943d4cb1bee48e677a1130b79d760d794b699 (diff)
use internal gunzip, now that the fh leak is closed.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageRepository.pm58
1 files changed, 8 insertions, 50 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
index 59f0ef85680..e3b2dc593fd 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageRepository.pm,v 1.102 2014/01/13 18:44:41 espie Exp $
+# $OpenBSD: PackageRepository.pm,v 1.103 2014/01/17 13:41:47 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -296,17 +296,11 @@ sub did_it_fork
}
}
-sub exec_gunzip
+sub uncompress
{
my $self = shift;
- $ENV{LC_ALL} = 'C';
- exec {OpenBSD::Paths->gzip}
- ("gzip",
- "-d",
- "-c",
- "-q",
- @_)
- or $self->{state}->fatal("Can't run gzip: #1", $!);
+ require IO::Uncompress::Gunzip;
+ return IO::Uncompress::Gunzip->new(@_, MultiStream => 1);
}
package OpenBSD::PackageRepository::Local;
@@ -369,14 +363,7 @@ sub open_pipe
if (defined $ENV{'PKG_CACHE'}) {
$self->may_copy($object, $ENV{'PKG_CACHE'});
}
- my $pid = open(my $fh, "-|");
- $self->did_it_fork($pid);
- if ($pid) {
- return $fh;
- } else {
- open STDERR, ">/dev/null";
- $self->exec_gunzip("-f", $self->relative_url($object->{name}));
- }
+ return $self->uncompress($self->relative_url($object->{name}));
}
sub may_exist
@@ -426,14 +413,7 @@ sub new
sub open_pipe
{
my ($self, $object) = @_;
- my $pid = open(my $fh, "-|");
- $self->did_it_fork($pid);
- if ($pid) {
- return $fh;
- } else {
- open STDERR, ">/dev/null";
- $self->exec_gunzip("-f", "-");
- }
+ return $self->uncompress(\*STDIN);
}
package OpenBSD::PackageRepository::Distant;
@@ -532,32 +512,12 @@ sub open_pipe
$object->{cache_dir} = $ENV{'PKG_CACHE'};
$object->{parent} = $$;
- my ($rdfh, $wrfh);
- pipe($rdfh, $wrfh);
-
- my $pid = open(my $fh, "-|");
- $self->did_it_fork($pid);
- if ($pid) {
- $object->{pid} = $pid;
- } else {
- open(STDIN, '<&', $rdfh) or
- $self->{state}->fatal("Bad dup: #1", $!);
- close($rdfh);
- close($wrfh);
- $self->exec_gunzip("-f", "-");
- }
- my $pid2 = fork();
-
+ my $pid2 = open(my $rdfh, "-|");
$self->did_it_fork($pid2);
if ($pid2) {
$object->{pid2} = $pid2;
} else {
open STDERR, '>', $object->{errors};
- open(STDOUT, '>&', $wrfh) or
- $self->{state}->fatal("Bad dup: #1", $!);
- close($rdfh);
- close($wrfh);
- close($fh);
if (defined $object->{cache_dir}) {
my $pid3 = open(my $in, "-|");
$self->did_it_fork($pid3);
@@ -571,9 +531,7 @@ sub open_pipe
}
exit(0);
}
- close($rdfh);
- close($wrfh);
- return $fh;
+ return $self->uncompress($rdfh);
}
sub finish_and_close