| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Slackeria::Plugin::Debian; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4256742
|
use strict; |
|
|
1
|
|
|
|
|
16
|
|
|
|
1
|
|
|
|
|
141
|
|
|
4
|
1
|
|
|
1
|
|
26
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
424
|
|
|
5
|
1
|
|
|
1
|
|
462
|
use 5.010; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
72
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
10030
|
use parent 'App::Slackeria::Plugin'; |
|
|
1
|
|
|
|
|
603
|
|
|
|
1
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5737
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
111575
|
|
|
|
1
|
|
|
|
|
18
|
|
|
10
|
1
|
|
|
1
|
|
612
|
use XML::LibXML; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
|
15
|
|
|
|
|
|
|
my ( $obj, %conf ) = @_; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $ref = {}; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$ref->{default} = \%conf; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$ref->{ua} = LWP::UserAgent->new( timeout => 10 ); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return bless( $ref, $obj ); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub check { |
|
27
|
|
|
|
|
|
|
my ($self) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $name = $self->{conf}->{name}; |
|
30
|
|
|
|
|
|
|
my $dist = $self->{conf}->{distribution} // 'sid'; |
|
31
|
|
|
|
|
|
|
my $reply = $self->{ua}->get("http://packages.debian.org/${dist}/${name}"); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
if ( not $reply->is_success ) { |
|
34
|
|
|
|
|
|
|
die( $reply->status_line ); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->{conf}->{href} //= 'http://packages.debian.org/sid/%s'; |
|
38
|
|
|
|
|
|
|
my $href = sprintf( $self->{conf}->{href}, $self->{conf}->{name} ); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $html = $reply->decoded_content(); |
|
41
|
|
|
|
|
|
|
my $tree = XML::LibXML->load_html( |
|
42
|
|
|
|
|
|
|
string => $html, |
|
43
|
|
|
|
|
|
|
recover => 2, |
|
44
|
|
|
|
|
|
|
suppress_errors => 1, |
|
45
|
|
|
|
|
|
|
suppress_warnings => 1, |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $xp_title = XML::LibXML::XPathExpression->new('//div[@id="content"]/h1'); |
|
49
|
|
|
|
|
|
|
my $re_package = qr{ |
|
50
|
|
|
|
|
|
|
^ Package: \s ${name} \s |
|
51
|
|
|
|
|
|
|
\( (? \S+ ) |
|
52
|
|
|
|
|
|
|
(?: \) | \s and \s others) |
|
53
|
|
|
|
|
|
|
}x; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
for my $node ( @{ $tree->findnodes($xp_title) } ) { |
|
56
|
|
|
|
|
|
|
my $text = $node->textContent; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
if ( $text =~ $re_package ) { |
|
59
|
|
|
|
|
|
|
return { |
|
60
|
|
|
|
|
|
|
data => $+{ver}, |
|
61
|
|
|
|
|
|
|
href => $href |
|
62
|
|
|
|
|
|
|
}; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
die("not found\n"); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |