| 1 | # -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*- | ||||||||||||||||||||||||||||||||||||
| 2 | package CPAN::Tarzip; | ||||||||||||||||||||||||||||||||||||
| 3 | 24 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 4 | 24 | ▶ | use vars qw($VERSION @ISA $BUGHUNTING); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 5 | 24 | ▶ | use CPAN::Debug; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 6 | 24 | ▶ | use File::Basename qw(basename); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 7 | 24 | $VERSION = "5.5014"; | |||||||||||||||||||||||||||||||||||
| 8 | # module is internal to CPAN.pm | ||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||
| 10 | 24 | @ISA = qw(CPAN::Debug); ## no critic | |||||||||||||||||||||||||||||||||||
| 11 | 24 | ▶ | $BUGHUNTING ||= 0; # released code must have turned off | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$CPAN::Tarzip::BUGHUNTING ||= 0
MC/DC0%0/1
$CPAN::Tarzip::BUGHUNTING ||= 0
$CPAN::Tarzip::BUGHUNTING
Truth table50%1/2
A
A= $CPAN::Tarzip::BUGHUNTING
| |||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||
| 13 | # it's ok if file doesn't exist, it just matters if it is .gz or .bz2 | ||||||||||||||||||||||||||||||||||||
| 14 | sub new { | ||||||||||||||||||||||||||||||||||||
| 15 | 39 | ▶ | my($class,$file) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 16 | 39 | ▶ | $CPAN::Frontend->mydie("CPAN::Tarzip->new called without arg") unless defined $file; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 17 | 39 | my $me = { FILE => $file }; | |||||||||||||||||||||||||||||||||||
| 18 | 39 | ▶ | if ($file =~ /\.(bz2|gz|zip|tbz|tgz)$/i) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 19 | 29 | $me->{ISCOMPRESSED} = 1; | |||||||||||||||||||||||||||||||||||
| 20 | } else { | ||||||||||||||||||||||||||||||||||||
| 21 | 10 | $me->{ISCOMPRESSED} = 0; | |||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||
| 23 | 39 | ▶ | if (0) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 24 | } elsif ($file =~ /\.(?:bz2|tbz)$/i) { | ||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | unless ($me->{UNGZIPPRG} = $CPAN::Config->{bzip2}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $bzip2 = _my_which("bzip2"); | |||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ($bzip2) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 28 | 0 | $me->{UNGZIPPRG} = $bzip2; | |||||||||||||||||||||||||||||||||||
| 29 | } else { | ||||||||||||||||||||||||||||||||||||
| 30 | 0 | $CPAN::Frontend->mydie(qq{ | |||||||||||||||||||||||||||||||||||
| 31 | CPAN.pm needs the external program bzip2 in order to handle '$file'. | ||||||||||||||||||||||||||||||||||||
| 32 | Please install it now and run 'o conf init bzip2' from the | ||||||||||||||||||||||||||||||||||||
| 33 | CPAN shell prompt to register it as external program. | ||||||||||||||||||||||||||||||||||||
| 34 | }); | ||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||
| 37 | } else { | ||||||||||||||||||||||||||||||||||||
| 38 | 39 | $me->{UNGZIPPRG} = _my_which("gzip"); | |||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||
| 40 | 39 | ▶ | $me->{TARPRG} = _my_which("tar") || _my_which("gtar"); | ||||||||||||||||||||||||||||||||||
|
Condition33%1/3
_my_which('tar') || _my_which('gtar')
MC/DC0%0/2
_my_which('tar') || _my_which('gtar')
_my_which('tar')
_my_which('gtar')
Truth table33%1/3
A || B
A= _my_which('tar')B= _my_which('gtar')
| |||||||||||||||||||||||||||||||||||||
| 41 | 39 | bless $me, $class; | |||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||
| 44 | sub _zlib_ok () { | ||||||||||||||||||||||||||||||||||||
| 45 | 58 | ▶ | $CPAN::META->has_inst("Compress::Zlib") or return; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_zlib_ok: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 46 | 58 | Compress::Zlib->can('gzopen'); | |||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||
| 49 | sub _my_which { | ||||||||||||||||||||||||||||||||||||
| 50 | 78 | ▶ | my($what) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_my_which: called CC=8 SCAR=36.6
| |||||||||||||||||||||||||||||||||||||
| 51 | 78 | ▶ | if ($CPAN::Config->{$what}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 52 | 0 | return $CPAN::Config->{$what}; | |||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||
| 54 | 78 | ▶ | if ($CPAN::META->has_inst("File::Which")) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 55 | 78 | return File::Which::which($what); | |||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||
| 57 | 0 | my @cand = MM->maybe_command($what); | |||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | return $cand[0] if @cand; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 59 | 0 | require File::Spec; | |||||||||||||||||||||||||||||||||||
| 60 | 0 | my $component; | |||||||||||||||||||||||||||||||||||
| 61 | 0 | PATH_COMPONENT: foreach $component (File::Spec->path()) { | |||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | next unless defined($component) && $component; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $component and $component
MC/DC0%0/2
defined $component and $component
defined $component
$component
Truth table0%0/3
A and B
A= defined $componentB= $component
| |||||||||||||||||||||||||||||||||||||
| 63 | 0 | my($abs) = File::Spec->catfile($component,$what); | |||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if (MM->maybe_command($abs)) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 65 | 0 | return $abs; | |||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||
| 68 | 0 | return; | |||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||
| 71 | sub gzip { | ||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my($self,$read) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
gzip: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $write = $self->{FILE}; | |||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if (_zlib_ok) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 75 | 0 | my($buffer,$fhw); | |||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | $fhw = FileHandle->new($read) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 77 | or $CPAN::Frontend->mydie("Could not open $read: $!"); | ||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $cwd = `pwd`; | |||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | my $gz = Compress::Zlib::gzopen($write, "wb") | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 80 | or $CPAN::Frontend->mydie("Cannot gzopen $write: $! (pwd is $cwd)\n"); | ||||||||||||||||||||||||||||||||||||
| 81 | 0 | binmode($fhw); | |||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $gz->gzwrite($buffer) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 83 | while read($fhw,$buffer,4096) > 0 ; | ||||||||||||||||||||||||||||||||||||
| 84 | 0 | $gz->gzclose() ; | |||||||||||||||||||||||||||||||||||
| 85 | 0 | $fhw->close; | |||||||||||||||||||||||||||||||||||
| 86 | 0 | return 1; | |||||||||||||||||||||||||||||||||||
| 87 | } else { | ||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $command = CPAN::HandleConfig->safe_quote($self->{UNGZIPPRG}); | |||||||||||||||||||||||||||||||||||
| 89 | 0 | system(qq{$command -c "$read" > "$write"})==0; | |||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||
| 94 | sub gunzip { | ||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | my($self,$write) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
gunzip: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $read = $self->{FILE}; | |||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if (_zlib_ok) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 98 | 0 | my($buffer,$fhw); | |||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $fhw = FileHandle->new(">$write") | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 100 | or $CPAN::Frontend->mydie("Could not open >$write: $!"); | ||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | my $gz = Compress::Zlib::gzopen($read, "rb") | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 102 | or $CPAN::Frontend->mydie("Cannot gzopen $read: $!\n"); | ||||||||||||||||||||||||||||||||||||
| 103 | 0 | binmode($fhw); | |||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $fhw->print($buffer) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 105 | while $gz->gzread($buffer) > 0 ; | ||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | $CPAN::Frontend->mydie("Error reading from $read: $!\n") | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 107 | if $gz->gzerror != Compress::Zlib::Z_STREAM_END(); | ||||||||||||||||||||||||||||||||||||
| 108 | 0 | $gz->gzclose() ; | |||||||||||||||||||||||||||||||||||
| 109 | 0 | $fhw->close; | |||||||||||||||||||||||||||||||||||
| 110 | 0 | return 1; | |||||||||||||||||||||||||||||||||||
| 111 | } else { | ||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $command = CPAN::HandleConfig->safe_quote($self->{UNGZIPPRG}); | |||||||||||||||||||||||||||||||||||
| 113 | 0 | system(qq{$command -d -c "$read" > "$write"})==0; | |||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||
| 118 | sub gtest { | ||||||||||||||||||||||||||||||||||||
| 119 | 46 | ▶ | my($self) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
gtest: called CC=20 SCAR=44.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 120 | 46 | ▶ | return $self->{GTEST} if exists $self->{GTEST}; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 121 | 39 | ▶ | defined $self->{FILE} or $CPAN::Frontend->mydie("gtest called but no FILE specified"); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 122 | 39 | my $read = $self->{FILE}; | |||||||||||||||||||||||||||||||||||
| 123 | 39 | my $success; | |||||||||||||||||||||||||||||||||||
| 124 | 39 | ▶ | if ($read=~/\.(?:bz2|tbz)$/ && $CPAN::META->has_inst("Compress::Bzip2")) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
$read =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
MC/DC0%0/2
$read =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
$read =~ /\.(?:bz2|tbz)$/
$CPAN::META->has_inst("Compress::Bzip2")
Truth table33%1/3
A and B
A= $read =~ /\.(?:bz2|tbz)$/B= $CPAN::META->has_inst("Compress::Bzip2")
| |||||||||||||||||||||||||||||||||||||
| 125 | 0 | my($buffer,$len); | |||||||||||||||||||||||||||||||||||
| 126 | 0 | $len = 0; | |||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | my $gz = Compress::Bzip2::bzopen($read, "rb") | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 128 | or $CPAN::Frontend->mydie(sprintf("Cannot bzopen %s: %s\n", | ||||||||||||||||||||||||||||||||||||
| 129 | $read, | ||||||||||||||||||||||||||||||||||||
| 130 | $Compress::Bzip2::bzerrno)); | ||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | while ($gz->bzread($buffer) > 0 ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 132 | 0 | $len += length($buffer); | |||||||||||||||||||||||||||||||||||
| 133 | 0 | $buffer = ""; | |||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $err = $gz->bzerror; | |||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $success = ! $err || $err == Compress::Bzip2::BZ_STREAM_END(); | ||||||||||||||||||||||||||||||||||
|
Condition0%0/3
!$err || $err == Compress::Bzip2::BZ_STREAM_END()
MC/DC0%0/2
!$err || $err == Compress::Bzip2::BZ_STREAM_END()
!$err
$err == Compress::Bzip2::BZ_STREAM_END()
Truth table0%0/3
not(A) || B
A= !$errB= $err == Compress::Bzip2::BZ_STREAM_END()
| |||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if ($len == -s $read) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 138 | 0 | $success = 0; | |||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | CPAN->debug("hit an uncompressed file") if $CPAN::DEBUG; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||
| 141 | 0 | $gz->gzclose(); | |||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | CPAN->debug("err[$err]success[$success]") if $CPAN::DEBUG; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 143 | ▶ | } elsif ( $read=~/\.(?:gz|tgz)$/ && _zlib_ok ) { | |||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$read =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
MC/DC50%1/2
$read =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
$read =~ /\.(?:gz|tgz)$/
&_zlib_ok()
Truth table66%2/3
A and B
A= $read =~ /\.(?:gz|tgz)$/B= &_zlib_ok()
| |||||||||||||||||||||||||||||||||||||
| 144 | # After I had reread the documentation in zlib.h, I discovered that | ||||||||||||||||||||||||||||||||||||
| 145 | # uncompressed files do not lead to an gzerror (anymore?). | ||||||||||||||||||||||||||||||||||||
| 146 | 29 | my($buffer,$len); | |||||||||||||||||||||||||||||||||||
| 147 | 29 | $len = 0; | |||||||||||||||||||||||||||||||||||
| 148 | 29 | ▶ | my $gz = Compress::Zlib::gzopen($read, "rb") | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 149 | or $CPAN::Frontend->mydie(sprintf("Cannot gzopen %s: %s\n", | ||||||||||||||||||||||||||||||||||||
| 150 | $read, | ||||||||||||||||||||||||||||||||||||
| 151 | $Compress::Zlib::gzerrno)); | ||||||||||||||||||||||||||||||||||||
| 152 | 29 | ▶ | while ($gz->gzread($buffer) > 0 ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 153 | 62 | $len += length($buffer); | |||||||||||||||||||||||||||||||||||
| 154 | 62 | $buffer = ""; | |||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||
| 156 | 29 | my $err = $gz->gzerror; | |||||||||||||||||||||||||||||||||||
| 157 | 29 | ▶ | $success = ! $err || $err == Compress::Zlib::Z_STREAM_END(); | ||||||||||||||||||||||||||||||||||
|
Condition66%2/3
!$err || $err == Compress::Zlib::Z_STREAM_END()
MC/DC0%0/2
!$err || $err == Compress::Zlib::Z_STREAM_END()
!$err
$err == Compress::Zlib::Z_STREAM_END()
Truth table66%2/3
not(A) || B
A= !$errB= $err == Compress::Zlib::Z_STREAM_END()
| |||||||||||||||||||||||||||||||||||||
| 158 | 29 | ▶ | if ($len == -s $read) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 159 | 0 | $success = 0; | |||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | CPAN->debug("hit an uncompressed file") if $CPAN::DEBUG; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||
| 162 | 29 | $gz->gzclose(); | |||||||||||||||||||||||||||||||||||
| 163 | 29 | ▶ | CPAN->debug("err[$err]success[$success]") if $CPAN::DEBUG; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 164 | } elsif (!$self->{ISCOMPRESSED}) { | ||||||||||||||||||||||||||||||||||||
| 165 | 10 | $success = 0; | |||||||||||||||||||||||||||||||||||
| 166 | } else { | ||||||||||||||||||||||||||||||||||||
| 167 | 0 | my $command = CPAN::HandleConfig->safe_quote($self->{UNGZIPPRG}); | |||||||||||||||||||||||||||||||||||
| 168 | 0 | $success = 0==system(qq{$command -qdt "$read"}); | |||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||
| 170 | 39 | return $self->{GTEST} = $success; | |||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||
| 174 | sub TIEHANDLE { | ||||||||||||||||||||||||||||||||||||
| 175 | 31 | ▶ | my($class,$file) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHANDLE: called CC=10 SCAR=31.1
| |||||||||||||||||||||||||||||||||||||
| 176 | 31 | my $ret; | |||||||||||||||||||||||||||||||||||
| 177 | 31 | $class->debug("file[$file]"); | |||||||||||||||||||||||||||||||||||
| 178 | 31 | my $self = $class->new($file); | |||||||||||||||||||||||||||||||||||
| 179 | 31 | ▶ | if (0) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||
| 180 | } elsif (!$self->gtest) { | ||||||||||||||||||||||||||||||||||||
| 181 | 10 | ▶ | my $fh = FileHandle->new($file) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 182 | or $CPAN::Frontend->mydie("Could not open file[$file]: $!"); | ||||||||||||||||||||||||||||||||||||
| 183 | 10 | binmode $fh; | |||||||||||||||||||||||||||||||||||
| 184 | 10 | $self->{FH} = $fh; | |||||||||||||||||||||||||||||||||||
| 185 | 10 | $class->debug("via uncompressed FH"); | |||||||||||||||||||||||||||||||||||
| 186 | ▶ | } elsif ($file =~ /\.(?:bz2|tbz)$/ && $CPAN::META->has_inst("Compress::Bzip2")) { | |||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$file =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
MC/DC0%0/2
$file =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
$file =~ /\.(?:bz2|tbz)$/
$CPAN::META->has_inst("Compress::Bzip2")
Truth table33%1/3
A and B
A= $file =~ /\.(?:bz2|tbz)$/B= $CPAN::META->has_inst("Compress::Bzip2")
| |||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | my $gz = Compress::Bzip2::bzopen($file,"rb") or | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 188 | $CPAN::Frontend->mydie("Could not bzopen $file"); | ||||||||||||||||||||||||||||||||||||
| 189 | 0 | $self->{GZ} = $gz; | |||||||||||||||||||||||||||||||||||
| 190 | 0 | $class->debug("via Compress::Bzip2"); | |||||||||||||||||||||||||||||||||||
| 191 | ▶ | } elsif ($file =~/\.(?:gz|tgz)$/ && _zlib_ok) { | |||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$file =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
MC/DC0%0/2
$file =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
$file =~ /\.(?:gz|tgz)$/
&_zlib_ok()
Truth table33%1/3
A and B
A= $file =~ /\.(?:gz|tgz)$/B= &_zlib_ok()
| |||||||||||||||||||||||||||||||||||||
| 192 | 21 | ▶ | my $gz = Compress::Zlib::gzopen($file,"rb") or | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 193 | $CPAN::Frontend->mydie("Could not gzopen $file"); | ||||||||||||||||||||||||||||||||||||
| 194 | 21 | $self->{GZ} = $gz; | |||||||||||||||||||||||||||||||||||
| 195 | 21 | $class->debug("via Compress::Zlib"); | |||||||||||||||||||||||||||||||||||
| 196 | } else { | ||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $gzip = CPAN::HandleConfig->safe_quote($self->{UNGZIPPRG}); | |||||||||||||||||||||||||||||||||||
| 198 | 0 | my $pipe = "$gzip -d -c $file |"; | |||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my $fh = FileHandle->new($pipe) or $CPAN::Frontend->mydie("Could not pipe[$pipe]: $!"); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 200 | 0 | binmode $fh; | |||||||||||||||||||||||||||||||||||
| 201 | 0 | $self->{FH} = $fh; | |||||||||||||||||||||||||||||||||||
| 202 | 0 | $class->debug("via external $gzip"); | |||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||
| 204 | 31 | $self; | |||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||
| 208 | sub READLINE { | ||||||||||||||||||||||||||||||||||||
| 209 | 17 | ▶ | my($self) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
READLINE: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||
| 210 | 17 | ▶ | if (exists $self->{GZ}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 211 | 14 | my $gz = $self->{GZ}; | |||||||||||||||||||||||||||||||||||
| 212 | 14 | my($line,$bytesread); | |||||||||||||||||||||||||||||||||||
| 213 | 14 | $bytesread = $gz->gzreadline($line); | |||||||||||||||||||||||||||||||||||
| 214 | 14 | ▶ | return undef if $bytesread <= 0; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 215 | 7 | return $line; | |||||||||||||||||||||||||||||||||||
| 216 | } else { | ||||||||||||||||||||||||||||||||||||
| 217 | 3 | my $fh = $self->{FH}; | |||||||||||||||||||||||||||||||||||
| 218 | 3 | return scalar <$fh>; | |||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||
| 223 | sub READ { | ||||||||||||||||||||||||||||||||||||
| 224 | 32 | ▶ | my($self,$ref,$length,$offset) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
READ: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||
| 225 | 32 | ▶ | $CPAN::Frontend->mydie("read with offset not implemented") if defined $offset; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 226 | 32 | ▶ | if (exists $self->{GZ}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 227 | 14 | my $gz = $self->{GZ}; | |||||||||||||||||||||||||||||||||||
| 228 | 14 | my $byteread = $gz->gzread($$ref,$length);# 30eaf79e8b446ef52464b5422da328a8 | |||||||||||||||||||||||||||||||||||
| 229 | 14 | return $byteread; | |||||||||||||||||||||||||||||||||||
| 230 | } else { | ||||||||||||||||||||||||||||||||||||
| 231 | 18 | my $fh = $self->{FH}; | |||||||||||||||||||||||||||||||||||
| 232 | 18 | return read($fh,$$ref,$length); | |||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||
| 237 | sub DESTROY { | ||||||||||||||||||||||||||||||||||||
| 238 | 39 | ▶ | my($self) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||
| 239 | 39 | ▶ | if (exists $self->{GZ}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 240 | 21 | my $gz = $self->{GZ}; | |||||||||||||||||||||||||||||||||||
| 241 | 21 | ▶ | $gz->gzclose() if defined $gz; # hard to say if it is allowed | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 242 | # to be undef ever. AK, 2000-09 | ||||||||||||||||||||||||||||||||||||
| 243 | } else { | ||||||||||||||||||||||||||||||||||||
| 244 | 18 | my $fh = $self->{FH}; | |||||||||||||||||||||||||||||||||||
| 245 | 18 | ▶ | $fh->close if defined $fh; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||
| 247 | 39 | undef $self; | |||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||
| 250 | sub untar { | ||||||||||||||||||||||||||||||||||||
| 251 | 8 | ▶ | my($self) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
untar: called CC=45 SCAR=69.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 252 | 8 | my $file = $self->{FILE}; | |||||||||||||||||||||||||||||||||||
| 253 | 8 | my($prefer) = 0; | |||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||
| 255 | 8 | ▶ | my $exttar = $self->{TARPRG} || ""; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'TARPRG'} || ''
MC/DC0%0/1
$self->{'TARPRG'} || ''
$self->{'TARPRG'}
Truth table50%1/2
A
A= $self->{'TARPRG'}
| |||||||||||||||||||||||||||||||||||||
| 256 | 8 | ▶ | $exttar = "" if $exttar =~ /^\s+$/; # user refuses to use it | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 257 | 8 | ▶ | my $extgzip = $self->{UNGZIPPRG} || ""; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'UNGZIPPRG'} || ''
MC/DC0%0/1
$self->{'UNGZIPPRG'} || ''
$self->{'UNGZIPPRG'}
Truth table50%1/2
A
A= $self->{'UNGZIPPRG'}
| |||||||||||||||||||||||||||||||||||||
| 258 | 8 | ▶ | $extgzip = "" if $extgzip =~ /^\s+$/; # user refuses to use it | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||
| 260 | 8 | ▶ | if (0) { # makes changing order easier | ||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||
| 261 | } elsif ($BUGHUNTING) { | ||||||||||||||||||||||||||||||||||||
| 262 | 0 | $prefer=2; | |||||||||||||||||||||||||||||||||||
| 263 | } elsif ($CPAN::Config->{prefer_external_tar}) { | ||||||||||||||||||||||||||||||||||||
| 264 | 0 | $prefer = 1; | |||||||||||||||||||||||||||||||||||
| 265 | ▶ | } elsif ( | |||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$CPAN::META->has_usable("Archive::Tar") and &_zlib_ok()
MC/DC0%0/2
$CPAN::META->has_usable("Archive::Tar") and &_zlib_ok()
$CPAN::META->has_usable("Archive::Tar")
&_zlib_ok()
Truth table33%1/3
A and B
A= $CPAN::META->has_usable("Archive::Tar")B= &_zlib_ok()
| |||||||||||||||||||||||||||||||||||||
| 266 | $CPAN::META->has_usable("Archive::Tar") | ||||||||||||||||||||||||||||||||||||
| 267 | && | ||||||||||||||||||||||||||||||||||||
| 268 | _zlib_ok ) { | ||||||||||||||||||||||||||||||||||||
| 269 | 8 | my $prefer_external_tar = $CPAN::Config->{prefer_external_tar}; | |||||||||||||||||||||||||||||||||||
| 270 | 8 | ▶ | unless (defined $prefer_external_tar) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 271 | 8 | ▶ | if ($^O =~ /(MSWin32|solaris)/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 272 | 0 | $prefer_external_tar = 0; | |||||||||||||||||||||||||||||||||||
| 273 | } else { | ||||||||||||||||||||||||||||||||||||
| 274 | 8 | $prefer_external_tar = 1; | |||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||
| 277 | 8 | ▶ | $prefer = $prefer_external_tar ? 1 : 2; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 278 | ▶ | } elsif ($exttar && $extgzip) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$exttar and $extgzip
MC/DC0%0/2
$exttar and $extgzip
$exttar
$extgzip
Truth table0%0/3
A and B
A= $exttarB= $extgzip
| |||||||||||||||||||||||||||||||||||||
| 279 | # no modules and not bz2 | ||||||||||||||||||||||||||||||||||||
| 280 | 0 | $prefer = 1; | |||||||||||||||||||||||||||||||||||
| 281 | # but solaris binary tar is a problem | ||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if ($^O eq 'solaris' && qx($exttar --version 2>/dev/null) !~ /gnu/i) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O eq "solaris" and not `$exttar --version 2>/dev/null` =~ /gnu/i
MC/DC0%0/2
$^O eq "solaris" and not `$exttar --version 2>/dev/null` =~ /gnu/i
$^O eq "solaris"
not `$exttar --version 2>/dev/null` =~ /gnu/i
Truth table0%0/3
A and not(B)
A= $^O eq "solaris"B= not `$exttar --version 2>/dev/null` =~ /gnu/i
| |||||||||||||||||||||||||||||||||||||
| 283 | 0 | $CPAN::Frontend->mywarn(<< 'END_WARN'); | |||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||
| 285 | WARNING: Many CPAN distributions were archived with GNU tar and some of | ||||||||||||||||||||||||||||||||||||
| 286 | them may be incompatible with Solaris tar. We respectfully suggest you | ||||||||||||||||||||||||||||||||||||
| 287 | configure CPAN to use a GNU tar instead ("o conf init tar") or install | ||||||||||||||||||||||||||||||||||||
| 288 | a recent Archive::Tar instead; | ||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||
| 290 | END_WARN | ||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||
| 292 | } else { | ||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | my $foundtar = $exttar ? "'$exttar'" : "nothing"; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | my $foundzip = $extgzip ? "'$extgzip'" : $foundtar ? "nothing" : "also nothing"; | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 295 | 0 | my $foundAT; | |||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if ($CPAN::META->has_usable("Archive::Tar")) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 297 | 0 | $foundAT = sprintf "'%s'", "Archive::Tar::"->VERSION; | |||||||||||||||||||||||||||||||||||
| 298 | } else { | ||||||||||||||||||||||||||||||||||||
| 299 | 0 | $foundAT = "nothing"; | |||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||
| 301 | 0 | my $foundCZ; | |||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if (_zlib_ok) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 303 | 0 | $foundCZ = sprintf "'%s'", "Compress::Zlib::"->VERSION; | |||||||||||||||||||||||||||||||||||
| 304 | } elsif ($foundAT) { | ||||||||||||||||||||||||||||||||||||
| 305 | 0 | $foundCZ = "nothing"; | |||||||||||||||||||||||||||||||||||
| 306 | } else { | ||||||||||||||||||||||||||||||||||||
| 307 | 0 | $foundCZ = "also nothing"; | |||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||
| 309 | 0 | $CPAN::Frontend->mydie(qq{ | |||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||
| 311 | CPAN.pm needs either the external programs tar and gzip -or- both | ||||||||||||||||||||||||||||||||||||
| 312 | modules Archive::Tar and Compress::Zlib installed. | ||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||
| 314 | For tar I found $foundtar, for gzip $foundzip. | ||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||
| 316 | For Archive::Tar I found $foundAT, for Compress::Zlib $foundCZ; | ||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||
| 318 | Can't continue cutting file '$file'. | ||||||||||||||||||||||||||||||||||||
| 319 | }); | ||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||
| 321 | 8 | my $tar_verb = "v"; | |||||||||||||||||||||||||||||||||||
| 322 | 8 | ▶ | if (defined $CPAN::Config->{tar_verbosity}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 323 | $tar_verb = $CPAN::Config->{tar_verbosity} eq "none" ? "" : | ||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | $CPAN::Config->{tar_verbosity}; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||
| 326 | 8 | ▶ | if ($prefer==1) { # 1 => external gzip+tar | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 327 | 8 | my($system); | |||||||||||||||||||||||||||||||||||
| 328 | 8 | my $is_compressed = $self->gtest(); | |||||||||||||||||||||||||||||||||||
| 329 | 8 | my $tarcommand = CPAN::HandleConfig->safe_quote($exttar); | |||||||||||||||||||||||||||||||||||
| 330 | 8 | ▶ | if ($is_compressed) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 331 | 8 | my $command = CPAN::HandleConfig->safe_quote($extgzip); | |||||||||||||||||||||||||||||||||||
| 332 | 8 | $system = qq{$command -d -c }. | |||||||||||||||||||||||||||||||||||
| 333 | qq{< "$file" | $tarcommand x${tar_verb}f -}; | ||||||||||||||||||||||||||||||||||||
| 334 | } else { | ||||||||||||||||||||||||||||||||||||
| 335 | 0 | $system = qq{$tarcommand x${tar_verb}f "$file"}; | |||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||
| 337 | 8 | ▶ | if (system($system) != 0) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 338 | # people find the most curious tar binaries that cannot handle | ||||||||||||||||||||||||||||||||||||
| 339 | # pipes | ||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if ($is_compressed) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 341 | 0 | (my $ungzf = $file) =~ s/\.gz(?!\n)\Z//; | |||||||||||||||||||||||||||||||||||
| 342 | 0 | $ungzf = basename $ungzf; | |||||||||||||||||||||||||||||||||||
| 343 | 0 | my $ct = CPAN::Tarzip->new($file); | |||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | if ($ct->gunzip($ungzf)) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 345 | 0 | $CPAN::Frontend->myprint(qq{Uncompressed $file successfully\n}); | |||||||||||||||||||||||||||||||||||
| 346 | } else { | ||||||||||||||||||||||||||||||||||||
| 347 | 0 | $CPAN::Frontend->mydie(qq{Couldn\'t uncompress $file\n}); | |||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||
| 349 | 0 | $file = $ungzf; | |||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||
| 351 | 0 | $system = qq{$tarcommand x${tar_verb}f "$file"}; | |||||||||||||||||||||||||||||||||||
| 352 | 0 | $CPAN::Frontend->myprint(qq{Using Tar:$system:\n}); | |||||||||||||||||||||||||||||||||||
| 353 | 0 | my $ret = system($system); | |||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if ($ret==0) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 355 | 0 | $CPAN::Frontend->myprint(qq{Untarred $file successfully\n}); | |||||||||||||||||||||||||||||||||||
| 356 | } else { | ||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if ($? == -1) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 358 | 0 | $CPAN::Frontend->mydie(sprintf qq{Couldn\'t untar %s: '%s'\n}, | |||||||||||||||||||||||||||||||||||
| 359 | $file, $!); | ||||||||||||||||||||||||||||||||||||
| 360 | } elsif ($? & 127) { | ||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | $CPAN::Frontend->mydie(sprintf qq{Couldn\'t untar %s: child died with signal %d, %s coredump\n}, | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 362 | $file, ($? & 127), ($? & 128) ? 'with' : 'without'); | ||||||||||||||||||||||||||||||||||||
| 363 | } else { | ||||||||||||||||||||||||||||||||||||
| 364 | 0 | $CPAN::Frontend->mydie(sprintf qq{Couldn\'t untar %s: child exited with value %d\n}, | |||||||||||||||||||||||||||||||||||
| 365 | $file, $? >> 8); | ||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||
| 368 | 0 | return 1; | |||||||||||||||||||||||||||||||||||
| 369 | } else { | ||||||||||||||||||||||||||||||||||||
| 370 | 8 | return 1; | |||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||
| 372 | } elsif ($prefer==2) { # 2 => modules | ||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | unless ($CPAN::META->has_usable("Archive::Tar")) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 374 | 0 | $CPAN::Frontend->mydie("Archive::Tar not installed, please install it to continue"); | |||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||
| 376 | # Make sure AT does not use uid/gid/permissions in the archive | ||||||||||||||||||||||||||||||||||||
| 377 | # This leaves it to the user's umask instead | ||||||||||||||||||||||||||||||||||||
| 378 | 0 | local $Archive::Tar::CHMOD = 1; | |||||||||||||||||||||||||||||||||||
| 379 | 0 | local $Archive::Tar::SAME_PERMISSIONS = 0; | |||||||||||||||||||||||||||||||||||
| 380 | # Make sure AT leaves current user as owner | ||||||||||||||||||||||||||||||||||||
| 381 | 0 | local $Archive::Tar::CHOWN = 0; | |||||||||||||||||||||||||||||||||||
| 382 | 0 | my $tar = Archive::Tar->new($file,1); | |||||||||||||||||||||||||||||||||||
| 383 | 0 | my $af; # archive file | |||||||||||||||||||||||||||||||||||
| 384 | my @af; | ||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if ($BUGHUNTING) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 386 | # RCS 1.337 had this code, it turned out unacceptable slow but | ||||||||||||||||||||||||||||||||||||
| 387 | # it revealed a bug in Archive::Tar. Code is only here to hunt | ||||||||||||||||||||||||||||||||||||
| 388 | # the bug again. It should never be enabled in published code. | ||||||||||||||||||||||||||||||||||||
| 389 | # GDGraph3d-0.53 was an interesting case according to Larry | ||||||||||||||||||||||||||||||||||||
| 390 | # Virden. | ||||||||||||||||||||||||||||||||||||
| 391 | 0 | warn(">>>Bughunting code enabled<<< " x 20); | |||||||||||||||||||||||||||||||||||
| 392 | 0 | for $af ($tar->list_files) { | |||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | if ($af =~ m!^(/|\.\./)!) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 394 | 0 | $CPAN::Frontend->mydie("ALERT: Archive contains ". | |||||||||||||||||||||||||||||||||||
| 395 | "illegal member [$af]"); | ||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||
| 397 | 0 | $CPAN::Frontend->myprint("$af\n"); | |||||||||||||||||||||||||||||||||||
| 398 | 0 | $tar->extract($af); # slow but effective for finding the bug | |||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | return if $CPAN::Signal; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||
| 401 | } else { | ||||||||||||||||||||||||||||||||||||
| 402 | 0 | for $af ($tar->list_files) { | |||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if ($af =~ m!^(/|\.\./)!) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 404 | 0 | $CPAN::Frontend->mydie("ALERT: Archive contains ". | |||||||||||||||||||||||||||||||||||
| 405 | "illegal member [$af]"); | ||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if ($tar_verb eq "v" || $tar_verb eq "vv") { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tar_verb eq "v" or $tar_verb eq "vv"
MC/DC0%0/2
$tar_verb eq "v" or $tar_verb eq "vv"
$tar_verb eq "v"
$tar_verb eq "vv"
Truth table0%0/3
A or B
A= $tar_verb eq "v"B= $tar_verb eq "vv"
| |||||||||||||||||||||||||||||||||||||
| 408 | 0 | $CPAN::Frontend->myprint("$af\n"); | |||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||
| 410 | 0 | push @af, $af; | |||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | return if $CPAN::Signal; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | $tar->extract(@af) or | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 414 | $CPAN::Frontend->mydie("Could not untar with Archive::Tar."); | ||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||
| 417 | 0 | return 1; | |||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||
| 421 | sub unzip { | ||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | my($self) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
unzip: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 423 | 0 | my $file = $self->{FILE}; | |||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | if ($CPAN::META->has_inst("Archive::Zip")) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 425 | # blueprint of the code from Archive::Zip::Tree::extractTree(); | ||||||||||||||||||||||||||||||||||||
| 426 | 0 | my $zip = Archive::Zip->new(); | |||||||||||||||||||||||||||||||||||
| 427 | 0 | my $status; | |||||||||||||||||||||||||||||||||||
| 428 | 0 | $status = $zip->read($file); | |||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | $CPAN::Frontend->mydie("Read of file[$file] failed\n") | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 430 | if $status != Archive::Zip::AZ_OK(); | ||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | $CPAN::META->debug("Successfully read file[$file]") if $CPAN::DEBUG; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 432 | 0 | my @members = $zip->members(); | |||||||||||||||||||||||||||||||||||
| 433 | 0 | for my $member ( @members ) { | |||||||||||||||||||||||||||||||||||
| 434 | 0 | my $af = $member->fileName(); | |||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | if ($af =~ m!^(/|\.\./)!) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 436 | 0 | $CPAN::Frontend->mydie("ALERT: Archive contains ". | |||||||||||||||||||||||||||||||||||
| 437 | "illegal member [$af]"); | ||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||
| 439 | 0 | $status = $member->extractToFileNamed( $af ); | |||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | $CPAN::META->debug("af[$af]status[$status]") if $CPAN::DEBUG; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | $CPAN::Frontend->mydie("Extracting of file[$af] from zipfile[$file] failed\n") if | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 442 | $status != Archive::Zip::AZ_OK(); | ||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | return if $CPAN::Signal; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||
| 445 | 0 | return 1; | |||||||||||||||||||||||||||||||||||
| 446 | } elsif ( my $unzip = $CPAN::Config->{unzip} ) { | ||||||||||||||||||||||||||||||||||||
| 447 | 0 | my @system = ($unzip, $file); | |||||||||||||||||||||||||||||||||||
| 448 | 0 | return system(@system) == 0; | |||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||
| 450 | else { | ||||||||||||||||||||||||||||||||||||
| 451 | 0 | $CPAN::Frontend->mydie(<<"END"); | |||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||
| 453 | Can't unzip '$file': | ||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||
| 455 | You have not configured an 'unzip' program and do not have Archive::Zip | ||||||||||||||||||||||||||||||||||||
| 456 | installed. Please either install Archive::Zip or else configure 'unzip' | ||||||||||||||||||||||||||||||||||||
| 457 | by running the command 'o conf init unzip' from the CPAN shell prompt. | ||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||
| 459 | END | ||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||
| 463 | 24 | 1; | |||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||
| 465 | __END__ | ||||||||||||||||||||||||||||||||||||