| 1 | package Enbld::Target; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use version; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use File::Path qw/make_path remove_tree/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use File::Find; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use File::Copy::Recursive qw/rcopy/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use autodie; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use List::Util qw/first/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | require Enbld::Definition; | |||||||||||||||||||||||||||
| 18 | 2 | require Enbld::Feature; | |||||||||||||||||||||||||||
| 19 | 2 | require Enbld::Condition; | |||||||||||||||||||||||||||
| 20 | 2 | require Enbld::Message; | |||||||||||||||||||||||||||
| 21 | 2 | require Enbld::Home; | |||||||||||||||||||||||||||
| 22 | 2 | require Enbld::HTTP; | |||||||||||||||||||||||||||
| 23 | 2 | require Enbld::Target::Symlink; | |||||||||||||||||||||||||||
| 24 | 2 | require Enbld::Error; | |||||||||||||||||||||||||||
| 25 | 2 | require Enbld::Deployed; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub new { | ||||||||||||||||||||||||||||
| 28 | 47 | ▶ | my ( $class, $name, $config ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 47 | my $self = { | |||||||||||||||||||||||||||
| 31 | name => $name, | ||||||||||||||||||||||||||||
| 32 | config => $config, | ||||||||||||||||||||||||||||
| 33 | attributes => undef, | ||||||||||||||||||||||||||||
| 34 | build => undef, | ||||||||||||||||||||||||||||
| 35 | install => undef, | ||||||||||||||||||||||||||||
| 36 | PATH => undef, | ||||||||||||||||||||||||||||
| 37 | conditions => undef, | ||||||||||||||||||||||||||||
| 38 | }; | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 47 | bless $self, $class; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 47 | $self->_set_config; | |||||||||||||||||||||||||||
| 43 | 47 | $self->_set_attributes; | |||||||||||||||||||||||||||
| 44 | 46 | $self->_set_PATH; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 46 | return $self; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | sub install { | ||||||||||||||||||||||||||||
| 50 | 14 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
install: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 14 | ▶ | if ( ! $self->_is_install_ok ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 1 | die( Enbld::Error->new( "'$self->{name}' is already installed." ) ); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 13 | my $condition = Enbld::Condition->new; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 13 | $self->{attributes}->add( 'VersionCondition', $condition->version ); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 13 | $self->_build( $condition ); | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 12 | return $self->{config}; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | sub _is_install_ok { | ||||||||||||||||||||||||||||
| 66 | 14 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_is_install_ok: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 14 | ▶ | return 1 if Enbld::Feature->is_force_install; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 13 | ▶ | return if $self->is_installed; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 12 | return 1; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | sub deploy { | ||||||||||||||||||||||||||||
| 74 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
deploy: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | my $condition = Enbld::Condition->new; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | $self->{attributes}->add( 'VersionCondition', $condition->version ); | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 1 | $self->_build_to_deploy( $condition ); | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1 | return $self->{config}; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | sub install_declared { | ||||||||||||||||||||||||||||
| 86 | 14 | ▶ | my ( $self, $declared_conditions ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
install_declared: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | $self->{attributes}->add( | ||||||||||||||||||||||||||||
| 89 | 'VersionCondition', | ||||||||||||||||||||||||||||
| 90 | $declared_conditions->{$self->{name}}{version} | ||||||||||||||||||||||||||||
| 91 | 14 | ); | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | return unless $self->_is_install_declared_ok( | ||||||||||||||||||||||||||||
| 94 | $declared_conditions->{$self->{name}} | ||||||||||||||||||||||||||||
| 95 | 14 | ▶ | ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 13 | $self->{conditions} = $declared_conditions; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 13 | $self->_build( $declared_conditions->{$self->{name}} ); | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 13 | return $self->{config}; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | sub deploy_declared { | ||||||||||||||||||||||||||||
| 105 | 1 | ▶ | my ( $self, $declared_conditions ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
deploy_declared: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | $self->{attributes}->add( | ||||||||||||||||||||||||||||
| 108 | 'VersionCondition', | ||||||||||||||||||||||||||||
| 109 | $declared_conditions->{$self->{name}}{version} | ||||||||||||||||||||||||||||
| 110 | 1 | ); | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 1 | $self->{conditions} = $declared_conditions; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 1 | $self->_build_to_deploy( $declared_conditions->{$self->{name}} ); | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 1 | return $self->{config}; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | sub _is_install_declared_ok { | ||||||||||||||||||||||||||||
| 120 | 14 | ▶ | my ( $self, $condition ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_is_install_declared_ok: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 14 | ▶ | return 1 if Enbld::Feature->is_force_install; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 13 | ▶ | return 1 unless $self->{config}->enabled; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 3 | ▶ | return 1 unless $condition->is_equal_to( $self->{config}->condition ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 1 | ▶ | return if $self->{config}->enabled eq $self->{attributes}->Version; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | return 1; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | sub upgrade { | ||||||||||||||||||||||||||||
| 131 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
upgrade: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 3 | ▶ | if ( ! $self->is_installed ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 1 | die( Enbld::Error->new( "'$self->{name}' is not installed yet." ) ); | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | $self->{attributes}->add( | ||||||||||||||||||||||||||||
| 138 | 'VersionCondition', | ||||||||||||||||||||||||||||
| 139 | $self->{config}->condition->version | ||||||||||||||||||||||||||||
| 140 | 2 | ); | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 2 | my $current = $self->{attributes}->Version; | |||||||||||||||||||||||||||
| 143 | 2 | my $enabled = $self->{config}->enabled; | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 2 | my $VersionList = $self->{attributes}->SortedVersionList; | |||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | my $index_current = | ||||||||||||||||||||||||||||
| 148 | 2 | ▶ | first { ${ $VersionList }[$_] eq $current } 0..$#{ $VersionList }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | my $index_enabled = | ||||||||||||||||||||||||||||
| 151 | 2 | ▶ | first { ${ $VersionList }[$_] eq $enabled } 0..$#{ $VersionList }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 2 | ▶ | if ( $index_current <= $index_enabled ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | 1 | die( Enbld::Error->new( "'$self->{name}' is up to date." ) ); | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 1 | $self->_build( $self->{config}->condition ); | |||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 1 | return $self->{config}; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | sub off { | ||||||||||||||||||||||||||||
| 163 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
off: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 2 | ▶ | if ( ! $self->is_installed ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 1 | die( Enbld::Error->new( "'$self->{name}' is not installed yet." ) ); | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 1 | $self->_drop; | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 1 | $self->{config}->drop_enabled; | |||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 1 | return $self->{config}; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | sub rehash { | ||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
rehash: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ( ! $self->is_installed ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 0 | die( Enbld::Error->new( "'$self->{name}' isn't installed yet." ) ); | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 0 | $self->_switch( $self->{config}->enabled ); | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | return $self->{config}; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | sub use { | ||||||||||||||||||||||||||||
| 189 | 4 | ▶ | my ( $self, $version ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
use: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 4 | ▶ | if ( ! $self->{config}->installed ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | 0 | die( Enbld::Error->new( "'$self->{name}' isn't installed yet." ) ); | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 4 | my $form = $self->{attributes}->VersionForm; | |||||||||||||||||||||||||||
| 196 | 4 | ▶ | if ( $version !~ /^$form$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 1 | die( Enbld::Error->new( "'$version' is not valid version form." ) ); | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 3 | ▶ | if ( $self->{config}->enabled && $self->{config}->enabled eq $version ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"config"}->enabled and $self->{"config"}->enabled eq $version
MC/DC50%1/2
$self->{"config"}->enabled and $self->{"config"}->enabled eq $version
$self->{"config"}->enabled
$self->{"config"}->enabled eq $version
Truth table66%2/3
A and B
A= $self->{"config"}->enabledB= $self->{"config"}->enabled eq $version
| |||||||||||||||||||||||||||||
| 201 | 1 | die( Enbld::Error->new( "'$version' is current enabled version." ) ); | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 2 | ▶ | if ( ! $self->{config}->is_installed_version( $version ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 1 | die( Enbld::Error->new( "'$version' isn't installed yet" ) ); | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 1 | $self->_switch( $version ); | |||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 1 | return $self->{config}; | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | sub is_installed { | ||||||||||||||||||||||||||||
| 214 | 22 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
is_installed: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 22 | return $self->{config}->enabled; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | sub is_outdated { | ||||||||||||||||||||||||||||
| 220 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
is_outdated: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 3 | ▶ | return unless ( $self->{config}->enabled ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | $self->{attributes}->add( | ||||||||||||||||||||||||||||
| 225 | 'VersionCondition', $self->{config}->condition->version | ||||||||||||||||||||||||||||
| 226 | 2 | ); | |||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 2 | my $current = $self->{attributes}->Version; | |||||||||||||||||||||||||||
| 229 | 2 | my $enabled = $self->{config}->enabled; | |||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 2 | my $VersionList = $self->{attributes}->SortedVersionList; | |||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | my $index_current = | ||||||||||||||||||||||||||||
| 234 | 2 | ▶ | first { ${ $VersionList }[$_] eq $current } 0..$#{ $VersionList }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | my $index_enabled = | ||||||||||||||||||||||||||||
| 237 | 2 | ▶ | first { ${ $VersionList }[$_] eq $enabled } 0..$#{ $VersionList }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 2 | ▶ | if ( $index_current > $index_enabled ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | 1 | return $current; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 1 | return; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | sub _set_config { | ||||||||||||||||||||||||||||
| 247 | 47 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_set_config: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 47 | ▶ | if ( ! $self->{config} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 27 | require Enbld::Config; | |||||||||||||||||||||||||||
| 251 | 27 | $self->{config} = Enbld::Config->new( name => $self->{name} ); | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | sub _set_attributes { | ||||||||||||||||||||||||||||
| 256 | 47 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_set_attributes: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 47 | $self->{attributes} = Enbld::Definition->new( $self->{name} )->parse; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | sub _set_PATH { | ||||||||||||||||||||||||||||
| 262 | 46 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_set_PATH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 46 | my $path = File::Spec->catdir( Enbld::Home->install_path, 'bin' ); | |||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 46 | $self->{PATH} = $path . ':' . $ENV{PATH}; | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | sub _switch { | ||||||||||||||||||||||||||||
| 270 | 1 | ▶ | my ( $self, $version ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_switch: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | my $path = File::Spec->catdir( | ||||||||||||||||||||||||||||
| 273 | Enbld::Home->depository, | ||||||||||||||||||||||||||||
| 274 | $self->{attributes}->DistName | ||||||||||||||||||||||||||||
| 275 | 1 | ); | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 1 | my $new = File::Spec->catdir( $path, $version ); | |||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 1 | Enbld::Target::Symlink->delete_symlink( $path ); | |||||||||||||||||||||||||||
| 280 | 1 | Enbld::Target::Symlink->create_symlink( $new ); | |||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | $self->{config}->set_enabled( | ||||||||||||||||||||||||||||
| 283 | $version, | ||||||||||||||||||||||||||||
| 284 | 1 | $self->{config}->condition( $version ), | |||||||||||||||||||||||||||
| 285 | ); | ||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | sub _drop { | ||||||||||||||||||||||||||||
| 289 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_drop: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | my $path = File::Spec->catdir( | ||||||||||||||||||||||||||||
| 292 | Enbld::Home->depository, | ||||||||||||||||||||||||||||
| 293 | $self->{attributes}->DistName, | ||||||||||||||||||||||||||||
| 294 | 1 | ); | |||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 1 | Enbld::Target::Symlink->delete_symlink( $path ); | |||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 1 | $self->{config}->drop_enabled; | |||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | sub _build { | ||||||||||||||||||||||||||||
| 302 | 27 | ▶ | my ( $self, $condition ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_build: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 27 | Enbld::Message->notify( "=====> Start building target '$self->{name}'." ); | |||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 27 | local $ENV{PATH} = $self->{PATH}; | |||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 27 | $self->_solve_dependencies; | |||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 27 | $self->_setup_install_directory; | |||||||||||||||||||||||||||
| 311 | 27 | $self->_exec_build_command( $condition ); | |||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 26 | ▶ | if ( $condition->modules ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | 0 | $self->_install_module( $condition ); | |||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 26 | $self->_postbuild; | |||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | 26 | my $finish_msg = "=====> Finish building target '$self->{name}'."; | |||||||||||||||||||||||||||
| 320 | 26 | Enbld::Message->notify( $finish_msg ); | |||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 26 | $self->{config}->set_enabled( $self->{attributes}->Version, $condition ); | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | sub _build_to_deploy { | ||||||||||||||||||||||||||||
| 326 | 2 | ▶ | my ( $self, $condition ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_build_to_deploy: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 2 | Enbld::Message->notify( "=====> Start building target '$self->{name}'." ); | |||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 2 | local $ENV{PATH} = $self->{PATH}; | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 2 | $self->_solve_dependencies_to_deploy; | |||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 2 | $self->{install} = Enbld::Home->deploy_path; | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 2 | $self->_exec_build_command( $condition ); | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 2 | ▶ | if ( $condition->modules ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 0 | $self->_install_module( $condition ); | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 2 | my $finish_msg = "=====> Finish building target '$self->{name}'."; | |||||||||||||||||||||||||||
| 343 | 2 | Enbld::Message->notify( $finish_msg ); | |||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 2 | $self->{config}->set_enabled( $self->{attributes}->Version, $condition ); | |||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | sub _exec_build_command { | ||||||||||||||||||||||||||||
| 349 | 29 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_exec_build_command: called CC=6 SCAR=18.3
| |||||||||||||||||||||||||||||
| 350 | 29 | my $condition = shift; | |||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | 29 | $self->_setup_build_directory; | |||||||||||||||||||||||||||
| 353 | 29 | chdir $self->{build}; | |||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 29 | $self->_prebuild; | |||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | 29 | ▶ | $self->_configure( $condition ) if $self->{attributes}->CommandConfigure; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | 28 | ▶ | $self->_make if $self->{attributes}->CommandMake; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 28 | ▶ | if ( $condition->make_test or Enbld::Feature->is_make_test_all ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$condition->make_test or "Enbld::Feature"->is_make_test_all
MC/DC50%1/2
$condition->make_test or "Enbld::Feature"->is_make_test_all
$condition->make_test
"Enbld::Feature"->is_make_test_all
Truth table66%2/3
A or B
A= $condition->make_testB= "Enbld::Feature"->is_make_test_all
| |||||||||||||||||||||||||||||
| 361 | 1 | $self->_test; | |||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | 28 | ▶ | $self->_install if $self->{attributes}->CommandInstall; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | sub _solve_dependencies { | ||||||||||||||||||||||||||||
| 368 | 27 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_solve_dependencies: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | 27 | ▶ | return if ( ! @{ $self->{attributes}->Dependencies } ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 3 | Enbld::Message->notify( "=====> Found dependencies." ); | |||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | 3 | require Enbld::App::Configuration; | |||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 3 | foreach my $dependency ( @{ $self->{attributes}->Dependencies } ) { | |||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | 3 | Enbld::Message->notify( "--> Dependency '$dependency'." ); | |||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | 3 | my $config = Enbld::App::Configuration->search_config( $dependency ); | |||||||||||||||||||||||||||
| 381 | 3 | my $target = Enbld::Target->new( $dependency, $config ); | |||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | 3 | ▶ | if ( $target->is_installed ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 384 | 1 | my $installed_msg = "--> $dependency is already installed."; | |||||||||||||||||||||||||||
| 385 | 1 | Enbld::Message->notify( $installed_msg ); | |||||||||||||||||||||||||||
| 386 | 1 | next; | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 2 | Enbld::Message->notify( "--> $dependency is not installed yet." ); | |||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | my $condition = $self->{conditions}{$dependency} ? | ||||||||||||||||||||||||||||
| 392 | 2 | ▶ | $self->{conditions}{$dependency} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | 2 | my $installed; | |||||||||||||||||||||||||||
| 395 | 2 | ▶ | if ( $condition ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | 1 | $installed = $target->install_declared( $self->{conditions} ); | |||||||||||||||||||||||||||
| 397 | } else { | ||||||||||||||||||||||||||||
| 398 | 1 | $installed = $target->install; | |||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 2 | Enbld::App::Configuration->set_config( $installed ); | |||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | sub _solve_dependencies_to_deploy { | ||||||||||||||||||||||||||||
| 406 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_solve_dependencies_to_deploy: called CC=6 SCAR=32.9
| |||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | 2 | ▶ | return if ( ! @{ $self->{attributes}->Dependencies } ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 0 | Enbld::Message->notify( "=====> Found dependencies." ); | |||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | 0 | foreach my $dependency ( @{ $self->{attributes}->Dependencies } ) { | |||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | 0 | ▶ | next if ( Enbld::Deployed->is_deployed( $dependency )); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | 0 | Enbld::Message->notify( "--> Dependency '$dependency'." ); | |||||||||||||||||||||||||||
| 417 | 0 | Enbld::Message->notify( "--> $dependency is not installed yet." ); | |||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 0 | my $target = Enbld::Target->new( $dependency ); | |||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | my $condition = $self->{conditions}{$dependency} ? | ||||||||||||||||||||||||||||
| 422 | 0 | ▶ | $self->{conditions}{$dependency} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 0 | my $installed; | |||||||||||||||||||||||||||
| 425 | 0 | ▶ | if ( $condition ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 426 | 0 | $installed = $target->deploy_declared( $self->{conditions} ); | |||||||||||||||||||||||||||
| 427 | } else { | ||||||||||||||||||||||||||||
| 428 | 0 | $installed = $target->deploy; | |||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | 0 | Enbld::Deployed->add( $installed ); | |||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | sub _prebuild { | ||||||||||||||||||||||||||||
| 436 | 29 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_prebuild: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | 29 | ▶ | $self->_apply_patchfiles if $self->{attributes}->PatchFiles; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | sub _configure { | ||||||||||||||||||||||||||||
| 442 | 29 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_configure: called CC=4 SCAR=14.8
| |||||||||||||||||||||||||||||
| 443 | 29 | my $condition = shift; | |||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 29 | ▶ | return $self unless $self->{attributes}->CommandConfigure; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | 29 | my $configure; | |||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | 29 | $configure = $self->{attributes}->CommandConfigure . ' '; | |||||||||||||||||||||||||||
| 450 | 29 | $configure .= $self->{attributes}->Prefix . $self->{install}; | |||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | 29 | ▶ | if( $self->{attributes}->AdditionalArgument ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 453 | 0 | $configure .= ' ' . $self->{attributes}->AdditionalArgument; | |||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | 29 | ▶ | if ( $condition->arguments ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 457 | 0 | $configure .= ' ' . $condition->arguments; | |||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | 29 | $self->_exec( $configure ); | |||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | sub _make { | ||||||||||||||||||||||||||||
| 464 | 28 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_make: called CC=3 SCAR=16.3
| |||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | 28 | ▶ | if ( $self->{attributes}->CommandConfigure ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 467 | 28 | $self->_exec( $self->{attributes}->CommandMake ); | |||||||||||||||||||||||||||
| 468 | 28 | return $self; | |||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | # this code for tree command...tree don't has configure | ||||||||||||||||||||||||||||
| 472 | 0 | my $args = $self->{attributes}->Prefix . $self->{install}; | |||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | 0 | ▶ | if ( $self->{attributes}->AdditionalArgument ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 475 | 0 | $args .= ' ' . $self->{attributes}->AdditionalArgument; | |||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | 0 | $self->_exec( $self->{attributes}->CommandMake . ' ' . $args ); | |||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 0 | return $self; | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | sub _test { | ||||||||||||||||||||||||||||
| 484 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_test: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | 1 | ▶ | return $self unless $self->{attributes}->CommandTest; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | 1 | $self->_exec( $self->{attributes}->CommandTest ); | |||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | sub _install { | ||||||||||||||||||||||||||||
| 492 | 28 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_install: called CC=3 SCAR=16.3
| |||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | 28 | ▶ | if ( $self->{attributes}->CommandConfigure ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 495 | 28 | $self->_exec( $self->{attributes}->CommandInstall ); | |||||||||||||||||||||||||||
| 496 | 28 | return $self; | |||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | 0 | my $args = $self->{attributes}->Prefix . $self->{install}; | |||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | 0 | ▶ | if ( $self->{attributes}->AdditionalArgument ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 502 | 0 | $args .= ' ' . $self->{attributes}->AdditionalArgument; | |||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | 0 | $self->_exec( $self->{attributes}->CommandInstall . ' ' . $args ); | |||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | 0 | return $self; | |||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | sub _install_module { | ||||||||||||||||||||||||||||
| 511 | 0 | ▶ | my ( $self, $condition ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_install_module: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | 0 | require Enbld::Module; | |||||||||||||||||||||||||||
| 514 | my $module = Enbld::Module->new( | ||||||||||||||||||||||||||||
| 515 | name => $self->{name}, | ||||||||||||||||||||||||||||
| 516 | path => $self->{install}, | ||||||||||||||||||||||||||||
| 517 | 0 | ); | |||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | 0 | $module->install( $condition->modules ); | |||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | sub _postbuild { | ||||||||||||||||||||||||||||
| 523 | 26 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_postbuild: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | 26 | $self->_copy_files; | |||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | my $path = File::Spec->catdir( | ||||||||||||||||||||||||||||
| 528 | Enbld::Home->depository, | ||||||||||||||||||||||||||||
| 529 | $self->{attributes}->DistName, | ||||||||||||||||||||||||||||
| 530 | 26 | ); | |||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | 26 | Enbld::Target::Symlink->delete_symlink( $path ); | |||||||||||||||||||||||||||
| 533 | 26 | Enbld::Target::Symlink->create_symlink( $self->{install} ); | |||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | sub _copy_files { | ||||||||||||||||||||||||||||
| 537 | 26 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_copy_files: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | 26 | ▶ | return $self unless ( my $dirs = $self->{attributes}->CopyFiles ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | 26 | for my $dir ( @{ $dirs } ) { | |||||||||||||||||||||||||||
| 542 | rcopy( | ||||||||||||||||||||||||||||
| 543 | File::Spec->catdir( $self->{build}, $dir ), | ||||||||||||||||||||||||||||
| 544 | 0 | File::Spec->catdir( $self->{install}, $dir ) | |||||||||||||||||||||||||||
| 545 | ); | ||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | sub _exec { | ||||||||||||||||||||||||||||
| 551 | 86 | ▶ | my ( $self, $cmd ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_exec: called CC=4 SCAR=14.7
| |||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | 86 | require Enbld::Logger; | |||||||||||||||||||||||||||
| 554 | 86 | my $logfile = Enbld::Logger->logfile; | |||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | 86 | Enbld::Message->notify( "--> $cmd" ); | |||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | 86 | system( "LANG=C;$cmd >> $logfile 2>&1" ); | |||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | 86 | ▶ | return $self unless $?; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | 1 | ▶ | if ( $? == -1 ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 563 | 0 | die( Enbld::Error->new( "Failed to execute:$cmd" )); | |||||||||||||||||||||||||||
| 564 | } elsif ( $? & 127 ) { | ||||||||||||||||||||||||||||
| 565 | 0 | my $err = "Child died with signal:$cmd"; | |||||||||||||||||||||||||||
| 566 | 0 | die( Enbld::Error->new( $err )); | |||||||||||||||||||||||||||
| 567 | } else { | ||||||||||||||||||||||||||||
| 568 | 1 | my $err = "Build fail.Command:$cmd return code:" . ( $? >> 8 ); | |||||||||||||||||||||||||||
| 569 | 1 | die( Enbld::Error->new( $err )); | |||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | sub _apply_patchfiles { | ||||||||||||||||||||||||||||
| 574 | 29 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_apply_patchfiles: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | 29 | my $patchfiles = $self->{attributes}->PatchFiles; | |||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||
| 578 | 29 | require Enbld::HTTP; | |||||||||||||||||||||||||||
| 579 | 29 | require Enbld::Message; | |||||||||||||||||||||||||||
| 580 | 29 | require Enbld::Logger; | |||||||||||||||||||||||||||
| 581 | 29 | my $logfile = Enbld::Logger->logfile; | |||||||||||||||||||||||||||
| 582 | 29 | foreach my $patchfile ( @{ $patchfiles } ) { | |||||||||||||||||||||||||||
| 583 | 25 | my @parse = split( /\//, $patchfile ); | |||||||||||||||||||||||||||
| 584 | 25 | my $path = File::Spec->catfile( $self->{build}, $parse[-1] ); | |||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | 25 | Enbld::HTTP->download( $patchfile, $path ); | |||||||||||||||||||||||||||
| 587 | 25 | Enbld::Message->notify( "--> Apply patch $parse[-1]." ); | |||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | 25 | system( "patch -p0 < $path >> $logfile 2>&1" ); | |||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | sub _setup_build_directory { | ||||||||||||||||||||||||||||
| 594 | 29 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_setup_build_directory: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | my $path = File::Spec->catfile( | ||||||||||||||||||||||||||||
| 597 | Enbld::Home->dists, | ||||||||||||||||||||||||||||
| 598 | $self->{attributes}->Filename | ||||||||||||||||||||||||||||
| 599 | 29 | ); | |||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||
| 601 | my $archivefile = | ||||||||||||||||||||||||||||
| 602 | 29 | Enbld::HTTP->download_archivefile( $self->{attributes}->URL, $path ); | |||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||
| 604 | 29 | my $build = $archivefile->extract( Enbld::Home->build ); | |||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||
| 606 | 29 | return ( $self->{build} = $build ); | |||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | sub _setup_install_directory { | ||||||||||||||||||||||||||||
| 610 | 27 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_setup_install_directory: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||
| 612 | my $depository = File::Spec->catdir( | ||||||||||||||||||||||||||||
| 613 | Enbld::Home->depository, | ||||||||||||||||||||||||||||
| 614 | $self->{attributes}->DistName, | ||||||||||||||||||||||||||||
| 615 | $self->{attributes}->Version, | ||||||||||||||||||||||||||||
| 616 | 27 | ); | |||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | 27 | ▶ | remove_tree( $depository ) if ( -d $depository ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | 27 | return ( $self->{install} = $depository ); | |||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||
| 623 | 2 | 1; | |||||||||||||||||||||||||||