| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package RPM2::LocalInstalled; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
40741
|
use 5.008; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
35
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
38
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
51
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4725
|
use RPM2; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Sort::Versions; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
) ] ); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
(our $VERSION) = '$Revision: 1.4 $' =~ /([\d.]+)/; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
|
27
|
|
|
|
|
|
|
my $class = shift; |
|
28
|
|
|
|
|
|
|
my $args = shift; |
|
29
|
|
|
|
|
|
|
my $self = {}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
if($args) { |
|
32
|
|
|
|
|
|
|
die "The argument supplied is not reference; Use ->new({ tags = [ qw/version release epoch ]}) for example." unless ref $args; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
my @default_tags = qw/version release epoch/; |
|
35
|
|
|
|
|
|
|
$self->{tags} = $args->{tags} || \@default_tags; |
|
36
|
|
|
|
|
|
|
foreach(@default_tags) { |
|
37
|
|
|
|
|
|
|
push @{$self->{tags}}, $_ unless $self->{tags} =~ /$_/; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
die "tags is not an array: " . ref $self->{tags} unless ref $self->{tags} eq 'ARRAY'; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
bless($self, $class); |
|
42
|
|
|
|
|
|
|
return $self; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub list_all { |
|
46
|
|
|
|
|
|
|
my $self = shift; |
|
47
|
|
|
|
|
|
|
my $rpmdb = RPM2->open_rpm_db(); |
|
48
|
|
|
|
|
|
|
my $i = $rpmdb->find_all_iter(); |
|
49
|
|
|
|
|
|
|
while(my $pkg = $i->next()) { |
|
50
|
|
|
|
|
|
|
my $info; |
|
51
|
|
|
|
|
|
|
foreach my $tag (@{$self->{tags}}) { |
|
52
|
|
|
|
|
|
|
$info->{$tag} = $pkg->tag($tag); |
|
53
|
|
|
|
|
|
|
$info->{$tag} = 0 if $tag eq 'epoch' && ! defined $pkg->tag($tag); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
push @{$self->{__all}->{$pkg->name()}}, $info; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
return $self->{__all}; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub list_newest { |
|
61
|
|
|
|
|
|
|
my $self = shift; |
|
62
|
|
|
|
|
|
|
$self->list_all() unless $self->{__all}; |
|
63
|
|
|
|
|
|
|
foreach my $pkgname (keys %{$self->{__all}}) { |
|
64
|
|
|
|
|
|
|
foreach(@{$self->{__all}->{$pkgname}}) { |
|
65
|
|
|
|
|
|
|
if($self->{__newest}->{$pkgname}) { |
|
66
|
|
|
|
|
|
|
my $everel1 = $_->{epoch} . ":" . $_->{version} . "-" . $_->{release}; |
|
67
|
|
|
|
|
|
|
my $everel2 = $self->{__newest}->{$pkgname}->{epoch} . ":" . $self->{__newest}->{$pkgname}->{version} . "-" . $self->{__newest}->{$pkgname}->{release}; |
|
68
|
|
|
|
|
|
|
push @{$self->{__older}->{$pkgname}}, $self->{__newest}->{$pkgname} if versioncmp($everel1, $everel2) == 1; |
|
69
|
|
|
|
|
|
|
$self->{__newest}->{$pkgname} = $_ if versioncmp($everel1, $everel2) == 1; |
|
70
|
|
|
|
|
|
|
} else { |
|
71
|
|
|
|
|
|
|
$self->{__newest}->{$pkgname} = $_; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
return $self->{__newest}; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub list_older { |
|
79
|
|
|
|
|
|
|
my $self = shift; |
|
80
|
|
|
|
|
|
|
$self->list_newest() unless $self->{__newest}; |
|
81
|
|
|
|
|
|
|
return $self->{__older}; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
|
85
|
|
|
|
|
|
|
__END__ |