| 1 | package Alien::Build::Plugin::Extract::Negotiate; | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use 5.008004; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Alien::Build::Plugin; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Alien::Build::Plugin::Extract::ArchiveTar; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Alien::Build::Plugin::Extract::ArchiveZip; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use Alien::Build::Plugin::Extract::CommandLine; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use Alien::Build::Plugin::Extract::Directory; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||
| 12 | # ABSTRACT: Extraction negotiation plugin | ||||||||||||||||||||||||||||||
| 13 | 6 | our $VERSION = '2.88'; # VERSION | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||
| 16 | 6 | has '+format' => 'tar'; | |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||
| 18 | sub init | ||||||||||||||||||||||||||||||
| 19 | 10 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||
| 20 | 10 | my($self, $meta) = @_; | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||
| 22 | 10 | my $format = $self->format; | |||||||||||||||||||||||||||||
| 23 | 10 | ▶ | $format = 'tar.gz' if $format eq 'tgz'; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 24 | 10 | ▶ | $format = 'tar.bz2' if $format eq 'tbz'; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 25 | 10 | ▶ | $format = 'tar.xz' if $format eq 'txz'; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||
| 27 | 10 | my $plugin = $self->pick($format); | |||||||||||||||||||||||||||||
| 28 | 10 | $meta->apply_plugin($plugin, format => $format); | |||||||||||||||||||||||||||||
| 29 | 10 | $self; | |||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||
| 33 | sub pick | ||||||||||||||||||||||||||||||
| 34 | 23 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
pick: called CC=11 SCAR=28.2
Pod
documented
| |||||||||||||||||||||||||||||||
| 35 | 23 | my(undef, $format) = @_; | |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||
| 37 | 23 | ▶ | if($format =~ /^tar(\.(gz|bz2))?$/) | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||||
| 39 | 12 | ▶ | if(Alien::Build::Plugin::Extract::ArchiveTar->available($format)) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 40 | { | ||||||||||||||||||||||||||||||
| 41 | 11 | return 'Extract::ArchiveTar'; | |||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||
| 43 | else | ||||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||||
| 45 | 1 | return 'Extract::CommandLine'; | |||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||
| 48 | elsif($format eq 'zip') | ||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||
| 50 | # Archive::Zip is not that reliable. But if it is already installed it is probably working | ||||||||||||||||||||||||||||||
| 51 | 5 | ▶ | if(Alien::Build::Plugin::Extract::ArchiveZip->available($format)) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||
| 53 | 2 | return 'Extract::ArchiveZip'; | |||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||
| 56 | # If it isn't available, then use the command-line unzip. Alien::unzip will be used | ||||||||||||||||||||||||||||||
| 57 | # as necessary in environments where it isn't already installed. | ||||||||||||||||||||||||||||||
| 58 | else | ||||||||||||||||||||||||||||||
| 59 | { | ||||||||||||||||||||||||||||||
| 60 | 3 | return 'Extract::CommandLine'; | |||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||
| 63 | elsif($format eq 'tar.xz') | ||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||
| 65 | # The windows version of tar.exe (which is based on BSD tar) will try to use external | ||||||||||||||||||||||||||||||
| 66 | # program xz to decompress tar.xz files if it is available. The default windows | ||||||||||||||||||||||||||||||
| 67 | # install does not have this in the PATH, but if it IS in the PATH then it often | ||||||||||||||||||||||||||||||
| 68 | # or always can hang, so the pure Perl Archive::Tar is more reliable on that platform, | ||||||||||||||||||||||||||||||
| 69 | # but will require a newer version of Archive::Tar and IO::Uncompress::UnXz | ||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if(Alien::Build::Plugin::Extract::ArchiveTar->available('tar.xz') || $^O eq 'MSWin32') | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
"Alien::Build::Plugin::Extract::ArchiveTar"->available("tar.xz") or $^O eq "MSWin32"
MC/DC0%0/2
"Alien::Build::Plugin::Extract::ArchiveTar"->available("tar.xz") or $^O eq "MSWin32"
"Alien::Build::Plugin::Extract::ArchiveTar"->available("tar.xz")
$^O eq "MSWin32"
Truth table0%0/3
A or B
A= "Alien::Build::Plugin::Extract::ArchiveTar"->available("tar.xz")B= $^O eq "MSWin32"
| |||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||
| 72 | 0 | return 'Extract::ArchiveTar'; | |||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||
| 74 | else | ||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||
| 76 | 0 | return 'Extract::CommandLine'; | |||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||
| 79 | elsif($format eq 'tar.Z') | ||||||||||||||||||||||||||||||
| 80 | { | ||||||||||||||||||||||||||||||
| 81 | 0 | return 'Extract::CommandLine'; | |||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||
| 83 | elsif($format eq 'd') | ||||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||||
| 85 | 5 | return 'Extract::Directory'; | |||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||
| 87 | elsif($format eq 'f') | ||||||||||||||||||||||||||||||
| 88 | { | ||||||||||||||||||||||||||||||
| 89 | 1 | return 'Extract::File'; | |||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||
| 91 | else | ||||||||||||||||||||||||||||||
| 92 | { | ||||||||||||||||||||||||||||||
| 93 | 0 | die "do not know how to handle format: $format"; | |||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||
| 97 | 6 | 1; | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||
| 99 | __END__ | ||||||||||||||||||||||||||||||