| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FreeBSD::Pkgs::FindUpdates; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
25990
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
25
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
5
|
1
|
|
|
1
|
|
854
|
use FreeBSD::Pkgs; |
|
|
1
|
|
|
|
|
5050
|
|
|
|
1
|
|
|
|
|
56
|
|
|
6
|
1
|
|
|
1
|
|
865
|
use FreeBSD::Ports::INDEXhash qw/INDEXhash/; |
|
|
1
|
|
|
|
|
930
|
|
|
|
1
|
|
|
|
|
781
|
|
|
7
|
1
|
|
|
1
|
|
766
|
use Sort::Versions; |
|
|
1
|
|
|
|
|
847
|
|
|
|
1
|
|
|
|
|
150
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use Error::Helper; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
789
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
FreeBSD::Pkgs::FindUpdates - Finds updates for FreeBSD pkgs by checking the ports index. |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.3.0 |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.3.0'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This does use FreeBSD::Ports::INDEXhash. Thus if you want to specifiy the location of the |
|
26
|
|
|
|
|
|
|
index file, you will want to see the supported methodes for it in that module. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use FreeBSD::Pkgs::FindUpdates; |
|
29
|
|
|
|
|
|
|
#initiates the module |
|
30
|
|
|
|
|
|
|
my $pkgsupdate = FreeBSD::Pkgs::FindUpdates->new; |
|
31
|
|
|
|
|
|
|
#finds changes |
|
32
|
|
|
|
|
|
|
my %changes=$pkgsupdate->find; |
|
33
|
|
|
|
|
|
|
#prints the upgraded stuff |
|
34
|
|
|
|
|
|
|
while(my ($name, $pkg) = each %{$changes{upgrade}}){ |
|
35
|
|
|
|
|
|
|
print $name.' updated from "'. |
|
36
|
|
|
|
|
|
|
$pkg->{oldversion}.'" to "'. |
|
37
|
|
|
|
|
|
|
$pkg->{newversion}."\"\n"; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
#prints the downgraded stuff |
|
40
|
|
|
|
|
|
|
while(my ($name, $pkg) = each %{$changes{upgrade}}){ |
|
41
|
|
|
|
|
|
|
print $name.' updated from "'. |
|
42
|
|
|
|
|
|
|
$pkg->{oldversion}.'" to "'. |
|
43
|
|
|
|
|
|
|
$pkg->{newversion}."\"\n"; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 METHODS |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 new |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This initiate the module. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub new { |
|
55
|
0
|
|
|
0
|
1
|
|
my %args; |
|
56
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
|
57
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
|
0
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
}; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $self={ |
|
61
|
|
|
|
|
|
|
error=>undef, |
|
62
|
|
|
|
|
|
|
errorString=>'' |
|
63
|
|
|
|
|
|
|
}; |
|
64
|
0
|
|
|
|
|
|
bless $self; |
|
65
|
0
|
|
|
|
|
|
return $self; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 find |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This finds any changes creates a hash. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Two arguements are optionally accepted. The first |
|
73
|
|
|
|
|
|
|
is a hash returned from INDEXhash |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#basic usage... |
|
76
|
|
|
|
|
|
|
my %changes=$pkgsupdate->find; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#create the INDEXhash and pkgdb and then pass it |
|
79
|
|
|
|
|
|
|
my $pkgdb=FreeBSD::Pkgs->new; |
|
80
|
|
|
|
|
|
|
$pkgdb->parseInstalled; |
|
81
|
|
|
|
|
|
|
if ( $pkgdb->error ){ |
|
82
|
|
|
|
|
|
|
warn('Error: FreeBSD::Pkgs->new errored'); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my %index=INDEXhash; |
|
86
|
|
|
|
|
|
|
my %changes=$pkgsupdate->find(\%index, $pkgdb); |
|
87
|
|
|
|
|
|
|
if ( $pkgsupdate->error ){ |
|
88
|
|
|
|
|
|
|
warn('Error:'.$pkgsupdate->error.': '.$pkgsupdate->errorString); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub find { |
|
94
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
95
|
0
|
|
|
|
|
|
my %index; |
|
96
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
|
97
|
0
|
|
|
|
|
|
%index= %{$_[1]}; |
|
|
0
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
}else { |
|
99
|
0
|
|
|
|
|
|
%index=INDEXhash(); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
0
|
|
|
|
|
|
my $pkgdb; |
|
102
|
0
|
0
|
|
|
|
|
if (defined($_[2])) { |
|
103
|
0
|
|
|
|
|
|
$pkgdb=$_[2]; |
|
104
|
|
|
|
|
|
|
}else { |
|
105
|
|
|
|
|
|
|
#parse the installed packages |
|
106
|
0
|
|
|
|
|
|
$pkgdb=FreeBSD::Pkgs->new; |
|
107
|
0
|
|
|
|
|
|
$pkgdb->parseInstalled({files=>0}); |
|
108
|
0
|
0
|
|
|
|
|
if ( $pkgdb->error ){ |
|
109
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
110
|
0
|
|
|
|
|
|
$self->{errorString}='FreeBSD::Pkgs->paseInstalled errored. error="'. |
|
111
|
|
|
|
|
|
|
$pkgdb->error.'" errorString="'.$pkgdb->errorString.'"'; |
|
112
|
0
|
|
|
|
|
|
$self->warn; |
|
113
|
0
|
|
|
|
|
|
return undef; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
#a hash of stuff that needes changed |
|
118
|
0
|
|
|
|
|
|
my %change; |
|
119
|
0
|
|
|
|
|
|
$change{upgrade}={}; |
|
120
|
0
|
|
|
|
|
|
$change{same}={}; |
|
121
|
0
|
|
|
|
|
|
$change{downgrade}={}; |
|
122
|
0
|
|
|
|
|
|
$change{from}={}; |
|
123
|
0
|
|
|
|
|
|
$change{to}={}; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
#process it |
|
126
|
0
|
|
|
|
|
|
while(my ($pkgname, $pkg) = each %{$pkgdb->{packages}}){ |
|
|
0
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my $src=$pkg->{contents}{origin}; |
|
128
|
0
|
|
|
|
|
|
my $path=$src; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
#versionless packagename |
|
131
|
0
|
|
|
|
|
|
my $vpkgname=$pkgname; |
|
132
|
0
|
|
|
|
|
|
my @vpkgnameSplit=split(/-/, $vpkgname); |
|
133
|
0
|
|
|
|
|
|
my $int=$#vpkgnameSplit - 1;#just called int as I can't think of a better name |
|
134
|
0
|
|
|
|
|
|
$vpkgname=join('-', @vpkgnameSplit[0..$int]); |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
#get the pkg version |
|
137
|
0
|
|
|
|
|
|
my $pkgversion=$pkgname; |
|
138
|
0
|
|
|
|
|
|
$pkgversion=~s/.*-//; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
#if this is not defined, we can't upgrade it... so skip it |
|
141
|
|
|
|
|
|
|
#stuff in stalled via cpan will do this |
|
142
|
0
|
0
|
|
|
|
|
if (!defined($src)) { |
|
143
|
0
|
0
|
|
|
|
|
if (!$pkgname =~ /^bsdpan-/) { |
|
144
|
0
|
|
|
|
|
|
warn('FreeBSD-Pkgs-FindUpdates find:1: No origin for "'.$pkgname.'"'); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
}else{ |
|
147
|
0
|
|
|
|
|
|
my $portname=$index{soriginsD2N}{$path}; |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
|
if (!defined($portname)) { |
|
150
|
0
|
|
|
|
|
|
warn("No port found for '".$path."'"); |
|
151
|
0
|
|
|
|
|
|
goto versionCompareEnd; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#versionless portname |
|
155
|
0
|
|
|
|
|
|
my $vportname=$portname; |
|
156
|
0
|
|
|
|
|
|
my @vportnameSplit=split(/-/, $vportname); |
|
157
|
0
|
|
|
|
|
|
$int=$#vportnameSplit - 1;#just called int as I can't think of a better name |
|
158
|
0
|
|
|
|
|
|
$vportname=join('-', @vportnameSplit[0..$int]); |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
#get the port version |
|
161
|
0
|
|
|
|
|
|
my $portversion=$portname; |
|
162
|
0
|
|
|
|
|
|
$portversion=~s/.*-//; |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
#if the pkg versionis less than the port version, it needs to be upgraded |
|
165
|
0
|
0
|
|
|
|
|
if (versioncmp($pkgversion, $portversion) == -1) { |
|
166
|
0
|
|
|
|
|
|
$change{upgrade}{$pkgname}={old=>$pkgname, new=>$portname, |
|
167
|
|
|
|
|
|
|
oldversion=>$pkgversion, |
|
168
|
|
|
|
|
|
|
newversion=>$portversion, |
|
169
|
|
|
|
|
|
|
port=>$path, |
|
170
|
|
|
|
|
|
|
}; |
|
171
|
0
|
|
|
|
|
|
$change{from}{$pkgname}=$portname; |
|
172
|
0
|
|
|
|
|
|
$change{to}{$portname}=$pkgname; |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
#if the pkg version and the port version are the same it is the same |
|
176
|
0
|
0
|
|
|
|
|
if (versioncmp($pkgversion, $portversion) == 0) { |
|
177
|
0
|
|
|
|
|
|
$change{same}{$pkgname}={old=>$pkgname, new=>$portname, |
|
178
|
|
|
|
|
|
|
oldversion=>$pkgversion, |
|
179
|
|
|
|
|
|
|
newversion=>$portversion, |
|
180
|
|
|
|
|
|
|
port=>$path |
|
181
|
|
|
|
|
|
|
}; |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
#if the pkg version is greater than the port version, it needs to be downgraded |
|
185
|
0
|
0
|
|
|
|
|
if (versioncmp($pkgversion, $portversion) == 1) { |
|
186
|
0
|
|
|
|
|
|
$change{downgrade}{$pkgname}={old=>$pkgname, new=>$portname, |
|
187
|
|
|
|
|
|
|
oldversion=>$pkgversion, |
|
188
|
|
|
|
|
|
|
newversion=>$portversion, |
|
189
|
|
|
|
|
|
|
port=>$path, |
|
190
|
|
|
|
|
|
|
}; |
|
191
|
0
|
|
|
|
|
|
$change{to}{$pkgname}=$portname; |
|
192
|
0
|
|
|
|
|
|
$change{from}{$portname}=$pkgname; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
versionCompareEnd: |
|
196
|
0
|
|
|
|
|
|
} |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
return %change; |
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 Changes Hash |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This hash contains several keys that are listed below. Each is a hash |
|
205
|
|
|
|
|
|
|
that contain several keys of their own. Please see the sub hash section |
|
206
|
|
|
|
|
|
|
for information on that. |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
The name of the installed package is used as the primary key in each. |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 downgrade |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
This is a hash that contains a list of packages to be down graded. |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 from |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
The keys to this hash are the packages that will be change from. The values |
|
217
|
|
|
|
|
|
|
are the names that it will changed to. |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 upgrade |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
This is a hash that contains a list of packages to be up graded. |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 same |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
This means there is no change. |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head2 to |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
The keys to this hash are the packages that will be change to. The values |
|
230
|
|
|
|
|
|
|
are the names that it will changed from. |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head2 sub hash |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
All three keys contain hashes that then contian these values. |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head3 old |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
This is the name of the currently installed package. |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head3 new |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
This is the name of what it will be changed to if upgraded/downgraded. |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head3 oldversion |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
This is the old version. |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head3 newversion |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
This is the version ofwhat it will be changed toif upgraded/downgraded. |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head3 port |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
This is the port that provides it. |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 ERROR CODES/HANDLING |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Error handling is provided by L. |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head2 1 |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
FreeBSD::Pkgs errored. |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 AUTHOR |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 BUGS |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
271
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
272
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head1 SUPPORT |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
perldoc FreeBSD::Pkgs::FindUpdates |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
You can also look for information at: |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=over 4 |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
L |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
L |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
L |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=item * Search CPAN |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
L |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=back |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
Copyright 2012 Zane C. Bowers-Hadley, all rights reserved. |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
312
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=cut |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
1; # End of FreeBSD::Pkgs::FindUpdates |