| 1 | package Minilla::WorkDir; | ||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Archive::Tar; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use IO::Compress::Gzip qw(gzip $GzipError); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use File::pushd; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Data::Dumper; # serializer | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use File::Spec::Functions qw(splitdir); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Time::Piece qw(gmtime); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use File::Basename qw(dirname); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use File::Path qw(mkpath); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use File::Copy qw(copy); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use CPAN::Meta; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Minilla::Logger; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Minilla::Changes; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use Minilla::Util qw(randstr cmd cmd_perl slurp slurp_raw spew spew_raw pod_escape); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Minilla::FileGatherer; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use Minilla::ReleaseTest; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | has project => ( | |||||||||||||||||||||||||||||||||||||||
| 27 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 28 | required => 1, | ||||||||||||||||||||||||||||||||||||||||
| 29 | handles => [qw(files)], | ||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||
| 32 | has dir => ( | ||||||||||||||||||||||||||||||||||||||||
| 33 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | isa => sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | Carp::confess("'dir' must not be undef") unless defined $_[0]; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 36 | }, | ||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ); | |||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | has manifest_files => ( | |||||||||||||||||||||||||||||||||||||||
| 40 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | has file_modes => ( | |||||||||||||||||||||||||||||||||||||||
| 44 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 45 | predicate => 'has_file_modes', | ||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | has [qw(prereq_specs)] => ( | |||||||||||||||||||||||||||||||||||||||
| 49 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||
| 52 | has 'cleanup' => ( | ||||||||||||||||||||||||||||||||||||||||
| 53 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | default => sub { $Minilla::DEBUG ? 0 : 1 }, | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | ); | |||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||
| 57 | has 'skip_prepare' => ( | ||||||||||||||||||||||||||||||||||||||||
| 58 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | default => sub { 0 }, | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | ); | |||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | has changes_time => ( | |||||||||||||||||||||||||||||||||||||||
| 63 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | has archive_timestamp => ( | |||||||||||||||||||||||||||||||||||||||
| 67 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||
| 70 | has file_mode_overrides => ( | ||||||||||||||||||||||||||||||||||||||||
| 71 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | default => sub { +{} }, | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ); | |||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | no Moo; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub _build_changes_time { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_changes_time: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $timestamp = $self->archive_timestamp; | |||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return defined $timestamp ? scalar(gmtime($timestamp)) : scalar(gmtime()); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | ▶ | sub DEMOLISH { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
DEMOLISH: called CC=2 SCAR=9.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 85 | 2 | ▶ | if ($self->cleanup) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | infof("Removing %s\n", $self->dir); | |||||||||||||||||||||||||||||||||||||||
| 87 | 0 | File::Path::rmtree($self->dir) | |||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub _build_dir { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_dir: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $dirname = $^O eq 'MSWin32' ? '_build' : '.build'; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | File::Spec->catfile($self->project->dir, $dirname, randstr(8)); | |||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub _build_prereq_specs { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_prereq_specs: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $cpanfile = Module::CPANfile->load(File::Spec->catfile($self->project->dir, 'cpanfile')); | |||||||||||||||||||||||||||||||||||||||
| 101 | 0 | return $cpanfile->prereq_specs; | |||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub _build_manifest_files { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_manifest_files: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my @files = (@{$self->files}, qw(LICENSE META.json META.yml MANIFEST)); | |||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if (-f File::Spec->catfile($self->dir, 'Makefile.PL')) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | push @files, 'Makefile.PL'; | |||||||||||||||||||||||||||||||||||||||
| 109 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | push @files, 'Build.PL'; | |||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | [do { | |||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my %h; | |||||||||||||||||||||||||||||||||||||||
| 115 | 0 | grep {!$h{$_}++} @files; | |||||||||||||||||||||||||||||||||||||||
| 116 | }]; | ||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $self->dir; | |||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=8 SCAR=38.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | infof("Creating working directory: %s\n", $self->dir); | |||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||
| 129 | # copying | ||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | mkpath($self->dir); | |||||||||||||||||||||||||||||||||||||||
| 131 | 2 | for my $src (@{$self->files}) { | |||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | next if -d $src; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | debugf("Copying %s\n", $src); | |||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if (not -e $src) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | warnf("Trying to copy non-existing file '$src', ignored\n"); | |||||||||||||||||||||||||||||||||||||||
| 137 | 0 | next; | |||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $relative_path = File::Spec->abs2rel($src, $self->project->dir); | |||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $dst = File::Spec->catfile($self->dir, $relative_path); | |||||||||||||||||||||||||||||||||||||||
| 141 | 0 | mkpath(dirname($dst)); | |||||||||||||||||||||||||||||||||||||||
| 142 | 0 | infof("cp %s %s\n", $src, $dst); | |||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | copy($src => $dst) or die "Copying failed: $src $dst, $!\n"; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $archive_path = _archive_path($relative_path); | |||||||||||||||||||||||||||||||||||||||
| 145 | my $mode = $self->has_file_modes && exists $self->file_modes->{$archive_path} | ||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | ? $self->file_modes->{$archive_path} | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->has_file_modes and exists $self->file_modes->{$archive_path}
MC/DC0%0/2
$self->has_file_modes and exists $self->file_modes->{$archive_path}
$self->has_file_modes
exists $self->file_modes->{$archive_path}
Truth table0%0/3
A and B
A= $self->has_file_modesB= exists $self->file_modes->{$archive_path}
| |||||||||||||||||||||||||||||||||||||||||
| 147 | : (stat($src))[2]; | ||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | chmod($mode, $dst) or die "Cannot change mode: $dst, $!\n"; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub build { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | return if $self->{build}++; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $guard = pushd($self->dir); | |||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | infof("Building %s\n", $self->dir); | |||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||
| 161 | # Generate meta file | ||||||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | my $meta = $self->skip_prepare | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 164 | ? CPAN::Meta->load_file('META.json', { lazy_validation => 0 }) | ||||||||||||||||||||||||||||||||||||||||
| 165 | : $self->project->cpan_meta(); | ||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | $meta = $self->project->finalize_cpan_meta($meta) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 167 | if $self->skip_prepare; | ||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $meta->save('META.yml', { | |||||||||||||||||||||||||||||||||||||||
| 169 | version => '1.4', | ||||||||||||||||||||||||||||||||||||||||
| 170 | }); | ||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $meta->save('META.json', { | |||||||||||||||||||||||||||||||||||||||
| 172 | version => '2', | ||||||||||||||||||||||||||||||||||||||||
| 173 | }); | ||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | infof("Writing MANIFEST file\n"); | |||||||||||||||||||||||||||||||||||||||
| 178 | 0 | spew('MANIFEST', join("\n", @{$self->manifest_files})); | |||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $self->project->regenerate_files() unless $self->skip_prepare; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | $self->_rewrite_changes() if $self->project->manage_changes; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $self->_rewrite_pod(); | |||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | unless ($ENV{MINILLA_DISABLE_WRITE_RELEASE_TEST}) { # DO NOT USE THIS ENVIRONMENT VARIABLE. | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | Minilla::ReleaseTest->write_release_tests($self->project, $self->dir); | |||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if (-f 'Build.PL') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | cmd_perl('Build.PL'); | |||||||||||||||||||||||||||||||||||||||
| 191 | 0 | cmd_perl('Build', 'build'); | |||||||||||||||||||||||||||||||||||||||
| 192 | } elsif (-f 'Makefile.PL') { | ||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | cmd_perl('Makefile.PL'); | |||||||||||||||||||||||||||||||||||||||
| 194 | 0 | cmd($Config{make}); | |||||||||||||||||||||||||||||||||||||||
| 195 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | die "There is no Makefile.PL/Build.PL"; | |||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | ▶ | sub _rewrite_changes { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rewrite_changes: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | my $orig = slurp_raw('Changes'); | |||||||||||||||||||||||||||||||||||||||
| 204 | 2 | my $version = $self->project->version; | |||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | if (Minilla::Changes::is_prepared($orig, $version)) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | $orig =~ s! | |||||||||||||||||||||||||||||||||||||||
| 207 | ^\{\{\$NEXT\}\}\h*\R(?:\h*\R)* | ||||||||||||||||||||||||||||||||||||||||
| 208 | (?=\Q$version\E(?:\h|\R|\z)) | ||||||||||||||||||||||||||||||||||||||||
| 209 | !!mx; | ||||||||||||||||||||||||||||||||||||||||
| 210 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | $orig =~ s!\{\{\$NEXT\}\}! | |||||||||||||||||||||||||||||||||||||||
| 212 | 1 | $version . ' ' . $self->changes_time->strftime('%Y-%m-%dT%H:%M:%SZ') | |||||||||||||||||||||||||||||||||||||||
| 213 | !e; | ||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | spew_raw('Changes', $orig); | |||||||||||||||||||||||||||||||||||||||
| 216 | 2 | ▶ | chmod(0644, 'Changes') or die "Cannot change mode: Changes, $!\n"; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | $self->file_mode_overrides->{'Changes'} = 0644; | |||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub _rewrite_pod { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rewrite_pod: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||
| 223 | # Disabled this feature. | ||||||||||||||||||||||||||||||||||||||||
| 224 | # my $orig =slurp_raw($self->project->main_module_path); | ||||||||||||||||||||||||||||||||||||||||
| 225 | # if (@{$self->project->contributors}) { | ||||||||||||||||||||||||||||||||||||||||
| 226 | # $orig =~ s! | ||||||||||||||||||||||||||||||||||||||||
| 227 | # (^=head \d \s+ (?:authors?)\b \s*) | ||||||||||||||||||||||||||||||||||||||||
| 228 | # (.*?) | ||||||||||||||||||||||||||||||||||||||||
| 229 | # (^=head \d \s+ | \z) | ||||||||||||||||||||||||||||||||||||||||
| 230 | # ! | ||||||||||||||||||||||||||||||||||||||||
| 231 | # ( $1 | ||||||||||||||||||||||||||||||||||||||||
| 232 | # . $2 | ||||||||||||||||||||||||||||||||||||||||
| 233 | # . "=head1 CONTRIBUTORS\n\n=over 4\n\n" | ||||||||||||||||||||||||||||||||||||||||
| 234 | # . join( '', map { "=item $_\n\n" } map { pod_escape($_) } @{ $self->project->contributors } ) | ||||||||||||||||||||||||||||||||||||||||
| 235 | # . "=back\n\n" | ||||||||||||||||||||||||||||||||||||||||
| 236 | # . $3 ) | ||||||||||||||||||||||||||||||||||||||||
| 237 | # !ixmse; | ||||||||||||||||||||||||||||||||||||||||
| 238 | # spew_raw($self->project->main_module_path => $orig); | ||||||||||||||||||||||||||||||||||||||||
| 239 | # } | ||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||
| 242 | # Return non-zero if fail | ||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | sub dist_test { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
dist_test: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my ($self, @targets) = @_; | |||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $self->build(); | |||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $self->project->verify_prereqs(); | |||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $guard = pushd($self->dir); | |||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $self->project->module_maker->run_tests(); | |||||||||||||||||||||||||||||||||||||||
| 253 | }; | ||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | return $@ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub dist { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
dist: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | $self->{tarball} ||= do { | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"tarball"} ||= do {
my $archive_timestamp = $self->archive_timestamp;
$self->build;
my $guard = pushd($self->dir);
my $tarball = sprintf("%s-%s.tar.gz", $self->project->dist_name, $self->project->version);
if (defined $archive_timestamp) {
$self->_write_reproducible_tarball($tarball, $archive_timestamp);
infof("Wrote %s\n", $tarball);
}
else {
my $force_mode = 0;
my $tar = "Archive::Tar"->new;
foreach my $file (@{$self->manifest_files;}) {
my $filename = "File::Spec"->catfile($self->project->dist_name . '-' . $self->project->version, $file);
my $data = slurp($file);
my $mode = (stat $file)[2];
if ($mode == 33206) {
$mode = 420;
++$force_mode;
};
$tar->add_data($filename, $data, {"mode", $mode});
};
$tar->write($tarball, 9);
infof("Wrote %s\n", $tarball . ($force_mode == 0 ? "" : " --> forced to mode 000664"));
};
"File::Spec"->rel2abs($tarball)
}
MC/DC0%0/2
$self->{"tarball"} ||= do {
my $archive_timestamp = $self->archive_timestamp;
$self->build;
my $guard = pushd($self->dir);
my $tarball = sprintf("%s-%s.tar.gz", $self->project->dist_name, $self->project->version);
if (defined $archive_timestamp) {
$self->_write_reproducible_tarball($tarball, $archive_timestamp);
infof("Wrote %s\n", $tarball);
}
else {
my $force_mode = 0;
my $tar = "Archive::Tar"->new;
foreach my $file (@{$self->manifest_files;}) {
my $filename = "File::Spec"->catfile($self->project->dist_name . '-' . $self->project->version, $file);
my $data = slurp($file);
my $mode = (stat $file)[2];
if ($mode == 33206) {
$mode = 420;
++$force_mode;
};
$tar->add_data($filename, $data, {"mode", $mode});
};
$tar->write($tarball, 9);
infof("Wrote %s\n", $tarball . ($force_mode == 0 ? "" : " --> forced to mode 000664"));
};
"File::Spec"->rel2abs($tarball)
}
$self->{"tarball"}
do {
my $archive_timestamp = $self->archive_timestamp;
$self->build;
my $guard = pushd($self->dir);
my $tarball = sprintf("%s-%s.tar.gz", $self->project->dist_name, $self->project->version);
if (defined $archive_timestamp) {
$self->_write_reproducible_tarball($tarball, $archive_timestamp);
infof("Wrote %s\n", $tarball);
}
else {
my $force_mode = 0;
my $tar = "Archive::Tar"->new;
foreach my $file (@{$self->manifest_files;}) {
my $filename = "File::Spec"->catfile($self->project->dist_name . '-' . $self->project->version, $file);
my $data = slurp($file);
my $mode = (stat $file)[2];
if ($mode == 33206) {
$mode = 420;
++$force_mode;
};
$tar->add_data($filename, $data, {"mode", $mode});
};
$tar->write($tarball, 9);
infof("Wrote %s\n", $tarball . ($force_mode == 0 ? "" : " --> forced to mode 000664"));
};
"File::Spec"->rel2abs($tarball)
}
Truth table0%0/3
A ||= B
A= $self->{"tarball"}B= do {
my $archive_timestamp = $self->archive_timestamp;
$self->build;
my $guard = pushd($self->dir);
my $tarball = sprintf("%s-%s.tar.gz", $self->project->dist_name, $self->project->version);
if (defined $archive_timestamp) {
$self->_write_reproducible_tarball($tarball, $archive_timestamp);
infof("Wrote %s\n", $tarball);
}
else {
my $force_mode = 0;
my $tar = "Archive::Tar"->new;
foreach my $file (@{$self->manifest_files;}) {
my $filename = "File::Spec"->catfile($self->project->dist_name . '-' . $self->project->version, $file);
my $data = slurp($file);
my $mode = (stat $file)[2];
if ($mode == 33206) {
$mode = 420;
++$force_mode;
};
$tar->add_data($filename, $data, {"mode", $mode});
};
$tar->write($tarball, 9);
infof("Wrote %s\n", $tarball . ($force_mode == 0 ? "" : " --> forced to mode 000664"));
};
"File::Spec"->rel2abs($tarball)
}
| |||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $archive_timestamp = $self->archive_timestamp; | |||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $self->build(); | |||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my $guard = pushd($self->dir); | |||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||
| 266 | # Create tar ball | ||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $tarball = sprintf('%s-%s.tar.gz', $self->project->dist_name, $self->project->version); | |||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if (defined $archive_timestamp) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $self->_write_reproducible_tarball($tarball, $archive_timestamp); | |||||||||||||||||||||||||||||||||||||||
| 271 | 0 | infof("Wrote %s\n", $tarball); | |||||||||||||||||||||||||||||||||||||||
| 272 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my $force_mode = 0; | |||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my $tar = Archive::Tar->new; | |||||||||||||||||||||||||||||||||||||||
| 275 | 0 | for my $file (@{$self->manifest_files}) { | |||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $filename = File::Spec->catfile($self->project->dist_name . '-' . $self->project->version, $file); | |||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my $data = slurp($file); | |||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $mode = (stat($file))[2]; | |||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||
| 280 | # On Windows, (stat($file))[2] * ALWAYS * results in octal 0100666 (which means it is | ||||||||||||||||||||||||||||||||||||||||
| 281 | # world writeable). World writeable files are always rejected by PAUSE. The solution is to | ||||||||||||||||||||||||||||||||||||||||
| 282 | # change a file mode octal 0100666 to octal 000664, such that it is * NOT * world | ||||||||||||||||||||||||||||||||||||||||
| 283 | # writeable. This works on Windows, as well as on other systems (Linux, Mac, etc...), because | ||||||||||||||||||||||||||||||||||||||||
| 284 | # the filemode 0100666 only occurs on Windows. (If it occurred on Linux, it would be wrong anyway) | ||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ($mode == 0100666) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $mode = 0644; | |||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $force_mode++; | |||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $tar->add_data($filename, $data, { mode => $mode }); | |||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $tar->write($tarball, COMPRESS_GZIP); | |||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | infof("Wrote %s\n", $tarball.($force_mode == 0 ? '' : ' --> forced to mode 000664')); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | File::Spec->rel2abs($tarball); | |||||||||||||||||||||||||||||||||||||||
| 298 | }; | ||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | sub _build_archive_timestamp { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_archive_timestamp: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if (exists $ENV{SOURCE_DATE_EPOCH}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | return _validate_archive_timestamp($ENV{SOURCE_DATE_EPOCH}, 'SOURCE_DATE_EPOCH'); | |||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my $guard = pushd($self->project->dir); | |||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | open my $verify_fh, '-|', 'git', 'rev-parse', '--verify', '--quiet', 'HEAD' | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 310 | or return; | ||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $head = <$verify_fh>; | |||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | return unless close $verify_fh && defined $head; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
close $verify_fh and defined $head
MC/DC0%0/2
close $verify_fh and defined $head
close $verify_fh
defined $head
Truth table0%0/3
A and B
A= close $verify_fhB= defined $head
| |||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | open my $fh, '-|', 'git', 'log', '-1', '--format=%ct' | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 315 | or return; | ||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $timestamp = <$fh>; | |||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | return unless close $fh; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | chomp $timestamp if defined $timestamp; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | return unless defined $timestamp && $timestamp =~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $timestamp and $timestamp =~ /\A[0-9]+\z/
MC/DC0%0/2
defined $timestamp and $timestamp =~ /\A[0-9]+\z/
defined $timestamp
$timestamp =~ /\A[0-9]+\z/
Truth table0%0/3
A and B
A= defined $timestampB= $timestamp =~ /\A[0-9]+\z/
| |||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | return _validate_archive_timestamp($timestamp, 'Git HEAD timestamp'); | |||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | sub _validate_archive_timestamp { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_archive_timestamp: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my ($timestamp, $source) = @_; | |||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | die "$source must be a non-negative integer\n" | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $timestamp and $timestamp =~ /\A[0-9]+\z/
MC/DC0%0/2
defined $timestamp and $timestamp =~ /\A[0-9]+\z/
defined $timestamp
$timestamp =~ /\A[0-9]+\z/
Truth table0%0/3
A and B
A= defined $timestampB= $timestamp =~ /\A[0-9]+\z/
| |||||||||||||||||||||||||||||||||||||||||
| 327 | unless defined $timestamp && $timestamp =~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | die "$source is too large for a tar header\n" | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 329 | if $timestamp > 8_589_934_591; | ||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | return 0 + $timestamp; | |||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | sub _write_reproducible_tarball { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_reproducible_tarball: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my ($self, $tarball, $timestamp) = @_; | |||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | my $file_modes = $self->has_file_modes ? $self->file_modes : undef; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my $file_mode_overrides = $self->file_mode_overrides; | |||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $generated_executables = $self->_generated_executable_files(); | |||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $prefix = $self->project->dist_name . '-' . $self->project->version; | |||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $tar = Archive::Tar->new; | |||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | for my $file (sort { _archive_path($a) cmp _archive_path($b) } @{$self->manifest_files}) { | |||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $archive_file = _archive_path($file); | |||||||||||||||||||||||||||||||||||||||
| 344 | my $mode = exists $file_mode_overrides->{$archive_file} | ||||||||||||||||||||||||||||||||||||||||
| 345 | ? $file_mode_overrides->{$archive_file} | ||||||||||||||||||||||||||||||||||||||||
| 346 | : $file_modes && exists $file_modes->{$archive_file} | ||||||||||||||||||||||||||||||||||||||||
| 347 | ? $file_modes->{$archive_file} | ||||||||||||||||||||||||||||||||||||||||
| 348 | : $file_modes | ||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | ? ($generated_executables->{$archive_file} ? 0755 : 0644) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/3
$file_modes and exists $file_modes->{$archive_file}
MC/DC0%0/2
$file_modes and exists $file_modes->{$archive_file}
$file_modes
exists $file_modes->{$archive_file}
Truth table0%0/3
A and B
A= $file_modesB= exists $file_modes->{$archive_file}
| |||||||||||||||||||||||||||||||||||||||||
| 350 | : (stat($file))[2]; | ||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | $mode = 0644 if $mode == 0100666; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $tar->add_data( | |||||||||||||||||||||||||||||||||||||||
| 354 | "$prefix/$archive_file", | ||||||||||||||||||||||||||||||||||||||||
| 355 | slurp_raw($file), | ||||||||||||||||||||||||||||||||||||||||
| 356 | { | ||||||||||||||||||||||||||||||||||||||||
| 357 | mode => $mode, | ||||||||||||||||||||||||||||||||||||||||
| 358 | mtime => $timestamp, | ||||||||||||||||||||||||||||||||||||||||
| 359 | uid => 0, | ||||||||||||||||||||||||||||||||||||||||
| 360 | gid => 0, | ||||||||||||||||||||||||||||||||||||||||
| 361 | uname => '', | ||||||||||||||||||||||||||||||||||||||||
| 362 | gname => '', | ||||||||||||||||||||||||||||||||||||||||
| 363 | }, | ||||||||||||||||||||||||||||||||||||||||
| 364 | ); | ||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $tar_data = $tar->write(); | |||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | die "Cannot create tar stream: " . $tar->error . "\n" | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 369 | unless defined $tar_data; | ||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $tar_data = _canonicalize_tar_headers($tar_data, $timestamp); | |||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | gzip( | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 373 | \$tar_data => $tarball, | ||||||||||||||||||||||||||||||||||||||||
| 374 | Minimal => 1, | ||||||||||||||||||||||||||||||||||||||||
| 375 | Time => 0, | ||||||||||||||||||||||||||||||||||||||||
| 376 | Level => 9, | ||||||||||||||||||||||||||||||||||||||||
| 377 | ) or die "Cannot write $tarball: $GzipError\n"; | ||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | sub _generated_executable_files { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generated_executable_files: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my @files = eval $self->project->script_files; | |||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | die "Cannot evaluate script_files: $@" if $@; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return +{ map { _archive_path($_) => 1 } @files }; | |||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub _archive_path { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_archive_path: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my ($path) = @_; | |||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | $path =~ s!\\!/!g if $^O eq 'MSWin32'; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | return $path; | |||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub _canonicalize_tar_headers { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_canonicalize_tar_headers: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my ($tar_data, $timestamp) = @_; | |||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my $offset = 0; | |||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | while ($offset + 512 <= length $tar_data) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my $header = substr($tar_data, $offset, 512); | |||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | last if $header eq "\0" x 512; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $size = substr($header, 124, 12); | |||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $size =~ s/\0.*\z//s; | |||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $size =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | $size = length($size) ? oct($size) : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $type = substr($header, 156, 1); | |||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | my $mode = $type eq '5' ? 0755 | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 409 | : $type eq 'L' ? 0644 | ||||||||||||||||||||||||||||||||||||||||
| 410 | : oct(substr($header, 100, 8)); | ||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | substr($header, 100, 8) = sprintf("%07o\0", $mode); | |||||||||||||||||||||||||||||||||||||||
| 413 | 0 | substr($header, 108, 8) = sprintf("%07o\0", 0); | |||||||||||||||||||||||||||||||||||||||
| 414 | 0 | substr($header, 116, 8) = sprintf("%07o\0", 0); | |||||||||||||||||||||||||||||||||||||||
| 415 | 0 | substr($header, 136, 12) = sprintf("%011o\0", $timestamp); | |||||||||||||||||||||||||||||||||||||||
| 416 | 0 | substr($header, 265, 32) = "\0" x 32; | |||||||||||||||||||||||||||||||||||||||
| 417 | 0 | substr($header, 297, 32) = "\0" x 32; | |||||||||||||||||||||||||||||||||||||||
| 418 | 0 | substr($header, 148, 8) = ' ' x 8; | |||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my $checksum = unpack('%32C*', $header); | |||||||||||||||||||||||||||||||||||||||
| 420 | 0 | substr($header, 148, 8) = sprintf("%06o\0 ", $checksum); | |||||||||||||||||||||||||||||||||||||||
| 421 | 0 | substr($tar_data, $offset, 512) = $header; | |||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | $offset += 512 + int(($size + 511) / 512) * 512; | |||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | return $tar_data; | |||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my ($self, @cmd) = @_; | |||||||||||||||||||||||||||||||||||||||
| 431 | 0 | $self->build(); | |||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $guard = pushd($self->dir); | |||||||||||||||||||||||||||||||||||||||
| 435 | 0 | cmd(@cmd); | |||||||||||||||||||||||||||||||||||||||
| 436 | }; | ||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | return $@ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||
| 440 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||