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