File Coverage

blib/lib/LedgerSMB/Installer/OS.pm
Criterion Covered Total %
statement 17 79 21.5
branch 0 16 0.0
condition 0 5 0.0
subroutine 6 15 40.0
pod 0 9 0.0
total 23 124 18.5


line stmt bran cond sub pod time code
1             package LedgerSMB::Installer::OS v0.999.11;
2              
3 1     1   669 use v5.20;
  1         5  
4 1     1   7 use experimental qw(signatures);
  1         2  
  1         8  
5              
6 1     1   197 use Cwd qw( getcwd );
  1         3  
  1         82  
7 1     1   6 use File::Basename qw( fileparse );
  1         2  
  1         87  
8 1     1   6 use File::Spec;
  1         2  
  1         30  
9              
10 1     1   34 use Log::Any qw($log);
  1         2  
  1         9  
11              
12 0     0 0   sub am_system_perl($self) {
  0            
  0            
13 0           return !!0;
14             }
15              
16 0     0 0   sub have_cmd($self, $cmd, $fatal = 1, $extra_path = []) {
  0            
  0            
  0            
  0            
  0            
17 0 0 0       if ($self->{cmd} and $self->{cmd}->{$cmd}) {
18 0           $log->debug( "Found cached command $self->{cmd}->{$cmd}" );
19 0           return $self->{cmd}->{$cmd};
20             }
21              
22 0           my $executable = '';
23 0 0         if (File::Spec->file_name_is_absolute( $cmd )) {
24 0 0         $executable = $cmd if -x $cmd;
25             }
26             else {
27 0           my (undef, $dirs) = File::Spec->splitpath( $cmd );
28 0 0         if ($dirs) {
29 0           $cmd = File::Spec->catfile( getcwd(), $cmd );
30 0 0         $executable = $cmd if -x $cmd;
31             }
32             else {
33             # Prefer specific added paths over system path; we may have
34             # installed something specific; if we did, we don't want to
35             # find the system global thing in its place.
36 0           for my $path ($extra_path->@*, File::Spec->path) {
37 0           my $expanded = File::Spec->catfile( $path, $cmd );
38 0 0         next if not -x $expanded;
39              
40 0           $executable = $expanded;
41 0           last;
42             }
43             }
44             }
45 0 0         if ($executable) {
    0          
46 0   0       $self->{cmd} //= {};
47 0           $self->{cmd}->{$cmd} = $executable;
48 0           $log->info( "Command $cmd found as $executable" );
49             }
50             elsif (not $fatal) {
51 0           $log->info( "Command $cmd not found" );
52             }
53             else {
54 0           die "Missing '$cmd'";
55             }
56 0           return $executable;
57             }
58              
59 0     0 0   sub executable_name($self, $command) {
  0            
  0            
  0            
60 0           return $command;
61             }
62              
63             sub have_pkgs($self, $pkgs) {
64             }
65              
66 0     0 0   sub pg_config_extra_paths($self) {
  0            
  0            
67 0           return ();
68             }
69              
70 0     0 0   sub pkgs_from_modules($self, $mod) {
  0            
  0            
  0            
71 0           die 'Operating system and distribution support needs to override the "pkgs_from_modules" method';
72             }
73              
74 0     0 0   sub pkg_can_install($self) {
  0            
  0            
75 0           return 0; # there's no such thing as generic installer support across operating systems
76             }
77              
78 0     0 0   sub pkg_install($self) {
  0            
  0            
79 0           die 'Operating system and distribution support needs to override the "pkg_install" method';
80             }
81              
82 0     0 0   sub pkg_uninstall($self) {
  0            
  0            
83 0           die 'Operating system and distribution support needs to override the "pkg_uninstall" method';
84             }
85              
86 0     0 0   sub name($self) {
  0            
  0            
87 0           die 'Operating system and distribution support needs to override the "name" method';
88             }
89              
90             sub cleanup_env($self, $config, %args) {
91             }
92              
93             1;