lib/Rex/Pkg/Arch.pm

filter: Statementstmt 40.0% 22 / 55 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 58.3% 7 / 12 Podpod 0.0% 0 / 5 totaltotal 28.4% 29 / 102 CC 12 SCAR 39.1
CC
12
Cov
28%
get_installed
110.0
new
12.0
bulk_install
2.0
CRAP 50.0
« lib/Rex/Hardware/Memory.pm ↑ Summary lib/Rex/Inventory/SMBios.pm »
1 #
2 # (c) Harm Müller <harm _DOT_ mueller _AT_ g m a i l _Dot_ com>
3 #
4  
5 package Rex::Pkg::Arch;
6  
7 1 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '1.16.1'; # VERSION
11  
12 1 ▶use Rex::Helper::Run;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Rex::Commands::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Rex::Commands::Fs;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use Rex::Pkg::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use base qw(Rex::Pkg::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
20 0 my $that = shift;
21 0 ▶ my $proto = ref($that) || $that;
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
22 0 my $self = $proto->SUPER::new(@_);
23  
24 0 bless( $self, $proto );
25  
26 0 ▶ if ( Rex::has_feature_version('1.5') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (Rex::has_feature_version('1.5')) { } 0 0 0
27 $self->{commands} = {
28 0 install => 'pacman --noprogressbar --noconfirm --needed -S %s',
29 install_version => 'pacman --noprogressbar --noconfirm --needed -S %s', # makes no sense to specify the package version
30 update_system => 'pacman --noprogressbar --noconfirm -Su',
31 dist_update_system => 'pacman --noprogressbar --noconfirm -Su',
32 remove => 'pacman --noprogressbar --noconfirm -Rs %s',
33 update_package_db => 'pacman --noprogressbar -Sy',
34 };
35 }
36 else {
37 $self->{commands} = {
38 0 install => 'pacman --noprogressbar --noconfirm --needed -S %s',
39 install_version => 'pacman --noprogressbar --noconfirm --needed -S %s', # makes no sense to specify the package version
40 update_system => 'pacman --noprogressbar --noconfirm -Syu',
41 dist_update_system => 'pacman --noprogressbar --noconfirm -Syu',
42 remove => 'pacman --noprogressbar --noconfirm -Rs %s',
43 update_package_db => 'pacman --noprogressbar -Sy',
44 };
45 }
46  
47 0 return $self;
48 }
49  
50 0 ▶sub bulk_install {
Subroutine bulk_install: not called CC=1 SCAR=6.9
Pod undocumented
51 0 my ( $self, $packages_aref, $option ) = @_;
52  
53 0 delete $option->{version}; # makes no sense to specify the same version for several packages
54  
55 0 $self->update( "@{$packages_aref}", $option );
56  
57 0 return 1;
58 }
59  
60 0 ▶sub get_installed {
Subroutine get_installed: not called CC=10 SCAR=47.0
Pod undocumented
61 0 my ( $self, $pkg ) = @_;
62 0 my ( @pkgs, $name, $version, $release, $arch );
63 0 my $pkg_query = 'pacman -Qi | egrep "^Name|^Version|^Architecture"';
64 0 ▶ if ( defined($pkg) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pkg) 0 0 0
65 0 $pkg_query .= " " . $pkg;
66 }
67 0 my @installed_packages = i_run $pkg_query;
68 0 for my $line (@installed_packages) {
69 0 ▶ if ( $line =~ m/^Name\s+:\s+([\S]+)$/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($line =~ /^Name\s+:\s+([\S]+)$/u) { } 0 0 0
elsif ($line =~ /^Version\s+:\s+([\S]+)-([\S]+)$/u) { } 0 0 0
elsif ($line =~ /^Architecture\s+:\s+([\S]+)$/u) { } 0 0 0
70 0 $name = $1;
71 }
72 elsif ( $line =~ m/^Version\s+:\s+([\S]+)-([\S]+)$/ ) {
73 0 $version = $1;
74 0 $release = $2;
75 }
76 elsif ( $line =~ m/^Architecture\s+:\s+([\S]+)$/ ) {
77 0 $arch = $1;
78 }
79 0 ▶ if ( defined($name)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name and defined $version and defined $release and defined $arch) 0 0 0
Condition0%0/9
defined $name and defined $version and defined $release and defined $arch
!ll&&!rl&&r
000
defined $name and defined $version and defined $release
!ll&&!rl&&r
000
defined $name and defined $version
!ll&&!rl&&r
000
MC/DC0%0/4
defined $name and defined $version and defined $release and defined $arch
defined $name defined $version defined $release defined $arch
Truth table0%0/5
A and B and C and D
A= defined $nameB= defined $versionC= defined $releaseD= defined $arch
ABCDresult
0XXX0
10XX0
110X0
11100
11111
80 && defined($version)
81 && defined($release)
82 && defined($arch) )
83 {
84 0 push(
85 @pkgs,
86 {
87 name => $name,
88 version => $version,
89 release => $release,
90 arch => $arch,
91 }
92 );
93 0 $name = $version = $release = $arch = undef;
94 }
95 }
96  
97 0 return @pkgs;
98 }
99  
100 0 ▶sub add_repository {
Subroutine add_repository: not called CC=1 SCAR=6.9
Pod undocumented
101 0 Rex::Logger::info(
102 "no suitable repo management use template/file for pacman.conf");
103 0 return 1;
104 }
105  
106 0 ▶sub rm_repository {
Subroutine rm_repository: not called CC=1 SCAR=6.9
Pod undocumented
107 0 Rex::Logger::info(
108 "no suitable repo management use template/file for pacman.conf");
109 0 return 1;
110 }
111  
112 1 1;
« lib/Rex/Hardware/Memory.pm ↑ Summary lib/Rex/Inventory/SMBios.pm »