line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Pkg::Redhat; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
14
|
use v5.12.5; |
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
65
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.2'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
9
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
13
|
1
|
|
|
1
|
|
7
|
use Rex::Commands::File; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
14
|
1
|
|
|
1
|
|
8
|
use Rex::Commands::Fs; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
6
|
|
15
|
1
|
|
|
1
|
|
7
|
use Rex::Pkg::Base; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
16
|
1
|
|
|
1
|
|
37
|
use base qw(Rex::Pkg::Base); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
854
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
0
|
|
|
0
|
0
|
|
my $that = shift; |
20
|
0
|
|
0
|
|
|
|
my $proto = ref($that) || $that; |
21
|
0
|
|
|
|
|
|
my $self = $proto->SUPER::new(@_); |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
bless( $self, $proto ); |
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
if ( Rex::has_feature_version('1.5') ) { |
26
|
|
|
|
|
|
|
$self->{commands} = { |
27
|
0
|
|
|
|
|
|
install => $self->_yum('-y install %s'), |
28
|
|
|
|
|
|
|
install_version => $self->_yum('-y install %s-%s'), |
29
|
|
|
|
|
|
|
update_system => $self->_yum("-y -C upgrade"), |
30
|
|
|
|
|
|
|
dist_update_system => $self->_yum("-y -C upgrade"), |
31
|
|
|
|
|
|
|
remove => $self->_yum('-y erase %s'), |
32
|
|
|
|
|
|
|
update_package_db => $self->_yum("clean all") . " ; " |
33
|
|
|
|
|
|
|
. $self->_yum("makecache"), |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
|
|
|
|
|
|
$self->{commands} = { |
38
|
0
|
|
|
|
|
|
install => $self->_yum('-y install %s'), |
39
|
|
|
|
|
|
|
install_version => $self->_yum('-y install %s-%s'), |
40
|
|
|
|
|
|
|
update_system => $self->_yum("-y upgrade"), |
41
|
|
|
|
|
|
|
dist_update_system => $self->_yum("-y upgrade"), |
42
|
|
|
|
|
|
|
remove => $self->_yum('-y erase %s'), |
43
|
|
|
|
|
|
|
update_package_db => $self->_yum("clean all") . " ; " |
44
|
|
|
|
|
|
|
. $self->_yum("makecache"), |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub bulk_install { |
52
|
0
|
|
|
0
|
0
|
|
my ( $self, $packages_aref, $option ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
delete $option->{version}; # makes no sense to specify the same version for several packages |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$self->update( "@{$packages_aref}", $option ); |
|
0
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return 1; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub get_installed { |
62
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my @lines = i_run |
65
|
|
|
|
|
|
|
'rpm -qa --nosignature --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n"'; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my @pkg; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
for my $line (@lines) { |
70
|
0
|
0
|
|
|
|
|
if ( $line =~ m/^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/ ) { |
71
|
0
|
|
|
|
|
|
push( |
72
|
|
|
|
|
|
|
@pkg, |
73
|
|
|
|
|
|
|
{ |
74
|
|
|
|
|
|
|
name => $1, |
75
|
|
|
|
|
|
|
epoch => $2, |
76
|
|
|
|
|
|
|
version => $3, |
77
|
|
|
|
|
|
|
release => $4, |
78
|
|
|
|
|
|
|
arch => $5, |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return @pkg; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub add_repository { |
88
|
0
|
|
|
0
|
0
|
|
my ( $self, %data ) = @_; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $name = $data{"name"}; |
91
|
0
|
|
0
|
|
|
|
my $desc = $data{"description"} || $data{"name"}; |
92
|
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
if ( exists $data{"key_url"} ) { |
94
|
0
|
|
|
|
|
|
i_run "rpm --import $data{key_url}"; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if ( exists $data{"key_file"} ) { |
98
|
0
|
|
|
|
|
|
i_run "rpm --import $data{key_file}"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my $fh = file_write "/etc/yum.repos.d/$name.repo"; |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
$fh->write("# This file is managed by Rex\n"); |
104
|
0
|
|
|
|
|
|
$fh->write("[$name]\n"); |
105
|
0
|
|
|
|
|
|
$fh->write("name=$desc\n"); |
106
|
0
|
|
|
|
|
|
$fh->write( "baseurl=" . $data{"url"} . "\n" ); |
107
|
0
|
|
|
|
|
|
$fh->write("enabled=1\n"); |
108
|
|
|
|
|
|
|
$fh->write( "gpgkey=" . $data{"gpgkey"} . "\n" ) |
109
|
0
|
0
|
|
|
|
|
if defined $data{"gpgkey"}; |
110
|
|
|
|
|
|
|
$fh->write( "gpgcheck=" . $data{"gpgcheck"} . "\n" ) |
111
|
0
|
0
|
|
|
|
|
if defined $data{"gpgcheck"}; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
$fh->close; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub rm_repository { |
117
|
0
|
|
|
0
|
0
|
|
my ( $self, $name ) = @_; |
118
|
0
|
|
|
|
|
|
unlink "/etc/yum.repos.d/$name.repo"; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _yum { |
122
|
0
|
|
|
0
|
|
|
my ( $self, @cmd ) = @_; |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
my $str; |
125
|
|
|
|
|
|
|
|
126
|
0
|
0
|
|
|
|
|
if ($Rex::Logger::debug) { |
127
|
0
|
|
|
|
|
|
$str = join( ' ', "yum ", @cmd ); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
else { |
130
|
0
|
|
|
|
|
|
$str = join( ' ', "yum -q ", @cmd ); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
return $str; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |