line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Install::RPM; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
53304
|
use strict; use warnings; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
5
|
use base 'Module::Install::Base'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
876
|
|
5
|
|
|
|
|
|
|
use 5.008; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { $| = 1; } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Just gather the list of required RPMs and their versions |
12
|
|
|
|
|
|
|
sub requires_rpm { |
13
|
|
|
|
|
|
|
my ($self, $rpm, $version) = @_; |
14
|
|
|
|
|
|
|
push @{$self->{rpms}}, [ $rpm, $version ]; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _version_cmp { |
18
|
|
|
|
|
|
|
my ($v1, $v2) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my @v1 = split /\./, $v1; |
21
|
|
|
|
|
|
|
my @v2 = split /\./, $v2; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $end = @v1 < @v2 ? $#v1 : $#v2; |
24
|
|
|
|
|
|
|
for my $i (0..$end) { |
25
|
|
|
|
|
|
|
my $c = $v1[$i] <=> $v2[$i]; |
26
|
|
|
|
|
|
|
return $c if $c; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
return 0; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _check_rpms { |
32
|
|
|
|
|
|
|
my $self = shift; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
unless ($self->can_run('rpm')) { |
35
|
|
|
|
|
|
|
die "ERROR: Unable to locate ``rpm'' executable\n"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $maxlen = 0; |
39
|
|
|
|
|
|
|
for my $r (@{$self->{rpms}}) { |
40
|
|
|
|
|
|
|
my $l = length($r->[0]); |
41
|
|
|
|
|
|
|
$maxlen = $l if $l > $maxlen; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
print "*** Checking for required RPMs\n"; |
45
|
|
|
|
|
|
|
for my $r (@{$self->{rpms}}) { |
46
|
|
|
|
|
|
|
my ($rpm,$version) = @$r; |
47
|
|
|
|
|
|
|
printf " - %-${maxlen}s ...", $rpm; |
48
|
|
|
|
|
|
|
chomp(my $query = qx(rpm -q $rpm)); |
49
|
|
|
|
|
|
|
if ($query =~ /not installed/) { |
50
|
|
|
|
|
|
|
print "missing", $version ? " (need version $version) " : '', "\n"; |
51
|
|
|
|
|
|
|
next; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
my @parts = split /-/, $query; |
54
|
|
|
|
|
|
|
pop @parts; # remove and ignore patch level |
55
|
|
|
|
|
|
|
my $rpm_version = pop @parts; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
if ($version && _version_cmp($rpm_version, $version) == -1) { |
58
|
|
|
|
|
|
|
print "too old ($rpm_version < $version)\n"; |
59
|
|
|
|
|
|
|
next; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
print "OK\n"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# TODO: Is there a better method to hook into this process? |
66
|
|
|
|
|
|
|
sub WriteAll { |
67
|
|
|
|
|
|
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$self->_check_rpms; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# TODO: surely there's a better way to do this |
72
|
|
|
|
|
|
|
return Module::Install::WriteAll::WriteAll($self); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |