| 1 | package OpenInteract2::Package; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | # $Id: Package.pm,v 1.56 2005/03/17 14:57:58 sjn Exp $ | ||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 87 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 87 | ▶ | use base qw( Exporter Class::Accessor::Fast ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 87 | ▶ | use Archive::Zip qw( :ERROR_CODES ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 87 | ▶ | use Cwd qw( cwd ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 87 | ▶ | use Data::Dumper qw( Dumper ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 87 | ▶ | use ExtUtils::Manifest (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 87 | ▶ | use File::Basename qw( basename dirname ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 87 | ▶ | use File::Copy qw( cp ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 87 | ▶ | use File::Path qw( mkpath ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 87 | ▶ | use File::Spec::Functions qw( :ALL ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 87 | ▶ | use File::Temp qw( tempdir ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | 87 | ▶ | use Log::Log4perl qw( get_logger ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | 87 | ▶ | use OpenInteract2::Constants qw( :log ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 87 | ▶ | use OpenInteract2::Context qw( CTX ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | 87 | ▶ | use OpenInteract2::Config::Package; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | 87 | ▶ | use OpenInteract2::Config::PackageChanges; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | 87 | ▶ | use OpenInteract2::Config::Readonly; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | 87 | ▶ | use OpenInteract2::Exception qw( oi_error ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 23 | 87 | ▶ | use OpenInteract2::I18N::Initializer; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | 87 | ▶ | use OpenInteract2::Repository; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | 87 | ▶ | use OpenInteract2::Util; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 87 | $OpenInteract2::Package::VERSION = sprintf("%d.%02d", q$Revision: 1.56 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 87 | my ( $log ); | |||||||||||||||||||||||||||||||
| 30 | 87 | @OpenInteract2::Package::EXPORT_OK = qw( DISTRIBUTION_EXTENSION ); | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 87 | ▶ | use constant DISTRIBUTION_EXTENSION => 'zip'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | # Define the subdirectories present in a default package | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 87 | my @PKG_SUBDIR = qw( | |||||||||||||||||||||||||||||||
| 37 | conf data msg struct template script html html/images | ||||||||||||||||||||||||||||||||
| 38 | OpenInteract2 OpenInteract2/Action OpenInteract2/SQLInstall | ||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 87 | my @FIELDS = qw( package_file directory name version | |||||||||||||||||||||||||||||||
| 42 | repository installed_date config ); | ||||||||||||||||||||||||||||||||
| 43 | 87 | OpenInteract2::Package->mk_accessors( @FIELDS ); | |||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | ######################################## | ||||||||||||||||||||||||||||||||
| 46 | # CONSTRUCTOR | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=11 SCAR=25.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 49 | 8 | my ( $class, $params ) = @_; | |||||||||||||||||||||||||||||||
| 50 | 8 | ▶ | $log ||= get_logger( LOG_OI ); | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$log ||= get_logger("OI2")
MC/DC0%0/2
$log ||= get_logger("OI2")
$log
get_logger("OI2")
Truth table66%2/3
A ||= B
A= $logB= get_logger("OI2")
| |||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 8 | my $self = bless( {}, $class ); | |||||||||||||||||||||||||||||||
| 53 | 8 | my ( $to_read ); | |||||||||||||||||||||||||||||||
| 54 | 8 | ▶ | if ( ref $params->{package_config} eq 'OpenInteract2::Config::Package' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 55 | 0 | $params->{directory} = $params->{package_config}->package_dir; | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | 8 | ▶ | if ( $params->{package_file} ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | unless ( -f $params->{package_file} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 59 | 0 | oi_error "Cannot initialize package with non-existent package ", | |||||||||||||||||||||||||||||||
| 60 | "file. (Given $params->{package_file})"; | ||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | 1 | my $full_path = rel2abs( $params->{package_file} ); | |||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 64 | $log->debug( "Setting full path for package file '$full_path'" ); | ||||||||||||||||||||||||||||||||
| 65 | 1 | $self->package_file( $full_path ); | |||||||||||||||||||||||||||||||
| 66 | 1 | $to_read++; | |||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | elsif ( $params->{directory} ) { | ||||||||||||||||||||||||||||||||
| 69 | 6 | my $full_directory = rel2abs( $params->{directory} ); | |||||||||||||||||||||||||||||||
| 70 | 6 | ▶ | unless ( -d $full_directory ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 71 | 0 | oi_error "Cannot initialize package with non-existent package ", | |||||||||||||||||||||||||||||||
| 72 | "directory. (Given $params->{directory})"; | ||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | $log->is_debug && | ||||||||||||||||||||||||||||||||
| 75 | 6 | ▶ | $log->debug( "Reading package from directory '$full_directory'" ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 76 | 6 | $self->directory( $full_directory ); | |||||||||||||||||||||||||||||||
| 77 | 6 | $to_read++; | |||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||
| 79 | 8 | ▶ | $self->_read_package_data if ( $to_read ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 80 | 8 | ▶ | $self->repository( $params->{repository} ) if ( $params->{repository} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 81 | 8 | return $self; | |||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | 7 | ▶ | sub _read_package_data { | ||||||||||||||||||||||||||||||
|
Subroutine
_read_package_data: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||
| 86 | 7 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 87 | 7 | ▶ | if ( $self->directory ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 88 | 6 | $self->_read_info_from_dir; | |||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | elsif ( $self->package_file ) { | ||||||||||||||||||||||||||||||||
| 91 | 1 | $self->_read_info_from_file; | |||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||
| 93 | else { | ||||||||||||||||||||||||||||||||
| 94 | 0 | oi_error "You must have set either 'directory' or 'package_file' ", | |||||||||||||||||||||||||||||||
| 95 | "to be able to read the package data"; | ||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | # Explode the info into a temp directory, then run _read_info_from_dir | ||||||||||||||||||||||||||||||||
| 100 | # with the temp dir as a parameter. Note: we cleanup the temp_dir on | ||||||||||||||||||||||||||||||||
| 101 | # DESTROY. | ||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | sub _read_info_from_file { | ||||||||||||||||||||||||||||||
|
Subroutine
_read_info_from_file: called CC=8 SCAR=22.2
| |||||||||||||||||||||||||||||||||
| 104 | 1 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 105 | 1 | ▶ | $log ||= get_logger( LOG_OI ); | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$log ||= get_logger("OI2")
MC/DC0%0/2
$log ||= get_logger("OI2")
$log
get_logger("OI2")
Truth table33%1/3
A ||= B
A= $logB= get_logger("OI2")
| |||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | 1 | my $tmp_dir = tempdir( 'OIPKGXXXXXX', TMPDIR => 1, CLEANUP => 1 ); | |||||||||||||||||||||||||||||||
| 108 | 1 | ▶ | unless ( -d $tmp_dir and -w $tmp_dir ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-d $tmp_dir and -w $tmp_dir
MC/DC0%0/2
-d $tmp_dir and -w $tmp_dir
-d $tmp_dir
-w $tmp_dir
Truth table33%1/3
A and B
A= -d $tmp_dirB= -w $tmp_dir
| |||||||||||||||||||||||||||||||||
| 109 | 0 | oi_error "Cannot find writeable temp dir"; | |||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||
| 111 | 1 | my $pwd = cwd(); | |||||||||||||||||||||||||||||||
| 112 | 1 | chdir( $tmp_dir ); | |||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | 1 | my $package_file = $self->package_file; | |||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 116 | $log->debug( "Reading package info from '$package_file'" ); | ||||||||||||||||||||||||||||||||
| 117 | 1 | eval { | |||||||||||||||||||||||||||||||
| 118 | 1 | my $extracted = $self->_extract_archive( $self->package_file ); | |||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | unless ( scalar @{ $extracted } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 120 | 0 | oi_error "Failed to extract any files from package ", | |||||||||||||||||||||||||||||||
| 121 | "file ", $self->package_file; | ||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | 1 | my @sample_path = split( '/', $extracted->[0]->fileName() ); | |||||||||||||||||||||||||||||||
| 124 | 1 | my $extracted_dir = catdir( $tmp_dir, $sample_path[0] ); | |||||||||||||||||||||||||||||||
| 125 | 1 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 126 | $log->debug( "Package unpacked to directory '$extracted_dir'" ); | ||||||||||||||||||||||||||||||||
| 127 | 1 | $self->_read_info_from_dir( $extracted_dir ); | |||||||||||||||||||||||||||||||
| 128 | 1 | $self->_read_manifest( $extracted_dir ); | |||||||||||||||||||||||||||||||
| 129 | 1 | $self->{_tmp_package_extract_dir} = $tmp_dir; | |||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||
| 131 | # This might seem really weird, but other objects (like | ||||||||||||||||||||||||||||||||
| 132 | # OI2::Config::PackageChanges) rely on the package being able | ||||||||||||||||||||||||||||||||
| 133 | # to report SOME sort of directory. | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | 1 | $self->directory( $extracted_dir ); | |||||||||||||||||||||||||||||||
| 136 | }; | ||||||||||||||||||||||||||||||||
| 137 | 1 | my $error = $@; | |||||||||||||||||||||||||||||||
| 138 | 1 | chdir( $pwd ); | |||||||||||||||||||||||||||||||
| 139 | 1 | ▶ | oi_error $error if ( $error ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 140 | 1 | return $self; | |||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | # Read in the cofiguration object and the name, version. | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | 7 | ▶ | sub _read_info_from_dir { | ||||||||||||||||||||||||||||||
|
Subroutine
_read_info_from_dir: called CC=4 SCAR=14.8
| |||||||||||||||||||||||||||||||||
| 147 | 7 | my ( $self, $dir ) = @_; | |||||||||||||||||||||||||||||||
| 148 | 7 | ▶ | $log ||= get_logger( LOG_OI ); | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$log ||= get_logger("OI2")
MC/DC0%0/2
$log ||= get_logger("OI2")
$log
get_logger("OI2")
Truth table33%1/3
A ||= B
A= $logB= get_logger("OI2")
| |||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||
| 150 | 7 | ▶ | $dir ||= $self->directory; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$dir ||= $self->directory
MC/DC0%0/2
$dir ||= $self->directory
$dir
$self->directory
Truth table66%2/3
A ||= B
A= $dirB= $self->directory
| |||||||||||||||||||||||||||||||||
| 151 | 7 | ▶ | unless ( -d $dir ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 152 | 0 | oi_error "Cannot read package information from invalid ", | |||||||||||||||||||||||||||||||
| 153 | "directory '$dir'"; | ||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | 7 | $self->config( OpenInteract2::Config::Package->new({ directory => $dir }) ); | |||||||||||||||||||||||||||||||
| 156 | 7 | $self->name( $self->config->name ); | |||||||||||||||||||||||||||||||
| 157 | 7 | $self->version( $self->config->version ); | |||||||||||||||||||||||||||||||
| 158 | 7 | return $self; | |||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | ######################################## | ||||||||||||||||||||||||||||||||
| 162 | # PROPERTIES | ||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||
| 164 | 6 | ▶ | sub full_name { | ||||||||||||||||||||||||||||||
|
Subroutine
full_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 165 | 6 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 166 | 6 | return join( '-', $self->name, $self->version ); | |||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | sub name_as_class { | ||||||||||||||||||||||||||||||
|
Subroutine
name_as_class: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 170 | 1 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||
| 171 | 1 | ▶ | $name ||= $self->name; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$name ||= $self->name
MC/DC0%0/2
$name ||= $self->name
$name
$self->name
Truth table33%1/3
A ||= B
A= $nameB= $self->name
| |||||||||||||||||||||||||||||||||
| 172 | 1 | my $class_name = ucfirst $name; | |||||||||||||||||||||||||||||||
| 173 | 1 | $class_name =~ s/_(\w)/\U$1\U/g; | |||||||||||||||||||||||||||||||
| 174 | 1 | return $class_name; | |||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||
| 177 | # don't use split here since the package name might have a '-' in it | ||||||||||||||||||||||||||||||||
| 178 | # (shouldn't happen, but still) | ||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | sub parse_full_name { | ||||||||||||||||||||||||||||||
|
Subroutine
parse_full_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 181 | 2 | my ( $class, $full_name ) = @_; | |||||||||||||||||||||||||||||||
| 182 | 2 | my ( $name, $version ) = $full_name =~ /^(.*)\-(.*)$/; | |||||||||||||||||||||||||||||||
| 183 | 2 | return ( $name, $version ); | |||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||
| 186 | # Get the changelog | ||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | 2 | ▶ | sub get_changes { | ||||||||||||||||||||||||||||||
|
Subroutine
get_changes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 189 | 2 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 190 | 2 | return OpenInteract2::Config::PackageChanges->new({ package => $self }); | |||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | # Get a list of files from the MANIFEST | ||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||
| 195 | 20 | ▶ | sub get_files { | ||||||||||||||||||||||||||||||
|
Subroutine
get_files: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 196 | 20 | my ( $self, $force ) = @_; | |||||||||||||||||||||||||||||||
| 197 | 20 | ▶ | $self->{_manifest} ||= []; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_manifest"} ||= []
MC/DC100%1/1
$self->{"_manifest"} ||= []
$self->{"_manifest"}
Truth table100%2/2
A
A= $self->{"_manifest"}
| |||||||||||||||||||||||||||||||||
| 198 | 20 | ▶ | if ( scalar @{ $self->{_manifest} } == 0 or $force ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar @{$self->{"_manifest"};} == 0 or $force
MC/DC50%1/2
scalar @{$self->{"_manifest"};} == 0 or $force
scalar @{$self->{"_manifest"};} == 0
$force
Truth table66%2/3
A or B
A= scalar @{$self->{"_manifest"};} == 0B= $force
| |||||||||||||||||||||||||||||||||
| 199 | 4 | $self->{_manifest} = $self->_read_manifest; | |||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||
| 201 | 20 | return $self->{_manifest}; | |||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||
| 205 | # Return a sorted arrayref of files in MANIFEST | ||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||
| 207 | 5 | ▶ | sub _read_manifest { | ||||||||||||||||||||||||||||||
|
Subroutine
_read_manifest: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||
| 208 | 5 | my ( $self, $manifest_dir ) = @_; | |||||||||||||||||||||||||||||||
| 209 | 5 | ▶ | unless ( $manifest_dir ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 210 | 4 | $manifest_dir = $self->directory; | |||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||
| 212 | 5 | ▶ | unless ( -d $manifest_dir ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 213 | 0 | oi_error "Cannot read files from MANIFEST in '$manifest_dir': ", | |||||||||||||||||||||||||||||||
| 214 | "the directory is invalid"; | ||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||
| 216 | 5 | my $pwd = cwd(); | |||||||||||||||||||||||||||||||
| 217 | 5 | chdir( $manifest_dir ); | |||||||||||||||||||||||||||||||
| 218 | 5 | my $file_map = ExtUtils::Manifest::maniread; | |||||||||||||||||||||||||||||||
| 219 | 5 | chdir( $pwd ); | |||||||||||||||||||||||||||||||
| 220 | 5 | return [ sort keys %{ $file_map } ]; | |||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||
| 224 | ######################################## | ||||||||||||||||||||||||||||||||
| 225 | # FILES/FILE SPECS | ||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||
| 227 | 2 | ▶ | sub get_module_files { | ||||||||||||||||||||||||||||||
|
Subroutine
get_module_files: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 228 | 2 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 229 | 2 | my $files = $self->get_files; | |||||||||||||||||||||||||||||||
| 230 | 2 | my @module_files = grep /\.pm/, @{ $files }; | |||||||||||||||||||||||||||||||
| 231 | 2 | my @module_specs = (); | |||||||||||||||||||||||||||||||
| 232 | 2 | foreach my $module_file ( @module_files ) { | |||||||||||||||||||||||||||||||
| 233 | 4 | my ( $vol, $dirs, $file ) = splitpath( $module_file ); | |||||||||||||||||||||||||||||||
| 234 | 4 | my @spec = splitdir( $dirs ); | |||||||||||||||||||||||||||||||
| 235 | 4 | pop @spec; | |||||||||||||||||||||||||||||||
| 236 | 4 | push @spec, $file; | |||||||||||||||||||||||||||||||
| 237 | 4 | push @module_specs, \@spec; | |||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||
| 239 | 2 | return \@module_specs; | |||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||
| 242 | 2 | ▶ | sub get_spops_files { | ||||||||||||||||||||||||||||||
|
Subroutine
get_spops_files: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 243 | 2 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 244 | 2 | my $base_files = $self->config->get_spops_files; | |||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||
| 246 | # If none returned, try to find our own | ||||||||||||||||||||||||||||||||
| 247 | 2 | ▶ | unless ( scalar @{ $base_files } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 248 | 2 | my $files = $self->get_files; | |||||||||||||||||||||||||||||||
| 249 | 2 | $base_files = [ grep { m|^conf/spops.*\.ini$| } @{ $files } ]; | |||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||
| 251 | 2 | my @spops_files = (); | |||||||||||||||||||||||||||||||
| 252 | 2 | ▶ | if ( my $rep = $self->repository ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 253 | 0 | my $dir = catdir( $rep->website_dir, 'conf', $self->name ); | |||||||||||||||||||||||||||||||
| 254 | 0 | @spops_files = map { s|^conf/||; catfile( $dir, $_ ) } @{ $base_files }; | |||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||
| 256 | else { | ||||||||||||||||||||||||||||||||
| 257 | 2 | my $dir = $self->directory; | |||||||||||||||||||||||||||||||
| 258 | 2 | @spops_files = map { catfile( $dir, $_ ) } @{ $base_files }; | |||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||
| 260 | 2 | $self->_check_file_validity( 'SPOPS configuration', \@spops_files ); | |||||||||||||||||||||||||||||||
| 261 | return \@spops_files | ||||||||||||||||||||||||||||||||
| 262 | 2 | } | |||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||
| 264 | 2 | ▶ | sub get_action_files { | ||||||||||||||||||||||||||||||
|
Subroutine
get_action_files: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 265 | 2 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 266 | 2 | my $base_files = $self->config->get_action_files; | |||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||
| 268 | # If none returned, try to find our own | ||||||||||||||||||||||||||||||||
| 269 | 2 | ▶ | unless ( scalar @{ $base_files } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 270 | 2 | my $files = $self->get_files; | |||||||||||||||||||||||||||||||
| 271 | $base_files = [ | ||||||||||||||||||||||||||||||||
| 272 | 2 | grep { m|^conf/action.*\.ini$| } @{ $files } | |||||||||||||||||||||||||||||||
| 273 | ]; | ||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||
| 275 | 2 | my @action_files = (); | |||||||||||||||||||||||||||||||
| 276 | 2 | ▶ | if ( my $rep = $self->repository ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 277 | 0 | my $dir = catdir( $rep->website_dir, 'conf', $self->name ); | |||||||||||||||||||||||||||||||
| 278 | 0 | @action_files = map { s|^conf/||; catfile( $dir, $_ ) } @{ $base_files }; | |||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||
| 280 | else { | ||||||||||||||||||||||||||||||||
| 281 | 2 | my $dir = $self->directory; | |||||||||||||||||||||||||||||||
| 282 | 2 | @action_files = map { catfile( $dir, $_ ) } @{ $base_files }; | |||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||
| 284 | 2 | $self->_check_file_validity( 'action configuration', \@action_files ); | |||||||||||||||||||||||||||||||
| 285 | 2 | return \@action_files; | |||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | 6 | ▶ | sub get_message_files { | ||||||||||||||||||||||||||||||
|
Subroutine
get_message_files: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 289 | 6 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 290 | 6 | my $base_files = $self->config->get_message_files; | |||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | # If none returned, try to find our own | ||||||||||||||||||||||||||||||||
| 293 | 6 | ▶ | unless ( scalar @{ $base_files } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 294 | 6 | my $files = $self->get_files; | |||||||||||||||||||||||||||||||
| 295 | 6 | $base_files = [ grep /^msg\/.*\.(mo|po|msg)$/, @{ $files } ]; | |||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||
| 297 | 6 | my $dir = $self->directory; | |||||||||||||||||||||||||||||||
| 298 | 0 | my @full_message_files = map { catfile( $dir, $_ ) } @{ $base_files }; | |||||||||||||||||||||||||||||||
| 299 | 6 | $self->_check_file_validity( 'localization file', \@full_message_files ); | |||||||||||||||||||||||||||||||
| 300 | 6 | return \@full_message_files; | |||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||
| 303 | 10 | ▶ | sub _check_file_validity { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_file_validity: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||
| 304 | 10 | my ( $self, $type, $files ) = @_; | |||||||||||||||||||||||||||||||
| 305 | 10 | foreach my $file ( @{ $files } ) { | |||||||||||||||||||||||||||||||
| 306 | 4 | ▶ | unless ( -f $file ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 307 | 0 | oi_error "Package $type returned '$file', an invalid file."; | |||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||
| 312 | ######################################## | ||||||||||||||||||||||||||||||||
| 313 | # INSTALL PACKAGE (CLASS) | ||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub install { | ||||||||||||||||||||||||||||||
|
Subroutine
install: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 316 | 0 | my ( $class, $params ) = @_; | |||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | $log ||= get_logger( LOG_OI ); | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2")
MC/DC0%0/2
$log ||= get_logger("OI2")
$log
get_logger("OI2")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2")
| |||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||
| 319 | 0 | my $repository = $class->_install_get_repository( $params ); | |||||||||||||||||||||||||||||||
| 320 | 0 | my $package_file = rel2abs( $params->{package_file} ); | |||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | unless ( -f $package_file ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 322 | 0 | oi_error "Valid package file must be specified in 'package_file'"; | |||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||
| 324 | $log->is_debug && | ||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | $log->debug( "Install info - [File: $package_file] ", | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 326 | "[Website dir: ", $repository->website_dir, "]" ); | ||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||
| 328 | 0 | my $pwd = cwd(); | |||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||
| 330 | # This should unpack the package into a temp dir, and deleting the | ||||||||||||||||||||||||||||||||
| 331 | # object (at the end of the method) should run DESTROY which | ||||||||||||||||||||||||||||||||
| 332 | # clears out that temp dir | ||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||
| 334 | 0 | my $tmp_package = $class->new({ package_file => $package_file }); | |||||||||||||||||||||||||||||||
| 335 | 0 | my $tmp_config = $tmp_package->config; | |||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||
| 337 | 0 | my $name = $tmp_config->name; | |||||||||||||||||||||||||||||||
| 338 | 0 | my $version = $tmp_config->version; | |||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | unless ( $name and $version ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name and $version
MC/DC0%0/2
$name and $version
$name
$version
Truth table0%0/3
A and B
A= $nameB= $version
| |||||||||||||||||||||||||||||||||
| 340 | 0 | oi_error "Package configuration not read or seems to be in ", | |||||||||||||||||||||||||||||||
| 341 | "error [Name: $name] [Version: $version]"; | ||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||
| 344 | 0 | $class->_install_check_modules( $tmp_config ); | |||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||
| 346 | 0 | my $full_package_dir = | |||||||||||||||||||||||||||||||
| 347 | $class->_install_check_dest_dir( $tmp_config, $repository ); | ||||||||||||||||||||||||||||||||
| 348 | 0 | chdir( $repository->full_package_dir ); | |||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||
| 350 | # Unarchive the package into the current directory; this will | ||||||||||||||||||||||||||||||||
| 351 | # create the directory name-version/ | ||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||
| 353 | 0 | eval { $class->_extract_archive( $package_file ) }; | |||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 355 | 0 | chdir( $pwd ); | |||||||||||||||||||||||||||||||
| 356 | 0 | $class->_remove_directory_tree( $full_package_dir ); | |||||||||||||||||||||||||||||||
| 357 | 0 | oi_error "Cannot unpack the distribution into its final ", | |||||||||||||||||||||||||||||||
| 358 | "directory '$full_package_dir': $@"; | ||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||
| 360 | $log->is_info && | ||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | $log->info( "Unpacked package into '$full_package_dir' ok" ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||
| 363 | 0 | my $installed_package = $class->new({ | |||||||||||||||||||||||||||||||
| 364 | directory => $full_package_dir, | ||||||||||||||||||||||||||||||||
| 365 | repository => $repository, | ||||||||||||||||||||||||||||||||
| 366 | }); | ||||||||||||||||||||||||||||||||
| 367 | 0 | $installed_package->installed_date( scalar( localtime ) ); | |||||||||||||||||||||||||||||||
| 368 | 0 | $installed_package->_install_html_and_widget_files_to_website; | |||||||||||||||||||||||||||||||
| 369 | 0 | $installed_package->copy_configuration_to_website(); | |||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | $log->is_info && | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 371 | $log->info( "Copied package files to website ok" ); | ||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||
| 373 | 0 | $repository->add_package( $installed_package ); | |||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | $log->is_info && | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 375 | $log->info( "Saved repository with new package ok." ); | ||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||
| 377 | 0 | undef $tmp_package; | |||||||||||||||||||||||||||||||
| 378 | 0 | chdir( $pwd ); | |||||||||||||||||||||||||||||||
| 379 | 0 | return $installed_package; | |||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | sub copy_configuration_to_website { | ||||||||||||||||||||||||||||||
|
Subroutine
copy_configuration_to_website: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 383 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | return unless ( $self->repository ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 385 | 0 | my $website_dir = $self->repository->website_dir; | |||||||||||||||||||||||||||||||
| 386 | 0 | my $package_dir = rel2abs( $self->directory ); | |||||||||||||||||||||||||||||||
| 387 | 0 | my $dest_conf_dir = catdir( $website_dir, 'conf', $self->name ); | |||||||||||||||||||||||||||||||
| 388 | 0 | my $dest_update_dir = catdir( $dest_conf_dir, 'updates' ); | |||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | mkpath( $dest_conf_dir ) unless ( -d $dest_conf_dir ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||
| 392 | 0 | my @conf_files = grep /^conf/, @{ $self->get_files }; | |||||||||||||||||||||||||||||||
| 393 | 0 | my @to_checksum = (); | |||||||||||||||||||||||||||||||
| 394 | 0 | my %checksums = $self->_read_conf_checksums( $dest_conf_dir ); | |||||||||||||||||||||||||||||||
| 395 | FILE: | ||||||||||||||||||||||||||||||||
| 396 | 0 | foreach my $src_base ( @conf_files ) { | |||||||||||||||||||||||||||||||
| 397 | 0 | my $src_path = catfile( $package_dir, $src_base ); | |||||||||||||||||||||||||||||||
| 398 | 0 | my $filename = basename( $src_path ); | |||||||||||||||||||||||||||||||
| 399 | 0 | my $dest_path = catfile( $dest_conf_dir, $filename ); | |||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | if ( -f $dest_path ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 401 | 0 | my $md5 = OpenInteract2::Util->digest_file( $src_path ); | |||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | next FILE if ( $checksums{ $filename } eq $md5 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 403 | 0 | my $update_path = | |||||||||||||||||||||||||||||||
| 404 | catfile( $dest_update_dir, $filename . '-' . $self->version ); | ||||||||||||||||||||||||||||||||
| 405 | 0 | $self->_create_full_path( $update_path ); | |||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | cp( $src_path, $update_path ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 407 | || oi_error "Cannot copy $src_path -> $update_path: $!"; | ||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||
| 409 | else { | ||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | cp( $src_path, $dest_path ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 411 | || oi_error "Cannot copy $src_path -> $dest_path: $!"; | ||||||||||||||||||||||||||||||||
| 412 | 0 | push @to_checksum, $filename; | |||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||
| 415 | 0 | $self->_write_conf_checksums( $dest_conf_dir, @to_checksum ); | |||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||
| 418 | ######################################## | ||||||||||||||||||||||||||||||||
| 419 | # PACKAGE SKELETON (CLASS) | ||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||
| 421 | # Creates a package directories using our base subdirectories | ||||||||||||||||||||||||||||||||
| 422 | # along with a package.ini file and some other goodies (?) | ||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||
| 424 | # Currently we're taking the strategy that exceptions from the action | ||||||||||||||||||||||||||||||||
| 425 | # subroutines will bubble up to the caller | ||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||
| 427 | 8 | ▶ | sub create_skeleton { | ||||||||||||||||||||||||||||||
|
Subroutine
create_skeleton: called CC=6 SCAR=18.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 428 | 8 | my ( $class, $params ) = @_; | |||||||||||||||||||||||||||||||
| 429 | 8 | my $name = $params->{name}; | |||||||||||||||||||||||||||||||
| 430 | 8 | ▶ | unless ( $name ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 431 | 1 | oi_error "Must pass in package name to create in 'name'"; | |||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | # dies on failure | ||||||||||||||||||||||||||||||||
| 435 | 7 | $name = $class->_skel_clean_package_name( $name ); | |||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||
| 437 | # Ensure the package dir doesn't already exist | ||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||
| 439 | 2 | my $full_skeleton_dir = rel2abs( $name ); | |||||||||||||||||||||||||||||||
| 440 | 2 | ▶ | if ( -d $full_skeleton_dir ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 441 | 1 | oi_error "Cannot create package destination directory ", | |||||||||||||||||||||||||||||||
| 442 | "'$full_skeleton_dir' already exists"; | ||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||
| 445 | 1 | ▶ | eval { mkdir( $full_skeleton_dir, 0777 ) || die $! }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 446 | 1 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 447 | 0 | oi_error "Failed to create package directory ", | |||||||||||||||||||||||||||||||
| 448 | "'$full_skeleton_dir': $@"; | ||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||
| 451 | 1 | eval { | |||||||||||||||||||||||||||||||
| 452 | 1 | $class->_skel_create_subdirectories( $full_skeleton_dir ); | |||||||||||||||||||||||||||||||
| 453 | $class->_skel_copy_resources( | ||||||||||||||||||||||||||||||||
| 454 | $name, $full_skeleton_dir, | ||||||||||||||||||||||||||||||||
| 455 | $params->{brick_name}, $params->{brick_vars} | ||||||||||||||||||||||||||||||||
| 456 | 1 | ); | |||||||||||||||||||||||||||||||
| 457 | 1 | $class->_skel_create_changelog( | |||||||||||||||||||||||||||||||
| 458 | $name, $full_skeleton_dir, 'Changes' ); | ||||||||||||||||||||||||||||||||
| 459 | 1 | $class->_skel_create_manifest( $full_skeleton_dir ); | |||||||||||||||||||||||||||||||
| 460 | }; | ||||||||||||||||||||||||||||||||
| 461 | 1 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 462 | 0 | my $error = $@; | |||||||||||||||||||||||||||||||
| 463 | 0 | $class->_remove_directory_tree( $full_skeleton_dir ); | |||||||||||||||||||||||||||||||
| 464 | 0 | oi_error $error; | |||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||
| 466 | 1 | my $created_package = $class->new({ directory => $full_skeleton_dir }); | |||||||||||||||||||||||||||||||
| 467 | 1 | return $created_package; | |||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||
| 472 | ######################################## | ||||||||||||||||||||||||||||||||
| 473 | # EXPORT PACKAGE | ||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||
| 475 | # Dump the package from its directory into a .zip distribution file | ||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||
| 477 | 7 | ▶ | sub export { | ||||||||||||||||||||||||||||||
|
Subroutine
export: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 478 | 7 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 479 | 7 | ▶ | unless ( $self->directory and -d $self->directory ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->directory and -d $self->directory
MC/DC50%1/2
$self->directory and -d $self->directory
$self->directory
-d $self->directory
Truth table66%2/3
A and B
A= $self->directoryB= -d $self->directory
| |||||||||||||||||||||||||||||||||
| 480 | 1 | oi_error "Package must have valid directory set for 'export'"; | |||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||
| 482 | 6 | $self->config->check_required_fields; | |||||||||||||||||||||||||||||||
| 483 | 5 | $self->_export_check_manifest; | |||||||||||||||||||||||||||||||
| 484 | 4 | return $self->_export_archive_package; | |||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||
| 488 | ######################################## | ||||||||||||||||||||||||||||||||
| 489 | # COPY PACKAGE FILES | ||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | sub copy_contents_to { | ||||||||||||||||||||||||||||||
|
Subroutine
copy_contents_to: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 492 | 0 | my ( $self, $dest_dir ) = @_; | |||||||||||||||||||||||||||||||
| 493 | 0 | my $src_dir = $self->directory; | |||||||||||||||||||||||||||||||
| 494 | 0 | my @copied = (); | |||||||||||||||||||||||||||||||
| 495 | 0 | my @same = (); | |||||||||||||||||||||||||||||||
| 496 | 0 | foreach my $file ( @{ $self->get_files } ) { | |||||||||||||||||||||||||||||||
| 497 | 0 | my $src_path = catfile( $src_dir, $file ); | |||||||||||||||||||||||||||||||
| 498 | 0 | my $dest_path = catfile( $dest_dir, $file ); | |||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if ( OpenInteract2::Util->is_same_file( $src_path, $dest_path ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 500 | 0 | push @same, $file; | |||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||
| 502 | else { | ||||||||||||||||||||||||||||||||
| 503 | 0 | $self->_create_full_path( $dest_path ); | |||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | cp( $src_path, $dest_path ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 505 | || oi_error "Cannot copy '$src_path' -> '$dest_path': $!"; | ||||||||||||||||||||||||||||||||
| 506 | 0 | push @copied, $file; | |||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||
| 509 | return { | ||||||||||||||||||||||||||||||||
| 510 | 0 | copied => \@copied, | |||||||||||||||||||||||||||||||
| 511 | same => \@same, | ||||||||||||||||||||||||||||||||
| 512 | }; | ||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||
| 516 | ######################################## | ||||||||||||||||||||||||||||||||
| 517 | # CHECK PACKAGE | ||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||
| 519 | 7 | ▶ | sub check { | ||||||||||||||||||||||||||||||
|
Subroutine
check: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 520 | 7 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 521 | 7 | ▶ | unless ( $self->directory and -d $self->directory ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->directory and -d $self->directory
MC/DC50%1/2
$self->directory and -d $self->directory
$self->directory
-d $self->directory
Truth table66%2/3
A and B
A= $self->directoryB= -d $self->directory
| |||||||||||||||||||||||||||||||||
| 522 | 1 | oi_error "Package must have valid directory set for 'check'"; | |||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||
| 524 | 6 | my $pwd = cwd(); | |||||||||||||||||||||||||||||||
| 525 | 6 | chdir( $self->directory ); | |||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||
| 527 | 6 | my @status = (); | |||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||
| 529 | # This is just a warning... | ||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||
| 531 | 6 | ▶ | my $changes_msg = ( -f 'Changes' ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 532 | ? 'Package changelog (Changes) exists' | ||||||||||||||||||||||||||||||||
| 533 | : 'Package changelog (Changes) DOES NOT EXIST. ' . | ||||||||||||||||||||||||||||||||
| 534 | 'People should know about your changes.'; | ||||||||||||||||||||||||||||||||
| 535 | 6 | push @status, { is_ok => 'yes', | |||||||||||||||||||||||||||||||
| 536 | action => 'Changelog check', | ||||||||||||||||||||||||||||||||
| 537 | filename => 'Changes', | ||||||||||||||||||||||||||||||||
| 538 | message => $changes_msg }; | ||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||
| 540 | 6 | my $pkg_files = $self->get_files; | |||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||
| 542 | 6 | push @status, $self->_check_manifest; | |||||||||||||||||||||||||||||||
| 543 | 6 | my ( $c_required, $c_modules ) = $self->_check_package_config; | |||||||||||||||||||||||||||||||
| 544 | 6 | push @status, $c_required, $c_modules; | |||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||
| 546 | 6 | my @ini_files = grep /^conf.*\.ini$/, @{ $pkg_files }; | |||||||||||||||||||||||||||||||
| 547 | 6 | push @status, $self->_check_ini_files( \@ini_files ); | |||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||
| 549 | 6 | ▶ | if ( $c_modules->{is_ok} eq 'no' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 550 | 0 | push @status, { | |||||||||||||||||||||||||||||||
| 551 | action => 'Check package modules', | ||||||||||||||||||||||||||||||||
| 552 | is_ok => 'no', | ||||||||||||||||||||||||||||||||
| 553 | message => 'Skipped module checks since dependencies failed', | ||||||||||||||||||||||||||||||||
| 554 | }; | ||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||
| 556 | else { | ||||||||||||||||||||||||||||||||
| 557 | 6 | my @pm_files = grep /\.pm$/, @{ $pkg_files }; | |||||||||||||||||||||||||||||||
| 558 | 6 | push @status, $self->_check_pm_files( \@pm_files ); | |||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||
| 561 | 6 | my @data_files = grep /^data\/.*\.dat$/, @{ $pkg_files }; | |||||||||||||||||||||||||||||||
| 562 | 6 | push @status, $self->_check_data_files( \@data_files ); | |||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||
| 564 | 6 | my @template_files = grep /^(template\/.*\.tmpl|widget)/, @{ $pkg_files }; | |||||||||||||||||||||||||||||||
| 565 | 6 | push @status, $self->_check_templates( \@template_files ); | |||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||
| 567 | 6 | my $message_files = $self->get_message_files; | |||||||||||||||||||||||||||||||
| 568 | 6 | push @status, $self->_check_message_files( $message_files ); | |||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||
| 570 | 6 | chdir( $pwd ); | |||||||||||||||||||||||||||||||
| 571 | 6 | return @status; | |||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||
| 575 | ######################################## | ||||||||||||||||||||||||||||||||
| 576 | # REMOVE PACKAGE | ||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||
| 578 | # Removes package from repository. Errors should bubble up | ||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | sub remove { | ||||||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 581 | 0 | my ( $self, $repository ) = @_; | |||||||||||||||||||||||||||||||
| 582 | 0 | my ( $status ); | |||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | $repository ||= $self->repository; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$repository ||= $self->repository
MC/DC0%0/2
$repository ||= $self->repository
$repository
$self->repository
Truth table0%0/3
A ||= B
A= $repositoryB= $self->repository
| |||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | if ( $repository ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 585 | 0 | eval { $repository->remove_package( $self ) }; | |||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 587 | 0 | $status = "FAILED: $@"; | |||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||
| 589 | else { | ||||||||||||||||||||||||||||||||
| 590 | 0 | $status = 'ok'; | |||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||
| 593 | else { | ||||||||||||||||||||||||||||||||
| 594 | 0 | $status = 'No repository set in package object, so the package ' . | |||||||||||||||||||||||||||||||
| 595 | 'could not be removed from the repository.'; | ||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||
| 597 | 0 | return { action => 'Remove Package', | |||||||||||||||||||||||||||||||
| 598 | message => $status }; | ||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||
| 602 | ######################################## | ||||||||||||||||||||||||||||||||
| 603 | # FILE/DIR UTILS | ||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | sub generate_distribution_digest { | ||||||||||||||||||||||||||||||
|
Subroutine
generate_distribution_digest: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 606 | 0 | my ( $class, $package_file ) = @_; | |||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | unless ( -f $package_file ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 608 | 0 | oi_error "Cannot generate digest: file '$package_file' invalid"; | |||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||
| 610 | 0 | return OpenInteract2::Util->digest_file( $package_file ); | |||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||
| 613 | # Find a file that exists in either the website directory or the base | ||||||||||||||||||||||||||||||||
| 614 | # installation directory. @file_list defines a number of choices | ||||||||||||||||||||||||||||||||
| 615 | # available for the file to be named. | ||||||||||||||||||||||||||||||||
| 616 | # | ||||||||||||||||||||||||||||||||
| 617 | # Returns: the full path and filename of the first match | ||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | sub find_file { | ||||||||||||||||||||||||||||||
|
Subroutine
find_file: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 620 | 0 | my ( $self, @file_list ) = @_; | |||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | return undef unless ( scalar @file_list ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 622 | 0 | foreach my $base_file ( @file_list ) { | |||||||||||||||||||||||||||||||
| 623 | 0 | my $filename = catfile( $self->directory, $base_file ); | |||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | return $filename if ( -f $filename ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||
| 626 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||
| 630 | # Slurps the $relative_filename into a variable and returns it | ||||||||||||||||||||||||||||||||
| 631 | # TODO: Used? | ||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | sub read_file { | ||||||||||||||||||||||||||||||
|
Subroutine
read_file: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 634 | 0 | my ( $self, $relative_filename ) = @_; | |||||||||||||||||||||||||||||||
| 635 | 0 | my $full_file = $self->find_file( $relative_filename ); | |||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | return undef unless ( $full_file ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | open( IN, '<', $full_file ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 638 | || oi_error "Cannot read '$full_file': $!"; | ||||||||||||||||||||||||||||||||
| 639 | 0 | my @content = <IN>; | |||||||||||||||||||||||||||||||
| 640 | 0 | close( IN ); | |||||||||||||||||||||||||||||||
| 641 | 0 | return join( '', @content ); | |||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||
| 645 | # auxiliary routine to create necessary directories for a file, given | ||||||||||||||||||||||||||||||||
| 646 | # the file; die on error, otherwise return a true value | ||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | sub _create_full_path { | ||||||||||||||||||||||||||||||
|
Subroutine
_create_full_path: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 649 | 0 | my ( $class, $filename ) = @_; | |||||||||||||||||||||||||||||||
| 650 | 0 | my $dirname = dirname( $filename ); | |||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | return 1 if ( -d $dirname ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||
| 653 | # NOTE: At least on 5.6.1, File::Path automatically dies when the | ||||||||||||||||||||||||||||||||
| 654 | # operation fails -- you don't need '|| die $!' | ||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||
| 656 | 0 | mkpath( $dirname, undef, 0755 ); | |||||||||||||||||||||||||||||||
| 657 | 0 | return 1; | |||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||
| 662 | # Remove a directory and all files/directories beneath it. Return the | ||||||||||||||||||||||||||||||||
| 663 | # number of removed files. | ||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||
| 665 | 4 | ▶ | sub _remove_directory_tree { | ||||||||||||||||||||||||||||||
|
Subroutine
_remove_directory_tree: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 666 | 4 | my ( $class, $dir ) = @_; | |||||||||||||||||||||||||||||||
| 667 | 4 | return File::Path::rmtree( $dir, undef, undef ); | |||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||
| 671 | ######################################## | ||||||||||||||||||||||||||||||||
| 672 | # INSTALL PACKAGE HELPERS | ||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||
| 674 | # When installing a package, there are files in two (so far) | ||||||||||||||||||||||||||||||||
| 675 | # directories that can be copied up to the main website | ||||||||||||||||||||||||||||||||
| 676 | # directory. Files placed in 'html/' get copied to $WEBSITE_DIR/html | ||||||||||||||||||||||||||||||||
| 677 | # and files in 'widget/' get copied to $WEBSITE_DIR/template. | ||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||
| 679 | # TODO: See note in POD about html files and page objects | ||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | sub _install_get_repository { | ||||||||||||||||||||||||||||||
|
Subroutine
_install_get_repository: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||
| 682 | 0 | my ( $class, $params ) = @_; | |||||||||||||||||||||||||||||||
| 683 | 0 | my ( $repository ); | |||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | if ( $params->{website_dir} and -d $params->{website_dir} ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$params->{"website_dir"} and -d $params->{"website_dir"}
MC/DC0%0/2
$params->{"website_dir"} and -d $params->{"website_dir"}
$params->{"website_dir"}
-d $params->{"website_dir"}
Truth table0%0/3
A and B
A= $params->{"website_dir"}B= -d $params->{"website_dir"}
| |||||||||||||||||||||||||||||||||
| 685 | $repository = OpenInteract2::Repository->new( | ||||||||||||||||||||||||||||||||
| 686 | 0 | { website_dir => $params->{website_dir} }); | |||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||
| 688 | elsif ( $params->{repository} ) { | ||||||||||||||||||||||||||||||||
| 689 | 0 | $repository = $params->{repository}; | |||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | if ( $repository ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 693 | 0 | my $install_dir = $repository->full_package_dir; | |||||||||||||||||||||||||||||||
| 694 | 0 | ▶ | unless ( -d $install_dir ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 695 | 0 | oi_error "Specified installation directory '$install_dir' ", | |||||||||||||||||||||||||||||||
| 696 | "is invalid"; | ||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||
| 699 | else { | ||||||||||||||||||||||||||||||||
| 700 | 0 | oi_error "No 'website_dir' or 'repository' specified -- cannot ", | |||||||||||||||||||||||||||||||
| 701 | "install package to unknown location."; | ||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||
| 703 | 0 | return $repository; | |||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||
| 707 | # See if the package has specified any modules that are necessary for | ||||||||||||||||||||||||||||||||
| 708 | # its operation. For now, we will refuse to install a package that | ||||||||||||||||||||||||||||||||
| 709 | # does not have supporting modules. | ||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | sub _install_check_modules { | ||||||||||||||||||||||||||||||
|
Subroutine
_install_check_modules: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 712 | 0 | my ( $class, $config ) = @_; | |||||||||||||||||||||||||||||||
| 713 | 0 | my $module = $config->module; | |||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | return unless ( ref $module eq 'ARRAY' and scalar @{ $module } ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
ref $module eq "ARRAY" and scalar @{$module;}
MC/DC0%0/1
ref $module eq "ARRAY" and scalar @{$module;}
ref $module eq "ARRAY"
Truth table0%0/2
A
A= ref $module eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 715 | 0 | my @failed_modules = $class->_check_module_install( @{ $module } ); | |||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | return unless ( scalar @failed_modules ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 717 | 0 | oi_error "Package '", $config->name, "' requires the following ", | |||||||||||||||||||||||||||||||
| 718 | "modules that are not currently installed:\n ", | ||||||||||||||||||||||||||||||||
| 719 | join( ', ', @failed_modules ), "\n", | ||||||||||||||||||||||||||||||||
| 720 | "Please install them and then reinstall."; | ||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | sub _install_check_dest_dir { | ||||||||||||||||||||||||||||||
|
Subroutine
_install_check_dest_dir: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 724 | 0 | my ( $class, $config, $repository ) = @_; | |||||||||||||||||||||||||||||||
| 725 | 0 | my $full_package_name = join( '-', $config->name, $config->version ); | |||||||||||||||||||||||||||||||
| 726 | 0 | my $full_package_dir = catfile( $repository->full_package_dir, | |||||||||||||||||||||||||||||||
| 727 | $full_package_name ); | ||||||||||||||||||||||||||||||||
| 728 | 0 | ▶ | if ( -d $full_package_dir ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 729 | 0 | oi_error "The directory into which the distribution should be ", | |||||||||||||||||||||||||||||||
| 730 | "unpacked '$full_package_dir' already exists."; | ||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||
| 732 | 0 | return $full_package_dir; | |||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | sub _install_html_and_widget_files_to_website { | ||||||||||||||||||||||||||||||
|
Subroutine
_install_html_and_widget_files_to_website: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||
| 736 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 737 | 0 | my @pkg_files = @{ $self->get_files }; | |||||||||||||||||||||||||||||||
| 738 | 0 | my %copy_files = (); | |||||||||||||||||||||||||||||||
| 739 | 0 | for ( grep /^html/, @pkg_files ) { | |||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | $log->is_debug && $log->debug( "Will copy HTML '$_' -> '$_'" ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 741 | 0 | $copy_files{ $_ } = $_; | |||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||
| 743 | 0 | foreach my $src ( grep /^widget/, @pkg_files ) { | |||||||||||||||||||||||||||||||
| 744 | 0 | my $dest = $src; | |||||||||||||||||||||||||||||||
| 745 | 0 | $dest =~ s|^widget|template|; | |||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | $log->is_debug && $log->debug( "Will copy widget '$_' -> '$_'" ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 747 | 0 | $copy_files{ $src } = $dest; | |||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||
| 750 | 0 | my ( @copied ); | |||||||||||||||||||||||||||||||
| 751 | 0 | eval { | |||||||||||||||||||||||||||||||
| 752 | 0 | $self->_install_do_copy_files_to_website( \%copy_files, \@copied ); | |||||||||||||||||||||||||||||||
| 753 | }; | ||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 755 | 0 | $log->error( "Caught error copying files to website: $@" ); | |||||||||||||||||||||||||||||||
| 756 | 0 | foreach my $filename ( @copied ) { | |||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | unlink( $filename ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 758 | || warn "Cannot cleanup '$filename': $!"; | ||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | if ( -f "$filename.backup" ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | rename( "$filename.backup", $filename ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 761 | || warn "Cannot activate backup for '$filename': $!"; | ||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | unlink( "$filename.backup" ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 763 | || warn "Cannot remove stale backup for '$filename': $!"; | ||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||
| 766 | 0 | @copied = (); | |||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||
| 768 | 0 | return @copied; | |||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | sub _install_do_copy_files_to_website { | ||||||||||||||||||||||||||||||
|
Subroutine
_install_do_copy_files_to_website: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||
| 772 | 0 | my ( $self, $copy_files, $track ) = @_; | |||||||||||||||||||||||||||||||
| 773 | 0 | my $website_dir = $self->repository->website_dir; | |||||||||||||||||||||||||||||||
| 774 | 0 | my $package_dir = rel2abs( $self->directory ); | |||||||||||||||||||||||||||||||
| 775 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||
| 777 | BASE_FILE: | ||||||||||||||||||||||||||||||||
| 778 | 0 | ▶ | while ( my ( $src_base, $dest_base ) = each %{ $copy_files } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 779 | 0 | my $src_path = catfile( $package_dir, $src_base ); | |||||||||||||||||||||||||||||||
| 780 | 0 | my $dest_path = catfile( $website_dir, $dest_base ); | |||||||||||||||||||||||||||||||
| 781 | 0 | my $dest_dir = dirname( $dest_path ); | |||||||||||||||||||||||||||||||
| 782 | 0 | $self->_create_full_path( $dest_path ); | |||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||
| 784 | 0 | ▶ | if ( -f $dest_path ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 785 | 0 | my $dest_file = basename( $dest_path ); | |||||||||||||||||||||||||||||||
| 786 | 0 | my $dest_dir = dirname( $dest_path ); | |||||||||||||||||||||||||||||||
| 787 | 0 | my $ro = OpenInteract2::Config::Readonly->new( $dest_dir ); | |||||||||||||||||||||||||||||||
| 788 | 0 | ▶ | unless ( $ro->is_writeable( $dest_file ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | $log->is_info | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 790 | && $log->info( "Skipping '$dest_path' because it's marked as readonly" ); | ||||||||||||||||||||||||||||||||
| 791 | 0 | next BASE_FILE; | |||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||
| 793 | 0 | ▶ | rename( $dest_path, "$dest_path.backup" ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 794 | || die "Cannot backup '$dest_path': $!\n"; | ||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||
| 796 | $log->is_debug && | ||||||||||||||||||||||||||||||||
| 797 | 0 | ▶ | $log->debug( "Copying '$src_path' -> '$dest_path'" ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 798 | 0 | $self->_create_full_path( $dest_path ); | |||||||||||||||||||||||||||||||
| 799 | 0 | ▶ | cp( $src_path, $dest_path ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 800 | || die "Cannot copy '$src_path' -> '$dest_path': $!\n"; | ||||||||||||||||||||||||||||||||
| 801 | 0 | chmod( 0666, $dest_path ); # let umask work... | |||||||||||||||||||||||||||||||
| 802 | 0 | push @{ $track }, $dest_path; | |||||||||||||||||||||||||||||||
| 803 | 0 | $count++; | |||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||
| 807 | 0 | ▶ | sub _read_conf_checksums { | ||||||||||||||||||||||||||||||
|
Subroutine
_read_conf_checksums: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||
| 808 | 0 | my ( $self, $conf_dir ) = @_; | |||||||||||||||||||||||||||||||
| 809 | 0 | my $checksum_file = catfile( $conf_dir, 'CHECKSUMS' ); | |||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | return () unless ( -f $checksum_file ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | open( CSUM, '<', $checksum_file ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 812 | || oi_error "Cannot read from $checksum_file: $!"; | ||||||||||||||||||||||||||||||||
| 813 | 0 | my %sums = (); | |||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | while ( <CSUM> ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 815 | 0 | chomp; | |||||||||||||||||||||||||||||||
| 816 | 0 | ▶ | next if ( /^#/ or /^\s*$/ ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
/^#/ or /^\s*$/
MC/DC0%0/2
/^#/ or /^\s*$/
/^#/
/^\s*$/
Truth table0%0/3
A or B
A= /^#/B= /^\s*$/
| |||||||||||||||||||||||||||||||||
| 817 | 0 | my ( $md5, $file ) = split /\s+/, $_, 2; | |||||||||||||||||||||||||||||||
| 818 | 0 | $sums{ $file } = $md5; | |||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||
| 820 | 0 | close( CSUM ); | |||||||||||||||||||||||||||||||
| 821 | 0 | return %sums; | |||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | sub _write_conf_checksums { | ||||||||||||||||||||||||||||||
|
Subroutine
_write_conf_checksums: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||
| 825 | 0 | my ( $self, $conf_dir, @files ) = @_; | |||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | return unless ( scalar @files ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 827 | 0 | my $checksum_file = catfile( $conf_dir, 'CHECKSUMS' ); | |||||||||||||||||||||||||||||||
| 828 | 0 | ▶ | my $oper = ( -f $checksum_file ) ? '>>' : '>'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 829 | 0 | ▶ | open( CSUM, $oper, $checksum_file ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 830 | || oi_error "Cannot write to $checksum_file: $!"; | ||||||||||||||||||||||||||||||||
| 831 | 0 | foreach my $file ( @files ) { | |||||||||||||||||||||||||||||||
| 832 | 0 | my $md5 = OpenInteract2::Util->digest_file( catfile( $conf_dir, $file ) ); | |||||||||||||||||||||||||||||||
| 833 | 0 | print CSUM "$md5 $file\n"; | |||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||
| 835 | 0 | close( CSUM ); | |||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||
| 839 | ######################################## | ||||||||||||||||||||||||||||||||
| 840 | # PACKAGE SKELETON HELPERS | ||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||
| 842 | # Ensure a package name is ok and that it can be used as a namespace | ||||||||||||||||||||||||||||||||
| 843 | # when necessary. | ||||||||||||||||||||||||||||||||
| 844 | # - Package name cannot be blank (empty and/or all spaces) | ||||||||||||||||||||||||||||||||
| 845 | # - Package name cannot have spaces (s/ /_/) | ||||||||||||||||||||||||||||||||
| 846 | # - Package name cannot have dashes (s/-/_/) | ||||||||||||||||||||||||||||||||
| 847 | # - Package name cannot start with a number (die) | ||||||||||||||||||||||||||||||||
| 848 | # - Package name cannot have nonword characters except '_' | ||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||
| 850 | 7 | ▶ | sub _skel_clean_package_name { | ||||||||||||||||||||||||||||||
|
Subroutine
_skel_clean_package_name: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||
| 851 | 7 | my ( $class, $name ) = @_; | |||||||||||||||||||||||||||||||
| 852 | 7 | my ( @failures ); | |||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||
| 854 | 7 | ▶ | $name =~ /^\s*$/ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 855 | && push @failures, "Name must not be blank"; | ||||||||||||||||||||||||||||||||
| 856 | 7 | ▶ | $name =~ s/ /_/g | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 857 | && push @failures, "Name must not have spaces"; | ||||||||||||||||||||||||||||||||
| 858 | 7 | ▶ | $name =~ s/\-/_/g | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 859 | && push @failures, "Name must not have dashes"; | ||||||||||||||||||||||||||||||||
| 860 | 7 | ▶ | $name =~ /^\d/ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 861 | && push @failures, "Name must not start with a number"; | ||||||||||||||||||||||||||||||||
| 862 | 7 | ▶ | $name =~ /\W/ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 863 | && push @failures, "Name must not have non-word characters"; | ||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||
| 865 | 7 | ▶ | if ( scalar @failures ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 866 | 5 | oi_error "Package name '$name' unacceptable: \n", | |||||||||||||||||||||||||||||||
| 867 | join( "\n", @failures ), "\n"; | ||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||
| 869 | 2 | return $name; | |||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||
| 872 | # Create subdirectories within a package | ||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||
| 874 | 1 | ▶ | sub _skel_create_subdirectories { | ||||||||||||||||||||||||||||||
|
Subroutine
_skel_create_subdirectories: called CC=5 SCAR=19.9
| |||||||||||||||||||||||||||||||||
| 875 | 1 | my ( $class, $base_dir ) = @_; | |||||||||||||||||||||||||||||||
| 876 | 1 | my @to_create = map { catdir( $base_dir, $_ ) } @PKG_SUBDIR; | |||||||||||||||||||||||||||||||
| 877 | 1 | ▶ | for ( my $i = 0; $i < scalar @to_create; $i++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 878 | 11 | ▶ | eval { mkdir( $to_create[ $i ], 0777 ) || die $! }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||
| 880 | # If we fail, see if we can cleanup our mess | ||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||
| 882 | 11 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 883 | 0 | my $error = $@; | |||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | for ( my $j = 0; $j < $i; $j++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 885 | 0 | eval { | |||||||||||||||||||||||||||||||
| 886 | 0 | $class->_remove_directory_tree( $to_create[ $j ] ) | |||||||||||||||||||||||||||||||
| 887 | }; | ||||||||||||||||||||||||||||||||
| 888 | 0 | warn "In process of cleaning up after failure, also ", | |||||||||||||||||||||||||||||||
| 889 | "failed to remove directory '$to_create[$j]': $@"; | ||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||
| 891 | 0 | oi_error "Failed to package subdirectory ", | |||||||||||||||||||||||||||||||
| 892 | "'$to_create[ $i ]': $error"; | ||||||||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||
| 895 | 1 | return \@to_create; | |||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||
| 899 | # Copies over all resources from the 'package' brick; you can also | ||||||||||||||||||||||||||||||||
| 900 | # specify your own brick and pass in any extra variables you want to | ||||||||||||||||||||||||||||||||
| 901 | # replace. | ||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||
| 903 | 1 | ▶ | sub _skel_copy_resources { | ||||||||||||||||||||||||||||||
|
Subroutine
_skel_copy_resources: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||
| 904 | 1 | my ( $class, $name, $dest_dir, $brick_name, $brick_vars ) = @_; | |||||||||||||||||||||||||||||||
| 905 | 1 | require OpenInteract2::Brick; | |||||||||||||||||||||||||||||||
| 906 | 1 | ▶ | $brick_name ||= 'package'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$brick_name ||= "package"
MC/DC0%0/1
$brick_name ||= "package"
$brick_name
Truth table50%1/2
A
A= $brick_name
| |||||||||||||||||||||||||||||||||
| 907 | 1 | ▶ | $brick_vars ||= {}; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$brick_vars ||= {}
MC/DC0%0/1
$brick_vars ||= {}
$brick_vars
Truth table50%1/2
A
A= $brick_vars
| |||||||||||||||||||||||||||||||||
| 908 | 1 | my $brick = OpenInteract2::Brick->new( $brick_name ); | |||||||||||||||||||||||||||||||
| 909 | 1 | my $class_name = $class->name_as_class( $name ); | |||||||||||||||||||||||||||||||
| 910 | return $brick->copy_all_resources_to( $dest_dir, { | ||||||||||||||||||||||||||||||||
| 911 | 1 | %{ $brick_vars }, | |||||||||||||||||||||||||||||||
| 912 | package_name => $name, | ||||||||||||||||||||||||||||||||
| 913 | class_name => $class_name, | ||||||||||||||||||||||||||||||||
| 914 | }); | ||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||
| 917 | # Create a 'Changes' file | ||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||
| 919 | 1 | ▶ | sub _skel_create_changelog { | ||||||||||||||||||||||||||||||
|
Subroutine
_skel_create_changelog: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||
| 920 | 1 | my ( $class, $package_name, $package_dir, $filename ) = @_; | |||||||||||||||||||||||||||||||
| 921 | 1 | my $full_filename = catfile( $package_dir, $filename ); | |||||||||||||||||||||||||||||||
| 922 | 1 | ▶ | eval { open( CHANGES, '>', $full_filename ) || die $! }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 923 | 1 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 924 | 0 | oi_error "Cannot create changelog '$filename': $@"; | |||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||
| 926 | 1 | my $time_stamp = scalar localtime; | |||||||||||||||||||||||||||||||
| 927 | 1 | print CHANGES <<INIT; | |||||||||||||||||||||||||||||||
| 928 | Revision history for OpenInteract2 package $package_name. | ||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||
| 930 | 0.01 $time_stamp | ||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||
| 932 | Package skeleton created by OpenInteract2::Package | ||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||
| 934 | INIT | ||||||||||||||||||||||||||||||||
| 935 | 1 | close( CHANGES ); | |||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||
| 938 | # Create a manifest file in the current directory. (Note that the | ||||||||||||||||||||||||||||||||
| 939 | # 'Quiet' and 'Verbose' parameters won't work properly until | ||||||||||||||||||||||||||||||||
| 940 | # ExtUtils::Manifest is patched which won't likely be until 5.6.1) | ||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||
| 942 | 1 | ▶ | sub _skel_create_manifest { | ||||||||||||||||||||||||||||||
|
Subroutine
_skel_create_manifest: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 943 | 1 | my ( $class, $package_dir ) = @_; | |||||||||||||||||||||||||||||||
| 944 | 1 | my $pwd = cwd(); | |||||||||||||||||||||||||||||||
| 945 | 1 | chdir( $package_dir ); | |||||||||||||||||||||||||||||||
| 946 | 0 | ▶ | local $SIG{__WARN__} = sub { return undef }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||
| 947 | 1 | $ExtUtils::Manifest::Quiet = 1; | |||||||||||||||||||||||||||||||
| 948 | 1 | $ExtUtils::Manifest::Verbose = 0; | |||||||||||||||||||||||||||||||
| 949 | 1 | ExtUtils::Manifest::mkmanifest(); | |||||||||||||||||||||||||||||||
| 950 | 1 | chdir( $pwd ); | |||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||
| 954 | ######################################## | ||||||||||||||||||||||||||||||||
| 955 | # EXPORT PACKAGE HELPERS | ||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||
| 957 | 5 | ▶ | sub _export_check_manifest { | ||||||||||||||||||||||||||||||
|
Subroutine
_export_check_manifest: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 958 | 5 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 959 | 5 | my $pwd = cwd(); | |||||||||||||||||||||||||||||||
| 960 | 5 | chdir( $self->directory ); | |||||||||||||||||||||||||||||||
| 961 | 5 | local $ExtUtils::Manifest::Quiet = 1; | |||||||||||||||||||||||||||||||
| 962 | 5 | my @missing = ExtUtils::Manifest::manicheck(); | |||||||||||||||||||||||||||||||
| 963 | 5 | chdir( $pwd ); | |||||||||||||||||||||||||||||||
| 964 | 5 | ▶ | if ( scalar @missing ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 965 | 1 | oi_error "Files in MANIFEST not found in package: ", | |||||||||||||||||||||||||||||||
| 966 | join( ', ', @missing ); | ||||||||||||||||||||||||||||||||
| 967 | } | ||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||
| 971 | # Create a directory, copy package files to it, zip up the directory | ||||||||||||||||||||||||||||||||
| 972 | # and then remove the directory. Errors should bubble up from routines | ||||||||||||||||||||||||||||||||
| 973 | # we call. | ||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||
| 975 | 4 | ▶ | sub _export_archive_package { | ||||||||||||||||||||||||||||||
|
Subroutine
_export_archive_package: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||
| 976 | 4 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 977 | 4 | my $package_id = $self->full_name; | |||||||||||||||||||||||||||||||
| 978 | 4 | my $export_dir = rel2abs( $package_id ); | |||||||||||||||||||||||||||||||
| 979 | 4 | ▶ | if ( -d $export_dir ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 980 | 1 | oi_error "Directory '$export_dir' already exists. Please ", | |||||||||||||||||||||||||||||||
| 981 | "remove it before exporting package."; | ||||||||||||||||||||||||||||||||
| 982 | } | ||||||||||||||||||||||||||||||||
| 983 | 3 | ▶ | eval { mkdir( $export_dir, 0777 ) || die $! }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 984 | 3 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 985 | 0 | oi_error "Cannot create directory '$export_dir' used to ", | |||||||||||||||||||||||||||||||
| 986 | "archive package: $@"; | ||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||
| 989 | # NOTE: Use the EU::MM utilities for this, even though we have a | ||||||||||||||||||||||||||||||||
| 990 | # 'get_files' method here (manicopy() wants a hashref for the | ||||||||||||||||||||||||||||||||
| 991 | # first argument...) | ||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||
| 993 | 3 | my $pwd = cwd(); | |||||||||||||||||||||||||||||||
| 994 | 3 | chdir( $self->directory ); | |||||||||||||||||||||||||||||||
| 995 | 3 | my $package_files = ExtUtils::Manifest::maniread(); | |||||||||||||||||||||||||||||||
| 996 | 3 | local $ExtUtils::Manifest::Quiet = 1; | |||||||||||||||||||||||||||||||
| 997 | 3 | ExtUtils::Manifest::manicopy( $package_files, $export_dir ); | |||||||||||||||||||||||||||||||
| 998 | 3 | chdir( $pwd ); | |||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||
| 1000 | # NOTE: Don't use File::Spec here, since Archive::Zip expects the | ||||||||||||||||||||||||||||||||
| 1001 | # files to be separated by '/' | ||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||
| 1003 | 3 | my @archive_files = map { "$package_id/$_" } keys %{ $package_files }; | |||||||||||||||||||||||||||||||
| 1004 | 3 | my $filename = eval { | |||||||||||||||||||||||||||||||
| 1005 | 3 | $self->_create_archive( $pwd, $package_id, @archive_files ) | |||||||||||||||||||||||||||||||
| 1006 | }; | ||||||||||||||||||||||||||||||||
| 1007 | 3 | my $error = $@; | |||||||||||||||||||||||||||||||
| 1008 | 3 | eval { | |||||||||||||||||||||||||||||||
| 1009 | 3 | $self->_remove_directory_tree( $export_dir ) | |||||||||||||||||||||||||||||||
| 1010 | }; | ||||||||||||||||||||||||||||||||
| 1011 | 3 | ▶ | oi_error $error if ( $error ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1012 | 2 | return $filename; | |||||||||||||||||||||||||||||||
| 1013 | } | ||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||
| 1016 | ######################################## | ||||||||||||||||||||||||||||||||
| 1017 | # ARCHIVE MANIPULATION | ||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||
| 1019 | # NOTE: We've moved from using Archive::Tar in 1.x to using | ||||||||||||||||||||||||||||||||
| 1020 | # Archive::Zip in 2.x, since the latter is better supported on Win32 | ||||||||||||||||||||||||||||||||
| 1021 | # systems. | ||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||
| 1023 | 3 | ▶ | sub _create_archive { | ||||||||||||||||||||||||||||||
|
Subroutine
_create_archive: called CC=12 SCAR=37.3
| |||||||||||||||||||||||||||||||||
| 1024 | 3 | my ( $self, $dir, $base_filename, @files ) = @_; | |||||||||||||||||||||||||||||||
| 1025 | 3 | ▶ | unless ( -d $dir and $base_filename and scalar @files ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
-d $dir and $base_filename and scalar @files
-d $dir and $base_filename
MC/DC0%0/2
-d $dir and $base_filename and scalar @files
-d $dir
$base_filename
Truth table33%1/3
A and B
A= -d $dirB= $base_filename
| |||||||||||||||||||||||||||||||||
| 1026 | 0 | die "Insufficient parameters to create archive ", | |||||||||||||||||||||||||||||||
| 1027 | "in directory '$dir', file '$base_filename'\n"; | ||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||
| 1030 | 3 | my $zip_filename = catfile( $dir, "$base_filename.zip" ); | |||||||||||||||||||||||||||||||
| 1031 | 3 | ▶ | if ( -f $zip_filename ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1032 | 1 | die "Cannot create ZIP archive: file '$zip_filename' already exists\n"; | |||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||
| 1035 | 2 | my $zip = Archive::Zip->new(); | |||||||||||||||||||||||||||||||
| 1036 | 2 | $zip->addFile( $_ ) for ( @files ); | |||||||||||||||||||||||||||||||
| 1037 | 2 | my $rv = $zip->writeToFileNamed( $zip_filename ); | |||||||||||||||||||||||||||||||
| 1038 | 2 | ▶ | unless ( $rv == AZ_OK ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1039 | 0 | my ( $msg ); | |||||||||||||||||||||||||||||||
| 1040 | 0 | ▶ | $msg = 'The read stream (or central directory) ended normally.' if ( $rv == AZ_STREAM_END ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1041 | 0 | ▶ | $msg = 'There was some generic kind of error.' if ( $rv == AZ_ERROR ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1042 | 0 | ▶ | $msg = 'There is a format error in a ZIP file being read.' if ( $rv == AZ_FORMAT_ERROR ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1043 | 0 | ▶ | $msg = 'There was an IO error.' if ( $rv == AZ_IO_ERROR ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1044 | 0 | ▶ | $msg ||= 'Unknown error'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$msg ||= "Unknown error"
MC/DC0%0/1
$msg ||= "Unknown error"
$msg
Truth table0%0/2
A
A= $msg
| |||||||||||||||||||||||||||||||||
| 1045 | 0 | die "Failed to create ZIP archive '$zip_filename': $msg\n"; | |||||||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||||||
| 1047 | 2 | return $zip_filename; | |||||||||||||||||||||||||||||||
| 1048 | } | ||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||
| 1051 | 1 | ▶ | sub _extract_archive { | ||||||||||||||||||||||||||||||
|
Subroutine
_extract_archive: called CC=10 SCAR=32.5
| |||||||||||||||||||||||||||||||||
| 1052 | 1 | my ( $class, $filename ) = @_; | |||||||||||||||||||||||||||||||
| 1053 | 1 | ▶ | unless ( -f $filename ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1054 | 0 | oi_error "Cannot extract archive from '$filename': invalid file"; | |||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||
| 1056 | 1 | my $zip = Archive::Zip->new( $filename ); | |||||||||||||||||||||||||||||||
| 1057 | 1 | ▶ | unless ( $zip ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1058 | 0 | oi_error "Failed to read ZIP file '$filename'"; | |||||||||||||||||||||||||||||||
| 1059 | } | ||||||||||||||||||||||||||||||||
| 1060 | 1 | my @extracted = (); | |||||||||||||||||||||||||||||||
| 1061 | 1 | my @errors = (); | |||||||||||||||||||||||||||||||
| 1062 | 1 | foreach my $to_extract ( $zip->members() ) { | |||||||||||||||||||||||||||||||
| 1063 | 22 | my $rv = $zip->extractMember( $to_extract ); | |||||||||||||||||||||||||||||||
| 1064 | 22 | my $label = "Error extracting $to_extract"; | |||||||||||||||||||||||||||||||
| 1065 | 22 | ▶ | if ( $rv == AZ_OK ) { | ||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||
| 1066 | 22 | push @extracted, $to_extract; | |||||||||||||||||||||||||||||||
| 1067 | } | ||||||||||||||||||||||||||||||||
| 1068 | elsif ( $rv == AZ_STREAM_END ) { | ||||||||||||||||||||||||||||||||
| 1069 | 0 | push @errors, "$label: read stream or central directory " . | |||||||||||||||||||||||||||||||
| 1070 | "ended normally"; | ||||||||||||||||||||||||||||||||
| 1071 | } | ||||||||||||||||||||||||||||||||
| 1072 | elsif ( $rv == AZ_FORMAT_ERROR ) { | ||||||||||||||||||||||||||||||||
| 1073 | 0 | push @errors, "$label: format error in the ZIP file"; | |||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||
| 1075 | elsif ( $rv == AZ_IO_ERROR ) { | ||||||||||||||||||||||||||||||||
| 1076 | 0 | push @errors, "$label: I/O error"; | |||||||||||||||||||||||||||||||
| 1077 | } | ||||||||||||||||||||||||||||||||
| 1078 | elsif ( $rv == AZ_ERROR ) { | ||||||||||||||||||||||||||||||||
| 1079 | 0 | push @errors, "$label: some generic error"; | |||||||||||||||||||||||||||||||
| 1080 | } | ||||||||||||||||||||||||||||||||
| 1081 | else { | ||||||||||||||||||||||||||||||||
| 1082 | 0 | push @errors, "$label: unknown Archive::Zip error ($rv)"; | |||||||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||||||
| 1084 | } | ||||||||||||||||||||||||||||||||
| 1085 | 1 | ▶ | if ( scalar @errors ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1086 | 0 | oi_error "Errors unzipping files from '$filename':\n - ", | |||||||||||||||||||||||||||||||
| 1087 | join( "\n - ", @errors ); | ||||||||||||||||||||||||||||||||
| 1088 | } | ||||||||||||||||||||||||||||||||
| 1089 | 1 | return \@extracted; | |||||||||||||||||||||||||||||||
| 1090 | } | ||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||
| 1093 | ######################################## | ||||||||||||||||||||||||||||||||
| 1094 | # CHECK PACKAGE HELPERS | ||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||
| 1096 | 6 | ▶ | sub _check_ini_files { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_ini_files: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||
| 1097 | 6 | my ( $self, $files ) = @_; | |||||||||||||||||||||||||||||||
| 1098 | 6 | my @status = (); | |||||||||||||||||||||||||||||||
| 1099 | 6 | foreach my $ini_file ( sort @{ $files } ) { | |||||||||||||||||||||||||||||||
| 1100 | 12 | my $s = { action => 'Check ini file', filename => $ini_file }; | |||||||||||||||||||||||||||||||
| 1101 | 12 | eval { OpenInteract2::Config->new( 'ini', { filename => $ini_file } ) }; | |||||||||||||||||||||||||||||||
| 1102 | 12 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1103 | 0 | $s->{is_ok} = 'no'; | |||||||||||||||||||||||||||||||
| 1104 | 0 | $s->{message} = "Cannot be read: $@"; | |||||||||||||||||||||||||||||||
| 1105 | } | ||||||||||||||||||||||||||||||||
| 1106 | else { | ||||||||||||||||||||||||||||||||
| 1107 | 12 | $s->{is_ok} = 'yes'; | |||||||||||||||||||||||||||||||
| 1108 | 12 | $s->{message} = 'Read ok'; | |||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||
| 1110 | 12 | push @status, $s; | |||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||
| 1112 | 6 | return @status; | |||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||
| 1116 | # Note that we suppress warnings within this routine | ||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||
| 1118 | 6 | ▶ | sub _check_pm_files { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_pm_files: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||
| 1119 | 6 | my ( $self, $files ) = @_; | |||||||||||||||||||||||||||||||
| 1120 | 0 | ▶ | local $SIG{__WARN__} = sub { return undef }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||
| 1121 | 6 | my @status = (); | |||||||||||||||||||||||||||||||
| 1122 | 6 | foreach my $pm_file ( sort @{ $files } ) { | |||||||||||||||||||||||||||||||
| 1123 | 12 | my $s = { action => 'Check module', filename => $pm_file }; | |||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||
| 1125 | # Be sure we're not just getting the results of a cached | ||||||||||||||||||||||||||||||||
| 1126 | # operation | ||||||||||||||||||||||||||||||||
| 1127 | 12 | ▶ | delete $INC{ $pm_file } if ( $INC{ $pm_file } ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||
| 1129 | 12 | eval { require "$pm_file" }; | |||||||||||||||||||||||||||||||
| 1130 | 12 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1131 | 6 | $s->{is_ok} = 'no'; | |||||||||||||||||||||||||||||||
| 1132 | 6 | $s->{message} = "Perl syntax/include check failed: $@"; | |||||||||||||||||||||||||||||||
| 1133 | } | ||||||||||||||||||||||||||||||||
| 1134 | else { | ||||||||||||||||||||||||||||||||
| 1135 | 6 | $s->{is_ok} = 'yes'; | |||||||||||||||||||||||||||||||
| 1136 | 6 | $s->{message} = "Perl syntax/include check ok"; | |||||||||||||||||||||||||||||||
| 1137 | } | ||||||||||||||||||||||||||||||||
| 1138 | 12 | push @status, $s; | |||||||||||||||||||||||||||||||
| 1139 | } | ||||||||||||||||||||||||||||||||
| 1140 | 6 | return @status; | |||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||
| 1144 | 6 | ▶ | sub _check_data_files { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_data_files: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 1145 | 6 | my ( $self, $files ) = @_; | |||||||||||||||||||||||||||||||
| 1146 | 6 | my @status = (); | |||||||||||||||||||||||||||||||
| 1147 | 6 | foreach my $data_file ( sort @{ $files } ) { | |||||||||||||||||||||||||||||||
| 1148 | 12 | my $s = { action => 'Check data file', filename => $data_file }; | |||||||||||||||||||||||||||||||
| 1149 | 12 | eval { OpenInteract2::Util->read_file_perl( $data_file ) }; | |||||||||||||||||||||||||||||||
| 1150 | 12 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1151 | 1 | $s->{is_ok} = 'no'; | |||||||||||||||||||||||||||||||
| 1152 | 1 | $s->{message} = "Not a valid Perl structure: $@" | |||||||||||||||||||||||||||||||
| 1153 | } | ||||||||||||||||||||||||||||||||
| 1154 | else { | ||||||||||||||||||||||||||||||||
| 1155 | 11 | $s->{is_ok} = 'yes'; | |||||||||||||||||||||||||||||||
| 1156 | 11 | $s->{message} = "File is a valid Perl data structure"; | |||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||
| 1158 | 12 | push @status, $s; | |||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||
| 1160 | 6 | return @status; | |||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||
| 1164 | # See if all the templates pass a basic syntax test -- do not log | ||||||||||||||||||||||||||||||||
| 1165 | # 'plugin not found' or 'no providers for template prefix' errors, | ||||||||||||||||||||||||||||||||
| 1166 | # since we assume those will be ok when it runs in the | ||||||||||||||||||||||||||||||||
| 1167 | # environment. (This could probably use some work, since the 'include' | ||||||||||||||||||||||||||||||||
| 1168 | # errors may happen before basic syntax checking, which is the main | ||||||||||||||||||||||||||||||||
| 1169 | # point of this...) | ||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||
| 1171 | 6 | ▶ | sub _check_templates { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_templates: called CC=6 SCAR=19.5
| |||||||||||||||||||||||||||||||||
| 1172 | 6 | my ( $self, $files ) = @_; | |||||||||||||||||||||||||||||||
| 1173 | 6 | require Template; | |||||||||||||||||||||||||||||||
| 1174 | 6 | my $template = Template->new(); | |||||||||||||||||||||||||||||||
| 1175 | 6 | my ( $out ); | |||||||||||||||||||||||||||||||
| 1176 | 6 | my @template_errors_ok = ( 'not found', | |||||||||||||||||||||||||||||||
| 1177 | 'no providers for template prefix', | ||||||||||||||||||||||||||||||||
| 1178 | 'file error' ); | ||||||||||||||||||||||||||||||||
| 1179 | 6 | my $template_errors_re = '^(' . join( '|', @template_errors_ok ) . ')'; | |||||||||||||||||||||||||||||||
| 1180 | 6 | my @status = (); | |||||||||||||||||||||||||||||||
| 1181 | 6 | foreach my $template_file ( sort @{ $files } ) { | |||||||||||||||||||||||||||||||
| 1182 | 6 | my $s = { action => 'Template check', filename => $template_file }; | |||||||||||||||||||||||||||||||
| 1183 | 6 | ▶ | if ( -f $template_file ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1184 | 6 | eval { | |||||||||||||||||||||||||||||||
| 1185 | 6 | ▶ | $template->process( $template_file, undef, \$out ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1186 | || die $template->error(), "\n" | ||||||||||||||||||||||||||||||||
| 1187 | }; | ||||||||||||||||||||||||||||||||
| 1188 | 6 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1189 | 6 | ▶ | if ( $@ =~ /$template_errors_re/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1190 | 6 | $s->{is_ok} = 'yes'; | |||||||||||||||||||||||||||||||
| 1191 | 6 | $s->{message} = "Template '$template_file' syntax seems to be ok"; | |||||||||||||||||||||||||||||||
| 1192 | } | ||||||||||||||||||||||||||||||||
| 1193 | else { | ||||||||||||||||||||||||||||||||
| 1194 | 0 | $s->{is_ok} = 'no'; | |||||||||||||||||||||||||||||||
| 1195 | 0 | $s->{message} = $@; | |||||||||||||||||||||||||||||||
| 1196 | } | ||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||
| 1198 | else { | ||||||||||||||||||||||||||||||||
| 1199 | 0 | $s->{is_ok} = 'yes'; | |||||||||||||||||||||||||||||||
| 1200 | 0 | $s->{message} = "Template '$template_file' syntax ok"; | |||||||||||||||||||||||||||||||
| 1201 | } | ||||||||||||||||||||||||||||||||
| 1202 | } | ||||||||||||||||||||||||||||||||
| 1203 | else { | ||||||||||||||||||||||||||||||||
| 1204 | 0 | $s->{is_ok} = 'no'; | |||||||||||||||||||||||||||||||
| 1205 | 0 | $s->{message} = "Template file '$template_file' does not exist"; | |||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||
| 1207 | 6 | push @status, $s; | |||||||||||||||||||||||||||||||
| 1208 | } | ||||||||||||||||||||||||||||||||
| 1209 | 6 | return @status; | |||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||
| 1212 | 6 | ▶ | sub _check_message_files { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_message_files: called CC=5 SCAR=24.1
| |||||||||||||||||||||||||||||||||
| 1213 | 6 | my ( $self, $message_files ) = @_; | |||||||||||||||||||||||||||||||
| 1214 | 6 | my @status = (); | |||||||||||||||||||||||||||||||
| 1215 | 6 | my $action = 'Check localization filename'; | |||||||||||||||||||||||||||||||
| 1216 | 6 | foreach my $message_file ( @{ $message_files } ) { | |||||||||||||||||||||||||||||||
| 1217 | 0 | ▶ | $log->is_debug && $log->debug( "Checking message file '$message_file'" ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1218 | 0 | my $lang = OpenInteract2::I18N::Initializer | |||||||||||||||||||||||||||||||
| 1219 | ->is_valid_message_file( $message_file ); | ||||||||||||||||||||||||||||||||
| 1220 | 0 | ▶ | my $msg = ( $lang ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1221 | ? "Extracted language '$lang' from '$message_file'" | ||||||||||||||||||||||||||||||||
| 1222 | : "File '$message_file' is invalid"; | ||||||||||||||||||||||||||||||||
| 1223 | 0 | ▶ | push @status, { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1224 | action => $action, | ||||||||||||||||||||||||||||||||
| 1225 | is_ok => ( $lang ) ? 'yes' : 'no', | ||||||||||||||||||||||||||||||||
| 1226 | message => $msg, | ||||||||||||||||||||||||||||||||
| 1227 | filename => $message_file, | ||||||||||||||||||||||||||||||||
| 1228 | }; | ||||||||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||||||
| 1230 | 6 | return @status; | |||||||||||||||||||||||||||||||
| 1231 | } | ||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||
| 1234 | # Ensure that the package config has all necessary fields | ||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||
| 1236 | 6 | ▶ | sub _check_package_config { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_package_config: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||
| 1237 | 6 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||
| 1239 | 6 | my $config = $self->config; | |||||||||||||||||||||||||||||||
| 1240 | 6 | my $base_filename = $config->filename; | |||||||||||||||||||||||||||||||
| 1241 | 6 | my $package_dir = $config->package_dir; | |||||||||||||||||||||||||||||||
| 1242 | 6 | $package_dir =~ s|\\|\\\\|g; # for win32 people... | |||||||||||||||||||||||||||||||
| 1243 | 6 | $base_filename =~ s|^$package_dir/||; | |||||||||||||||||||||||||||||||
| 1244 | 6 | my %req_s = ( action => 'Config required fields', | |||||||||||||||||||||||||||||||
| 1245 | filename => $base_filename ); | ||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||
| 1247 | 6 | eval { $config->check_required_fields( 'author' ) }; | |||||||||||||||||||||||||||||||
| 1248 | 6 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1249 | 0 | $req_s{is_ok} = 'no'; | |||||||||||||||||||||||||||||||
| 1250 | 0 | $req_s{message} = "$@"; | |||||||||||||||||||||||||||||||
| 1251 | } | ||||||||||||||||||||||||||||||||
| 1252 | else { | ||||||||||||||||||||||||||||||||
| 1253 | 6 | $req_s{is_ok} = 'yes'; | |||||||||||||||||||||||||||||||
| 1254 | 6 | $req_s{message} = 'All required fields in package configuration defined'; | |||||||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||
| 1257 | 6 | my %module_s = ( action => 'Config defined modules' ); | |||||||||||||||||||||||||||||||
| 1258 | 6 | ▶ | if ( ref $config->module eq 'ARRAY' and scalar @{ $config->module } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
ref $config->module eq "ARRAY" and scalar @{$config->module;}
MC/DC0%0/1
ref $config->module eq "ARRAY" and scalar @{$config->module;}
ref $config->module eq "ARRAY"
Truth table50%1/2
A
A= ref $config->module eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 1259 | 6 | my @failed_modules = $self->_check_module_install( @{ $config->module } ); | |||||||||||||||||||||||||||||||
| 1260 | 6 | ▶ | if ( scalar @failed_modules ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1261 | 0 | $module_s{is_ok} = 'no'; | |||||||||||||||||||||||||||||||
| 1262 | 0 | $module_s{message} = 'Following modules must be installed: ' . | |||||||||||||||||||||||||||||||
| 1263 | join( ', ', @failed_modules ); | ||||||||||||||||||||||||||||||||
| 1264 | } | ||||||||||||||||||||||||||||||||
| 1265 | else { | ||||||||||||||||||||||||||||||||
| 1266 | 6 | my $required = join( ', ', @{ $config->module } ); | |||||||||||||||||||||||||||||||
| 1267 | 6 | $module_s{is_ok} = 'yes'; | |||||||||||||||||||||||||||||||
| 1268 | 6 | $module_s{message} = "All modules required by package are installed: $required"; | |||||||||||||||||||||||||||||||
| 1269 | } | ||||||||||||||||||||||||||||||||
| 1270 | } | ||||||||||||||||||||||||||||||||
| 1271 | else { | ||||||||||||||||||||||||||||||||
| 1272 | 0 | $module_s{is_ok} = 'yes'; | |||||||||||||||||||||||||||||||
| 1273 | 0 | $module_s{message} = 'No modules defined, test skipped'; | |||||||||||||||||||||||||||||||
| 1274 | } | ||||||||||||||||||||||||||||||||
| 1275 | 6 | return ( \%req_s, \%module_s ); | |||||||||||||||||||||||||||||||
| 1276 | } | ||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||
| 1279 | 6 | ▶ | sub _check_module_install { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_module_install: called CC=7 SCAR=25.1
| |||||||||||||||||||||||||||||||||
| 1280 | 6 | my ( $self, @modules ) = @_; | |||||||||||||||||||||||||||||||
| 1281 | 6 | my ( @failed_modules ); | |||||||||||||||||||||||||||||||
| 1282 | MODULE: | ||||||||||||||||||||||||||||||||
| 1283 | 6 | foreach my $module ( @modules ) { | |||||||||||||||||||||||||||||||
| 1284 | 6 | ▶ | next unless ( $module ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1285 | 6 | ▶ | if ( $module =~ /\|\|/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1286 | 0 | my @alt_modules = split /\s*\|\|\s*/, $module; | |||||||||||||||||||||||||||||||
| 1287 | 0 | foreach my $alt_module ( @alt_modules ) { | |||||||||||||||||||||||||||||||
| 1288 | 0 | eval "require $alt_module"; | |||||||||||||||||||||||||||||||
| 1289 | 0 | ▶ | next MODULE unless ( $@ ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||
| 1291 | 0 | push @failed_modules, join( ' or ', @alt_modules ); | |||||||||||||||||||||||||||||||
| 1292 | } | ||||||||||||||||||||||||||||||||
| 1293 | else { | ||||||||||||||||||||||||||||||||
| 1294 | 6 | eval "require $module"; | |||||||||||||||||||||||||||||||
| 1295 | 6 | ▶ | push @failed_modules, $module if ( $@ ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1296 | } | ||||||||||||||||||||||||||||||||
| 1297 | } | ||||||||||||||||||||||||||||||||
| 1298 | 6 | return @failed_modules; | |||||||||||||||||||||||||||||||
| 1299 | } | ||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||
| 1302 | # Check to ensure that all files in the MANIFEST exist and that there | ||||||||||||||||||||||||||||||||
| 1303 | # aren't any extra files in the directory -- this is just feedback | ||||||||||||||||||||||||||||||||
| 1304 | # from the EU::Manifest module, but don't let it print out results of | ||||||||||||||||||||||||||||||||
| 1305 | # its findings (Quiet) | ||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||
| 1307 | 6 | ▶ | sub _check_manifest { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_manifest: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 1308 | 6 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 1309 | 6 | local $ExtUtils::Manifest::Quiet = 1; | |||||||||||||||||||||||||||||||
| 1310 | 6 | my @missing = ExtUtils::Manifest::manicheck(); | |||||||||||||||||||||||||||||||
| 1311 | 6 | my %missing_s = ( action => 'Files missing from MANIFEST' ); | |||||||||||||||||||||||||||||||
| 1312 | 6 | ▶ | if ( scalar @missing ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1313 | 1 | $missing_s{is_ok} = 'no'; | |||||||||||||||||||||||||||||||
| 1314 | 1 | $missing_s{message} = 'Files not found from MANIFEST: ' . | |||||||||||||||||||||||||||||||
| 1315 | join( ", ", @missing ); | ||||||||||||||||||||||||||||||||
| 1316 | } | ||||||||||||||||||||||||||||||||
| 1317 | else { | ||||||||||||||||||||||||||||||||
| 1318 | 5 | $missing_s{is_ok} = 'yes'; | |||||||||||||||||||||||||||||||
| 1319 | 5 | $missing_s{message} = 'All files in MANIFEST exist in package'; | |||||||||||||||||||||||||||||||
| 1320 | } | ||||||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||||||
| 1322 | 6 | my @extra = ExtUtils::Manifest::filecheck(); | |||||||||||||||||||||||||||||||
| 1323 | 6 | my %extra_s = ( action => 'Extra files not in MANIFEST' ); | |||||||||||||||||||||||||||||||
| 1324 | 6 | ▶ | if ( scalar @extra ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1325 | 1 | $extra_s{is_ok} = 'no'; | |||||||||||||||||||||||||||||||
| 1326 | 1 | $extra_s{message} = 'Files not in MANIFEST found: ' . | |||||||||||||||||||||||||||||||
| 1327 | join( ', ', @extra ); | ||||||||||||||||||||||||||||||||
| 1328 | } | ||||||||||||||||||||||||||||||||
| 1329 | else { | ||||||||||||||||||||||||||||||||
| 1330 | 5 | $extra_s{is_ok} = 'yes'; | |||||||||||||||||||||||||||||||
| 1331 | 5 | $extra_s{message} = 'No files not in MANIFEST found in package'; | |||||||||||||||||||||||||||||||
| 1332 | } | ||||||||||||||||||||||||||||||||
| 1333 | 6 | return ( \%missing_s, \%extra_s ); | |||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||||||
| 1337 | # If we were given a file at the beginning and extracted the contents, | ||||||||||||||||||||||||||||||||
| 1338 | # clean it up when this object goes away. (See _read_info_from_file()) | ||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||
| 1340 | 8 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 1341 | 8 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 1342 | 8 | ▶ | if ( $self->{_tmp_package_extract_dir} and | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"_tmp_package_extract_dir"} and -d $self->{"_tmp_package_extract_dir"}
MC/DC50%1/2
$self->{"_tmp_package_extract_dir"} and -d $self->{"_tmp_package_extract_dir"}
$self->{"_tmp_package_extract_dir"}
-d $self->{"_tmp_package_extract_dir"}
Truth table66%2/3
A and B
A= $self->{"_tmp_package_extract_dir"}B= -d $self->{"_tmp_package_extract_dir"}
| |||||||||||||||||||||||||||||||||
| 1343 | -d $self->{_tmp_package_extract_dir} ) { | ||||||||||||||||||||||||||||||||
| 1344 | 1 | $self->_remove_directory_tree( $self->{_tmp_package_extract_dir} ); | |||||||||||||||||||||||||||||||
| 1345 | } | ||||||||||||||||||||||||||||||||
| 1346 | } | ||||||||||||||||||||||||||||||||
| 1347 | |||||||||||||||||||||||||||||||||
| 1348 | 87 | 1; | |||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||
| 1350 | __END__ | ||||||||||||||||||||||||||||||||