line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OS::CheckUpdates::AUR; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
49390
|
use v5.16; |
|
3
|
|
|
|
|
8
|
|
4
|
3
|
|
|
3
|
|
13
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
66
|
|
5
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
139
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
2130
|
use if $ENV{CHECKUPDATES_DEBUG}, 'Smart::Comments'; |
|
3
|
|
|
|
|
22
|
|
|
3
|
|
|
|
|
15
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
1362
|
use WWW::AUR::URI qw(rpc_uri); |
|
3
|
|
|
|
|
59973
|
|
|
3
|
|
|
|
|
159
|
|
10
|
3
|
|
|
3
|
|
1677
|
use WWW::AUR::UserAgent; |
|
3
|
|
|
|
|
86932
|
|
|
3
|
|
|
|
|
82
|
|
11
|
3
|
|
|
3
|
|
1594
|
use IO::Pipe; |
|
3
|
|
|
|
|
19716
|
|
|
3
|
|
|
|
|
80
|
|
12
|
3
|
|
|
3
|
|
17
|
use JSON; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
18
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
OS::CheckUpdates::AUR - checkupdates for aur |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 VERSION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Version 0.04 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
checkupdates for aur |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Example of code: |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use OS::CheckUpdates::AUR; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $foo = OS::CheckUpdates::AUR->new(); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Print available updates: |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$foo->print(); |
40
|
|
|
|
|
|
|
# or |
41
|
|
|
|
|
|
|
printf("%s %s -> %s\n", @{$_}[0..2]) foreach (@{$foo->get()}); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 new() |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
New... |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new { |
52
|
|
|
|
|
|
|
### OS-CheckUpdates-AUR created here |
53
|
2
|
|
|
2
|
1
|
16
|
return bless({}, shift); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 get() |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Get array with checkupdates: [name, local_ver, aur_ver] |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get { |
63
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
### get() run refresh() if updates db is not created |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
0
|
exists $self->{'updates'} |
68
|
|
|
|
|
|
|
or $self->refresh(); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
### get() return updates |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
return $self->{'updates'}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 print |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Print checkupdates into stdout in chekupdates format. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub print { |
82
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
0
|
printf("%s %s -> %s\n", @{$_}[0..2]) foreach (@{$self->get()}); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
return 1; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 refresh() |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Create/retrive/parse/refresh data about packages. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub refresh { |
96
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
97
|
0
|
|
|
|
|
0
|
my $local; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
0
|
$self->{'updates'} = []; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
### refresh() reading 'pacman -Qm' output |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
my $pipe = IO::Pipe->new(); |
104
|
0
|
|
|
|
|
0
|
$pipe->reader(qw[pacman -Qm]); |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
0
|
while(<$pipe>) { |
107
|
0
|
|
|
|
|
0
|
my ($name, $version) = split(" "); |
108
|
0
|
|
|
|
|
0
|
$local->{$name} = $version; |
109
|
|
|
|
|
|
|
}; |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
0
|
if ($#{[keys %$local]} < 0) { |
|
0
|
|
|
|
|
0
|
|
112
|
|
|
|
|
|
|
### found 0 packages, nothing to do... |
113
|
0
|
|
|
|
|
0
|
return $self; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
### refresh() getting multiinfo() |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
0
|
my @multiinfo_results = @{$self->multiinfo(sort keys %$local)->{'results'}}; |
|
0
|
|
|
|
|
0
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
### refresh() comparing versions |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
0
|
my %seen; |
123
|
0
|
|
|
|
|
0
|
foreach (@multiinfo_results) { |
124
|
0
|
|
|
|
|
0
|
my $name = $_->{'Name'}; |
125
|
0
|
0
|
|
|
|
0
|
my $vloc = $local->{$name} or next; |
126
|
0
|
|
|
|
|
0
|
my $vaur = $_->{'Version'}; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
!$seen{$name}++ |
129
|
|
|
|
|
|
|
and ($vaur ne $vloc) |
130
|
|
|
|
|
|
|
and ($self->vercmp($vloc, $vaur) eq "-1") |
131
|
0
|
0
|
0
|
|
|
0
|
and push @{$self->{'updates'}}, [$name, $vloc, $vaur]; |
|
0
|
|
0
|
|
|
0
|
|
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
### Locally installed: $#{[keys %$local]} + 1 |
135
|
|
|
|
|
|
|
### Found on AUR: $#multiinfo_results + 1 |
136
|
|
|
|
|
|
|
### Updates: $#{$self->{'updates'}} + 1 |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
0
|
return $self |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 vercmp($$) |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Compare two versions in pacman way. Frontend for vercmp command. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub vercmp { |
149
|
12
|
|
|
12
|
1
|
22807
|
my ($self, $a, $b) = @_; |
150
|
|
|
|
|
|
|
|
151
|
12
|
100
|
100
|
|
|
166
|
if (defined $a and defined $b) { |
152
|
6
|
|
|
|
|
213
|
my $pipe = IO::Pipe->new(); |
153
|
6
|
|
|
|
|
712
|
$pipe->reader('vercmp', $a, $b); |
154
|
|
|
|
|
|
|
|
155
|
5
|
|
|
|
|
78370
|
while(<$pipe>) { |
156
|
5
|
|
|
|
|
51
|
chomp; |
157
|
|
|
|
|
|
|
|
158
|
5
|
50
|
50
|
|
|
98
|
/^(-1|0|1)$/ |
159
|
|
|
|
|
|
|
and return scalar $_ |
160
|
|
|
|
|
|
|
or last; |
161
|
|
|
|
|
|
|
}; |
162
|
|
|
|
|
|
|
|
163
|
5
|
|
|
|
|
66
|
$!=1; die(__PACKAGE__ . '->varcmp(): command not generated proper output'); |
|
5
|
|
|
|
|
550
|
|
164
|
|
|
|
|
|
|
}; |
165
|
|
|
|
|
|
|
|
166
|
6
|
|
|
|
|
21
|
$!=1; die(__PACKAGE__ . '->varcmp(): one or more versions are empty'); |
|
6
|
|
|
|
|
119
|
|
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 multiinfo(@) |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Fast method to get info about multiple packages. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub multiinfo { |
176
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
177
|
0
|
|
|
|
|
|
my $lwp = WWW::AUR::UserAgent->new( |
178
|
|
|
|
|
|
|
'timeout' => 10, |
179
|
|
|
|
|
|
|
'agent' => sprintf( |
180
|
|
|
|
|
|
|
'WWW::AUR/v%s (OS::CheckUpdates::AUR/v%s)', |
181
|
|
|
|
|
|
|
$WWW::AUR::VERSION, |
182
|
|
|
|
|
|
|
$VERSION, |
183
|
|
|
|
|
|
|
), |
184
|
|
|
|
|
|
|
'protocols_allowed' => ['https'], |
185
|
|
|
|
|
|
|
); |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
my $response = $lwp->get(rpc_uri('multiinfo', @_)); |
188
|
|
|
|
|
|
|
|
189
|
0
|
0
|
|
|
|
|
$response->is_success |
190
|
|
|
|
|
|
|
and return decode_json($response->decoded_content); |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
### LWP decoded: $response->decoded_content |
193
|
|
|
|
|
|
|
|
194
|
0
|
|
|
|
|
|
$!=1; die(__PACKAGE__ . '->multiinfo(): LWP status error: ' . $response->status_line) |
|
0
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 AUTHOR |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
3ED, C<< >> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 BUGS |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
204
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
205
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 SUPPORT |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
perldoc OS::CheckUpdates::AUR |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
You can also look for information at: |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=over 4 |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
L |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
L |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item * CPAN Ratings |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
L |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item * Search CPAN |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
L |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=back |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Copyright 2016 3ED. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
248
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
249
|
|
|
|
|
|
|
copy of the full license at: |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
L |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
254
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
255
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
256
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
259
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
260
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
263
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
266
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
267
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
268
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
269
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
270
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
271
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
272
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
275
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
276
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
277
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
278
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
279
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
280
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
281
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=cut |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
1; # End of OS::CheckUpdates::AUR |