| 1 | package Parse::Debian::PackageDesc; | ||||||||||||
| 2 | |||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | our $VERSION = 0.15; | |||||||||||
| 6 | 2 | ▶ | use 5.00800; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 2 | ▶ | use Carp qw(carp croak); # NEVER USE warn OR die ! | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 2 | ▶ | use English qw(-no_match_vars); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | ▶ | use File::Basename; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 2 | ▶ | use Encode; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | |||||||||||||
| 13 | |||||||||||||
| 14 | 4 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 15 | 4 | my ($class, $path, %user_opts) = @_; | |||||||||||
| 16 | |||||||||||||
| 17 | 4 | my $self = bless { | |||||||||||
| 18 | path => $path, | ||||||||||||
| 19 | options => { %user_opts }, | ||||||||||||
| 20 | }, $class; | ||||||||||||
| 21 | 4 | ▶ | if (-r $path) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 22 | 2 | open F, $path; | |||||||||||
| 23 | 2 | $self->{contents} = decode('utf-8', join("", <F>)); | |||||||||||
| 24 | 2 | close F; | |||||||||||
| 25 | } | ||||||||||||
| 26 | else { | ||||||||||||
| 27 | 2 | croak "Can't read file '$path'"; | |||||||||||
| 28 | } | ||||||||||||
| 29 | |||||||||||||
| 30 | 2 | return $self; | |||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | 1 | ▶ | sub path { $_[0]->{path} } | ||||||||||
|
Subroutine
path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 34 | |||||||||||||
| 35 | 12 | ▶ | sub get_line_attr { | ||||||||||
|
Subroutine
get_line_attr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 36 | 12 | my ($self, $attr) = @_; | |||||||||||
| 37 | |||||||||||||
| 38 | 12 | $self->{contents} =~ /^$attr: (.*)/m; | |||||||||||
| 39 | 12 | return $1; | |||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 3 | ▶ | sub get_block_attr { | ||||||||||
|
Subroutine
get_block_attr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 43 | 3 | my ($self, $attr) = @_; | |||||||||||
| 44 | |||||||||||||
| 45 | # Collect lines that start with space | ||||||||||||
| 46 | 3 | $self->{contents} =~ /^$attr:\s*\n(( [^\n]+\n)+)/m; | |||||||||||
| 47 | 3 | return $1; | |||||||||||
| 48 | } | ||||||||||||
| 49 | |||||||||||||
| 50 | 1 | ▶ | sub date { | ||||||||||
|
Subroutine
date: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 51 | 1 | $_[0]->get_line_attr("Date"); | |||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | 1 | ▶ | sub name { | ||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 55 | 1 | $_[0]->source; | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | # This is special because we have to cover the binNMU case (we get lines like: | ||||||||||||
| 59 | # "Source: libparse-debian-packagedesc-perl (0.12-1)" but we have to return | ||||||||||||
| 60 | # just "libparse-debian-packagedesc-perl") | ||||||||||||
| 61 | 3 | ▶ | sub source { | ||||||||||
|
Subroutine
source: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 62 | 3 | my $source_value = $_[0]->get_line_attr("Source"); | |||||||||||
| 63 | 3 | $source_value =~ s/ .*//; | |||||||||||
| 64 | 3 | return $source_value; | |||||||||||
| 65 | } | ||||||||||||
| 66 | |||||||||||||
| 67 | 1 | ▶ | sub architecture { | ||||||||||
|
Subroutine
architecture: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 68 | 1 | split(/\s+/, $_[0]->get_line_attr("Architecture")); | |||||||||||
| 69 | } | ||||||||||||
| 70 | |||||||||||||
| 71 | 3 | ▶ | sub version { | ||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 72 | 3 | $_[0]->get_line_attr("Version"); | |||||||||||
| 73 | } | ||||||||||||
| 74 | |||||||||||||
| 75 | 10 | ▶ | sub extract_upstream_version { | ||||||||||
|
Subroutine
extract_upstream_version: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 76 | 10 | my ($pkg, $version) = @_; | |||||||||||
| 77 | |||||||||||||
| 78 | 10 | $version =~ s/-[a-z0-9+.~]+$//i; | |||||||||||
| 79 | 10 | return $version | |||||||||||
| 80 | } | ||||||||||||
| 81 | |||||||||||||
| 82 | 1 | ▶ | sub upstream_version { | ||||||||||
|
Subroutine
upstream_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 83 | 1 | my ($self) = @_; | |||||||||||
| 84 | 1 | return __PACKAGE__->extract_upstream_version($self->version); | |||||||||||
| 85 | } | ||||||||||||
| 86 | |||||||||||||
| 87 | 10 | ▶ | sub extract_debian_revision { | ||||||||||
|
Subroutine
extract_debian_revision: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 88 | 10 | my ($pkg, $version) = @_; | |||||||||||
| 89 | |||||||||||||
| 90 | 10 | $version =~ /-([a-z0-9+.~]+)$/i; | |||||||||||
| 91 | 10 | ▶ | return $1 || ""; | ||||||||||
|
Condition100%2/2
$1 || ''
MC/DC100%1/1
$1 || ''
$1
Truth table100%2/2
A
A= $1
| |||||||||||||
| 92 | } | ||||||||||||
| 93 | |||||||||||||
| 94 | 1 | ▶ | sub debian_revision { | ||||||||||
|
Subroutine
debian_revision: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 95 | 1 | my ($self) = @_; | |||||||||||
| 96 | 1 | return __PACKAGE__->extract_debian_revision($self->version); | |||||||||||
| 97 | } | ||||||||||||
| 98 | |||||||||||||
| 99 | 1 | ▶ | sub distribution { | ||||||||||
|
Subroutine
distribution: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 100 | 1 | $_[0]->get_line_attr("Distribution"); | |||||||||||
| 101 | } | ||||||||||||
| 102 | |||||||||||||
| 103 | 1 | ▶ | sub urgency { | ||||||||||
|
Subroutine
urgency: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 104 | 1 | $_[0]->get_line_attr("Urgency"); | |||||||||||
| 105 | } | ||||||||||||
| 106 | |||||||||||||
| 107 | 2 | ▶ | sub maintainer { | ||||||||||
|
Subroutine
maintainer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 108 | 2 | $_[0]->get_line_attr("Maintainer"); | |||||||||||
| 109 | } | ||||||||||||
| 110 | |||||||||||||
| 111 | 0 | ▶ | sub changed_by { | ||||||||||
|
Subroutine
changed_by: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 112 | 0 | $_[0]->get_line_attr("Changed-By"); | |||||||||||
| 113 | } | ||||||||||||
| 114 | |||||||||||||
| 115 | 0 | ▶ | sub binary_packages { | ||||||||||
|
Subroutine
binary_packages: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 116 | 0 | split(/\s/, $_[0]->get_line_attr("Binary")); | |||||||||||
| 117 | } | ||||||||||||
| 118 | |||||||||||||
| 119 | 1 | ▶ | sub changes { | ||||||||||
|
Subroutine
changes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 120 | 1 | $_[0]->get_block_attr("Changes"); | |||||||||||
| 121 | } | ||||||||||||
| 122 | |||||||||||||
| 123 | 2 | ▶ | sub files { | ||||||||||
|
Subroutine
files: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 124 | 2 | my ($self) = @_; | |||||||||||
| 125 | |||||||||||||
| 126 | 2 | my $files = $self->get_block_attr("Files"); | |||||||||||
| 127 | 2 | return map { my @fields = split(/\s+/, $_); $fields[5] } | |||||||||||
| 128 | split(/\n/, $files); | ||||||||||||
| 129 | } | ||||||||||||
| 130 | |||||||||||||
| 131 | 1 | ▶ | sub binary_package_files { | ||||||||||
|
Subroutine
binary_package_files: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 132 | 1 | my ($self) = @_; | |||||||||||
| 133 | |||||||||||||
| 134 | 1 | grep { $_ =~ /\.deb$/ } $self->files; | |||||||||||
| 135 | } | ||||||||||||
| 136 | |||||||||||||
| 137 | 0 | ▶ | sub execute_gpg_verify { | ||||||||||
|
Subroutine
execute_gpg_verify: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 138 | 0 | my ($self) = @_; | |||||||||||
| 139 | |||||||||||||
| 140 | my $options = defined $self->{options}->{gpg_homedir} ? | ||||||||||||
| 141 | 0 | ▶ | "--homedir '$self->{options}->{gpg_homedir}'" : | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 142 | ""; | ||||||||||||
| 143 | 0 | my $gpg_cmd_line = "LC_ALL=C gpg $options --verify ".$self->path." 2>&1"; | |||||||||||
| 144 | 0 | $self->{gpg_verify_output} = `$gpg_cmd_line`; | |||||||||||
| 145 | 0 | $self->{gpg_verify_status} = $?; | |||||||||||
| 146 | } | ||||||||||||
| 147 | |||||||||||||
| 148 | 0 | ▶ | sub gpg_verify_status { | ||||||||||
|
Subroutine
gpg_verify_status: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 149 | 0 | my ($self) = @_; | |||||||||||
| 150 | |||||||||||||
| 151 | 0 | ▶ | if (!$self->{gpg_verify_status}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 152 | 0 | $self->execute_gpg_verify; | |||||||||||
| 153 | } | ||||||||||||
| 154 | 0 | return $self->{gpg_verify_status}; | |||||||||||
| 155 | } | ||||||||||||
| 156 | |||||||||||||
| 157 | 0 | ▶ | sub gpg_verify_output { | ||||||||||
|
Subroutine
gpg_verify_output: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 158 | 0 | my ($self) = @_; | |||||||||||
| 159 | |||||||||||||
| 160 | 0 | ▶ | if (!$self->{gpg_verify_output}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 161 | 0 | $self->execute_gpg_verify; | |||||||||||
| 162 | } | ||||||||||||
| 163 | 0 | return $self->{gpg_verify_output}; | |||||||||||
| 164 | } | ||||||||||||
| 165 | |||||||||||||
| 166 | 0 | ▶ | sub correct_signature { | ||||||||||
|
Subroutine
correct_signature: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 167 | 0 | my ($self) = @_; | |||||||||||
| 168 | 0 | return ($self->gpg_verify_status == 0); | |||||||||||
| 169 | } | ||||||||||||
| 170 | |||||||||||||
| 171 | 0 | ▶ | sub signature_id { | ||||||||||
|
Subroutine
signature_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 172 | 0 | my ($self) = @_; | |||||||||||
| 173 | 0 | $self->gpg_verify_output =~ /^gpg: Signature.*ID (\w+)$/m; | |||||||||||
| 174 | 0 | return $1; | |||||||||||
| 175 | } | ||||||||||||
| 176 | |||||||||||||
| 177 | 2 | 1; | |||||||||||
| 178 | |||||||||||||
| 179 | __END__ | ||||||||||||