lib/Rex/Pkg/SuSE.pm

filter: Statementstmt 32.6% 16 / 49 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 5 / 10 Podpod 0.0% 0 / 5 totaltotal 25.3% 21 / 83 CC 10 SCAR 23.3
CC
10
Cov
24%
add_repository
20.0
new
12.0
get_installed
12.0
CRAP 10.3
« lib/Rex/Virtualization/Docker/daemon.pm ↑ Summary blib/lib/Rex/Helper/Array.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Pkg::SuSE;
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::Pkg::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use base qw(Rex::Pkg::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
17 0 my $that = shift;
18 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
19 0 my $self = $proto->SUPER::new(@_);
20  
21 0 bless( $self, $proto );
22  
23 0 ▶ if ( Rex::has_feature_version('1.5') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (Rex::has_feature_version('1.5')) { } 0 0 0
24 $self->{commands} = {
25 0 install => 'zypper -n install %s',
26 install_version => 'zypper -n install $pkg-%s',
27 update_system => 'zypper -n --no-refresh up',
28 dist_update_system => 'zypper -n --no-refresh up',
29 remove => 'zypper -n remove %s',
30 update_package_db => 'zypper -n ref -fd',
31 };
32 }
33 else {
34 $self->{commands} = {
35 0 install => 'zypper -n install %s',
36 install_version => 'zypper -n install $pkg-%s',
37 update_system => 'zypper -n up',
38 dist_update_system => 'zypper -n up',
39 remove => 'zypper -n remove %s',
40 update_package_db => 'zypper --no-gpg-checks -n ref -fd',
41 };
42 }
43  
44 0 return $self;
45 }
46  
47 0 ▶sub bulk_install {
Subroutine bulk_install: not called CC=1 SCAR=6.9
Pod undocumented
48 0 my ( $self, $packages_aref, $option ) = @_;
49  
50 0 delete $option->{version}; # makes no sense to specify the same version for several packages
51  
52 0 $self->update( "@{$packages_aref}", $option );
53  
54 0 return 1;
55 }
56  
57 0 ▶sub get_installed {
Subroutine get_installed: not called CC=3 SCAR=24.8
Pod undocumented
58 0 my ($self) = @_;
59  
60 0 my @lines = i_run
61 'rpm -qa --nosignature --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n"';
62  
63 0 my @pkg;
64  
65 0 for my $line (@lines) {
66 0 ▶ if ( $line =~ m/^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/u) 0 0 0
67 0 push(
68 @pkg,
69 {
70 name => $1,
71 epoch => $2,
72 version => $3,
73 release => $4,
74 arch => $5,
75 }
76 );
77 }
78 }
79  
80 0 return @pkg;
81 }
82  
83 0 ▶sub add_repository {
Subroutine add_repository: not called CC=4 SCAR=30.0
Pod undocumented
84 0 my ( $self, %data ) = @_;
85 i_run "zypper addrepo -f -n "
86 . $data{"name"} . " "
87 . $data{"url"} . " "
88 0 . $data{"name"}, fail_ok => 1;
89 0 ▶ if ( $? == 4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? == 4) 0 0 0
90 0 ▶ if ( Rex::Config->get_do_reporting ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Rex::Config"->get_do_reporting) 0 0 0
91 0 return { changed => 0 };
92 }
93 }
94 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
95 0 die( "Error adding repository " . $data{name} );
96 }
97 }
98  
99 0 ▶sub rm_repository {
Subroutine rm_repository: not called CC=3 SCAR=24.8
Pod undocumented
100 0 my ( $self, $name ) = @_;
101 0 i_run "zypper removerepo $name", fail_ok => 1;
102 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
103 0 die("Error removing repository $name");
104 }
105  
106 0 ▶ if ( Rex::Config->get_do_reporting ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Rex::Config"->get_do_reporting) 0 0 0
107 0 return { changed => 1 };
108 }
109 }
110  
111 1 1;
« lib/Rex/Virtualization/Docker/daemon.pm ↑ Summary blib/lib/Rex/Helper/Array.pm »