| 1 | package PAR::Repository; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 22 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 22 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 22 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 22 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 22 | ▶ | use File::Spec::Functions qw/catfile catdir splitpath/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 22 | ▶ | use File::Path qw/mkpath/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 22 | ▶ | use PAR::Dist qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 22 | ▶ | use YAML::Syck qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 22 | ▶ | use File::Copy qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 22 | ▶ | use Cwd qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 22 | ▶ | use Archive::Zip qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 22 | ▶ | use File::Temp qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 22 | ▶ | use version qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 22 | ▶ | use PAR::Indexer qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 22 | ▶ | use PAR::Repository::Zip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 22 | ▶ | use PAR::Repository::DBM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 22 | ▶ | use PAR::Repository::Query; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 22 | our @ISA = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | PAR::Repository::Zip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | PAR::Repository::DBM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | PAR::Repository::Query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 22 | ▶ | use constant REPOSITORY_INFO_FILE => 'repository_info.yml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 22 | our $VERSION = '0.21'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 22 | our $VERBOSE = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # does the running platform have symlinks? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | our $Supports_Symlinks = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | exists($ENV{PAR_REPOSITORY_SYMLINK_SUPPORT}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ? $ENV{PAR_REPOSITORY_SYMLINK_SUPPORT} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 22 | ▶ | : eval { symlink("",""); 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # template for a repository_info.yml file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 22 | ▶ | our $Info_Template = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | repository_version => $VERSION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # on platforms which don't have symlinks, fake them for new repositories! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ($Supports_Symlinks ? () : (fake_symlinks => 1)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # Hash of compatible PAR::Repository versions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 22 | our $Compatible_Versions = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $VERSION => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | '0.19'=> 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | '0.18_01'=> 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | '0.17_01'=> 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | '0.17'=> 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | '0.16_02' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | '0.16_01' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | '0.16' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | '0.15' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | '0.14' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | '0.13' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | '0.12' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | '0.11' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | '0.10' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | '0.03' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | '0.02' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | PAR::Repository - Create and modify PAR repositories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # Usually, you want to use the 'parrepo' script which comes with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # this distribution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | use PAR::Repository; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | my $repo = PAR::Repository->new( path => '/path/to/repository' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # creates a new repository if it doesn't exist, opens it if it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # does exist. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | $repo->inject( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | file => 'Foo-Bar-0.01-x86_64-linux-gnu-thread-multi-5.8.7.par' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | $repo->remove( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | file => '...' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | $repo->query_module(regex => 'Foo::Bar'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | This module is intended for creation and maintenance of PAR repositories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | A PAR repository is collection of F<.par> archives which contain Perl code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | and associated libraries for use on specific platforms. In the most common | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | case, these archives differ from CPAN distributions in that they ship the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | (possibly compiled) output of C<make> in the F<blib/> subdirectory of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | CPAN distribution's build directory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | You can access a PAR repository using the L<PAR::Repository::Client> module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | or the L<PAR> module which provides syntactic sugar around the client. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | L<PAR> allows you to load libraries from repositories on demand. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | =head2 PAR REPOSITORIES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | A PAR repository is, basically, just a directory with certain stuff in it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | It contains: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | =item modules_dists.dbm.zip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | An index that maps module names to file names. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | Details can be found in L<PAR::Repository::DBM>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | =item symlinks.dbm.zip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | An index that maps file names to other files. You shouldn't have to care | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | about it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | Details can be found in L<PAR::Repository::DBM>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | =item scripts_dists.dbm.zip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | An index that maps script names to file names. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | Details can be found in L<PAR::Repository::DBM>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | =item repository_info.yml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | A simple YAML file which contains meta information for the repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | It currently contains the following bits of information: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | =item dbm_checksums.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | A text file associating the DBM files with their MD5 checksums. (new in 0.15) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | =item repository_version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | The version of PAR::Repository this repository was created with. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | When opening an existing repository, PAR::Repository checks that the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | repository was created by a compatible PAR::Repository version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | Similarily, PAR::Repository::Client checks that the repository has | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | a compatible version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | =item I<arch/perl-version> directories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | Your system architecture is identified with a certain string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | For example, my development box is C<x86_64-linux-gnu-thread-multi>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | For every such architecture for which there are PAR archives | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | in the repository, there is a directory with the name of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | architecture. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | There is one special directory called C<any_arch> which is meant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | for PAR archives that are architecture independent. (Usually | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | I<pure-perl> modules.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | In every such architecture directory, there is a number of directories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | for every Perl version. (5.6.0, 5.6.1, 5.8.0, ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | Again, there is a special directory for modules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | that work with any version of Perl. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | This directory is called C<any_version>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | Of course, a module won't run with Perl 4 and probably not even with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5.001. Whether a module works with I<any version> of perl is something | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | you need to decide when injecting modules into the repository and depends | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | on the scope of the repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | These inner directories contain the PAR archives. The directories exist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | mostly because large repositories with a lot of modules for a lot of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | architectures would otherwise have too large directory lists. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | =item PAR archives | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | Within the I<arch/perl-version> directories come the actual PAR archives. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | The name of each such file is of the following form: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | I<Distribution-Name>-I<Distribution-Version>-I<Architecture>-I<Perl-Version>.par | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | Following is a list of class and instance methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | (Instance methods until otherwise mentioned.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | Other methods callable on C<PAR::Repository> objects are inherited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | from classes listed in the I<SEE ALSO> section. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | Creates a new PAR::Repository object. Takes named arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | Mandatory paramater: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | C<path> should be the path to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | PAR repository. If the repository does not exist yet, it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | is created empty. If the repository exists, it is I<opened>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | That means any modifications you apply to the repository object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | are applied to the I<opened> repository on disk. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | Optional parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | Additionally, you may supply the C<fake_symlinks =E<gt> 1> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | or C<convert_symlinks =E<gt> 1> parameters. Both default to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | false. I<convert_symlinks> will convert an existing repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | that uses symbolic links to using no symbolic links as if it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | had been created with the I<fake_symlinks> option. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | If the repository has to be created, I<fake_symlinks> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | flags it as using no symbolic links. Copies will be used instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | this may result is a larger but more portable repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | I<convert_symlinks> implies I<fake_symlinks>. See also I<CAVEATS> below. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | I<fake_symlinks> is the default for creating new repositories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | on platforms which do not support symlinks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 112 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=21 SCAR=40.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 112 | my $proto = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 112 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 112 | ▶ | croak(__PACKAGE__."->new() takes an even number of arguments.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | if @_ % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 112 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | croak(__PACKAGE__."->new() needs a 'path' argument.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 112 | ▶ | if not defined $args{path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 112 | my $path = $args{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 112 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # The tied dbm hashes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | modules_hash => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | symlinks_hash => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | scripts_hash => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | dependencies_hash => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # The temp dbm files on disk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | modules_dbm_temp_file => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | symlinks_dbm_temp_file => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | scripts_dbm_temp_file => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | dependencies_dbm_temp_file => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # The YAML info as Perl data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | info => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } => $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 112 | $self->verbose(2, "Created new repository object in path '$path'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # check that the repository exists or create it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 112 | my $mod_dbm = catfile($path, PAR::Repository::DBM::MODULES_DBM_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 112 | my $sym_dbm = catfile($path, PAR::Repository::DBM::SYMLINKS_DBM_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 112 | my $scr_dbm = catfile($path, PAR::Repository::DBM::SCRIPTS_DBM_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 112 | my $dep_dbm = catfile($path, PAR::Repository::DBM::DEPENDENCIES_DBM_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 112 | my $info_file = catfile($path, PAR::Repository::REPOSITORY_INFO_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 112 | ▶ | if (-d $path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
-d $path and -f $mod_dbm . '.zip' and -f $sym_dbm . '.zip' and -f $info_file
-d $path and -f $mod_dbm . '.zip' and -f $sym_dbm . '.zip'
-d $path and -f $mod_dbm . '.zip'
MC/DC25%1/4
-d $path and -f $mod_dbm . '.zip' and -f $sym_dbm . '.zip' and -f $info_file
-d $path
-f $mod_dbm . '.zip'
-f $sym_dbm . '.zip'
-f $info_file
Truth table40%2/5
A and B and C and D
A= -d $pathB= -f $mod_dbm . '.zip'C= -f $sym_dbm . '.zip'D= -f $info_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | and -f $mod_dbm.'.zip' and -f $sym_dbm.'.zip' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | and -f $info_file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # everything is in place. good. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 101 | $self->verbose(3, "Repository exists"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # load repository info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 101 | $self->{info} = YAML::Syck::LoadFile($info_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 101 | ▶ | if ( not defined $self->{info} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
defined $self->{'info'} && exists $self->{'info'}{'repository_version'}
MC/DC0%0/2
defined $self->{'info'} && exists $self->{'info'}{'repository_version'}
defined $self->{'info'}
exists $self->{'info'}{'repository_version'}
Truth table33%1/3
A && B
A= defined $self->{'info'}B= exists $self->{'info'}{'repository_version'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | or not exists $self->{info}{repository_version} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | croak("Repository exists, but it does not contain a valid repository_info.yml file."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | elsif ( not exists $Compatible_Versions->{$self->{info}{repository_version}} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | croak("Repository exists, but it was created with an incompatible version of PAR::Repository (".$self->{info}{repository_version}.")"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # the following is a special case because the "incompatible changes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # with every "\d+.\d" release" rule was introduced in 0.10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | elsif ( $Compatible_Versions->{$self->{info}{repository_version}} eq '0.03' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | $self->_update_info_version or return (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $self->verbose(3, "Updated repository version"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 101 | ▶ | if ($args{convert_symlinks}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $self->_convert_symlinks(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 101 | ▶ | if (!$Supports_Symlinks and !$self->{info}{fake_symlinks}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$PAR::Repository::Supports_Symlinks or $self->{"info"}{"fake_symlinks"}
MC/DC0%0/2
$PAR::Repository::Supports_Symlinks or $self->{"info"}{"fake_symlinks"}
$PAR::Repository::Supports_Symlinks
$self->{"info"}{"fake_symlinks"}
Truth table66%2/3
A or B
A= $PAR::Repository::Supports_SymlinksB= $self->{"info"}{"fake_symlinks"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | croak("Repository may use symlinks but your platform does not support them. " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ."Use the convert_symlinks => 1 option to the PAR::Repository constructor " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ."to convert the repository to one which does not use symbolic links."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 101 | $self->verbose(3, "Opened repository successfully"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # Generate scripts db and upgrade repository version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # if the scripts db doesn't exist. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 101 | ▶ | if (not -f $scr_dbm.'.zip') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $self->verbose(1, "Upgrading repository version to $VERSION"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | $self->_update_info_version or return (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->verbose(3, "Creating scripts database"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $self->_create_dbm($scr_dbm.'.zip'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # Generate deps db and upgrade repository version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # if the deps db doesn't exist. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 101 | ▶ | if (not -f $dep_dbm.'.zip') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $self->verbose(1, "Upgrading repository version to $VERSION"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | $self->_update_info_version or return (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $self->verbose(3, "Creating dependencies database"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $self->_create_dbm($dep_dbm.'.zip'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } # end if everything is in place | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 11 | $self->verbose(3, "Repository doesn't exist yet"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 11 | ▶ | $self->_create_repository($path, !$Supports_Symlinks||$args{fake_symlinks}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
!$PAR::Repository::Supports_Symlinks || $args{'fake_symlinks'}
MC/DC50%1/2
!$PAR::Repository::Supports_Symlinks || $args{'fake_symlinks'}
!$PAR::Repository::Supports_Symlinks
$args{'fake_symlinks'}
Truth table66%2/3
not(A) || B
A= !$PAR::Repository::Supports_SymlinksB= $args{'fake_symlinks'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 112 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # creates a new repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # called by the constructor if the directory doesn't exist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 11 | ▶ | sub _create_repository { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_repository: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 11 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 11 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 11 | my $fake_symlinks = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 11 | ▶ | if (-d $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | croak("The repository path exists, but is not a repository. Delete it to create a new repository."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 11 | mkpath([$path]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 11 | my $mod_dbm = catfile($path, PAR::Repository::DBM::MODULES_DBM_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 11 | my $sym_dbm = catfile($path, PAR::Repository::DBM::SYMLINKS_DBM_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 11 | my $scr_dbm = catfile($path, PAR::Repository::DBM::SCRIPTS_DBM_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 11 | my $dep_dbm = catfile($path, PAR::Repository::DBM::DEPENDENCIES_DBM_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 11 | my $info_file = catfile($path, PAR::Repository::REPOSITORY_INFO_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 11 | $self->verbose(3, "Creating repository databases"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 11 | foreach my $dbm ($mod_dbm, $sym_dbm, $scr_dbm, $dep_dbm) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 44 | $self->_create_dbm($dbm.'.zip'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 11 | my $info_copy = {%$Info_Template}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 11 | ▶ | $info_copy->{fake_symlinks} = 1 if $fake_symlinks; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 11 | YAML::Syck::DumpFile($info_file, $info_copy); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 11 | $self->{info} = YAML::Syck::LoadFile($info_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # converts all symlinks to files, sets {info}->{fake_symlinks}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # and saves it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # called by the constructor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 3 | ▶ | sub _convert_symlinks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_symlinks: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 3 | $self->{error} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 3 | $self->verbose(1, "Converting symlinks to files!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | # change to repo path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 3 | my $old_dir = Cwd::cwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 3 | chdir($self->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 3 | my $info_file = catfile($self->{path}, PAR::Repository::REPOSITORY_INFO_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 3 | my ($symdbm, $temp_file) = $self->symlinks_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 3 | ▶ | while (my ($file, $symlinks) = each %$symdbm) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 1 | my ($distname, $distver, $arch, $perlver) = PAR::Dist::parse_dist_name($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 1 | my $file_fullpath = File::Spec->catfile($arch, $perlver, $file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | foreach my $symlink_file (@$symlinks) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | my ($distname, $distver, $arch, $perlver) = PAR::Dist::parse_dist_name($symlink_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 1 | my $symlink_file_fullpath = File::Spec->catfile($arch, $perlver, $symlink_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # first unlink or else File::Copy may claim it can't copy because the files are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # the same. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | ▶ | (unlink( $symlink_file_fullpath ) and File::Copy::copy( $file_fullpath, $symlink_file_fullpath )) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
unlink $symlink_file_fullpath and File::Copy::copy($file_fullpath, $symlink_file_fullpath)
MC/DC0%0/2
unlink $symlink_file_fullpath and File::Copy::copy($file_fullpath, $symlink_file_fullpath)
unlink $symlink_file_fullpath
File::Copy::copy($file_fullpath, $symlink_file_fullpath)
Truth table33%1/3
A and B
A= unlink $symlink_file_fullpathB= File::Copy::copy($file_fullpath, $symlink_file_fullpath)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | or chdir($old_dir), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | die "Error converting symlinks in repository to real files: Could not copy " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | ."'$file' to '$symlink_file'. Your repository may be in an inconsistent " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | ."state now. Reason: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 3 | chdir($old_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 3 | $self->{info}{fake_symlinks} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 3 | YAML::Syck::DumpFile($info_file, $self->{info}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 3 | $self->{info} = YAML::Syck::LoadFile($info_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | =head2 inject | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | Injects a new PAR distribution into the repository. Takes named parameters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | Mandatory parameters: I<file>, the path and filename of the PAR distribution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | to inject. The name of the file can be used to automatically determine the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | I<distname>, I<distversion>, I<arch>, and I<perlversion> parameters if the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | form of the file name is as follows: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | Dist-Name-0.01-x86_64-linux-gnu-thread-multi-5.8.7.par | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | This would set C<distname => 'Dist-Name', distversion => '0.01', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | arch => 'linux-gnu-thread-multi', perlversion => '5.8.7'>. You can override | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | this automatic detection using the corresponding parameters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | If the file exists in the repository, inject returns false. If the file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | was added successfully, inject returns true. See the C<overwrite> parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | C<inject()> scans the distribution for modules and indexes these in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | the modules-dists dbm. Additionally, it scans the distribution for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | scripts in the C<script> and C<bin> subdirectories of the distribution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | (All files in these folders are considered executables. C<main.pl> is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | skipped.) You can turn the indexing of scripts off with the C<no_scripts> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | parameter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | Optional parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | =item I<distname> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | The distribution name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | =item I<distversion> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | The distribution version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | =item I<arch> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | The architecture string. It can be C<any_arch> in order to inject this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | distribution as an architecture independent distribution. You can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | use the C<any_arch> parameter for this as well (recommended). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | Setting this to C<any_arch> is slightly different from using the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | parameter of the same name. Setting C<arch=>'any_arch'> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | actually puts the file into the C<any_arch> directory. Setting only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | the parameter C<any_arch> creates a symlink there. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | =item I<perlversion> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | The version of perl. Note that it has to be in the C<5.8.7> and not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | in the C<5.008007> form! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | There is a special case of setting this to C<any_version> meaning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | that the distribution can run on any version of perl. The distribution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | will then be injected into the C<any_version> tree of the repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | You can also achieve this by using the C<any_version> parameter which is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | recommended. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | Setting this to C<any_version> is slightly different from using the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | parameter of the same name. Setting C<perlversion=>'any_version'> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | actually puts the file into the C<any_version> directory. Setting only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | the parameter C<any_version> creates a symlink there. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | =item I<any_arch> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | Specifies that this distribution is suitable for any architecture. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | (Default: no.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | If set, a symlink to the distribution file is created in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | C<any_arch> directory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | =item I<any_version> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | Specifies that this distribution is suitable for any version of perl. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | (Default: no.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | If set, a symlink to the distribution file is created in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | C<any_version> directory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | =item I<overwrite> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | If this is set to a true value, if the file exists in the repository, it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | will be overwritten. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | =item I<no_scripts> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | By default, PAR::Repository indexes all modules found in a distribution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | as well as all scripts. Set this parameter to a true value to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | skip indexing scripts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | =item I<ignore_provides> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | Set this to true if you want to ignore the META.yml C<provides> section | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | which should normally list all modules in the distribution. In that case, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | a manual scan for packages is performed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | =item I<no_dependencies> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | Set this to true if you want to skip inserting dependency information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | into the database. You'd better have a good idea why you want this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 13 | ▶ | sub inject { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inject: called CC=33 SCAR=44.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 13 | ▶ | croak(__PACKAGE__."->inject() takes an even number of arguments.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | if @_ % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 13 | $self->verbose(2, "Entering inject()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 13 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 13 | my $dfile = $args{file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 13 | ▶ | croak(__PACKAGE__."->inject() needs a 'file' parameter.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | if not defined $dfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 13 | ▶ | croak(__PACKAGE__."->inject(): Specified file '$dfile' does not exist.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | if not -f $dfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # determine the name of the target (in-repository) file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 13 | my ($target_file, $distname, $distver, $arch, $perlver) = $self->_get_target_file('inject', \%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 13 | $self->verbose(3, "Target file will be '$target_file'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | # read META.yml from PAR archive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 13 | my $meta = PAR::Dist::get_meta($dfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 13 | my $meta_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 13 | ▶ | if (defined $meta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 13 | $self->verbose(3, "We have a META.yml"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 13 | $meta_data = YAML::Syck::Load($meta); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # Deterimine the packages in the distribution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 13 | my $packages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 13 | ▶ | if (!$args{ignore_provides} and defined $meta_data and exists $meta_data->{provides}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $args{"ignore_provides"} and defined $meta_data and exists $meta_data->{"provides"}
not $args{"ignore_provides"} and defined $meta_data
MC/DC0%0/3
not $args{"ignore_provides"} and defined $meta_data and exists $meta_data->{"provides"}
not $args{"ignore_provides"}
defined $meta_data
exists $meta_data->{"provides"}
Truth table25%1/4
not(A) and B and C
A= not $args{"ignore_provides"}B= defined $meta_dataC= exists $meta_data->{"provides"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # cool, we have a working META.yml with provides! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 13 | $self->verbose(3, "... which has a 'provides' field"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 13 | $packages = $meta_data->{provides}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | # we need to do the scanning ourselves (damn) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | $self->verbose(3, "Need to scan for .pm files"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | $packages = PAR::Indexer::scan_par_for_packages($dfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 13 | ▶ | if (not defined $packages) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | # error scanning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | croak("Your PAR distribution is either invalid or doesn't contain any modules."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # Determine dependencies as declared in META.yml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 13 | my $dependencies; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 13 | ▶ | if (not $args{no_dependencies}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 13 | $dependencies = PAR::Indexer::dependencies_from_meta_yml($meta_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # FIXME This is not the right way. There should be a dependency scanner, no? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 13 | ▶ | $dependencies = {} if not defined $dependencies; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # determine any scripts to index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 13 | my $scripts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 13 | ▶ | if (not $args{no_scripts}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 13 | $self->verbose(3, "Scanning par for scripts"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 13 | $scripts = PAR::Indexer::scan_par_for_scripts($dfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # create path in repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 13 | my $destpath = catdir($arch, $perlver); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 13 | $self->verbose(3, "Creating path in repository: '$destpath'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 13 | mkpath( catdir($self->{path}, $destpath) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # copy file over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 13 | my $target_in_rep = catfile($destpath, $target_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 13 | my $complete_target = catdir($self->{path}, $target_in_rep); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 13 | ▶ | if (-f $complete_target or -l $complete_target) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-f $complete_target or -l $complete_target
MC/DC0%0/2
-f $complete_target or -l $complete_target
-f $complete_target
-l $complete_target
Truth table33%1/3
A or B
A= -f $complete_targetB= -l $complete_target
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | # damn, we're overwriting an existing archive or symlink. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | if (not $args{overwrite}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | # don't overwrite | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | $self->verbose(1, "Found existing file '$target_in_rep'. Not overwriting because 'overwrite' isn't set."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | elsif ($self->_is_symlink($target_file, switch_to_path => 1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $self->verbose(1, "Found existing symlink '$target_in_rep'. Overwriting because 'overwrite' is set."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $self->_remove_symlink(sym => $target_in_rep); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | $self->verbose(1, "Found existing file '$target_in_rep'. Overwriting because 'overwrite' is set."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $self->remove(file => $target_in_rep); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 13 | File::Copy::copy($dfile, $complete_target); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | # insert into modules dbm. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 13 | $self->verbose(3, "Inserting packages into modules DBM"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 13 | $self->_add_packages(packages => $packages, file => $target_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # insert into scripts dbm. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 13 | ▶ | if (not $args{no_scripts}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 13 | $self->verbose(3, "Inserting scripts into scripts DBM"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 13 | $self->_add_scripts(scripts => $scripts, file => $target_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | # insert into deps dbm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 13 | ▶ | if (not $args{no_dependencies}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 13 | $self->verbose(3, "Inserting dependencies into dependencies DBM"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 13 | $self->_add_dependencies(dependencies => $dependencies, file => $target_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 13 | ▶ | my $is_any_arch = $args{any_arch} && !($arch eq 'any_arch'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args{'any_arch'} && !($arch eq 'any_arch')
MC/DC50%1/2
$args{'any_arch'} && !($arch eq 'any_arch')
$args{'any_arch'}
!($arch eq 'any_arch')
Truth table66%2/3
A && not(B)
A= $args{'any_arch'}B= !($arch eq 'any_arch')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 13 | ▶ | my $is_any_perl = $args{any_version} && !($arch eq 'any_version'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args{'any_version'} && !($arch eq 'any_version')
MC/DC50%1/2
$args{'any_version'} && !($arch eq 'any_version')
$args{'any_version'}
!($arch eq 'any_version')
Truth table66%2/3
A && not(B)
A= $args{'any_version'}B= !($arch eq 'any_version')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | # add symlinks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 13 | $self->verbose(3, "Adding symlinks to symlinks DBM"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 13 | ▶ | if ($is_any_arch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 3 | my $dir = catdir('any_arch', $perlver); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 3 | mkpath(catdir($self->{path}, $dir)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 3 | my $sym = join('-', $distname, $distver, 'any_arch', $perlver).'.par'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | my $success = $self->_add_symlink( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | file => $target_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | sym => $sym, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | overwrite => $args{overwrite}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | # associate packages and scripts with symlink as well | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 3 | ▶ | $self->_add_packages(packages => $packages, file => $sym) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | if $success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | $self->_add_scripts(scripts => $scripts, file => $sym) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 3 | ▶ | if $success and not $args{no_scripts}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$success and not $args{"no_scripts"}
MC/DC0%0/2
$success and not $args{"no_scripts"}
$success
not $args{"no_scripts"}
Truth table33%1/3
A and not(B)
A= $successB= not $args{"no_scripts"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 13 | ▶ | if ($is_any_perl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 1 | my $dir = catdir($arch, 'any_version'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | mkpath(catdir($self->{path}, $dir)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 1 | my $sym = join('-', $distname, $distver, $arch, 'any_version').'.par'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | my $success = $self->_add_symlink( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | file => $target_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | sym => $sym, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | overwrite => $args{overwrite}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | # associate packages and scripts with symlink as well | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | ▶ | $self->_add_packages(packages => $packages, file => $sym) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | if $success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | $self->_add_scripts(scripts => $scripts, file => $sym) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 1 | ▶ | if $success and not $args{no_scripts}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$success and not $args{"no_scripts"}
MC/DC0%0/2
$success and not $args{"no_scripts"}
$success
not $args{"no_scripts"}
Truth table33%1/3
A and not(B)
A= $successB= not $args{"no_scripts"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 13 | ▶ | if ($is_any_arch and $is_any_perl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$is_any_arch and $is_any_perl
MC/DC0%0/2
$is_any_arch and $is_any_perl
$is_any_arch
$is_any_perl
Truth table66%2/3
A and B
A= $is_any_archB= $is_any_perl
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | my $dir = catdir('any_arch', 'any_version'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | mkpath(catdir($self->{path}, $dir)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | my $sym = join('-', $distname, $distver, 'any_arch', 'any_version').'.par'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | my $success = $self->_add_symlink( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | file => $target_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | sym => $sym, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | overwrite => $args{overwrite}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # associate packages and scripts with symlink as well | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | $self->_add_packages(packages => $packages, file => $sym) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | if $success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | $self->_add_scripts(scripts => $scripts, file => $sym) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | if $success and not $args{no_scripts}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$success and not $args{"no_scripts"}
MC/DC0%0/2
$success and not $args{"no_scripts"}
$success
not $args{"no_scripts"}
Truth table0%0/3
A and not(B)
A= $successB= not $args{"no_scripts"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 13 | $self->close_modules_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 13 | $self->close_symlinks_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 13 | $self->close_scripts_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 13 | $self->close_dependencies_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 13 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | # first argument is a path in the repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | # expects to be called from within the main repository path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | # or with the switch_to_path => 1 option. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | # returns a boolean indicating whether a file is a symlink or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # not. Normally, this is just -l $file, but if fake_symlinks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | # is in effect, the file will be a real file and we have to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | # check the symlink dbm! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 22 | ▶ | sub _is_symlink { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_symlink: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 22 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 22 | $self->verbose(3, "Entering _is_symlink('$file')"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 22 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 22 | my $old_dir = Cwd::cwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 22 | ▶ | chdir($self->{path}) if $args{switch_to_path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 22 | (undef, undef, $file) = File::Spec->splitpath($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 22 | (undef, undef, my $filearch, my $filepver) = PAR::Dist::parse_dist_name($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 22 | ▶ | if ($self->{info}{fake_symlinks}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 9 | $self->verbose(5, "In _is_symlink: fake_symlinks enabled."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 9 | my ($symh) = $self->symlinks_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 9 | foreach my $symlinks (values %$symh) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | # otherwise, things might potentially blow up with strange directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | # separators. This will need better consideration in the future. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 4 | ▶ | chdir($old_dir), return 1 if grep { $file eq $_ } @$symlinks; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 7 | chdir($old_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 7 | return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 13 | $self->verbose(5, "In _is_symlink: fake_symlinks disabled."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 13 | my $f = File::Spec->catfile($filearch, $filepver, $file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 13 | my $link = -l $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 13 | chdir($old_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 13 | return $link; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | =head2 remove | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | Removes a distribution from the repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | The information needed for this consists of four pieces: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | The distribution name, the distribution version, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | architecture name and the perl version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | This information can be gathered from either a file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | name (see the I<file> parameter) or from individual | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | parameters (see below) or from a mixture of these. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | The explicit parameters take precedence before the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | file name parsing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | If the specified distribution isn't in the repository, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | the method returns false. If the specified distribution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | is a symlink to another distribution, the symlink will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | removed, but not the linked distribution. If the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | specified distribution is an actual distribution in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | repository that has other symlinks, the distribution as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | well as any symlinks are removed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | Returns true on success. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | Parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | =item I<file> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | The file name of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | distribution to remove. The file name should not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | include any path information. That means you must not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | worry about the way it is stored in the repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | Any paths are stripped and the .par extension is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | appended if it's not explicitly specified. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | The format must be as with the inject() method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | =item I<distname> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | The distribution name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | =item I<distversion> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | The distribution version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | =item I<arch> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | The architecture string. It can be C<any_arch> or an actual | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | architecture name. For details, see the discussion in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | manual entry for the C<inject> method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | =item I<perlversion> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | The version of perl. Note that it has to be in the C<5.8.7> and not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | in the C<5.008007> form! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | It can be C<any_version> instead of an actual perl version. For details, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | see the discussion in the manual entry for the C<inject> method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | You may omit the C<file> parameter if the full file name can be constructed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | from the individual pieces of information. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 14 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: called CC=16 SCAR=31.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 14 | ▶ | croak(__PACKAGE__."->remove() takes an even number of arguments.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | if @_ % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 14 | $self->verbose(2, "Entering remove()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 14 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | # my $dfile = $args{file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | # croak(__PACKAGE__."->remove() needs a 'file' parameter.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | # if not defined $dfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | # croak(__PACKAGE__."->remove(): Specified file '$dfile' does not exist.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | # if not -f $dfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | # determine the name of the target (in-repository) file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 14 | my ($target_file, $distname, $distver, $arch, $perlver) = $self->_get_target_file('remove', \%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 14 | $self->verbose(3, "Target file for removal will be '$target_file'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | # change to repo path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 14 | my $old_dir = Cwd::cwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 14 | chdir($self->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 14 | my $complete_target = catfile( $arch, $perlver, $target_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 14 | ▶ | if (not -f $complete_target and not -l $complete_target) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
-f $complete_target || -l $complete_target
MC/DC0%0/2
-f $complete_target || -l $complete_target
-f $complete_target
-l $complete_target
Truth table33%1/3
A || B
A= -f $complete_targetB= -l $complete_target
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | # not in repo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | $self->verbose(1, "Target file is not in repository"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | chdir($old_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | elsif ($self->_is_symlink($target_file)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # target is a symlink, remove the link only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 1 | $self->verbose(1, "Target file is a symlink. Removing the symlink only"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 1 | chdir($old_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 1 | my ($modh) = $self->modules_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 1 | my ($scrh) = $self->scripts_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 1 | ▶ | if (not $self->_remove_files_from_db($modh, [$target_file]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->_remove_files_from_db($modh, [$target_file]) && $self->_remove_files_from_db($scrh, [$target_file]) && $self->_remove_symlink('sym', $target_file)
$self->_remove_files_from_db($modh, [$target_file]) and $self->_remove_files_from_db($scrh, [$target_file])
MC/DC0%0/3
$self->_remove_files_from_db($modh, [$target_file]) && $self->_remove_files_from_db($scrh, [$target_file]) && $self->_remove_symlink('sym', $target_file)
$self->_remove_files_from_db($modh, [$target_file])
$self->_remove_files_from_db($scrh, [$target_file])
$self->_remove_symlink('sym', $target_file)
Truth table25%1/4
A and B && C
A= $self->_remove_files_from_db($modh, [$target_file])B= $self->_remove_files_from_db($scrh, [$target_file])C= $self->_remove_symlink('sym', $target_file)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | or not $self->_remove_files_from_db($scrh, [$target_file]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | or not $self->_remove_symlink(sym => $target_file) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | $self->close_modules_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | $self->close_scripts_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 1 | $self->close_modules_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 1 | $self->close_scripts_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 13 | chdir($old_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | # target is a file. remove file and its symlinks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 13 | my ($symh) = $self->symlinks_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 13 | my ($modh) = $self->modules_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 13 | my ($scrh) = $self->scripts_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 13 | my ($deph) = $self->dependencies_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | # find links | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | # Why so complicated? Because DBM::Deep has too much magic! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 13 | ▶ | my $links = exists($symh->{$target_file}) ? $symh->{$target_file} : []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 13 | ▶ | if (not defined $links) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | die "Found undefined value in symlinks DBM for file name '$target_file'! This is a regression!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 13 | $links = [ map {$_} @$links ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 13 | my @module_and_links = ($target_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 13 | push @module_and_links, @$links; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | # remove mention of the distro and links | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | # from modules and scripts dbs (This is slow!) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 13 | $self->_remove_files_from_db($modh, \@module_and_links); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 13 | $self->_remove_files_from_db($scrh, \@module_and_links); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | # remove dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 13 | ▶ | if (exists $deph->{$target_file}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 13 | delete $deph->{$target_file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | # remove links | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 13 | foreach my $link (@$links) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 3 | $self->_remove_symlink(sym => $link) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | # remove the whole archive from the symlinks db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 13 | ▶ | if ( exists($symh->{$target_file}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $symh->{$target_file} and ref $symh->{$target_file} and @{$symh->{$target_file};} == 0
exists $symh->{$target_file} and ref $symh->{$target_file}
MC/DC0%0/3
exists $symh->{$target_file} and ref $symh->{$target_file} and @{$symh->{$target_file};} == 0
exists $symh->{$target_file}
ref $symh->{$target_file}
@{$symh->{$target_file};} == 0
Truth table25%1/4
A and B and C
A= exists $symh->{$target_file}B= ref $symh->{$target_file}C= @{$symh->{$target_file};} == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | and ref($symh->{$target_file}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | and @{$symh->{$target_file}} == 0 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | delete $symh->{$target_file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | # remove file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 13 | $old_dir = Cwd::cwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 13 | chdir($self->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 13 | ▶ | unlink($complete_target) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | or die "Could not remove file '$complete_target' from repository. Current path is '".Cwd::cwd()."'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 13 | chdir($old_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 13 | $self->close_modules_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 13 | $self->close_symlinks_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 13 | $self->close_scripts_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 13 | $self->close_dependencies_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 13 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | =head2 verbose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | Print a verbose status message. First argument should be an integer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | second argument should be the message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | If the global variable C<$PAR::Repository::VERBOSE> is set to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | a value equal to or higher than the integer passed as first argument, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | the verbose message will be sent to STDOUT. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | The global verbose variable defaults to 0. Setting it to a negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | value should suppress B<any> output except fatal errors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | Valid values are: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 => Non-fatal errors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 1 => Short status messages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 2 => Method entry messages.- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 3 => Full debug output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | A newline is attached to all output. If the verbosity global | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | variable is set to a "4", all status messages are sent to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | STDERR instead via warn. That means the source line of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | status message is attached. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 1949 | ▶ | sub verbose { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbose: called CC=3 SCAR=13.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 1949 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 1949 | my $verbosity = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 1949 | my $msg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 1949 | ▶ | if ($PAR::Repository::VERBOSE >= 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | my %call_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | @call_info{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | qw(pack file line sub has_args wantarray evaltext is_require) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } = caller(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | warn "$msg at $call_info{file} line $call_info{line}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | elsif ($PAR::Repository::VERBOSE >= $verbosity) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | print "$msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 1949 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | =head2 _cmp_dist_versions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | Compares the versions of two files. Takes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | two file names as arguments. Parses the distribution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | version from those file names and compares those | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | versions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | Returns -1 if the version of the first file is less than that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | of the second file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | Returns 0 if the versions are equal. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | Returns 1 if the version of the first file is greater than that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | of the second file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | For internal use only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | ▶ | sub _cmp_dist_versions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cmp_dist_versions: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | my $f1 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | my $f2 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | (undef, my $dv1, undef, undef) = PAR::Dist::parse_dist_name($f1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | (undef, my $dv2, undef, undef) = PAR::Dist::parse_dist_name($f2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | ▶ | if (not defined $dv1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | ▶ | return 0 if not defined $dv2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | elsif (not defined $dv2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | my $v1 = version->new($dv1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | my $v2 = version->new($dv2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | return($v1 <=> $v2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | =head2 _add_packages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | Adds a number of package E<lt>-E<gt> file associations to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | modulesE<lt>-E<gt>dists DBM file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | Parameters: C<packages => \%pkg_hash> a hash of package names as keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | and their versions (optionally) as values. C<file => $target_file> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | the file in the repository to associate these packages with. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | For internal use only! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 17 | ▶ | sub _add_packages { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_packages: called CC=9 SCAR=22.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 17 | $self->verbose(2, "Entering _add_packages()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 17 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 17 | my $packages = $args{packages}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 17 | my $target_file = $args{file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 17 | my ($hash, $temp_file) = $self->modules_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 17 | my %missing_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | my %seen_files; # if a version is not available, fall back to another version in the file IF it's a META style provides | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 17 | foreach my $pkgname (keys %$packages) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 51 | ▶ | $hash->{$pkgname} = {} if not exists $hash->{$pkgname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 51 | my $this_pkg_dists = $hash->{$pkgname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 51 | ▶ | if (!ref($packages->{$pkgname})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | # flat pkg => version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | ▶ | $this_pkg_dists->{$target_file} = $packages->{$pkgname}||'0'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$packages->{$pkgname} || '0'
MC/DC0%0/1
$packages->{$pkgname} || '0'
$packages->{$pkgname}
Truth table0%0/2
A
A= $packages->{$pkgname}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | # nested META.yml style provides | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 51 | ▶ | if (not exists $packages->{$pkgname}{version}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 17 | $missing_version{$pkgname} = $packages->{$pkgname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 34 | $this_pkg_dists->{$target_file} = $packages->{$pkgname}{version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | $seen_files{ $packages->{$pkgname}{file} } = $packages->{$pkgname}{version} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | if defined $packages->{$pkgname}{file} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 34 | ▶ | and defined $packages->{$pkgname}{version}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $packages->{$pkgname}{"file"} and defined $packages->{$pkgname}{"version"}
MC/DC0%0/2
defined $packages->{$pkgname}{"file"} and defined $packages->{$pkgname}{"version"}
defined $packages->{$pkgname}{"file"}
defined $packages->{$pkgname}{"version"}
Truth table33%1/3
A and B
A= defined $packages->{$pkgname}{"file"}B= defined $packages->{$pkgname}{"version"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | } # end foreach package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | # fill in the missing versions that might be resolved using the file matching | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | # this is here since the ordering isn't defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 17 | foreach my $pkgname (keys %missing_version) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 17 | my $this_pkg_dists = $hash->{$pkgname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 17 | $this_pkg_dists->{$target_file} = $seen_files{ $missing_version{$pkgname}{file} }; # degrades to undef | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 17 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | =head2 _add_scripts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | Adds a number of script E<lt>-E<gt> file associations to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | scriptsE<lt>-E<gt>dists DBM file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | Parameters: C<scripts => \%script_hash> a hash of script names as keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | and their versions (optionally) as values. C<file => $target_file> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | the file in the repository to associate these scripts with. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | For internal use only! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 17 | ▶ | sub _add_scripts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_scripts: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 17 | $self->verbose(2, "Entering _add_scripts()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 17 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 17 | my $scripts = $args{scripts}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 17 | my $target_file = $args{file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 17 | my ($hash) = $self->scripts_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 17 | foreach my $scr (keys %$scripts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | ▶ | $hash->{$scr} = {} if not exists $hash->{$scr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | $hash->{$scr}{$target_file} = $scripts->{$scr}{version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 17 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | =head2 _add_symlink | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | Adds a symlink to the repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | Parameters: C<file => "file"> and C<sym => "symlink">. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | I<file> and I<symlink> B<must not include any path>. The path in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | repository is generated from the file name! (Paths in the repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | do not carry any additional information. They are for grouping only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | and reduce the number of files in a single directory.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | Optional parameter: C<overwrite => bool>. If true, overwrites old symlinks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | Never overwrites files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | This is a private method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 4 | ▶ | sub _add_symlink { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_symlink: called CC=11 SCAR=26.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 4 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 4 | my $file = $args{file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 4 | my $sym = $args{sym}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 4 | $self->verbose(2, "Entering _add_symlink, adding symlink '$sym' to '$file'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | # We do not want any user defined directories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | # Why? Because they would end up in the database with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | # system-specific path separators. BANG! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 4 | (undef, undef, $file) = splitpath($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 4 | (undef, undef, $sym) = splitpath($sym); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | # get the directory in the repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 4 | (undef, undef, my $filearch, my $filepver) = PAR::Dist::parse_dist_name($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 4 | (undef, undef, my $symarch, my $sympver) = PAR::Dist::parse_dist_name($sym); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 4 | my $filedir = catdir( $filearch, $filepver ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 4 | my $symdir = catdir( $symarch, $sympver ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 4 | my $file_full = catfile( $filedir, $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 4 | my $sym_full = catfile( $symdir, $sym ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 4 | my $overwrite = $args{overwrite}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 4 | ▶ | if (!$Supports_Symlinks and !$self->{info}{fake_symlinks}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$PAR::Repository::Supports_Symlinks or $self->{"info"}{"fake_symlinks"}
MC/DC0%0/2
$PAR::Repository::Supports_Symlinks or $self->{"info"}{"fake_symlinks"}
$PAR::Repository::Supports_Symlinks
$self->{"info"}{"fake_symlinks"}
Truth table66%2/3
A or B
A= $PAR::Repository::Supports_SymlinksB= $self->{"info"}{"fake_symlinks"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | croak("Symlinks are not supported on this system! Try creating a repository " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | ."with the fake_symlinks option set or convert it by supplying the " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | ."convert_symlinks => 1 option to the PAR::Repository constructor."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | # get the symlinks dbm while in the old path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 4 | my ($shash) = $self->symlinks_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 4 | my $old_dir = Cwd::cwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 4 | chdir($self->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 4 | ▶ | if ($self->_is_symlink($sym)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | ▶ | $self->verbose(1, "Symlink '$sym' exists. Overwrite is set to ".($overwrite?1:0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | ▶ | chdir($old_dir), return undef if not $overwrite; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | $self->_remove_symlink(sym => $sym); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | elsif (-f $sym_full) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | $self->verbose(1, "Symlink '$sym' is a file. Not overwriting"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | chdir($old_dir), return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | # Files always take precedence over symlinks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 4 | ▶ | if ($self->{info}{fake_symlinks}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 1 | $self->verbose(1, "fake_symlinks is set. Copying file instead of linking"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 1 | ▶ | File::Copy::copy($file_full, $sym_full) or die $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 3 | my $source_file = catfile( File::Spec->updir, File::Spec->updir, $file_full ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 3 | ▶ | symlink($source_file, $sym_full) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | or die "Could not create symlink from (full repo paths) '$sym_full' to file '$source_file'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 4 | ▶ | $shash->{$file} = [] if not defined $shash->{$file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 4 | push @{$shash->{$file}}, $sym; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 4 | chdir($old_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | =head2 _add_dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | Adds a number of distribution E<lt>-E<gt> module associations to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | dependencies DBM file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | Parameters: C<file =E<gt> 'DistName-0.01-.....par', dependencies =E<gt> \%deps_hash> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | where C<\%deps_hash> the returned structure from C<PAR::Indexer::dependencies_from_meta_yml>: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | module names associated to their minimal required versions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | For internal use only! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 13 | ▶ | sub _add_dependencies { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_dependencies: called CC=8 SCAR=22.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 13 | $self->verbose(2, "Entering _add_dependencies()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 13 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 13 | my $distribution = $args{file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 13 | my $dependencies = $args{dependencies}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | return() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 13 | ▶ | if not defined $distribution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not defined $distribution && defined $dependencies && ref $dependencies eq "HASH" or keys %$dependencies == 0
defined $distribution && defined $dependencies && ref $dependencies eq 'HASH'
defined $distribution and defined $dependencies
MC/DC0%0/4
not defined $distribution && defined $dependencies && ref $dependencies eq "HASH" or keys %$dependencies == 0
defined $distribution
defined $dependencies
ref $dependencies eq 'HASH'
keys %$dependencies == 0
Truth table20%1/5
not(A and B && C) or D
A= defined $distributionB= defined $dependenciesC= ref $dependencies eq 'HASH'D= keys %$dependencies == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | or not defined $dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | or not ref($dependencies) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | or keys(%$dependencies) == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 13 | my ($hash, $temp_file) = $self->dependencies_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | # FIXME: shouldn't really exist, no? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 13 | ▶ | my $dist_hash = $hash->{$distribution} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$hash->{$distribution} ||= {}
MC/DC0%0/1
$hash->{$distribution} ||= {}
$hash->{$distribution}
Truth table50%1/2
A
A= $hash->{$distribution}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 13 | foreach my $dep_name (keys %$dependencies) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 52 | $dist_hash->{$dep_name} = $dependencies->{$dep_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 52 | ▶ | $dist_hash->{$dep_name} = 0 if not defined $dist_hash->{$dep_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 13 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | =head2 _update_info_version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | Writes the YAML repository info file and upgrades the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | repository version to the current version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | Should be used with care and considered a private method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | ▶ | sub _update_info_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_info_version: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 0 | $self->verbose(2, "Entering _update_info_version"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | ▶ | my $yaml = $self->{info} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"info"} ||= {}
MC/DC0%0/1
$self->{"info"} ||= {}
$self->{"info"}
Truth table0%0/2
A
A= $self->{"info"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | $yaml->{repository_version} = $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | my $info_file = catfile($self->{path}, PAR::Repository::REPOSITORY_INFO_FILE()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | ▶ | unless (YAML::Syck::DumpFile($info_file, $yaml)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | croak("Could not write repository info YAML file to '$info_file'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | =head2 _remove_files_from_db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | First argument is the reference to the modules or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | scripts DBM hash. Second argument is an array reference to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | an array of file names. Removes all mention of those | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | distribution files (symlinks or actual files) from the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | DBM hash. This is a slow operation because the hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | associates in the opposite direction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | If any occurrances have been deleted, this method cleans up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | the DBM file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | Returns 1 on success. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | This is a private method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 28 | ▶ | sub _remove_files_from_db { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_files_from_db: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 28 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 28 | my $db = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 28 | my $files = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 28 | $self->verbose(2, "Entering _remove_files_from_db('".join("', '",@$files)."'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 28 | my %files = map {($_ => undef)} @$files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 28 | my $deleted = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 28 | foreach my $namespace_or_script (keys %$db) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 42 | my $in_dists = $db->{$namespace_or_script}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 42 | foreach my $distfile (keys %$in_dists) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 54 | ▶ | if (exists $files{$distfile}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 51 | $deleted++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 51 | delete $in_dists->{$distfile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | # is empty? namespace no more in repository? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 42 | ▶ | if (keys(%$in_dists) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 39 | $deleted++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 39 | delete $db->{$namespace_or_script}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | } # end for each namespace or script | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 28 | ▶ | if ($deleted) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | # recover disk space. See DBM::Deep docs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 14 | tied(%$db)->optimize(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 28 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | =head2 _remove_symlink | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | Removes a symlink from the repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | Parameters: C<sym => "full/path/in/repo">. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | Or: C<sym => "foo.par"> (omitting the path). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | This is a private method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 4 | ▶ | sub _remove_symlink { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_symlink: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 4 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 4 | $self->verbose(2, "Entering _remove_symlink(sym => '".$args{sym}."')"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 4 | my $sym = $args{sym}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | # We do not want any user defined directories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | # Why? Because they would end up in the database with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | # system-specific path separators. BANG! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 4 | (undef, undef, $sym) = splitpath($sym); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | # get the directory in the repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 4 | (undef, undef, my $symarch, my $sympver) = PAR::Dist::parse_dist_name($sym); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 4 | my $symdir = catdir( $symarch, $sympver ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 4 | my $sym_full = catfile( $symdir, $sym ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | # change to repo path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 4 | my $old_dir = Cwd::cwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 4 | chdir($self->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 4 | my ($shash) = $self->symlinks_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 4 | ▶ | if (not $self->_is_symlink($sym)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | $self->verbose(1, "Symlink '$sym' ('$sym_full' in the repository) doesn't exist or is not a symlink"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | chdir($old_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | # remove references to that symlink from the db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 4 | $self->verbose(3, "Removing all references to symlink from DBM"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 4 | foreach my $file (keys %{$shash}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 4 | my $syms = $shash->{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 4 | @$syms = grep {$_ ne $sym} @$syms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 4 | ▶ | delete $shash->{$file} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | if @$syms == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | # recover disk space. See DBM::Deep docs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 4 | tied(%$shash)->optimize(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 4 | $self->verbose(3, "Removing symlink '$sym'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 4 | ▶ | unlink($sym_full) or (chdir($old_dir), return ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 4 | chdir($old_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 27 | ▶ | sub _get_target_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_target_file: called CC=10 SCAR=23.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 27 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 27 | my $method = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 27 | my %args = %{shift()}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 27 | $self->verbose(2, "Entering _get_target_file()"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 27 | my ($distname, $distver, $arch, $perlver); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 27 | ▶ | if (grep {!defined($_)} @args{qw/distname distversion arch perlversion/}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 27 | $self->verbose(3, "Did not get all distribution information as parameters. Parsing distribution name"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 27 | my ($v, $p, $f) = splitpath($args{file}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 27 | ($distname, $distver, $arch, $perlver) = PAR::Dist::parse_dist_name($f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 27 | ▶ | $distname = $args{distname} if defined $args{distname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 27 | ▶ | $distver = $args{distversion} if defined $args{distversion}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 27 | ▶ | $arch = $args{arch} if defined $args{arch}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | 27 | ▶ | $perlver = $args{perlversion} if defined $args{perlversion}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 27 | ▶ | croak("Could not determine distribution name") if not defined $distname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 27 | ▶ | croak("Could not determine distribution version") if not defined $distver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 27 | ▶ | croak("Could not determine distribution architecture") if not defined $arch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 27 | ▶ | croak("Could not determine distribution perl version") if not defined $perlver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 27 | my $target_file = join('-', $distname, $distver, $arch, $perlver).".par"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 27 | $self->verbose(3, "Target file will be '$target_file'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 27 | return($target_file, $distname, $distver, $arch, $perlver); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 112 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 112 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 112 | $self->verbose(2, "Entering DESTROY {}"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 112 | $self->close_scripts_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 112 | $self->close_modules_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 112 | $self->close_symlinks_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 112 | $self->close_dependencies_dbm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 112 | $self->update_dbm_checksums; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 22 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||