Installer.pm

filter: Statementstmt 15.5% 62 / 399 Branchbran 0.0% 0 / 158 Conditioncond 0.0% 0 / 42 MC/DCmcdc 0.0% 0 / 25 Subroutinesub 45.2% 19 / 42 Podpod 0.0% 0 / 5 totaltotal 12.0% 81 / 671 CC 104 SCAR 66.5
CC
104
Cov
10%
install
2256.0
_compute_all_deps
182.0
compute
156.0
CRAP 773.1
↑ Summary Installer/OS.pm »
1 package LedgerSMB::Installer v0.999.14;
2  
3 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use experimental qw(signatures);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use CPAN::Meta::Requirements;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use File::Path qw( make_path remove_tree );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use File::Temp qw( tempfile );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Getopt::Long qw(GetOptionsFromArray);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use HTTP::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use JSON::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use List::Util qw(uniq);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Module::CoreList;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Log::Any qw($log);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Log::Any::Adapter;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Module::CPANfile;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use LedgerSMB::Installer::Configuration;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 1 my $INSTALLER_VERSION = 'version CLONED'; # not intended to be the module version
27  
28 1 my $http = HTTP::Tiny->new( agent => 'LedgerSMB-Installer/0.1' );
29 1 my $json = JSON::PP->new->canonical;
30  
31 0 ▶sub _post_boot_configure($class, $dss, $config) {
Subroutine _post_boot_configure: not called CC=1 SCAR=6.9
32 0 Log::Any::Adapter->set('Stdout', log_level => $config->loglevel);
33 }
34  
35 0 ▶sub _boot($class, $args, $options) {
Subroutine _boot: not called CC=1 SCAR=6.9
36 0 my $dss = $class->_load_dist_support;
37 0 my $config = LedgerSMB::Installer::Configuration->new(
38 sys_pkgs => ($EFFECTIVE_USER_ID == 0)
39 );
40  
41 0 GetOptionsFromArray(
42 $args,
43 $config->option_callbacks( $options ),
44 );
45  
46 # normalize $installpath (at least cpanm needs that)
47 # assume $locallib to be inside $installpath
48 0 $config->normalize_paths;
49  
50 0 $class->_post_boot_configure( $dss, $config );
51 0 return ($dss, $config);
52 }
53  
54 1 my $signing_key_data = <<'KEY_DATA_END';
55 -----BEGIN PGP PUBLIC KEY BLOCK-----
56 Comment: Hostname: fr.pgpkeys.eu
57 Version: Hockeypuck 2.2.4
58  
59 xsBNBEYTN1ABCACuVLUCasiD4KnetfEHtMo+qDjKbcWauIkw/KU+gj8kN7Y+E3ye
60 cLxtY1gJlZp0iIgnZ6aw7bPCleTXbBfXXbMyLs0+CN9cfCyXB5TU4nlh16or/vlE
61 C+0WjEuD9Qznm805RXJGvIRPobXrxcO7aB7pT3NkKj2z//9D0w0uC+BDEl0uihZG
62 +fIbb2ihPWO/r9ghHhyMRTibSRye09owhVpr/5gYRFtvp7OsYHaLhUD3+WXPhGIZ
63 U7YqBFRumDNR+S8EewuKj0CBxCtC+iSFyR/fNPh50FbtgqY/9qLmZa/u42oyjrCl
64 TM+ALCM+PutEPVEIyVoO4jluoZ8yG4IFVxyxABEBAAHNZUxlZGdlclNNQiBDb3Jl
65 IFRlYW0gKFRoaXMgaXMgdGhlIGtleSB1c2VkIGZvciBwYWNrYWdlIHNpZ25pbmcu
66 KSA8bGVkZ2VyLXNtYi1jb3JlQGxpc3RzLmxlZGdlcnNtYi5vcmc+wsB2BBMBAgAg
67 BQJGEzdQAhsDBgsJCAcDAgQVAggDBBYCAwECHgECF4AACgkQOaYpVY2grxAaDwgA
68 kp2LZNyrZDom1tBwR3aisfYFkkiuFrUZUn+fYwr7wnkq06gpYGZrNgdcanSxjGoD
69 wf2kMeCwWAD6sao824onboJWRi1LR3Q5RKIAvYBeLZ75/hYSy3JP/YLMl047IWcU
70 CMaqZfmXPHvkOdUblPxCaKJM8c9Sb6KxGzu4BU2Y97TvQjn9xNbq4t7Pgpu5RORH
71 Hp96V+kZXGxzQo0gCE+6dr1JFZeTKmTkGSvkchndn5UVLguLIg9kCxxcDiS7hmTx
72 yB+b0+kPgRUb0YVp6QqFq7O8fvzhsW8sYopBJsbArODS2qeMiwPUnKs+7qkZg8Jd
73 j2QoHZCY06NU6yvqq/CIt8JGBBARAgAGBQJIx9P/AAoJEHc352JrCredRJwAnRFe
74 UDqpUCw368z/Ht6FDInXnC2kAJ995NXymKbQVg478EdOrJT8h1SPRA==
75 =a/2y
76 -----END PGP PUBLIC KEY BLOCK-----
77 KEY_DATA_END
78  
79 0 ▶sub _build_install_tree($class, $dss, $config, $installpath, $version) {
Subroutine _build_install_tree: not called CC=3 SCAR=24.8
80 0 my $archive = "ledgersmb-$version.tar.gz";
81  
82 0 ▶ if (not -d $installpath ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $installpath) 0 0 0
83 0 $log->info( "Creating installation path $installpath" );
84 0 make_path( $installpath ); # croaks on fatal errors
85 }
86  
87 0 $log->info( "Downloading release tarball $archive" );
88 0 $class->_download( $installpath, $version );
89  
90 0 $log->info( "Verifying tarball against gpg public key & signature" );
91 0 my $downloaded_tar = File::Spec->catfile( $installpath, $archive );
92 0 ▶ $dss->verify_sig( $installpath,
Branch: 1 branch
BranchTrueFalseTotal
if $config->verify_sig 0 0 0
93 $downloaded_tar,
94 "$downloaded_tar.asc",
95 $signing_key_data )
96 if $config->verify_sig;
97  
98 0 $log->info( "Extracting release tarball" );
99 0 $dss->untar( $downloaded_tar,
100 $installpath,
101 no_same_owner => 1,
102 strip_components => 1 );
103 0 $config->cpanfile_path( File::Spec->catfile( $installpath, 'cpanfile' ) );
104  
105 0 $log->info( "Removing extracted release tarball" );
106 # croaks on fatal errors:
107 0 remove_tree( $downloaded_tar, "$downloaded_tar.asc" );
108 }
109  
110 0 ▶sub _get_cpanfile($class, $config) {
Subroutine _get_cpanfile: not called CC=4 SCAR=30.0
111 0 ▶ return $config->cpanfile if $config->cpanfile;
Branch: 1 branch
BranchTrueFalseTotal
if $config->cpanfile 0 0 0
112  
113 0 my $cpanfile;
114 0 ▶ if ($config->cpanfile_path) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->cpanfile_path) { } 0 0 0
115 0 $cpanfile = $config->cpanfile_path;
116 }
117 else {
118 0 my $url =
119 sprintf("https://raw.githubusercontent.com/ledgersmb/LedgerSMB/refs/tags/%s/cpanfile",
120 $config->effective_version);
121  
122 0 my $response = $http->get( $url );
123 0 ▶ unless ($response->{success}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($response->{"success"}) 0 0 0
124 0 die $log->fatal("Unable to get '$url' from GitHub: $response->{content}");
125 }
126  
127 0 my ($fh, $fn) = tempfile();
128 0 print $fh $response->{content};
129 0 $fh->flush;
130 0 $cpanfile = $fn;
131 }
132  
133 0 my $decl = Module::CPANfile->load( $cpanfile );
134 0 $config->cpanfile( $decl );
135  
136 0 return $decl;
137 }
138  
139 0 ▶sub _get_immediate_prereqs($class, $config) {
Subroutine _get_immediate_prereqs: not called CC=1 SCAR=6.9
140 0 my $decl = $class->_get_cpanfile( $config );
141 0 return $decl->prereqs;
142 }
143  
144 0 ▶sub _compute_immediate_deps($class, $config) {
Subroutine _compute_immediate_deps: not called CC=4 SCAR=30.0
145 0 my @types = qw( requires recommends );
146 0 my @phases = qw( runtime );
147 0 my $decl = $class->_get_cpanfile( $config );
148 0 my $prereqs = $decl->prereqs_with( map { $_->identifier } $decl->features ); # all features
149 0 my $effective = CPAN::Meta::Requirements->new;
150 0 for my $phase (@phases) {
151 0 for my $type (@types) {
152 0 $effective->add_requirements( $prereqs->requirements_for( $phase, $type ) );
153 }
154 }
155  
156 0 my @mods = sort { lc($a) cmp lc($b) } $effective->required_modules;
157  
158 0 $log->debug( "Direct dependency count: " . scalar(@mods) );
159 0 $log->trace( "- $_" ) for (sort @mods);
160 0 return sort @mods;
161 }
162  
163 0 ▶sub _compute_all_deps($class, $config) {
Subroutine _compute_all_deps: not called CC=13 SCAR=52.0
164 0 my @deps = $class->_compute_immediate_deps( $config );
165  
166 0 my @orig_deps = (@deps, );
167 0 my @last_deps = @deps;
168 0 my %dists;
169 0 my $iteration = 1;
170 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
@last_deps and do { do { my $query = {"_source", [("release", "distribution", "status", "provides"), "dependency.*"], "query", {"bool", {"must", [{"term", {"status", "latest"}}, {"terms", {"provides", [@last_deps]}}], "filter", {"match_all", {}}}}}; my $body = $json->encode($query); my $r = $http->request("POST", "https://fastapi.metacpan.org/v1/release/_search?size=1000", {"headers", {"Content-Type", "application/json"}, "content", $body}); unless ($r->{"success"}) { die qq[Unable to request module dependencies; POST request failed for https://fastapi.metacpan.org/v1/release/_search, response: $r->{"status"} - $r->{"reason"}]; } ; my $hits = $json->decode($r->{"content"})->{"hits"}; foreach my $release (@{$$hits{"hits"}}) { $dists{$release->{"_source"}{"distribution"}} = 1; } ; my %provide; foreach my $release (@{$$hits{"hits"}}) { foreach my $provided (@{$$release{"_source"}{"provides"}}) { $provide{$provided} = 1; } ; } ; my %rdeps; foreach my $release (@{$$hits{"hits"}}) { foreach my $dep (@{$$release{"_source"}{"dependency"}}) { next unless $dep->{"relationship"} eq "requires"; next unless $dep->{"phase"} eq "runtime"; $rdeps{$dep->{"module"}} = 1; } ; } ; delete $rdeps{"perl"}; @last_deps = sort(grep({my $m = $_; my $c = "Module::CoreList"->is_core($m); not $provide{$m} || $c;} keys %rdeps)); push @deps, @last_deps; $LedgerSMB::Installer::log->trace("Dependency resolution iteration $iteration - " . 'remaining to resolve: ' . scalar(@last_deps)); ++$iteration } } 0 0 0
171 0 my $query = {
172 _source => [ qw( release distribution status provides ), 'dependency.*' ],
173 query => {
174 bool => {
175 must => [
176 { term => { status => 'latest' } },
177 { terms => { provides => [ @last_deps ] } }
178 ],
179 filter => {
180 match_all => {}
181 }
182 }
183 }
184 };
185  
186 0 my $body = $json->encode( $query );
187 0 my $r = $http->request( 'POST', 'https://fastapi.metacpan.org/v1/release/_search?size=1000',
188 { headers => { 'Content-Type' => 'application/json' },
189 content => $body });
190 0 ▶ unless ($r->{success}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($r->{"success"}) 0 0 0
191 0 die "Unable to request module dependencies; POST request failed for https://fastapi.metacpan.org/v1/release/_search, response: $r->{status} - $r->{reason}";
192 }
193 0 my $hits = $json->decode($r->{content})->{hits};
194  
195 0 for my $release ($hits->{hits}->@*) {
196 0 $dists{$release->{_source}->{distribution}} = 1;
197 }
198  
199 0 my %provide;
200 0 for my $release ($hits->{hits}->@*) {
201 0 for my $provided ($release->{_source}->{provides}->@*) {
202 0 $provide{$provided} = 1;
203 }
204 }
205  
206 0 my %rdeps;
207 0 for my $release ($hits->{hits}->@*) {
208 0 for my $dep ($release->{_source}->{dependency}->@*) {
209 0 ▶ next unless $dep->{relationship} eq 'requires';
Branch: 1 branch
BranchTrueFalseTotal
unless $dep->{"relationship"} eq "requires" 0 0 0
210 0 ▶ next unless $dep->{phase} eq 'runtime';
Branch: 1 branch
BranchTrueFalseTotal
unless $dep->{"phase"} eq "runtime" 0 0 0
211 0 $rdeps{$dep->{module}} = 1;
212 }
213 }
214  
215 0 delete $rdeps{perl};
216 @last_deps = sort grep {
217 0 my $m = $_;
218 0 my $c = Module::CoreList->is_core($m);
219  
220 0 ▶ not ($provide{$m} or $c);
Condition0%0/3
$provide{$m} || $c
l!l&&r!l&&!r
000
MC/DC0%0/2
$provide{$m} || $c
$provide{$m} $c
Truth table0%0/3
A || B
A= $provide{$m}B= $c
ABresult
1X1
011
000
221 } keys %rdeps;
222 0 push @deps, @last_deps;
223  
224 0 $log->trace( "Dependency resolution iteration $iteration - "
225 . "remaining to resolve: " . scalar(@last_deps) );
226 0 $iteration++;
227 } while (@last_deps);
228  
229 0 my @missed = do {
230 0 my %deps = map { $_ => 1 } @deps;
231 0 grep { !$deps{$_} } @orig_deps;
232 };
233 0 ▶ $log->error( "Unable to resolve dependencies for modules: "
Branch: 1 branch
BranchTrueFalseTotal
if @missed 0 0 0
234 . join(', ', @missed) )
235 if (@missed);
236 0 @deps = sort uniq (@deps, @missed);
237 0 $log->debug( "Dependency tree size: " . scalar(@deps) );
238 0 $log->trace( "- $_" ) for (@deps);
239 0 return @deps;
240 }
241  
242 0 ▶sub _compute_dep_pkgs($class, $dss, $config ) {
Subroutine _compute_dep_pkgs: not called CC=1 SCAR=6.9
243 0 my @mods = $class->_compute_all_deps( $config );
244  
245 # the array passed in gets modified; copy @mods so we still have it below
246 0 my ($pkgs, $unmapped) = $dss->pkgs_from_modules( [ @mods ] );
247  
248 0 my $c = scalar(@mods);
249 0 my $p = scalar(keys $pkgs->%*);
250 0 my $u = scalar($unmapped->@*);
251 0 $log->debug( "Resolved $c modules to $p packages; $u unmapped" );
252 0 return ([ sort keys $pkgs->%* ], $unmapped);
253 }
254  
255 0 ▶sub _download($class, $installpath, $version) {
Subroutine _download: not called CC=9 SCAR=45.0
256 0 my $fn = "ledgersmb-$version.tar.gz";
257 my $url =
258 $ENV{ARTIFACT_LOCATION} // (
259 0 ▶ ($version =~ m/\d+\.\d+\.\d+\-/)
Branch: 1 branch
BranchTrueFalseTotal
$version =~ /\d+\.\d+\.\d+\-/u ? : 0 0 0
Condition0%0/3
$ENV{"ARTIFACT_LOCATION"} // ($version =~ /\d+\.\d+\.\d+\-/u ? "https://download.ledgersmb.org/f/Beta%20Releases/$version/" : "https://download.ledgersmb.org/f/Releases/$version/")
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{"ARTIFACT_LOCATION"} // ($version =~ /\d+\.\d+\.\d+\-/u ? "https://download.ledgersmb.org/f/Beta%20Releases/$version/" : "https://download.ledgersmb.org/f/Releases/$version/")
$ENV{"ARTIFACT_LOCATION"} ($version =~ /\d+\.\d+\.\d+\-/u ? "https://download.ledgersmb.org/f/Beta%20Releases/$version/" : "https://download.ledgersmb.org/f/Releases/$version/")
Truth table0%0/3
A // B
A= $ENV{"ARTIFACT_LOCATION"}B= ($version =~ /\d+\.\d+\.\d+\-/u ? "https://download.ledgersmb.org/f/Beta%20Releases/$version/" : "https://download.ledgersmb.org/f/Releases/$version/")
ABresult
1X1
011
000
260 ? "https://download.ledgersmb.org/f/Beta%20Releases/$version/"
261 : "https://download.ledgersmb.org/f/Releases/$version/"
262 );
263 0 my $http = HTTP::Tiny->new;
264  
265 0 do {
266 0 ▶ open( my $fh, '>', File::Spec->catfile($installpath, $fn))
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", "File::Spec"->catfile($installpath, $fn) or croak($LedgerSMB::Installer::log->fatal("Unable to open output file ${fn}: $!")) 0 0 0
267 or croak $log->fatal( "Unable to open output file $fn: $!" );
268 0 binmode $fh, ':raw';
269 my $r = $http->get(
270 "$url$fn",
271 {
272 0 ▶ data_callback => sub($data, $status) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
273 0 print $fh $data;
274 }
275 0 });
276  
277 0 ▶ if ($r->{status} == 599) {
Branch: 2 branches
BranchTrueFalseTotal
if ($r->{'status'} == 599) { } 0 0 0
elsif (not $r->{'success'}) { } 0 0 0
278 0 croak $log->fatal( "Unable to request $url$fn: " . $r->{content} );
279 }
280 elsif (not $r->{success}) {
281 0 croak $log->fatal( "Unable to request $url$fn: $r->{status} - $r->{reason}" );
282 }
283 };
284  
285 0 do {
286 0 my $r = $http->get( "$url$fn.asc" );
287 0 ▶ if ($r->{status} == 599) {
Branch: 2 branches
BranchTrueFalseTotal
if ($r->{'status'} == 599) { } 0 0 0
elsif (not $r->{'success'}) { } 0 0 0
288 0 croak $log->fatal( "Unable to request $url/$fn: " . $r->{content} );
289 }
290 elsif (not $r->{success}) {
291 0 croak $log->fatal( "Unable to request $url/$fn: $r->{status} - $r->{reason}" );
292 }
293 else {
294 0 ▶ open( my $fh, '>', File::Spec->catfile($installpath, "$fn.asc"))
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", "File::Spec"->catfile($installpath, "$fn.asc") or croak($LedgerSMB::Installer::log->fatal("Unable to open output file $fn.asc: $!")) 0 0 0
295 or croak $log->fatal( "Unable to open output file $fn.asc: $!" );
296 0 binmode $fh, ':raw';
297 0 print $fh $r->{content};
298 }
299 };
300 }
301  
302 0 ▶sub _find_executable($class, $dss, $executable, $dirs) {
Subroutine _find_executable: not called CC=6 SCAR=37.4
303 0 ▶ while (my $dir = shift $dirs->@*) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dir = shift @$dirs) 0 0 0
304 0 my $exe = File::Spec->catfile( $dir, $dss->executable_name( $executable ) );
305 0 ▶ $log->trace( "Found $executable: $exe; but not executable" )
Branch: 1 branch
BranchTrueFalseTotal
if -e $exe and not -x $exe 0 0 0
Condition0%0/3
-e $exe and not -x $exe
!ll&&!rl&&r
000
MC/DC0%0/2
-e $exe and not -x $exe
-e $exe not -x $exe
Truth table0%0/3
A and not(B)
A= -e $exeB= not -x $exe
ABresult
0X0
100
111
306 if -e $exe and not -x $exe;
307 0 ▶ my $rv = -x $exe ? $exe : '';
Branch: 1 branch
BranchTrueFalseTotal
-x $exe ? : 0 0 0
308  
309 0 ▶ if ($rv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rv) 0 0 0
310 0 $log->debug( "Searching for $executable; found $exe" );
311 0 return $rv;
312 }
313 }
314 0 return undef;
315 }
316  
317 # This function is borrowed from App::Info::RDBMS::PostgreSQL v0.57
318 # because that is what DBD::Pg uses to identify where pg_config lives
319 0 ▶sub _search_bin_dirs($class) {
Subroutine _search_bin_dirs: not called CC=3 SCAR=24.8
320 return (( exists $ENV{POSTGRES_HOME}
321 ? (File::Spec->catdir($ENV{POSTGRES_HOME}, "bin"))
322 : ()
323 ),
324 ( exists $ENV{POSTGRES_LIB}
325 0 ▶ ? (File::Spec->catdir($ENV{POSTGRES_LIB}, File::Spec->updir, "bin"))
Branch: 2 branches
BranchTrueFalseTotal
exists $ENV{'POSTGRES_HOME'} ? : 0 0 0
exists $ENV{'POSTGRES_LIB'} ? : 0 0 0
326 : ()
327 ),
328 File::Spec->path,
329 qw(/usr/local/pgsql/bin
330 /usr/local/postgres/bin
331 /usr/lib/postgresql/bin
332 /opt/pgsql/bin
333 /usr/local/bin
334 /usr/local/sbin
335 /usr/bin
336 /usr/sbin
337 /bin),
338 'C:\Program Files\PostgreSQL\bin');
339 }
340 # end of borrowed code
341  
342 0 ▶sub _find_pg_config($class, $dss, $config) {
Subroutine _find_pg_config: not called CC=1 SCAR=6.9
343 0 my @dirs = $class->_search_bin_dirs;
344  
345 # TODO: Check for pg_config in $config
346  
347 0 return $class->_find_executable( $dss, 'pg_config', \@dirs );
348 }
349  
350 0 ▶sub _find_xml2_config($class, $dss, $config) {
Subroutine _find_xml2_config: not called CC=1 SCAR=6.9
351 0 return $class->_find_executable( $dss, 'xml2-config', [ File::Spec->path ] );
352 }
353  
354 0 ▶sub _find_latex($class, $dss, $config) {
Subroutine _find_latex: not called CC=1 SCAR=6.9
355 0 return $class->_find_executable( $dss, 'latex', [ File::Spec->path ] );
356 }
357  
358  
359 # mapping taken from File::Spec
360 1 my %module = (
361 MSWin32 => 'win32',
362 os2 => 'os2',
363 VMS => 'vms',
364 NetWare => 'win32',
365 symbian => 'win32',
366 dos => 'os2',
367 cygwin => 'cygwin',
368 amigaos => 'amigaos',
369 linux => 'linux' # not mapped in File::Spec
370 );
371  
372 0 ▶sub _get_os($class) {
Subroutine _get_os: not called CC=2 SCAR=17.9
373 0 ▶ return $module{$^O} || 'unix';
Condition0%0/2
$module{$^O} || 'unix'
l!l
00
MC/DC0%0/1
$module{$^O} || 'unix'
$module{$^O}
Truth table0%0/2
A
A= $module{$^O}
Aresult
11
00
374 }
375  
376 0 ▶sub _load_dist_support($class) {
Subroutine _load_dist_support: not called CC=2 SCAR=17.9
377 0 my $OS = $class->_get_os;
378  
379 0 $log->info( "Detected O/S: $OS" );
380 0 my $oss_class = "LedgerSMB::Installer::OS::$OS";
381  
382 0 local $@ = undef;
383 0 ▶ unless (eval "require $oss_class") {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval "require $oss_class") 0 0 0
384 0 say "Unable to load $oss_class: $@";
385 0 say "No support for $OS";
386 0 exit 2;
387 }
388  
389 0 my $oss = $oss_class->new; # operating system support instance
390 0 $log->debug( "Detecting distribution" );
391 0 return $oss->detect_dss; # detect and return distribution support instance
392 }
393  
394 0 ▶sub compute($class, @args) {
Subroutine compute: not called CC=12 SCAR=50.5
Pod undocumented
395 0 my ($dss, $config) = $class->_boot(
396 \@args,
397 [ 'yes|y!', 'target=s', 'local-lib=s', 'log-level=s' ]
398 );
399  
400 0 ▶ if (@args != 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args != 2) 0 0 0
401 0 die "Incorrect number of arguments";
402 }
403  
404 0 my $version = shift @args;
405 0 $config->compute_deps( 1 );
406 0 ▶ $config->version( $version ) if defined $version;
Branch: 1 branch
BranchTrueFalseTotal
if defined $version 0 0 0
407  
408 0 my $deps_outfile = $args[0];
409 0 ▶ open( my $out, '>:raw', $deps_outfile )
Branch: 1 branch
BranchTrueFalseTotal
open my $out, ">:raw", $deps_outfile or die "Unable to open output file '${deps_outfile}': $!" 0 0 0
410 or die "Unable to open output file '$deps_outfile': $!";
411  
412  
413 0 ▶ unless ($dss->am_system_perl) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dss->am_system_perl) 0 0 0
414 0 ▶ close( $out ) or warn $log->warn( "Unable to close output file" );
Branch: 1 branch
BranchTrueFalseTotal
close $out or warn $LedgerSMB::Installer::log->warn("Unable to close output file") 0 0 0
415 0 unlink $deps_outfile;
416 0 die $log->fatal( "Not running the system perl; not able to re-use system packages" );
417 }
418  
419 ###TODO: _get_immediate_prereqs may throw
420 0 my $prereqs = $class->_get_immediate_prereqs( $config );
421 0 my $requirements = $prereqs->merged_requirements();
422 0 ▶ unless ($requirements->accepts_module( 'perl', $])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($requirements->accepts_module("perl", $])) 0 0 0
423 0 ▶ close( $out ) or warn $log->warn( "Unable to close output file" );
Branch: 1 branch
BranchTrueFalseTotal
close $out or warn $LedgerSMB::Installer::log->warn("Unable to close output file") 0 0 0
424 0 unlink $deps_outfile;
425 0 my $perl_version = version->parse( $] )->normal;
426 0 die $log->fatal( "Perl version ($perl_version) not compliant with LedgerSMB " . $config->effective_version
427 . "; requires: " . $requirements->requirements_for_module( 'perl' ));
428 }
429  
430 ###TODO: prepare_pkg_resolver_env may throw
431 0 ▶ if ($config->effective_prepare_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_prepare_env) 0 0 0
432 0 $dss->prepare_pkg_resolver_env( $config );
433 }
434 0 my $exception;
435 0 do {
436 0 local $@ = undef;
437 0 my $failed = not eval {
438 0 $log->info( "Computing O/S packages for declared dependencies" );
439 0 my ($deps, $mods) = $class->_compute_dep_pkgs( $dss, $config );
440  
441 0 say $out $json->encode( { identifier => $dss->dependency_packages_identifier,
442 packages => $deps,
443 modules => $mods,
444 name => $dss->name,
445 'schema-version' => "1" } );
446  
447 0 return 1;
448 };
449 0 ▶ $exception = $@ if $failed;
Branch: 1 branch
BranchTrueFalseTotal
if $failed 0 0 0
450  
451 0 $log->info( "Dependencies written to $deps_outfile" );
452 0 ▶ if ($config->effective_uninstall_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_uninstall_env) 0 0 0
453 0 $log->warning( "Cleaning up Perl module installation dependencies" );
454 0 $dss->cleanup_env($config);
455 }
456 };
457 0 ▶ die $exception if defined $exception;
Branch: 1 branch
BranchTrueFalseTotal
if defined $exception 0 0 0
458  
459 0 return 0;
460 }
461  
462 sub download($class, @args) {
463 }
464  
465 0 ▶sub help($class, @args) {
Subroutine help: not called CC=1 SCAR=6.9
Pod undocumented
466 0 my $help_text = do {
467 0 local $/ = undef;
468 0 <DATA>;
469 };
470 0 $help_text =~ s/\bSCRIPT\b/$0/g;
471 0 say $help_text;
472  
473 0 return 0;
474 }
475  
476 0 ▶sub _module_will_install($class, $mod, $pkgs, $unmapped) {
Subroutine _module_will_install: not called CC=4 SCAR=30.0
477 # no packages will be installed:
478 0 ▶ return 0 if ((not $pkgs) or (not $pkgs->@*));
Branch: 1 branch
BranchTrueFalseTotal
unless $pkgs and @$pkgs 0 0 0
Condition0%0/3
$pkgs and @$pkgs
!ll&&!rl&&r
000
MC/DC0%0/2
$pkgs and @$pkgs
$pkgs @$pkgs
Truth table0%0/3
A and B
A= $pkgsB= @$pkgs
ABresult
0X0
100
111
479  
480 # package in the list of those not installed through a package:
481 0 ▶ return 0 if (grep { $mod eq $_ } $unmapped->@*);
Branch: 1 branch
BranchTrueFalseTotal
if grep {$mod eq $_;} @$unmapped 0 0 0
482  
483 # package must be in one of the packages being installed
484 0 return 1;
485 }
486  
487 0 ▶sub install($class, @args) {
Subroutine install: not called CC=47 SCAR=77.2
Pod undocumented
488 0 my $rv = 1;
489 0 my ($dss, $config) = $class->_boot(
490 \@args,
491 [ 'yes|y!', 'system-packages!', 'prepare-env!', 'target=s',
492 'local-lib=s', 'log-level=s', 'verify-sig!' ]
493 );
494 0 my $version = shift @args;
495 0 ▶ $config->version( $version ) if defined $version;
Branch: 1 branch
BranchTrueFalseTotal
if defined $version 0 0 0
496  
497 0 my ($pkg_deps, $unmapped_mods);
498 0 my @extra_pkgs;
499 0 ▶ if ($dss->am_system_perl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dss->am_system_perl) 0 0 0
500 0 my $name = $dss->name;
501 0 my $dep_pkg_id = $dss->dependency_packages_identifier;
502 0 ▶ if ($config->sys_pkgs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->sys_pkgs) 0 0 0
503 0 ($pkg_deps, $unmapped_mods) = $config->retrieve_precomputed_deps($name, $dep_pkg_id);
504 }
505 0 ▶ if ($pkg_deps) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg_deps) { } 0 0 0
506 0 ▶ if ($dss->pkg_can_install()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dss->pkg_can_install) { } 0 0 0
507 0 ▶ if ($config->effective_prepare_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_prepare_env) 0 0 0
508 0 $dss->prepare_builder_env( $config );
509 }
510 0 goto INSTALL_SYS_PKGS;
511 }
512 else {
513 0 $log->warn( "Unable to install system packages; will resort to installation of CPAN modules" );
514 0 $pkg_deps = undef;
515 }
516 }
517 else {
518 0 $log->warn( "No precomputed dependencies available for $name/$dep_pkg_id" );
519 0 $log->info( "Configuring environment for dependency computation" );
520 }
521 }
522  
523 ########################################################################################
524 #
525 # Need to clean up on failure after this point! We have changed system state!
526 #
527 ########################################################################################
528 0 $dss->prepare_extraction_env( $config );
529 0 $class->_build_install_tree( $dss, $config, $config->installpath, $config->effective_version );
530 0 my $prereqs = $class->_get_immediate_prereqs( $config );
531 0 my $requirements = $prereqs->merged_requirements();
532  
533 0 ▶ unless ($requirements->accepts_module( 'perl', $])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($requirements->accepts_module("perl", $])) 0 0 0
534 # BAIL: No suitable Perl here...
535 #
536 # well, we might want to see if Perlbrew is installed with an acceptable version?
537 #
538 # and if not, we could install Perlbrew here...
539 0 die $log->fatal( "Not running a Perl version compliant with LedgerSMB " . $config->effective_version );
540 }
541  
542 0 ▶ if ($config->effective_prepare_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_prepare_env) 0 0 0
543 0 $dss->prepare_builder_env( $config );
544 }
545  
546 0 ▶ if ($dss->am_system_perl and $dss->pkg_can_install) { # and $dss->deps_can_map
Branch: 1 branch
BranchTrueFalseTotal
if ($dss->am_system_perl and $dss->pkg_can_install) { } 0 0 0
Condition0%0/3
$dss->am_system_perl and $dss->pkg_can_install
!ll&&!rl&&r
000
MC/DC0%0/2
$dss->am_system_perl and $dss->pkg_can_install
$dss->am_system_perl $dss->pkg_can_install
Truth table0%0/3
A and B
A= $dss->am_system_perlB= $dss->pkg_can_install
ABresult
0X0
100
111
547 0 ▶ if ($config->effective_prepare_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_prepare_env) 0 0 0
548 0 $dss->prepare_pkg_resolver_env( $config );
549 }
550 0 ($pkg_deps, $unmapped_mods) = $class->_compute_dep_pkgs( $dss, $config );
551 }
552 else {
553 0 $unmapped_mods = [ $class->_compute_all_deps( $config ) ];
554 }
555  
556 0 $log->info( "Checking for availability of DBD::Pg" );
557 0 ▶ if (not eval { require DBD::Pg; 1; } # not loadable, and
Branch: 3 branches
BranchTrueFalseTotal
if (not eval { do { require DBD::Pg; 1 } } || $class->_module_will_install('DBD::Pg', $pkg_deps, $unmapped_mods)) { } 0 0 0
elsif (eval { do { require DBD::Pg; 1 } }) { } 0 0 0
elsif (not grep({$_ eq 'DBD::Pg';} @$unmapped_mods)) { } 0 0 0
Condition0%0/3
eval { do { require DBD::Pg; 1 } } || $class->_module_will_install('DBD::Pg', $pkg_deps, $unmapped_mods)
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { require DBD::Pg; 1 } } || $class->_module_will_install('DBD::Pg', $pkg_deps, $unmapped_mods)
eval { do { require DBD::Pg; 1 } } $class->_module_will_install('DBD::Pg', $pkg_deps, $unmapped_mods)
Truth table0%0/3
A || B
A= eval { do { require DBD::Pg; 1 } }B= $class->_module_will_install('DBD::Pg', $pkg_deps, $unmapped_mods)
ABresult
1X1
011
000
558 and not $class->_module_will_install( 'DBD::Pg', $pkg_deps, $unmapped_mods )) {
559 # don't have DBD::Pg
560 # *and* won't install as part of $pkg_deps
561  
562 0 my $pg_config = $class->_find_pg_config( $dss, $config );
563 0 ▶ die $log->fatal( "Missing 'pg_config' command to build DBD::Pg" )
Branch: 1 branch
BranchTrueFalseTotal
unless $pg_config 0 0 0
564 unless $pg_config;
565 0 chomp( my $include_dir = `'$pg_config' --includedir` );
566  
567 0 $log->debug( "Directory for PostgreSQL headers: $include_dir" );
568 0 my $header_file = File::Spec->catfile( $include_dir, 'libpq-fe.h' );
569  
570 0 ▶ if (not -e $header_file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $header_file) 0 0 0
571 0 ▶ if (not $dss->pkg_can_install) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dss->pkg_can_install) 0 0 0
572 0 die $log->fatal( "Missing 'libpq-fe.h' PostgreSQL header to build DBD::Pg" );
573 }
574  
575 0 my ($run_deps, $build_deps) = $dss->pkg_deps_dbd_pg;
576 0 $config->mark_pkgs_for_cleanup( $build_deps );
577 0 push @extra_pkgs, $run_deps->@*, $build_deps->@*;
578 }
579 }
580 0 elsif (eval { require DBD::Pg; 1; }) {
581 0 $log->info( "DBD::Pg is loadable" );
582 }
583 0 elsif (not grep { $_ eq 'DBD::Pg' } $unmapped_mods->@*) {
584 0 $log->info( "DBD::Pg will be installed" );
585 }
586 else {
587 0 $log->fatal( "Internal error: DBD::Pg not available and won't be installed, but build prereqs not checked?!?!" );
588 }
589  
590 0 $log->info( "Checking for availability of LaTeX::Driver" );
591 0 ▶ if (not eval { require LaTeX::Driver; 1; } # loadable, and
Branch: 3 branches
BranchTrueFalseTotal
if (not eval { do { require LaTeX::Driver; 1 } } || $class->_module_will_install('LaTeX::Driver', $pkg_deps, $unmapped_mods)) { } 0 0 0
elsif (eval { do { require LaTeX::Driver; 1 } }) { } 0 0 0
elsif (not grep({$_ eq 'LaTeX::Driver';} @$unmapped_mods)) { } 0 0 0
Condition0%0/3
eval { do { require LaTeX::Driver; 1 } } || $class->_module_will_install('LaTeX::Driver', $pkg_deps, $unmapped_mods)
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { require LaTeX::Driver; 1 } } || $class->_module_will_install('LaTeX::Driver', $pkg_deps, $unmapped_mods)
eval { do { require LaTeX::Driver; 1 } } $class->_module_will_install('LaTeX::Driver', $pkg_deps, $unmapped_mods)
Truth table0%0/3
A || B
A= eval { do { require LaTeX::Driver; 1 } }B= $class->_module_will_install('LaTeX::Driver', $pkg_deps, $unmapped_mods)
ABresult
1X1
011
000
592 and not $class->_module_will_install( 'LaTeX::Driver', $pkg_deps, $unmapped_mods )) {
593 # don't have LaTeX::Driver
594 # *and* won't install as part of $pkg_deps
595  
596 # testing early, because LaTeX::Driver only installs
597 # when LaTeX is installed...
598  
599 0 my $latex = $class->_find_latex( $dss, $config );
600 0 ▶ if (not $latex) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($latex) 0 0 0
601 0 ▶ if (not $dss->pkg_can_install) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dss->pkg_can_install) 0 0 0
602 0 die $log->fatal( "Missing 'latex' executable required for building 'LaTeX::Driver' module" );
603 }
604 }
605 }
606 0 elsif (eval { require LaTeX::Driver; 1; }) {
607 0 $log->info( "LaTeX::Driver is loadable" );
608 }
609 0 elsif (not grep { $_ eq 'LaTeX::Driver' } $unmapped_mods->@*) {
610 0 $log->info( "LaTeX::Driver will be installed" );
611 }
612 else {
613 0 $log->fatal( "Internal error: LaTeX::Driver not available and won't be installed, but build prereqs not checked?!?!" );
614 }
615 0 ▶ if ($dss->pkg_can_install) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dss->pkg_can_install) { } 0 0 0
616 # installs LaTeX *and* styles required for standard templates
617 0 my ($run_deps, $build_deps) = $dss->pkg_deps_latex;
618 0 $config->mark_pkgs_for_cleanup( $build_deps );
619 0 push @extra_pkgs, $run_deps->@*, $build_deps->@*;
620 }
621 else {
622 ###TODO: figure out how to warn the user of minimal required
623 # styles configuration...
624 }
625  
626 0 $log->info( "Checking for availability of XML::Parser" );
627 0 ▶ if (not eval { require XML::Parser; 1; }
Branch: 3 branches
BranchTrueFalseTotal
if (not eval { do { require XML::Parser; 1 } } || $class->_module_will_install('XML::Parser', $pkg_deps, $unmapped_mods)) { } 0 0 0
elsif (eval { do { require XML::Parser; 1 } }) { } 0 0 0
elsif (not grep({$_ eq 'XML::Parser';} @$unmapped_mods)) { } 0 0 0
Condition0%0/3
eval { do { require XML::Parser; 1 } } || $class->_module_will_install('XML::Parser', $pkg_deps, $unmapped_mods)
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { require XML::Parser; 1 } } || $class->_module_will_install('XML::Parser', $pkg_deps, $unmapped_mods)
eval { do { require XML::Parser; 1 } } $class->_module_will_install('XML::Parser', $pkg_deps, $unmapped_mods)
Truth table0%0/3
A || B
A= eval { do { require XML::Parser; 1 } }B= $class->_module_will_install('XML::Parser', $pkg_deps, $unmapped_mods)
ABresult
1X1
011
000
628 and not $class->_module_will_install( 'XML::Parser', $pkg_deps, $unmapped_mods)) {
629  
630 0 $log->info( "Checking availability of libexpat" );
631 0 ▶ my $incpath = $ENV{EXPATINCPATH} // '';
Condition0%0/2
$ENV{"EXPATINCPATH"} // ""
l!l
00
MC/DC0%0/1
$ENV{"EXPATINCPATH"} // ""
$ENV{"EXPATINCPATH"}
Truth table0%0/2
A
A= $ENV{"EXPATINCPATH"}
Aresult
11
00
632 0 ▶ my $libpath = $ENV{EXPATLIBPATH} // '';
Condition0%0/2
$ENV{"EXPATLIBPATH"} // ""
l!l
00
MC/DC0%0/1
$ENV{"EXPATLIBPATH"} // ""
$ENV{"EXPATLIBPATH"}
Truth table0%0/2
A
A= $ENV{"EXPATLIBPATH"}
Aresult
11
00
633  
634 # Devel::CheckLib tries to find the C compiler when use-d
635 # however, we might be installing it as part of the installation
636 # process, so we don't want Devel::CheckLib to check when loading the script...
637 0 eval "use Devel::CheckLib qw(assert_lib);";
638 0 ▶ unless (eval { assert_lib( lib => [qw(expat)],
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { assert_lib('lib', ['expat'], 'header', ['expat.h'], 'incpath', $incpath, $libpath ? ('libpath', $libpath) : ()); 1 } }) { } 0 0 0
$libpath ? : 0 0 0
639 header => ['expat.h'],
640 incpath => $incpath,
641 ( $libpath ? (libpath => $libpath) : () )
642 0 ); 1; }) {
643 0 ▶ if (not $dss->pkg_can_install) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $dss->pkg_can_install) { } 0 0 0
644 ###TODO: We could push Alien::Expat into @unmapped_mods
645 # instead of bailing out here...
646 0 die $log->fatal( "Missing XML parser library Expat blocking installation of XML::Parser" );
647 }
648 else {
649 0 my ($run_deps, $build_deps) = $dss->pkg_deps_expat;
650 0 $config->mark_pkgs_for_cleanup( $build_deps );
651 0 push @extra_pkgs, $run_deps->@*, $build_deps->@*;
652 }
653 }
654 else {
655 0 $log->info( "Found expat header and library for XML::Parser compilation" );
656 }
657 }
658 0 elsif (eval { require XML::Parser; 1; }) {
659 0 $log->info( "XML::Parser is loadable" );
660 }
661 0 elsif (not grep { $_ eq 'XML::Parser' } $unmapped_mods->@*) {
662 0 $log->info( "XML::Parser will be installed" );
663 }
664 else {
665 0 $log->fatal( "Internal error: XML::Parser not available and won't be installed, but build prereqs not checked?!?!" );
666 }
667  
668 0 ▶ if ((not eval { require XML::LibXML; 1; }
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require XML::LibXML; 1 } } or $class->_module_will_install("XML::LibXML", $pkg_deps, $unmapped_mods) or (eval { do { require XML::Twig; 1 } } or $class->_module_will_install("XML::Twig", $pkg_deps, $unmapped_mods))) 0 0 0
Condition0%0/9
eval { do { require XML::LibXML; 1 } } or $class->_module_will_install("XML::LibXML", $pkg_deps, $unmapped_mods) or (eval { do { require XML::Twig; 1 } } or $class->_module_will_install("XML::Twig", $pkg_deps, $unmapped_mods))
l!l&&r!l&&!r
000
eval { do { require XML::LibXML; 1 } } or $class->_module_will_install("XML::LibXML", $pkg_deps, $unmapped_mods)
l!l&&r!l&&!r
000
eval { do { require XML::Twig; 1 } } or $class->_module_will_install("XML::Twig", $pkg_deps, $unmapped_mods)
l!l&&r!l&&!r
000
MC/DC0%0/4
eval { do { require XML::LibXML; 1 } } or $class->_module_will_install("XML::LibXML", $pkg_deps, $unmapped_mods) or (eval { do { require XML::Twig; 1 } } or $class->_module_will_install("XML::Twig", $pkg_deps, $unmapped_mods))
eval { do { require XML::LibXML; 1 } } $class->_module_will_install("XML::LibXML", $pkg_deps, $unmapped_mods) eval { do { require XML::Twig; 1 } } $class->_module_will_install("XML::Twig", $pkg_deps, $unmapped_mods)
Truth table0%0/5
A or B or C or D
A= eval { do { require XML::LibXML; 1 } }B= $class->_module_will_install("XML::LibXML", $pkg_deps, $unmapped_mods)C= eval { do { require XML::Twig; 1 } }D= $class->_module_will_install("XML::Twig", $pkg_deps, $unmapped_mods)
ABCDresult
1XXX1
01XX1
001X1
00011
00000
669 and not $class->_module_will_install( 'XML::LibXML', $pkg_deps, $unmapped_mods ))
670 0 and (not eval { require XML::Twig; 1; }
671 and not $class->_module_will_install( 'XML::Twig', $pkg_deps, $unmapped_mods ))) {
672 # don't have either XML::LibXML or XML::Twig
673  
674 0 my $xml2_config = $class->_find_xml2_config( $dss, $config );
675 0 ▶ if (not $xml2_config) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($xml2_config) 0 0 0
676 0 ▶ if (not $dss->pkg_can_install) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $dss->pkg_can_install) { } 0 0 0
677 0 warn $log->warning("Missing 'xml2-config' executable required for building XML::LibXML -- falling back to Alien::Libxml2" );
678 }
679 else {
680 0 my ($run_deps, $build_deps) = $dss->pkg_deps_xml;
681 0 $config->mark_pkgs_for_cleanup( $build_deps );
682 0 push @extra_pkgs, $run_deps->@*, $build_deps->@*;
683 }
684 }
685 }
686  
687 0 ▶ goto PREPARE_TREE if (not $pkg_deps or not $pkg_deps->@*);
Branch: 1 branch
BranchTrueFalseTotal
unless $pkg_deps and @$pkg_deps 0 0 0
Condition0%0/3
$pkg_deps and @$pkg_deps
!ll&&!rl&&r
000
MC/DC0%0/2
$pkg_deps and @$pkg_deps
$pkg_deps @$pkg_deps
Truth table0%0/3
A and B
A= $pkg_depsB= @$pkg_deps
ABresult
0X0
100
111
688  
689 0 INSTALL_SYS_PKGS:
690 $log->info( "Installing O/S packages: " . join(' ', $pkg_deps->@*) );
691 0 $dss->pkg_install( $pkg_deps );
692  
693 PREPARE_TREE:
694 0 ▶ if (@extra_pkgs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@extra_pkgs) 0 0 0
695 0 $log->info( "Installing build dependency packages: " . join(' ', @extra_pkgs) );
696 0 $dss->pkg_install( \@extra_pkgs );
697 }
698 0 ▶ if ($config->effective_prepare_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_prepare_env) 0 0 0
699 0 $dss->prepare_installer_env( $config );
700 }
701  
702 ###TODO: ideally, we pass the immediate dependencies instead of the installation path;
703 # that allows selection of specific features in a later iteration
704 #
705 # Installs dependencies from cpanfile (because it respects dependency versions,
706 # which the simple list of dependencies does not); then installs the extra
707 # dependencies which were not satisfied from the list of unmapped_mods)
708 0 $dss->cpanm_install( $config->installpath, $config->locallib, $unmapped_mods );
709 0 $rv = 0;
710  
711 0 $log->info( "Generating application server startup script (server-start)" );
712 0 $dss->generate_start_script( File::Spec->rel2abs( $config->installpath ),
713 File::Spec->rel2abs( $config->locallib ) );
714  
715 0 CLEANUP:
716 $log->warning( "Cleaning up Perl module installation dependencies" );
717 0 $dss->cleanup_env($config);
718  
719 0 ▶ if ($rv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rv) { } 0 0 0
720 0 ▶ if (-e $config->installpath) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $config->installpath) 0 0 0
721 0 $log->warning( "Cleaning up installation path" );
722 0 remove_tree $config->installpath;
723 }
724  
725 0 say "Failed to complete server installation.";
726 }
727 else {
728 0 my $installpath = $config->installpath;
729 0 say "
730 LedgerSMB installation into $installpath completed.
731  
732 The LedgerSMB server can be started using the generated
733 startup script:
734  
735 \$ $installpath/server-start
736  
737 The server will run with its default configuration. To change
738 the configuration, copy the file doc/conf/ledgersmb.yaml to
739 $installpath and modify it. After modification, restart the
740 LedgerSMB server to activate the new configuration.
741  
742 ";
743 }
744  
745 0 return $rv;
746 }
747  
748 0 ▶sub print_id( $class, @args) {
Subroutine print_id: not called CC=1 SCAR=6.9
Pod undocumented
749 0 my $dss = $class->_load_dist_support;
750 0 say $dss->dependency_packages_identifier;
751 }
752  
753 0 ▶sub run($class, $cmd, @args) {
Subroutine run: not called CC=7 SCAR=40.3
Pod undocumented
754 0 STDOUT->autoflush(1);
755 0 STDERR->autoflush(1);
756  
757 0 ▶ if ($cmd =~ m/^-/) { # option(s)
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^-/u) 0 0 0
758 0 unshift @args, $cmd;
759 0 $cmd = 'install';
760 }
761  
762 0 ▶ if ($cmd eq 'compute') {
Branch: 5 branches
BranchTrueFalseTotal
if ($cmd eq 'compute') { } 0 0 0
elsif ($cmd eq 'download') { } 0 0 0
elsif ($cmd eq 'help') { } 0 0 0
elsif ($cmd eq 'install') { } 0 0 0
elsif ($cmd eq 'system-id') { } 0 0 0
763 0 say $log->info( "Computing dependencies using installer $INSTALLER_VERSION" );
764 0 return $class->compute( @args );
765 }
766 elsif ($cmd eq 'download') {
767 0 return $class->download( @args );
768 }
769 elsif ($cmd eq 'help') {
770 0 return $class->help( @args );
771 }
772 elsif ($cmd eq 'install') {
773 0 say $log->info( "Installing LedgerSMB using installer $INSTALLER_VERSION" );
774 0 return $class->install( @args );
775 }
776 elsif ($cmd eq 'system-id') {
777 0 return $class->print_id( @args );
778 }
779 else {
780 0 $class->help();
781 0 exit 1;
782 }
783 }
784  
785  
786 1 1;
787  
788 =head1 NAME
789  
790 LedgerSMB::Installer - Installer for the LedgerSMB accounting web application
791  
792 =head1 DESCRIPTION
793  
794 =head1 MAINTAINER
795  
796 Erik Huelsmann
797  
798 =head1 AUTHOR
799  
800 Erik Huelsmann
801  
802 =head1 LICENSE
803  
804 Copyright 2025 Erik Huelsmann
805  
806 Permission is hereby granted, free of charge, to any person obtaining a copy
807 of this software and associated documentation files (the "Software"), to deal
808 in the Software without restriction, including without limitation the rights
809 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
810 copies of the Software, and to permit persons to whom the Software is
811 furnished to do so, subject to the following conditions:
812  
813 The above copyright notice and this permission notice shall be included in
814 all copies or substantial portions of the Software.
815  
816 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
817 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
818 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
819 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
820 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
821 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
822 SOFTWARE.
823  
824 =cut
825  
826 __DATA__
↑ Summary Installer/OS.pm »