Installer.pm

filter: Statementstmt 15.6% 62 / 397 Branchbran 0.0% 0 / 154 Conditioncond 0.0% 0 / 41 MC/DCmcdc 0.0% 0 / 24 Subroutinesub 45.2% 19 / 42 Podpod 0.0% 0 / 5 totaltotal 12.2% 81 / 663 CC 102 SCAR 66.6
CC
102
Cov
10%
install
2256.0
_compute_all_deps
156.0
compute
156.0
CRAP 778.8
↑ Summary Installer/OS.pm »
1 package LedgerSMB::Installer v0.999.11;
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 ▶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 ▶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 ▶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 ▶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 ▶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 ▶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 ▶sub _compute_all_deps($class, $config) {
Subroutine _compute_all_deps: not called CC=12 SCAR=50.5
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}); 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 my $hits = $json->decode($r->{content})->{hits};
191  
192 0 for my $release ($hits->{hits}->@*) {
193 0 $dists{$release->{_source}->{distribution}} = 1;
194 }
195  
196 0 my %provide;
197 0 for my $release ($hits->{hits}->@*) {
198 0 for my $provided ($release->{_source}->{provides}->@*) {
199 0 $provide{$provided} = 1;
200 }
201 }
202  
203 0 my %rdeps;
204 0 for my $release ($hits->{hits}->@*) {
205 0 for my $dep ($release->{_source}->{dependency}->@*) {
206 0 ▶ next unless $dep->{relationship} eq 'requires';
Branch: 1 branch
BranchTrueFalseTotal
unless $dep->{"relationship"} eq "requires" 0 0 0
207 0 ▶ next unless $dep->{phase} eq 'runtime';
Branch: 1 branch
BranchTrueFalseTotal
unless $dep->{"phase"} eq "runtime" 0 0 0
208 0 $rdeps{$dep->{module}} = 1;
209 }
210 }
211  
212 0 delete $rdeps{perl};
213 @last_deps = sort grep {
214 0 my $m = $_;
215 0 my $c = Module::CoreList->is_core($m);
216  
217 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
218 } keys %rdeps;
219 0 push @deps, @last_deps;
220  
221 0 $log->trace( "Dependency resolution iteration $iteration - "
222 . "remaining to resolve: " . scalar(@last_deps) );
223 0 $iteration++;
224 } while (@last_deps);
225  
226 0 my @missed = do {
227 0 my %deps = map { $_ => 1 } @deps;
228 0 grep { !$deps{$_} } @orig_deps;
229 };
230 0 ▶ $log->error( "Unable to resolve dependencies for modules: "
Branch: 1 branch
BranchTrueFalseTotal
if @missed 0 0 0
231 . join(', ', @missed) )
232 if (@missed);
233 0 @deps = sort uniq (@deps, @missed);
234 0 $log->debug( "Dependency tree size: " . scalar(@deps) );
235 0 $log->trace( "- $_" ) for (@deps);
236 0 return @deps;
237 }
238  
239 ▶sub _compute_dep_pkgs($class, $dss, $config ) {
Subroutine _compute_dep_pkgs: not called CC=1 SCAR=6.9
240 0 my @mods = $class->_compute_all_deps( $config );
241  
242 # the array passed in gets modified; copy @mods so we still have it below
243 0 my ($pkgs, $unmapped) = $dss->pkgs_from_modules( [ @mods ] );
244  
245 0 my $c = scalar(@mods);
246 0 my $p = scalar(keys $pkgs->%*);
247 0 my $u = scalar($unmapped->@*);
248 0 $log->debug( "Resolved $c modules to $p packages; $u unmapped" );
249 0 return ([ sort keys $pkgs->%* ], $unmapped);
250 }
251  
252 ▶sub _download($class, $installpath, $version) {
Subroutine _download: not called CC=8 SCAR=42.8
253 0 my $fn = "ledgersmb-$version.tar.gz";
254 0 ▶ my $url = $ENV{ARTIFACT_LOCATION} // "https://download.ledgersmb.org/f/Releases/$version/";
Condition0%0/2
$ENV{"ARTIFACT_LOCATION"} // "https://download.ledgersmb.org/f/Releases/$version/"
l!l
00
MC/DC0%0/1
$ENV{"ARTIFACT_LOCATION"} // "https://download.ledgersmb.org/f/Releases/$version/"
$ENV{"ARTIFACT_LOCATION"}
Truth table0%0/2
A
A= $ENV{"ARTIFACT_LOCATION"}
Aresult
11
00
255 0 my $http = HTTP::Tiny->new;
256  
257 0 do {
258 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
259 or croak $log->fatal( "Unable to open output file $fn: $!" );
260 0 binmode $fh, ':raw';
261 ▶ my $r = $http->get(
Subroutine __ANON__: not called CC=1 SCAR=6.9
262 "$url$fn",
263 {
264 data_callback => sub($data, $status) {
265 0 print $fh $data;
266 }
267 0 });
268  
269 0 ▶ if ($r->{status} == 599) {
Branch: 2 branches
BranchTrueFalseTotal
if ($r->{'status'} == 599) { } 0 0 0
elsif (not $r->{'success'}) { } 0 0 0
270 0 croak $log->fatal( "Unable to request $url$fn: " . $r->{content} );
271 }
272 elsif (not $r->{success}) {
273 0 croak $log->fatal( "Unable to request $url$fn: $r->{status} - $r->{reason}" );
274 }
275 };
276  
277 0 do {
278 0 my $r = $http->get( "$url$fn.asc" );
279 0 ▶ if ($r->{status} == 599) {
Branch: 2 branches
BranchTrueFalseTotal
if ($r->{'status'} == 599) { } 0 0 0
elsif (not $r->{'success'}) { } 0 0 0
280 0 croak $log->fatal( "Unable to request $url/$fn: " . $r->{content} );
281 }
282 elsif (not $r->{success}) {
283 0 croak $log->fatal( "Unable to request $url/$fn: $r->{status} - $r->{reason}" );
284 }
285 else {
286 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
287 or croak $log->fatal( "Unable to open output file $fn.asc: $!" );
288 0 binmode $fh, ':raw';
289 0 print $fh $r->{content};
290 }
291 };
292 }
293  
294 ▶sub _find_executable($class, $dss, $executable, $dirs) {
Subroutine _find_executable: not called CC=6 SCAR=37.4
295 0 ▶ while (my $dir = shift $dirs->@*) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dir = shift @$dirs) 0 0 0
296 0 my $exe = File::Spec->catfile( $dir, $dss->executable_name( $executable ) );
297 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
298 if -e $exe and not -x $exe;
299 0 ▶ my $rv = -x $exe ? $exe : '';
Branch: 1 branch
BranchTrueFalseTotal
-x $exe ? : 0 0 0
300  
301 0 ▶ if ($rv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rv) 0 0 0
302 0 $log->debug( "Searching for $executable; found $exe" );
303 0 return $rv;
304 }
305 }
306 0 return undef;
307 }
308  
309 # This function is borrowed from App::Info::RDBMS::PostgreSQL v0.57
310 # because that is what DBD::Pg uses to identify where pg_config lives
311 ▶sub _search_bin_dirs($class) {
Subroutine _search_bin_dirs: not called CC=3 SCAR=24.8
312 return (( exists $ENV{POSTGRES_HOME}
313 ? (File::Spec->catdir($ENV{POSTGRES_HOME}, "bin"))
314 : ()
315 ),
316 ( exists $ENV{POSTGRES_LIB}
317 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
318 : ()
319 ),
320 File::Spec->path,
321 qw(/usr/local/pgsql/bin
322 /usr/local/postgres/bin
323 /usr/lib/postgresql/bin
324 /opt/pgsql/bin
325 /usr/local/bin
326 /usr/local/sbin
327 /usr/bin
328 /usr/sbin
329 /bin),
330 'C:\Program Files\PostgreSQL\bin');
331 }
332 # end of borrowed code
333  
334 ▶sub _find_pg_config($class, $dss, $config) {
Subroutine _find_pg_config: not called CC=1 SCAR=6.9
335 0 my @dirs = $class->_search_bin_dirs;
336  
337 # TODO: Check for pg_config in $config
338  
339 0 return $class->_find_executable( $dss, 'pg_config', \@dirs );
340 }
341  
342 ▶sub _find_xml2_config($class, $dss, $config) {
Subroutine _find_xml2_config: not called CC=1 SCAR=6.9
343 0 return $class->_find_executable( $dss, 'xml2-config', [ File::Spec->path ] );
344 }
345  
346 ▶sub _find_latex($class, $dss, $config) {
Subroutine _find_latex: not called CC=1 SCAR=6.9
347 0 return $class->_find_executable( $dss, 'latex', [ File::Spec->path ] );
348 }
349  
350  
351 # mapping taken from File::Spec
352 1 my %module = (
353 MSWin32 => 'win32',
354 os2 => 'os2',
355 VMS => 'vms',
356 NetWare => 'win32',
357 symbian => 'win32',
358 dos => 'os2',
359 cygwin => 'cygwin',
360 amigaos => 'amigaos',
361 linux => 'linux' # not mapped in File::Spec
362 );
363  
364 ▶sub _get_os($class) {
Subroutine _get_os: not called CC=2 SCAR=17.9
365 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
366 }
367  
368 ▶sub _load_dist_support($class) {
Subroutine _load_dist_support: not called CC=2 SCAR=17.9
369 0 my $OS = $class->_get_os;
370  
371 0 $log->info( "Detected O/S: $OS" );
372 0 my $oss_class = "LedgerSMB::Installer::OS::$OS";
373  
374 0 local $@ = undef;
375 0 ▶ unless (eval "require $oss_class") {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval "require $oss_class") 0 0 0
376 0 say "Unable to load $oss_class: $@";
377 0 say "No support for $OS";
378 0 exit 2;
379 }
380  
381 0 my $oss = $oss_class->new; # operating system support instance
382 0 $log->debug( "Detecting distribution" );
383 0 return $oss->detect_dss; # detect and return distribution support instance
384 }
385  
386 ▶sub compute($class, @args) {
Subroutine compute: not called CC=12 SCAR=50.5
Pod undocumented
387 0 my ($dss, $config) = $class->_boot(
388 \@args,
389 [ 'yes|y!', 'target=s', 'local-lib=s', 'log-level=s' ]
390 );
391  
392 0 ▶ if (@args != 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args != 2) 0 0 0
393 0 die "Incorrect number of arguments";
394 }
395  
396 0 my $version = shift @args;
397 0 $config->compute_deps( 1 );
398 0 ▶ $config->version( $version ) if defined $version;
Branch: 1 branch
BranchTrueFalseTotal
if defined $version 0 0 0
399  
400 0 my $deps_outfile = $args[0];
401 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
402 or die "Unable to open output file '$deps_outfile': $!";
403  
404  
405 0 ▶ unless ($dss->am_system_perl) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dss->am_system_perl) 0 0 0
406 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
407 0 unlink $deps_outfile;
408 0 die $log->fatal( "Not running the system perl; not able to re-use system packages" );
409 }
410  
411 ###TODO: _get_immediate_prereqs may throw
412 0 my $prereqs = $class->_get_immediate_prereqs( $config );
413 0 my $requirements = $prereqs->merged_requirements();
414 0 ▶ unless ($requirements->accepts_module( 'perl', $])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($requirements->accepts_module("perl", $])) 0 0 0
415 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
416 0 unlink $deps_outfile;
417 0 my $perl_version = version->parse( $] )->normal;
418 0 die $log->fatal( "Perl version ($perl_version) not compliant with LedgerSMB " . $config->effective_version
419 . "; requires: " . $requirements->requirements_for_module( 'perl' ));
420 }
421  
422 ###TODO: prepare_pkg_resolver_env may throw
423 0 ▶ if ($config->effective_prepare_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_prepare_env) 0 0 0
424 0 $dss->prepare_pkg_resolver_env( $config );
425 }
426 0 my $exception;
427 0 do {
428 0 local $@ = undef;
429 0 my $failed = not eval {
430 0 $log->info( "Computing O/S packages for declared dependencies" );
431 0 my ($deps, $mods) = $class->_compute_dep_pkgs( $dss, $config );
432  
433 0 say $out $json->encode( { identifier => $dss->dependency_packages_identifier,
434 packages => $deps,
435 modules => $mods,
436 name => $dss->name,
437 'schema-version' => "1" } );
438  
439 0 return 1;
440 };
441 0 ▶ $exception = $@ if $failed;
Branch: 1 branch
BranchTrueFalseTotal
if $failed 0 0 0
442  
443 0 $log->info( "Dependencies written to $deps_outfile" );
444 0 ▶ if ($config->effective_uninstall_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_uninstall_env) 0 0 0
445 0 $log->warning( "Cleaning up Perl module installation dependencies" );
446 0 $dss->cleanup_env($config);
447 }
448 };
449 0 ▶ die $exception if defined $exception;
Branch: 1 branch
BranchTrueFalseTotal
if defined $exception 0 0 0
450  
451 0 return 0;
452 }
453  
454 sub download($class, @args) {
455 }
456  
457 ▶sub help($class, @args) {
Subroutine help: not called CC=1 SCAR=6.9
Pod undocumented
458 0 my $help_text = do {
459 0 local $/ = undef;
460 0 <DATA>;
461 };
462 0 $help_text =~ s/\bSCRIPT\b/$0/g;
463 0 say $help_text;
464  
465 0 return 0;
466 }
467  
468 ▶sub _module_will_install($class, $mod, $pkgs, $unmapped) {
Subroutine _module_will_install: not called CC=4 SCAR=30.0
469 # no packages will be installed:
470 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
471  
472 # package in the list of those not installed through a package:
473 0 ▶ return 0 if (grep { $mod eq $_ } $unmapped->@*);
Branch: 1 branch
BranchTrueFalseTotal
if grep {$mod eq $_;} @$unmapped 0 0 0
474  
475 # package must be in one of the packages being installed
476 0 return 1;
477 }
478  
479 ▶sub install($class, @args) {
Subroutine install: not called CC=47 SCAR=77.2
Pod undocumented
480 0 my $rv = 1;
481 0 my ($dss, $config) = $class->_boot(
482 \@args,
483 [ 'yes|y!', 'system-packages!', 'prepare-env!', 'target=s',
484 'local-lib=s', 'log-level=s', 'verify-sig!' ]
485 );
486 0 my $version = shift @args;
487 0 ▶ $config->version( $version ) if defined $version;
Branch: 1 branch
BranchTrueFalseTotal
if defined $version 0 0 0
488  
489 0 my ($pkg_deps, $unmapped_mods);
490 0 my @extra_pkgs;
491 0 ▶ if ($dss->am_system_perl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dss->am_system_perl) 0 0 0
492 0 my $name = $dss->name;
493 0 my $dep_pkg_id = $dss->dependency_packages_identifier;
494 0 ▶ if ($config->sys_pkgs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->sys_pkgs) 0 0 0
495 0 ($pkg_deps, $unmapped_mods) = $config->retrieve_precomputed_deps($name, $dep_pkg_id);
496 }
497 0 ▶ if ($pkg_deps) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg_deps) { } 0 0 0
498 0 ▶ if ($dss->pkg_can_install()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dss->pkg_can_install) { } 0 0 0
499 0 ▶ if ($config->effective_prepare_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_prepare_env) 0 0 0
500 0 $dss->prepare_builder_env( $config );
501 }
502 0 goto INSTALL_SYS_PKGS;
503 }
504 else {
505 0 $log->warn( "Unable to install system packages; will resort to installation of CPAN modules" );
506 0 $pkg_deps = undef;
507 }
508 }
509 else {
510 0 $log->warn( "No precomputed dependencies available for $name/$dep_pkg_id" );
511 0 $log->info( "Configuring environment for dependency computation" );
512 }
513 }
514  
515 ########################################################################################
516 #
517 # Need to clean up on failure after this point! We have changed system state!
518 #
519 ########################################################################################
520 0 $dss->prepare_extraction_env( $config );
521 0 $class->_build_install_tree( $dss, $config, $config->installpath, $config->effective_version );
522 0 my $prereqs = $class->_get_immediate_prereqs( $config );
523 0 my $requirements = $prereqs->merged_requirements();
524  
525 0 ▶ unless ($requirements->accepts_module( 'perl', $])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($requirements->accepts_module("perl", $])) 0 0 0
526 # BAIL: No suitable Perl here...
527 #
528 # well, we might want to see if Perlbrew is installed with an acceptable version?
529 #
530 # and if not, we could install Perlbrew here...
531 0 die $log->fatal( "Not running a Perl version compliant with LedgerSMB " . $config->effective_version );
532 }
533  
534 0 ▶ if ($config->effective_prepare_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_prepare_env) 0 0 0
535 0 $dss->prepare_builder_env( $config );
536 }
537  
538 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
539 0 ▶ if ($config->effective_prepare_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_prepare_env) 0 0 0
540 0 $dss->prepare_pkg_resolver_env( $config );
541 }
542 0 ($pkg_deps, $unmapped_mods) = $class->_compute_dep_pkgs( $dss, $config );
543 }
544 else {
545 0 $unmapped_mods = [ $class->_compute_all_deps( $config ) ];
546 }
547  
548 0 $log->info( "Checking for availability of DBD::Pg" );
549 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
550 and not $class->_module_will_install( 'DBD::Pg', $pkg_deps, $unmapped_mods )) {
551 # don't have DBD::Pg
552 # *and* won't install as part of $pkg_deps
553  
554 0 my $pg_config = $class->_find_pg_config( $dss, $config );
555 0 ▶ die $log->fatal( "Missing 'pg_config' command to build DBD::Pg" )
Branch: 1 branch
BranchTrueFalseTotal
unless $pg_config 0 0 0
556 unless $pg_config;
557 0 chomp( my $include_dir = `'$pg_config' --includedir` );
558  
559 0 $log->debug( "Directory for PostgreSQL headers: $include_dir" );
560 0 my $header_file = File::Spec->catfile( $include_dir, 'libpq-fe.h' );
561  
562 0 ▶ if (not -e $header_file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $header_file) 0 0 0
563 0 ▶ if (not $dss->pkg_can_install) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dss->pkg_can_install) 0 0 0
564 0 die $log->fatal( "Missing 'libpq-fe.h' PostgreSQL header to build DBD::Pg" );
565 }
566  
567 0 my ($run_deps, $build_deps) = $dss->pkg_deps_dbd_pg;
568 0 $config->mark_pkgs_for_cleanup( $build_deps );
569 0 push @extra_pkgs, $run_deps->@*, $build_deps->@*;
570 }
571 }
572 0 elsif (eval { require DBD::Pg; 1; }) {
573 0 $log->info( "DBD::Pg is loadable" );
574 }
575 0 elsif (not grep { $_ eq 'DBD::Pg' } $unmapped_mods->@*) {
576 0 $log->info( "DBD::Pg will be installed" );
577 }
578 else {
579 0 $log->fatal( "Internal error: DBD::Pg not available and won't be installed, but build prereqs not checked?!?!" );
580 }
581  
582 0 $log->info( "Checking for availability of LaTeX::Driver" );
583 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
584 and not $class->_module_will_install( 'LaTeX::Driver', $pkg_deps, $unmapped_mods )) {
585 # don't have LaTeX::Driver
586 # *and* won't install as part of $pkg_deps
587  
588 # testing early, because LaTeX::Driver only installs
589 # when LaTeX is installed...
590  
591 0 my $latex = $class->_find_latex( $dss, $config );
592 0 ▶ if (not $latex) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($latex) 0 0 0
593 0 ▶ if (not $dss->pkg_can_install) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dss->pkg_can_install) 0 0 0
594 0 die $log->fatal( "Missing 'latex' executable required for building 'LaTeX::Driver' module" );
595 }
596 }
597 }
598 0 elsif (eval { require LaTeX::Driver; 1; }) {
599 0 $log->info( "LaTeX::Driver is loadable" );
600 }
601 0 elsif (not grep { $_ eq 'LaTeX::Driver' } $unmapped_mods->@*) {
602 0 $log->info( "LaTeX::Driver will be installed" );
603 }
604 else {
605 0 $log->fatal( "Internal error: LaTeX::Driver not available and won't be installed, but build prereqs not checked?!?!" );
606 }
607 0 ▶ if ($dss->pkg_can_install) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dss->pkg_can_install) { } 0 0 0
608 # installs LaTeX *and* styles required for standard templates
609 0 my ($run_deps, $build_deps) = $dss->pkg_deps_latex;
610 0 $config->mark_pkgs_for_cleanup( $build_deps );
611 0 push @extra_pkgs, $run_deps->@*, $build_deps->@*;
612 }
613 else {
614 ###TODO: figure out how to warn the user of minimal required
615 # styles configuration...
616 }
617  
618 0 $log->info( "Checking for availability of XML::Parser" );
619 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
620 and not $class->_module_will_install( 'XML::Parser', $pkg_deps, $unmapped_mods)) {
621  
622 0 $log->info( "Checking availability of libexpat" );
623 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
624 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
625  
626 # Devel::CheckLib tries to find the C compiler when use-d
627 # however, we might be installing it as part of the installation
628 # process, so we don't want Devel::CheckLib to check when loading the script...
629 0 eval "use Devel::CheckLib qw(assert_lib);";
630 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
631 header => ['expat.h'],
632 incpath => $incpath,
633 ( $libpath ? (libpath => $libpath) : () )
634 0 ); 1; }) {
635 0 ▶ if (not $dss->pkg_can_install) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $dss->pkg_can_install) { } 0 0 0
636 ###TODO: We could push Alien::Expat into @unmapped_mods
637 # instead of bailing out here...
638 0 die $log->fatal( "Missing XML parser library Expat blocking installation of XML::Parser" );
639 }
640 else {
641 0 my ($run_deps, $build_deps) = $dss->pkg_deps_expat;
642 0 $config->mark_pkgs_for_cleanup( $build_deps );
643 0 push @extra_pkgs, $run_deps->@*, $build_deps->@*;
644 }
645 }
646 else {
647 0 $log->info( "Found expat header and library for XML::Parser compilation" );
648 }
649 }
650 0 elsif (eval { require XML::Parser; 1; }) {
651 0 $log->info( "XML::Parser is loadable" );
652 }
653 0 elsif (not grep { $_ eq 'XML::Parser' } $unmapped_mods->@*) {
654 0 $log->info( "XML::Parser will be installed" );
655 }
656 else {
657 0 $log->fatal( "Internal error: XML::Parser not available and won't be installed, but build prereqs not checked?!?!" );
658 }
659  
660 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
661 and not $class->_module_will_install( 'XML::LibXML', $pkg_deps, $unmapped_mods ))
662 0 and (not eval { require XML::Twig; 1; }
663 and not $class->_module_will_install( 'XML::Twig', $pkg_deps, $unmapped_mods ))) {
664 # don't have either XML::LibXML or XML::Twig
665  
666 0 my $xml2_config = $class->_find_xml2_config( $dss, $config );
667 0 ▶ if (not $xml2_config) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($xml2_config) 0 0 0
668 0 ▶ if (not $dss->pkg_can_install) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $dss->pkg_can_install) { } 0 0 0
669 0 warn $log->warning("Missing 'xml2-config' executable required for building XML::LibXML -- falling back to Alien::Libxml2" );
670 }
671 else {
672 0 my ($run_deps, $build_deps) = $dss->pkg_deps_xml;
673 0 $config->mark_pkgs_for_cleanup( $build_deps );
674 0 push @extra_pkgs, $run_deps->@*, $build_deps->@*;
675 }
676 }
677 }
678  
679 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
680  
681 0 INSTALL_SYS_PKGS:
682 $log->info( "Installing O/S packages: " . join(' ', $pkg_deps->@*) );
683 0 $dss->pkg_install( $pkg_deps );
684  
685 PREPARE_TREE:
686 0 ▶ if (@extra_pkgs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@extra_pkgs) 0 0 0
687 0 $log->info( "Installing build dependency packages: " . join(' ', @extra_pkgs) );
688 0 $dss->pkg_install( \@extra_pkgs );
689 }
690 0 ▶ if ($config->effective_prepare_env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->effective_prepare_env) 0 0 0
691 0 $dss->prepare_installer_env( $config );
692 }
693  
694 ###TODO: ideally, we pass the immediate dependencies instead of the installation path;
695 # that allows selection of specific features in a later iteration
696 #
697 # Installs dependencies from cpanfile (because it respects dependency versions,
698 # which the simple list of dependencies does not); then installs the extra
699 # dependencies which were not satisfied from the list of unmapped_mods)
700 0 $dss->cpanm_install( $config->installpath, $config->locallib, $unmapped_mods );
701 0 $rv = 0;
702  
703 0 $log->info( "Generating application server startup script (server-start)" );
704 0 $dss->generate_start_script( File::Spec->rel2abs( $config->installpath ),
705 File::Spec->rel2abs( $config->locallib ) );
706  
707 0 CLEANUP:
708 $log->warning( "Cleaning up Perl module installation dependencies" );
709 0 $dss->cleanup_env($config);
710  
711 0 ▶ if ($rv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rv) { } 0 0 0
712 0 ▶ if (-e $config->installpath) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $config->installpath) 0 0 0
713 0 $log->warning( "Cleaning up installation path" );
714 0 remove_tree $config->installpath;
715 }
716  
717 0 say "Failed to complete server installation.";
718 }
719 else {
720 0 my $installpath = $config->installpath;
721 0 say "
722 LedgerSMB installation into $installpath completed.
723  
724 The LedgerSMB server can be started using the generated
725 startup script:
726  
727 \$ $installpath/server-start
728  
729 The server will run with its default configuration. To change
730 the configuration, copy the file doc/conf/ledgersmb.yaml to
731 $installpath and modify it. After modification, restart the
732 LedgerSMB server to activate the new configuration.
733  
734 ";
735 }
736  
737 0 return $rv;
738 }
739  
740 ▶sub print_id( $class, @args) {
Subroutine print_id: not called CC=1 SCAR=6.9
Pod undocumented
741 0 my $dss = $class->_load_dist_support;
742 0 say $dss->dependency_packages_identifier;
743 }
744  
745 ▶sub run($class, $cmd, @args) {
Subroutine run: not called CC=7 SCAR=40.3
Pod undocumented
746 0 STDOUT->autoflush(1);
747 0 STDERR->autoflush(1);
748  
749 0 ▶ if ($cmd =~ m/^-/) { # option(s)
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^-/u) 0 0 0
750 0 unshift @args, $cmd;
751 0 $cmd = 'install';
752 }
753  
754 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
755 0 say $log->info( "Computing dependencies using installer $INSTALLER_VERSION" );
756 0 return $class->compute( @args );
757 }
758 elsif ($cmd eq 'download') {
759 0 return $class->download( @args );
760 }
761 elsif ($cmd eq 'help') {
762 0 return $class->help( @args );
763 }
764 elsif ($cmd eq 'install') {
765 0 say $log->info( "Installing LedgerSMB using installer $INSTALLER_VERSION" );
766 0 return $class->install( @args );
767 }
768 elsif ($cmd eq 'system-id') {
769 0 return $class->print_id( @args );
770 }
771 else {
772 0 $class->help();
773 0 exit 1;
774 }
775 }
776  
777  
778 1 1;
779  
780 =head1 NAME
781  
782 LedgerSMB::Installer - Installer for the LedgerSMB accounting web application
783  
784 =head1 DESCRIPTION
785  
786 =head1 MAINTAINER
787  
788 Erik Huelsmann
789  
790 =head1 AUTHOR
791  
792 Erik Huelsmann
793  
794 =head1 LICENSE
795  
796 Copyright 2025 Erik Huelsmann
797  
798 Permission is hereby granted, free of charge, to any person obtaining a copy
799 of this software and associated documentation files (the "Software"), to deal
800 in the Software without restriction, including without limitation the rights
801 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
802 copies of the Software, and to permit persons to whom the Software is
803 furnished to do so, subject to the following conditions:
804  
805 The above copyright notice and this permission notice shall be included in
806 all copies or substantial portions of the Software.
807  
808 THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
809 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
810 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
811 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
812 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
813 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
814 SOFTWARE.
815  
816 =cut
817  
818 __DATA__
↑ Summary Installer/OS.pm »