| 1 | package CPAN::Mini::Extract; # git description: 6eeec63 | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =pod | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | CPAN::Mini::Extract - Create CPAN::Mini mirrors with the archives extracted | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # Create a CPAN extractor | ||||||||||||||||||||||||||||
| 12 | my $cpan = CPAN::Mini::Extract->new( | ||||||||||||||||||||||||||||
| 13 | remote => 'http://mirrors.kernel.org/cpan/', | ||||||||||||||||||||||||||||
| 14 | local => '/home/adam/.minicpan', | ||||||||||||||||||||||||||||
| 15 | trace => 1, | ||||||||||||||||||||||||||||
| 16 | extract => '/home/adam/.cpanextracted', | ||||||||||||||||||||||||||||
| 17 | extract_filter => sub { /\.pm$/ and ! /\b(inc|t)\b/ }, | ||||||||||||||||||||||||||||
| 18 | extract_check => 1, | ||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # Run the minicpan process | ||||||||||||||||||||||||||||
| 22 | my $changes = $cpan->run; | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | C<CPAN::Mini::Extract> provides a base for implementing systems that | ||||||||||||||||||||||||||||
| 27 | download "all" of CPAN, extract the dists and then process the files | ||||||||||||||||||||||||||||
| 28 | within. | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | It provides the same syncronisation functionality as L<CPAN::Mini> except | ||||||||||||||||||||||||||||
| 31 | that it also maintains a parallel directory tree that contains a directory | ||||||||||||||||||||||||||||
| 32 | located at an identical path to each archive file, with a controllable | ||||||||||||||||||||||||||||
| 33 | subset of the files in the archive extracted below. | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head2 How does it work | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | C<CPAN::Mini::Extract> starts with a L<CPAN::Mini> local mirror, which it | ||||||||||||||||||||||||||||
| 38 | will optionally update before each run. Once the L<CPAN::Mini> directory | ||||||||||||||||||||||||||||
| 39 | is current, it will scan both directory trees, extracting any new archives | ||||||||||||||||||||||||||||
| 40 | and removing any extracted archives no longer in the minicpan mirror. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =head1 EXTENDING | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | This class is relatively straight forward, but may evolve over time. | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | If you wish to write an extension, please stay in contact with the | ||||||||||||||||||||||||||||
| 47 | maintainer while doing so. | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head1 METHODS | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 3 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 54 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 55 | 3 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 56 | 3 | ▶ | use File::Basename (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 57 | 3 | ▶ | use File::Path (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 58 | 3 | ▶ | use File::Spec 0.80 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 59 | 3 | ▶ | use File::Remove 0.34 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 60 | 3 | ▶ | use List::Util 1.15 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 61 | 3 | ▶ | use File::HomeDir 0.88 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 62 | 3 | ▶ | use File::Temp 0.21 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | 3 | ▶ | use URI 1.37 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 64 | 3 | ▶ | use URI::file (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 65 | 3 | ▶ | use IO::File 1.14 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 66 | 3 | ▶ | use IO::Uncompress::Gunzip 2.017 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 67 | 3 | ▶ | use Archive::Tar 1.22 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | 3 | ▶ | use Params::Util 1.00 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 69 | 3 | ▶ | use LWP::Online 0.03 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 70 | 3 | ▶ | use File::Find::Rule 0.30 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 71 | 3 | ▶ | use CPAN::Mini 1.111004 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 3 | our $VERSION = '1.24'; | |||||||||||||||||||||||||||
| 74 | 3 | our @ISA = 'CPAN::Mini'; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | ##################################################################### | ||||||||||||||||||||||||||||
| 79 | # Constructor and Accessors | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =pod | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =head2 new | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | The C<new> constructor is used to create and configure a new CPAN | ||||||||||||||||||||||||||||
| 86 | Processor. It takes a set of named params something like the following. | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | # Create a CPAN processor | ||||||||||||||||||||||||||||
| 89 | my $Object = CPAN::Mini::Extract->new( | ||||||||||||||||||||||||||||
| 90 | # The normal CPAN::Mini params | ||||||||||||||||||||||||||||
| 91 | remote => 'ftp://cpan.pair.com/pub/CPAN/', | ||||||||||||||||||||||||||||
| 92 | local => '/home/adam/.minicpan', | ||||||||||||||||||||||||||||
| 93 | trace => 1, | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | # Additional params | ||||||||||||||||||||||||||||
| 96 | extract => '/home/adam/explosion', | ||||||||||||||||||||||||||||
| 97 | extract_filter => sub { /\.pm$/ and ! /\b(inc|t)\b/ }, | ||||||||||||||||||||||||||||
| 98 | extract_check => 1, | ||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =over | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =item minicpan args | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | C<CPAN::Mini::Extract> inherits from L<CPAN::Mini>, so all of the arguments | ||||||||||||||||||||||||||||
| 106 | that can be used with L<CPAN::Mini> will also work with | ||||||||||||||||||||||||||||
| 107 | C<CPAN::Mini::Extract>. | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | Please note that C<CPAN::Mini::Extract> applies some additional defaults | ||||||||||||||||||||||||||||
| 110 | beyond the normal ones, like turning C<skip_perl> on. | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =item offline | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | Although useless with L<CPAN::Mini> itself, the C<offline> flag will | ||||||||||||||||||||||||||||
| 115 | cause the CPAN synchronisation step to be skipped, and only any | ||||||||||||||||||||||||||||
| 116 | extraction tasks to be done. (False by default) | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =item extract | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | Provides the directory (which must exist and be writable, or be creatable) | ||||||||||||||||||||||||||||
| 121 | that the tarball dists should be extracted to. | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =item extract_filter | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | C<CPAN::Mini::Extract> allows you to specify a filter controlling which | ||||||||||||||||||||||||||||
| 126 | types of files are extracted from the Archive. Please note that ONLY | ||||||||||||||||||||||||||||
| 127 | normal files are ever considered for extraction from an archive, with | ||||||||||||||||||||||||||||
| 128 | any directories needed created automatically. | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | Although by default C<CPAN::Mini::Extract> only extract files of type .pm, | ||||||||||||||||||||||||||||
| 131 | .t and .pl from the archives, you can add a list of additional things you | ||||||||||||||||||||||||||||
| 132 | do not want to be extracted. | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | The filter should be provided as a subroutine reference. This sub will | ||||||||||||||||||||||||||||
| 135 | be called with $_ set to the path of the file. The subroutine should | ||||||||||||||||||||||||||||
| 136 | return true if the file is to be extracted, or false if not. | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | # Extract all .pm files, except those in an include directory | ||||||||||||||||||||||||||||
| 139 | extract_filter => sub { /\.pm$/ and ! /\binc\b/ }, | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =item extract_check | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | The main extraction process is done as each new archive is downloaded, | ||||||||||||||||||||||||||||
| 144 | but occasionally in a process this long-running something may go wrong | ||||||||||||||||||||||||||||
| 145 | and you can end up with archives not extracted. | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | In addition, sometimes the processing of the extracted archives is | ||||||||||||||||||||||||||||
| 148 | destructive and will result in them being deleted each run. | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | Once the mirror update has been completed, the C<extract_check> keyword | ||||||||||||||||||||||||||||
| 151 | forces the processor to go back over every tarball in the mirror and | ||||||||||||||||||||||||||||
| 152 | double check that it has a corrosponding extracted directory. | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =item extract_force | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | For cases in which the filter has been changed, the C<extract_flush> | ||||||||||||||||||||||||||||
| 157 | boolean flag can be used to forcefully delete and re-extract every | ||||||||||||||||||||||||||||
| 158 | extracted directory. | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =back | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | Returns a new C<CPAN::Mini::Extract> object, or dies on error. | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | =cut | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=12 SCAR=29.8
Pod
documented
| |||||||||||||||||||||||||||||
| 167 | 3 | my $class = shift; | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | # Use the CPAN::Mini settings as defaults, and add any | ||||||||||||||||||||||||||||
| 170 | # additional explicit params. | ||||||||||||||||||||||||||||
| 171 | 3 | my %config = ( CPAN::Mini->read_config, @_ ); | |||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | # Unless provided auto-detect offline mode | ||||||||||||||||||||||||||||
| 174 | 3 | ▶ | unless ( defined $config{offline} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | 1 | $config{offline} = LWP::Online::offline(); | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | # Fake a remote URI if CPAN::Mini can't handle offline mode | ||||||||||||||||||||||||||||
| 179 | 3 | my %fake = (); | |||||||||||||||||||||||||||
| 180 | 3 | ▶ | if ( $config{offline} and $CPAN::Mini::VERSION < 0.570 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$config{"offline"} and $CPAN::Mini::VERSION < "0.57"
MC/DC0%0/2
$config{"offline"} and $CPAN::Mini::VERSION < "0.57"
$config{"offline"}
$CPAN::Mini::VERSION < "0.57"
Truth table66%2/3
A and B
A= $config{"offline"}B= $CPAN::Mini::VERSION < "0.57"
| |||||||||||||||||||||||||||||
| 181 | 0 | my $tempdir = File::Temp::tempdir(); | |||||||||||||||||||||||||||
| 182 | 0 | my $tempuri = URI::file->new( $tempdir )->as_string; | |||||||||||||||||||||||||||
| 183 | 0 | $fake{remote} = $tempuri; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | # Use a default local path if none provided | ||||||||||||||||||||||||||||
| 187 | 3 | ▶ | unless ( defined $config{local} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 0 | my $local = File::Spec->catdir( | |||||||||||||||||||||||||||
| 189 | File::HomeDir->my_data, 'minicpan', | ||||||||||||||||||||||||||||
| 190 | ); | ||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | # Call our superclass to create the object | ||||||||||||||||||||||||||||
| 194 | 3 | my $self = $class->SUPER::new( %config, %fake ); | |||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | # Check the extract param | ||||||||||||||||||||||||||||
| 197 | 3 | ▶ | $self->{extract} or Carp::croak( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | "Did not provide an 'extract' path" | ||||||||||||||||||||||||||||
| 199 | ); | ||||||||||||||||||||||||||||
| 200 | 3 | ▶ | if ( -e $self->{extract} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | unless ( -d _ and -w _ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d _ and -w _
MC/DC0%0/2
-d _ and -w _
-d _
-w _
Truth table0%0/3
A and B
A= -d _B= -w _
| |||||||||||||||||||||||||||||
| 202 | 0 | Carp::croak( | |||||||||||||||||||||||||||
| 203 | "The 'extract' path is not a writable directory" | ||||||||||||||||||||||||||||
| 204 | ); | ||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | } else { | ||||||||||||||||||||||||||||
| 207 | File::Path::mkpath( $self->{extract}, $self->{trace}, $self->{dirmode} ) | ||||||||||||||||||||||||||||
| 208 | 3 | ▶ | or Carp::croak("The 'extract' path could not be created"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | # Set defaults and apply rules | ||||||||||||||||||||||||||||
| 212 | 3 | ▶ | unless ( defined $self->{extract_check} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 3 | $self->{extract_check} = 1; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | 3 | ▶ | if ( $self->{extract_force} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 1 | $self->{extract_check} = 1; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | # Compile file_filters if needed | ||||||||||||||||||||||||||||
| 220 | 3 | $self->_compile_filter('extract_filter'); | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | # We'll need a temp directory for expansions | ||||||||||||||||||||||||||||
| 223 | 3 | $self->{tempdir} = File::Temp::tempdir( CLEANUP => 1 ); | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 3 | $self; | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | ##################################################################### | ||||||||||||||||||||||||||||
| 233 | # Main Methods | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | =pod | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | =head2 run | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | The C<run> methods starts the main process, updating the minicpan mirror | ||||||||||||||||||||||||||||
| 240 | and extracted version, and then launching the PPI Processor to process the | ||||||||||||||||||||||||||||
| 241 | files in the source directory. | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | Returns the number of changes made to the local minicpan and extracted | ||||||||||||||||||||||||||||
| 244 | directories, or dies on error. | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | =cut | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||
|
Subroutine
run: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 249 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | # Prepare to start | ||||||||||||||||||||||||||||
| 252 | 0 | local $| = 1; | |||||||||||||||||||||||||||
| 253 | 0 | my $changes; | |||||||||||||||||||||||||||
| 254 | 0 | $self->{added} = {}; | |||||||||||||||||||||||||||
| 255 | 0 | $self->{cleaned} = {}; | |||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | # If we want to force re-expansion, | ||||||||||||||||||||||||||||
| 258 | # remove all current expansion dirs. | ||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if ( $self->{extract_force} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 260 | 0 | $self->log("Flushing all expansion directories (extract_force enabled)\n"); | |||||||||||||||||||||||||||
| 261 | 0 | my $authors_dir = File::Spec->catfile( $self->{extract}, 'authors' ); | |||||||||||||||||||||||||||
| 262 | 0 | ▶ | if ( -e $authors_dir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | 0 | $self->log("Removing $authors_dir..."); | |||||||||||||||||||||||||||
| 264 | 0 | ▶ | File::Remove::remove( \1, $authors_dir ) or Carp::croak( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | "Failed to remove previous expansion directory '$authors_dir'" | ||||||||||||||||||||||||||||
| 266 | ); | ||||||||||||||||||||||||||||
| 267 | 0 | $self->log(" removed\n"); | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | # Update the CPAN::Mini local mirror | ||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if ( $self->{offline} and $CPAN::Mini::VERSION < 0.570 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"offline"} and $CPAN::Mini::VERSION < "0.57"
MC/DC0%0/2
$self->{"offline"} and $CPAN::Mini::VERSION < "0.57"
$self->{"offline"}
$CPAN::Mini::VERSION < "0.57"
Truth table0%0/3
A and B
A= $self->{"offline"}B= $CPAN::Mini::VERSION < "0.57"
| |||||||||||||||||||||||||||||
| 273 | 0 | $self->log("Skipping minicpan update (offline mode enabled)\n"); | |||||||||||||||||||||||||||
| 274 | } else { | ||||||||||||||||||||||||||||
| 275 | 0 | $self->log("Updating minicpan local mirror...\n"); | |||||||||||||||||||||||||||
| 276 | 0 | $self->update_mirror; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 0 | ▶ | $changes ||= 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$changes ||= 0
MC/DC0%0/1
$changes ||= 0
$changes
Truth table0%0/2
A
A= $changes
| |||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ( $self->{extract_check} or $self->{extract_force} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"extract_check"} or $self->{"extract_force"}
MC/DC0%0/2
$self->{"extract_check"} or $self->{"extract_force"}
$self->{"extract_check"}
$self->{"extract_force"}
Truth table0%0/3
A or B
A= $self->{"extract_check"}B= $self->{"extract_force"}
| |||||||||||||||||||||||||||||
| 281 | # Expansion checking is enabled, and we didn't do a normal | ||||||||||||||||||||||||||||
| 282 | # forced check, so find the full list of files to check. | ||||||||||||||||||||||||||||
| 283 | 0 | $self->log("Tarball expansion checking enabled\n"); | |||||||||||||||||||||||||||
| 284 | my @files = File::Find::Rule->new | ||||||||||||||||||||||||||||
| 285 | ->name('*.tar.gz') | ||||||||||||||||||||||||||||
| 286 | ->file | ||||||||||||||||||||||||||||
| 287 | ->relative | ||||||||||||||||||||||||||||
| 288 | 0 | ->in( $self->{local} ); | |||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | # Filter to just those we need to extract | ||||||||||||||||||||||||||||
| 291 | 0 | $self->log("Checking " . scalar(@files) . " tarballs\n"); | |||||||||||||||||||||||||||
| 292 | 0 | @files = grep { ! -d File::Spec->catfile( $self->{extract}, $_ ) } @files; | |||||||||||||||||||||||||||
| 293 | 0 | ▶ | if ( @files ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 294 | 0 | $self->log("Scheduling " . scalar(@files) . " tarballs for expansion\n"); | |||||||||||||||||||||||||||
| 295 | } else { | ||||||||||||||||||||||||||||
| 296 | 0 | $self->log("No tarballs need to be extracted\n"); | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | # Expand each of the tarballs | ||||||||||||||||||||||||||||
| 300 | 0 | foreach my $file ( sort @files ) { | |||||||||||||||||||||||||||
| 301 | 0 | $self->mirror_extract( $file ); | |||||||||||||||||||||||||||
| 302 | 0 | $changes++; | |||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 0 | $self->log("Completed minicpan extraction\n"); | |||||||||||||||||||||||||||
| 307 | 0 | $changes; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | ##################################################################### | ||||||||||||||||||||||||||||
| 315 | # CPAN::Mini Methods | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | # Track what we have added | ||||||||||||||||||||||||||||
| 318 | 0 | ▶ | sub mirror_file { | ||||||||||||||||||||||||||
|
Subroutine
mirror_file: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 319 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 320 | 0 | my $file = shift; | |||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | # Do the normal stuff | ||||||||||||||||||||||||||||
| 323 | 0 | my $rv = $self->SUPER::mirror_file($file, @_); | |||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | # Expand the tarball if needed | ||||||||||||||||||||||||||||
| 326 | 0 | ▶ | unless ( -d File::Spec->catfile( $self->{extract}, $file ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 327 | 0 | $self->{current_file} = $file; | |||||||||||||||||||||||||||
| 328 | 0 | ▶ | $self->mirror_extract( $file ) or return undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | 0 | delete $self->{current_file}; | |||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | $self->{added}->{$file} = 1; | |||||||||||||||||||||||||||
| 333 | 0 | delete $self->{current_file}; | |||||||||||||||||||||||||||
| 334 | 0 | $rv; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | ▶ | sub mirror_extract { | ||||||||||||||||||||||||||
|
Subroutine
mirror_extract: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 338 | 0 | my ($self, $file) = @_; | |||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | # Don't try to extract anything other than normal tarballs for now. | ||||||||||||||||||||||||||||
| 341 | 0 | ▶ | return 1 unless $file =~ /\.t(ar\.)?gz$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | # Extract the new file to the matching directory in | ||||||||||||||||||||||||||||
| 344 | # the processor source directory. | ||||||||||||||||||||||||||||
| 345 | 0 | my $local_file = File::Spec->catfile( $self->{local}, $file ); | |||||||||||||||||||||||||||
| 346 | 0 | my $extract_dir = File::Spec->catfile( $self->{extract}, $file ); | |||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | # Do the actual extraction | ||||||||||||||||||||||||||||
| 349 | 0 | $self->_extract_archive( $local_file, $extract_dir ); | |||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | # Also remove any processing directory. | ||||||||||||||||||||||||||||
| 353 | # And track what we have removed. | ||||||||||||||||||||||||||||
| 354 | 0 | ▶ | sub clean_file { | ||||||||||||||||||||||||||
|
Subroutine
clean_file: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 355 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 356 | 0 | my $file = shift; # Absolute path | |||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | # Convert to relative path, and clear the expansion directory | ||||||||||||||||||||||||||||
| 359 | 0 | my $relative = File::Spec->abs2rel( $file, $self->{local} ); | |||||||||||||||||||||||||||
| 360 | 0 | $self->clean_extract( $relative ); | |||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | # We are doing this in the reverse order to when we created it. | ||||||||||||||||||||||||||||
| 363 | 0 | my $rv = $self->SUPER::clean_file($file, @_); | |||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 0 | $self->{cleaned}->{$file} = 1; | |||||||||||||||||||||||||||
| 366 | 0 | $rv; | |||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | # Remove a processing directory | ||||||||||||||||||||||||||||
| 370 | 0 | ▶ | sub clean_extract { | ||||||||||||||||||||||||||
|
Subroutine
clean_extract: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 371 | 0 | my ($self, $file) = @_; | |||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | # Remove the source directory, if it exists | ||||||||||||||||||||||||||||
| 374 | 0 | my $source_path = File::Spec->catfile( $self->{extract}, $file ); | |||||||||||||||||||||||||||
| 375 | 0 | ▶ | if ( -e $source_path ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 376 | 0 | ▶ | File::Remove::remove( \1, $source_path ) or Carp::carp( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 377 | "Cannot remove $source_path $!" | ||||||||||||||||||||||||||||
| 378 | ); | ||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | 0 | 1; | |||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | ##################################################################### | ||||||||||||||||||||||||||||
| 389 | # Support Methods and Error Handling | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | # Compile a set of filters | ||||||||||||||||||||||||||||
| 392 | 3 | ▶ | sub _compile_filter { | ||||||||||||||||||||||||||
|
Subroutine
_compile_filter: called CC=7 SCAR=34.7
| |||||||||||||||||||||||||||||
| 393 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 394 | 3 | my $name = shift; | |||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | # Shortcut for "no filters" | ||||||||||||||||||||||||||||
| 397 | 3 | ▶ | return 1 unless $self->{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | # If the filter is already a code ref, shortcut | ||||||||||||||||||||||||||||
| 400 | 2 | ▶ | return 1 if Params::Util::_CODELIKE($self->{$name}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | # Allow a single Regexp object for the filter | ||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if ( Params::Util::_INSTANCE($self->{$name}, 'Regexp') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 404 | 0 | $self->{$name} = [ $self->{$name} ]; | |||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | # Check for bad cases | ||||||||||||||||||||||||||||
| 408 | 0 | ▶ | Params::Util::_ARRAY0($self->{$name}) or Carp::croak( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 409 | "$name is not an ARRAY reference" | ||||||||||||||||||||||||||||
| 410 | ); | ||||||||||||||||||||||||||||
| 411 | 0 | ▶ | unless ( @{$self->{$name}} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 412 | 0 | delete $self->{$name}; | |||||||||||||||||||||||||||
| 413 | 0 | return 1; | |||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | # Check we only got Regexp objects | ||||||||||||||||||||||||||||
| 417 | 0 | my @filters = @{$self->{$name}}; | |||||||||||||||||||||||||||
| 418 | 0 | ▶ | if ( scalar grep { ! Params::Util::_INSTANCE($_, 'Regexp') } @filters ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 419 | 0 | return $self->_error("$name can only contains Regexp filters"); | |||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | # Build the anonymous sub | ||||||||||||||||||||||||||||
| 423 | 0 | ▶ | $self->{$name} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 424 | 0 | foreach my $regexp ( @filters ) { | |||||||||||||||||||||||||||
| 425 | 0 | ▶ | return 1 if $_ =~ $regexp; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||
| 427 | 0 | return ''; | |||||||||||||||||||||||||||
| 428 | 0 | }; | |||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | 0 | 1; | |||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | # Encapsulate the actual extraction mechanism | ||||||||||||||||||||||||||||
| 434 | 1 | ▶ | sub _extract_archive { | ||||||||||||||||||||||||||
|
Subroutine
_extract_archive: called CC=10 SCAR=25.0
| |||||||||||||||||||||||||||||
| 435 | 1 | my ($self, $gz, $to) = @_; | |||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | # Do a one-shot separate decompression because for some reason | ||||||||||||||||||||||||||||
| 438 | # the default on-the-fly decompression is horridly memory | ||||||||||||||||||||||||||||
| 439 | # innefficientm, allocating and freeing massive blocks of memory | ||||||||||||||||||||||||||||
| 440 | # for every single block that gets read in. | ||||||||||||||||||||||||||||
| 441 | 1 | my $archive = $self->_extract_gz( $gz ); | |||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | # IO::Zlib::tell will cause problems and Archive::Tar | ||||||||||||||||||||||||||||
| 444 | # tries to use it by default, so invoke it with a | ||||||||||||||||||||||||||||
| 445 | # file handle to MAKE it do the right thing. | ||||||||||||||||||||||||||||
| 446 | 1 | ▶ | my $io = IO::File->new( $archive, "r" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 447 | or die "Failed to open $archive"; | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | # Some hints to Archive::Tar to make it behave to make it | ||||||||||||||||||||||||||||
| 450 | # work better on Win32, and to ignore the ownership crap | ||||||||||||||||||||||||||||
| 451 | # that we don't care about. | ||||||||||||||||||||||||||||
| 452 | 1 | local $Archive::Tar::WARN = 0; | |||||||||||||||||||||||||||
| 453 | 1 | local $Archive::Tar::CHOWN = 0; | |||||||||||||||||||||||||||
| 454 | 1 | local $Archive::Tar::CHMOD = 0; | |||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | # Load the archive | ||||||||||||||||||||||||||||
| 457 | 1 | my $tar = eval { | |||||||||||||||||||||||||||
| 458 | 1 | Archive::Tar->new( $io ); | |||||||||||||||||||||||||||
| 459 | }; | ||||||||||||||||||||||||||||
| 460 | 1 | ▶ | if ( $@ or ! $tar ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ or not $tar
MC/DC0%0/2
$@ or not $tar
$@
not $tar
Truth table33%1/3
A or not(B)
A= $@B= not $tar
| |||||||||||||||||||||||||||||
| 461 | 0 | return $self->_tar_error("Loading of $archive failed"); | |||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | # Get the complete list of files | ||||||||||||||||||||||||||||
| 465 | 1 | my @files = eval { | |||||||||||||||||||||||||||
| 466 | 1 | $tar->list_files( [ 'name', 'size' ] ) | |||||||||||||||||||||||||||
| 467 | }; | ||||||||||||||||||||||||||||
| 468 | 1 | ▶ | return $self->_tar_error("Loading of $archive failed") if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | # Filter to get just the ones we want | ||||||||||||||||||||||||||||
| 471 | 1 | @files = map { $_->{name} } grep { $_->{size} } @files; | |||||||||||||||||||||||||||
| 472 | 1 | ▶ | if ( $self->{extract_filter} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 473 | 1 | @files = grep &{$self->{extract_filter}}, @files; | |||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | # Iterate and extract each file | ||||||||||||||||||||||||||||
| 477 | 1 | File::Path::mkpath( $to, $self->{trace}, $self->{dirmode} ); | |||||||||||||||||||||||||||
| 478 | 1 | foreach my $wanted ( sort @files ) { | |||||||||||||||||||||||||||
| 479 | # Where to extract to | ||||||||||||||||||||||||||||
| 480 | 1 | my $to_file = File::Spec->catfile( $to, $wanted ); | |||||||||||||||||||||||||||
| 481 | 1 | my $to_dir = File::Basename::dirname( $to_file ); | |||||||||||||||||||||||||||
| 482 | 1 | File::Path::mkpath( $to_dir, $self->{trace}, $self->{dirmode} ); | |||||||||||||||||||||||||||
| 483 | 1 | $self->log("write $to_file\n"); | |||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | 1 | my $rv; | |||||||||||||||||||||||||||
| 486 | SCOPE: { | ||||||||||||||||||||||||||||
| 487 | 1 | $rv = eval { | |||||||||||||||||||||||||||
| 488 | 1 | $tar->extract_file( $wanted, $to_file ); | |||||||||||||||||||||||||||
| 489 | }; | ||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||
| 491 | 1 | ▶ | if ( $@ or ! $rv ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ or not $rv
MC/DC0%0/2
$@ or not $rv
$@
not $rv
Truth table33%1/3
A or not(B)
A= $@B= not $rv
| |||||||||||||||||||||||||||||
| 492 | # There was an error during the extraction | ||||||||||||||||||||||||||||
| 493 | 0 | $self->_tar_error( " ... failed" ); | |||||||||||||||||||||||||||
| 494 | 0 | ▶ | if ( -e $to_file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 495 | # Remove any partial file left behind | ||||||||||||||||||||||||||||
| 496 | 0 | File::Remove::remove( $to_file ); | |||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||
| 498 | 0 | return 1; | |||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | # Clean up | ||||||||||||||||||||||||||||
| 503 | 1 | $tar->clear; | |||||||||||||||||||||||||||
| 504 | 1 | undef $tar; | |||||||||||||||||||||||||||
| 505 | 1 | $io->close; | |||||||||||||||||||||||||||
| 506 | 1 | File::Remove::remove( $archive ); | |||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 1 | return 1; | |||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | # Extract a gz-compressed file to a temp file | ||||||||||||||||||||||||||||
| 512 | 3 | my $counter = 0; | |||||||||||||||||||||||||||
| 513 | 1 | ▶ | sub _extract_gz { | ||||||||||||||||||||||||||
|
Subroutine
_extract_gz: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 514 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 515 | 1 | my $gz = shift; | |||||||||||||||||||||||||||
| 516 | 1 | my $tar = ++$counter . '.tar'; | |||||||||||||||||||||||||||
| 517 | my $file = File::Spec->catfile( | ||||||||||||||||||||||||||||
| 518 | 1 | $self->{tempdir}, $tar, | |||||||||||||||||||||||||||
| 519 | ); | ||||||||||||||||||||||||||||
| 520 | 1 | ▶ | IO::Uncompress::Gunzip::gunzip( $gz => $file ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 521 | or die "Failed to uncompress $gz"; | ||||||||||||||||||||||||||||
| 522 | 1 | return $file; | |||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | 0 | ▶ | sub _tar_error { | ||||||||||||||||||||||||||
|
Subroutine
_tar_error: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 526 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | # Get and clean up the message | ||||||||||||||||||||||||||||
| 529 | 0 | my $message = shift; | |||||||||||||||||||||||||||
| 530 | 0 | ▶ | if ( ! $message and $self->{current_file} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $message and $self->{"current_file"}
MC/DC0%0/2
not $message and $self->{"current_file"}
not $message
$self->{"current_file"}
Truth table0%0/3
not(A) and B
A= not $messageB= $self->{"current_file"}
| |||||||||||||||||||||||||||||
| 531 | 0 | $message = "Expansion of $self->{current_file} failed"; | |||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||
| 533 | 0 | ▶ | if ( ! $message ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 534 | 0 | $message = "Expansion of file failed"; | |||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||
| 536 | 0 | ▶ | $message .= " (Archive::Tar warning)" if $@ =~ /Archive::Tar warning/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 537 | 0 | $message .= "\n"; | |||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | 0 | $self->log($message); | |||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | 3 | 1; | |||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | =pod | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | Bugs should always be submitted via the CPAN bug tracker | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPAN-Mini-Extract> | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | For other issues, contact the maintainer | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | L<CPAN::Mini> | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | Funding provided by The Perl Foundation. | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | Copyright 2005 - 2012 Adam Kennedy. | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | This program is free software; you can redistribute | ||||||||||||||||||||||||||||
| 569 | it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | The full text of the license can be found in the | ||||||||||||||||||||||||||||
| 572 | LICENSE file included with this module. | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | =cut | ||||||||||||||||||||||||||||