| 1 | # Copyright © 2009 Raphaël Hertzog <hertzog@debian.org> | ||||||||||||||||||||||||||||
| 2 | # Copyright © 2012-2013 Guillem Jover <guillem@debian.org> | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 5 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||
| 6 | # the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||
| 7 | # (at your option) any later version. | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||
| 12 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||
| 14 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||
| 15 | # along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =encoding utf8 | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 NAME | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | Dpkg::Changelog::Entry::Debian - represents a Debian changelog entry | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | This class represents a Debian changelog entry. | ||||||||||||||||||||||||||||
| 26 | It implements the generic interface L<Dpkg::Changelog::Entry>. | ||||||||||||||||||||||||||||
| 27 | Only functions specific to this implementation are described below, | ||||||||||||||||||||||||||||
| 28 | the rest are inherited. | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | package Dpkg::Changelog::Entry::Debian 2.00; | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 2 | ▶ | use v5.36; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 2 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||
| 37 | match_header | ||||||||||||||||||||||||||||
| 38 | match_trailer | ||||||||||||||||||||||||||||
| 39 | find_closes | ||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 2 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | 2 | ▶ | use Time::Piece; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 2 | ▶ | use Dpkg::Gettext; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 46 | 2 | ▶ | use Dpkg::Control::Fields; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | 2 | ▶ | use Dpkg::Control::Changelog; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | 2 | ▶ | use Dpkg::Changelog::Entry; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | 2 | ▶ | use Dpkg::Version; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 2 | ▶ | use parent qw(Dpkg::Changelog::Entry); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 2 | my $name_chars = qr/[-+0-9a-z.]/i; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # The matched content is the source package name ($1), the version ($2), | ||||||||||||||||||||||||||||
| 56 | # the target distributions ($3) and the options on the rest of the line ($4). | ||||||||||||||||||||||||||||
| 57 | 2 | my $regex_header = qr{ | |||||||||||||||||||||||||||
| 58 | ^ | ||||||||||||||||||||||||||||
| 59 | (\w$name_chars*) # Package name. | ||||||||||||||||||||||||||||
| 60 | \ \(([^\(\) \t]+)\) # Package version. | ||||||||||||||||||||||||||||
| 61 | ((?:\s+$name_chars+)+) # Target distribution. | ||||||||||||||||||||||||||||
| 62 | \; # Separator. | ||||||||||||||||||||||||||||
| 63 | (.*?) # Key=Value options. | ||||||||||||||||||||||||||||
| 64 | \s*$ # Trailing space. | ||||||||||||||||||||||||||||
| 65 | }xi; | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # The matched content is the maintainer name ($1), its email ($2), | ||||||||||||||||||||||||||||
| 68 | # some blanks ($3) and the timestamp ($4), which is decomposed into | ||||||||||||||||||||||||||||
| 69 | # day of week ($6), date-time ($7) and this into month name ($8). | ||||||||||||||||||||||||||||
| 70 | 2 | my $regex_trailer = qr< | |||||||||||||||||||||||||||
| 71 | ^ | ||||||||||||||||||||||||||||
| 72 | \ -- # Trailer marker. | ||||||||||||||||||||||||||||
| 73 | \ (.*) # Maintainer name. | ||||||||||||||||||||||||||||
| 74 | \ \<(.*)\> # Maintainer email. | ||||||||||||||||||||||||||||
| 75 | (\ \ ?) # Blanks. | ||||||||||||||||||||||||||||
| 76 | ( | ||||||||||||||||||||||||||||
| 77 | ((\w+)\,\s*)? # Day of week (abbreviated). | ||||||||||||||||||||||||||||
| 78 | ( | ||||||||||||||||||||||||||||
| 79 | \d{1,2}\s+ # Day of month. | ||||||||||||||||||||||||||||
| 80 | (\w+)\s+ # Month name (abbreviated). | ||||||||||||||||||||||||||||
| 81 | \d{4}\s+ # Year. | ||||||||||||||||||||||||||||
| 82 | \d{1,2}:\d\d:\d\d\s+[-+]\d{4} # ISO 8601 date. | ||||||||||||||||||||||||||||
| 83 | ) | ||||||||||||||||||||||||||||
| 84 | ) | ||||||||||||||||||||||||||||
| 85 | \s*$ # Trailing space. | ||||||||||||||||||||||||||||
| 86 | >x; | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 2 | my %week_day = map { $_ => 1 } qw(Mon Tue Wed Thu Fri Sat Sun); | |||||||||||||||||||||||||||
| 89 | 2 | my @month_abbrev = qw( | |||||||||||||||||||||||||||
| 90 | Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec | ||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||
| 92 | 2 | my %month_abbrev = map { $_ => 1 } @month_abbrev; | |||||||||||||||||||||||||||
| 93 | 2 | my @month_name = qw( | |||||||||||||||||||||||||||
| 94 | January February March April May June July | ||||||||||||||||||||||||||||
| 95 | August September October November December | ||||||||||||||||||||||||||||
| 96 | ); | ||||||||||||||||||||||||||||
| 97 | 2 | my %month_name = map { $month_name[$_] => $month_abbrev[$_] } 0 .. 11; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =head1 METHODS | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =over 4 | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =item @items = $entry->get_change_items() | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | Return a list of change items. Each item contains at least one line. | ||||||||||||||||||||||||||||
| 106 | A change line starting with an asterisk denotes the start of a new item. | ||||||||||||||||||||||||||||
| 107 | Any change line like "C<[ Raphaël Hertzog ]>" is treated like an item of its | ||||||||||||||||||||||||||||
| 108 | own even if it starts a set of items attributed to this person (the | ||||||||||||||||||||||||||||
| 109 | following line necessarily starts a new item). | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =cut | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 2 | ▶ | sub get_change_items { | ||||||||||||||||||||||||||
|
Subroutine
get_change_items: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||
| 114 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 115 | 2 | my (@items, @blanks, $item); | |||||||||||||||||||||||||||
| 116 | 2 | foreach my $line (@{$self->get_part('changes')}) { | |||||||||||||||||||||||||||
| 117 | 18 | ▶ | if ($line =~ /^\s*\*/) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 118 | 8 | ▶ | push @items, $item if defined $item; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 8 | $item = "$line\n"; | |||||||||||||||||||||||||||
| 120 | } elsif ($line =~ /^\s*\[\s[^\]]+\s\]\s*$/) { | ||||||||||||||||||||||||||||
| 121 | 4 | ▶ | push @items, $item if defined $item; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 4 | push @items, "$line\n"; | |||||||||||||||||||||||||||
| 123 | 4 | $item = undef; | |||||||||||||||||||||||||||
| 124 | 4 | @blanks = (); | |||||||||||||||||||||||||||
| 125 | } elsif ($line =~ /^\s*$/) { | ||||||||||||||||||||||||||||
| 126 | 2 | push @blanks, "$line\n"; | |||||||||||||||||||||||||||
| 127 | } else { | ||||||||||||||||||||||||||||
| 128 | 4 | ▶ | if (defined $item) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 4 | $item .= "@blanks$line\n"; | |||||||||||||||||||||||||||
| 130 | } else { | ||||||||||||||||||||||||||||
| 131 | 0 | $item = "$line\n"; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | 4 | @blanks = (); | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | 2 | ▶ | push @items, $item if defined $item; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 2 | return @items; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =item @errors = $entry->parse_header() | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =item @errors = $entry->parse_trailer() | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | Return a list of errors. Each item in the list is an error message | ||||||||||||||||||||||||||||
| 145 | describing the problem. If the empty list is returned, no errors | ||||||||||||||||||||||||||||
| 146 | have been found. | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | =cut | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 250 | ▶ | sub parse_header { | ||||||||||||||||||||||||||
|
Subroutine
parse_header: called CC=12 SCAR=29.3
Pod
documented
| |||||||||||||||||||||||||||||
| 151 | 250 | my $self = shift; | |||||||||||||||||||||||||||
| 152 | 250 | my @errors; | |||||||||||||||||||||||||||
| 153 | 250 | ▶ | if (defined($self->{header}) and $self->{header} =~ $regex_header) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"header"} and $self->{"header"} =~ /$regex_header/u
MC/DC0%0/2
defined $self->{"header"} and $self->{"header"} =~ /$regex_header/u
defined $self->{"header"}
$self->{"header"} =~ /$regex_header/u
Truth table33%1/3
A and B
A= defined $self->{"header"}B= $self->{"header"} =~ /$regex_header/u
| |||||||||||||||||||||||||||||
| 154 | 250 | $self->{header_source} = $1; | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 250 | my $version = Dpkg::Version->new($2); | |||||||||||||||||||||||||||
| 157 | 250 | my ($ok, $msg) = version_check($version); | |||||||||||||||||||||||||||
| 158 | 250 | ▶ | if ($ok) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 250 | $self->{header_version} = $version; | |||||||||||||||||||||||||||
| 160 | } else { | ||||||||||||||||||||||||||||
| 161 | 0 | push @errors, sprintf(g_("version '%s' is invalid: %s"), $version, $msg); | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 250 | @{$self->{header_dists}} = split ' ', $3; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 250 | my $options = $4; | |||||||||||||||||||||||||||
| 167 | 250 | $options =~ s/^\s+//; | |||||||||||||||||||||||||||
| 168 | 250 | my $c = Dpkg::Control::Changelog->new(); | |||||||||||||||||||||||||||
| 169 | 250 | foreach my $opt (split(/\s*,\s*/, $options)) { | |||||||||||||||||||||||||||
| 170 | 254 | ▶ | unless ($opt =~ m/^([-0-9a-z]+)\=\s*(.*\S)$/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | 0 | push @errors, sprintf(g_("bad key-value after ';': '%s'"), $opt); | |||||||||||||||||||||||||||
| 172 | 0 | next; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | ## no critic (RegularExpressions::ProhibitCaptureWithoutTest) | ||||||||||||||||||||||||||||
| 175 | 254 | my ($k, $v) = (field_capitalize($1), $2); | |||||||||||||||||||||||||||
| 176 | 254 | ▶ | if (exists $c->{$k}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | 0 | push @errors, sprintf(g_('repeated key-value %s'), $k); | |||||||||||||||||||||||||||
| 178 | } else { | ||||||||||||||||||||||||||||
| 179 | 254 | $c->{$k} = $v; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | 254 | ▶ | if ($k eq 'Urgency') { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 182 | 250 | ▶ | push @errors, sprintf(g_('badly formatted urgency value: %s'), $v) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | unless ($v =~ m/^([-0-9a-z]+)((\s+.*)?)$/i); | ||||||||||||||||||||||||||||
| 184 | } elsif ($k eq 'Binary-Only') { | ||||||||||||||||||||||||||||
| 185 | 0 | ▶ | push @errors, sprintf(g_('bad binary-only value: %s'), $v) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | unless ($v eq 'yes'); | ||||||||||||||||||||||||||||
| 187 | } elsif ($k =~ m/^X[BCS]+-/i) { | ||||||||||||||||||||||||||||
| 188 | } else { | ||||||||||||||||||||||||||||
| 189 | 0 | push @errors, sprintf(g_('unknown key-value %s'), $k); | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | 250 | $self->{header_fields} = $c; | |||||||||||||||||||||||||||
| 193 | } else { | ||||||||||||||||||||||||||||
| 194 | 0 | push @errors, g_('header does not match expected regex'); | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | 250 | return @errors; | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 248 | ▶ | sub parse_trailer { | ||||||||||||||||||||||||||
|
Subroutine
parse_trailer: called CC=9 SCAR=29.5
Pod
documented
| |||||||||||||||||||||||||||||
| 200 | 248 | my $self = shift; | |||||||||||||||||||||||||||
| 201 | 248 | my @errors; | |||||||||||||||||||||||||||
| 202 | 248 | ▶ | if (defined($self->{trailer}) and $self->{trailer} =~ $regex_trailer) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"trailer"} and $self->{"trailer"} =~ /$regex_trailer/u
MC/DC0%0/2
defined $self->{"trailer"} and $self->{"trailer"} =~ /$regex_trailer/u
defined $self->{"trailer"}
$self->{"trailer"} =~ /$regex_trailer/u
Truth table33%1/3
A and B
A= defined $self->{"trailer"}B= $self->{"trailer"} =~ /$regex_trailer/u
| |||||||||||||||||||||||||||||
| 203 | 248 | $self->{trailer_maintainer} = "$1 <$2>"; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 248 | ▶ | if ($3 ne ' ') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 0 | push @errors, g_('badly formatted trailer line'); | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | # Validate the week day. Date::Parse used to ignore it, but Time::Piece | ||||||||||||||||||||||||||||
| 210 | # is much more strict and it does not gracefully handle bogus values. | ||||||||||||||||||||||||||||
| 211 | 248 | ▶ | if (defined $5 and not exists $week_day{$6}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $5 and not exists $week_day{$6}
MC/DC0%0/2
defined $5 and not exists $week_day{$6}
defined $5
not exists $week_day{$6}
Truth table66%2/3
A and not(B)
A= defined $5B= not exists $week_day{$6}
| |||||||||||||||||||||||||||||
| 212 | 0 | push @errors, sprintf(g_('ignoring invalid week day \'%s\''), $6); | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | # Ignore the week day ('%a, '), as we have validated it above. | ||||||||||||||||||||||||||||
| 216 | 248 | local $ENV{LC_ALL} = 'C'; | |||||||||||||||||||||||||||
| 217 | eval { | ||||||||||||||||||||||||||||
| 218 | 248 | my $tp = Time::Piece->strptime($7, '%d %b %Y %T %z'); | |||||||||||||||||||||||||||
| 219 | 248 | $self->{trailer_timepiece} = $tp; | |||||||||||||||||||||||||||
| 220 | 248 | ▶ | } or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | # Validate the month. Date::Parse used to accept both abbreviated | ||||||||||||||||||||||||||||
| 222 | # and full months, but Time::Piece strptime() implementation only | ||||||||||||||||||||||||||||
| 223 | # matches the abbreviated one with %b, which is what we want anyway. | ||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if (not exists $month_abbrev{$8}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | # We have to nest the conditionals because May is the same in | ||||||||||||||||||||||||||||
| 226 | # full and abbreviated forms! | ||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if (exists $month_name{$8}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | push @errors, sprintf(g_('uses full \'%s\' instead of abbreviated month name \'%s\''), | ||||||||||||||||||||||||||||
| 229 | 0 | $8, $month_name{$8}); | |||||||||||||||||||||||||||
| 230 | } else { | ||||||||||||||||||||||||||||
| 231 | 0 | push @errors, sprintf(g_('invalid abbreviated month name \'%s\''), $8); | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | 0 | push @errors, sprintf(g_("cannot parse non-conformant date '%s'"), $7); | |||||||||||||||||||||||||||
| 235 | }; | ||||||||||||||||||||||||||||
| 236 | 248 | $self->{trailer_timestamp_date} = $4; | |||||||||||||||||||||||||||
| 237 | } else { | ||||||||||||||||||||||||||||
| 238 | 0 | push @errors, g_('trailer does not match expected regex'); | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | 248 | return @errors; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | =item $entry->normalize() | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | Normalize the content. Strip whitespaces at end of lines, use a single | ||||||||||||||||||||||||||||
| 246 | empty line to separate each part. | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | =cut | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 0 | ▶ | sub normalize { | ||||||||||||||||||||||||||
|
Subroutine
normalize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 251 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 252 | 0 | $self->SUPER::normalize(); | |||||||||||||||||||||||||||
| 253 | # XXX: Recreate header/trailer. | ||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | =item $src = $entry->get_source() | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | Return the name of the source package associated to the changelog entry. | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | =cut | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 502 | ▶ | sub get_source { | ||||||||||||||||||||||||||
|
Subroutine
get_source: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 263 | 502 | my $self = shift; | |||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 502 | return $self->{header_source}; | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | =item $ver = $entry->get_version() | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | Return the version associated to the changelog entry. | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | =cut | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 1966 | ▶ | sub get_version { | ||||||||||||||||||||||||||
|
Subroutine
get_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 275 | 1966 | my $self = shift; | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 1966 | return $self->{header_version}; | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | =item @dists = $entry->get_distributions() | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | Return a list of target distributions for this version. | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | =cut | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 504 | ▶ | sub get_distributions { | ||||||||||||||||||||||||||
|
Subroutine
get_distributions: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 287 | 504 | my $self = shift; | |||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 504 | ▶ | if (defined $self->{header_dists}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 504 | ▶ | return @{$self->{header_dists}} if wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 291 | 2 | return $self->{header_dists}[0]; | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | 0 | return; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | =item $ctrl = $entry->get_optional_fields() | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | Return a set of optional fields exposed by the changelog entry. | ||||||||||||||||||||||||||||
| 299 | It always returns a L<Dpkg::Control> object (possibly empty though). | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =cut | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 1478 | ▶ | sub get_optional_fields { | ||||||||||||||||||||||||||
|
Subroutine
get_optional_fields: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 304 | 1478 | my $self = shift; | |||||||||||||||||||||||||||
| 305 | 1478 | my $c; | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 1478 | ▶ | if (defined $self->{header_fields}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | 1478 | $c = $self->{header_fields}; | |||||||||||||||||||||||||||
| 309 | } else { | ||||||||||||||||||||||||||||
| 310 | 0 | $c = Dpkg::Control::Changelog->new(); | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 1478 | my @closes = find_closes(join("\n", @{$self->{changes}})); | |||||||||||||||||||||||||||
| 314 | 1478 | ▶ | if (@closes) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | 1034 | $c->{Closes} = join ' ', @closes; | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 1478 | return $c; | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | =item $urgency = $entry->get_urgency() | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | Return the urgency of the associated upload. | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | =cut | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 738 | ▶ | sub get_urgency { | ||||||||||||||||||||||||||
|
Subroutine
get_urgency: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||
| 328 | 738 | my $self = shift; | |||||||||||||||||||||||||||
| 329 | 738 | my $c = $self->get_optional_fields(); | |||||||||||||||||||||||||||
| 330 | 738 | ▶ | if (exists $c->{Urgency}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | 738 | $c->{Urgency} =~ s/\s.*$//; | |||||||||||||||||||||||||||
| 332 | 738 | return lc $c->{Urgency}; | |||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | 0 | return; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | =item $maint = $entry->get_maintainer() | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | Return the string identifying the person who signed this changelog entry. | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | =cut | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 502 | ▶ | sub get_maintainer { | ||||||||||||||||||||||||||
|
Subroutine
get_maintainer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 344 | 502 | my $self = shift; | |||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 502 | return $self->{trailer_maintainer}; | |||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | =item $time = $entry->get_timestamp() | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | Return the timestamp of the changelog entry. | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | =cut | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 508 | ▶ | sub get_timestamp { | ||||||||||||||||||||||||||
|
Subroutine
get_timestamp: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 356 | 508 | my $self = shift; | |||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 508 | return $self->{trailer_timestamp_date}; | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | =item $time = $entry->get_timepiece() | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | Return the timestamp of the changelog entry as a L<Time::Piece> object. | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | This function might return undef if there was no timestamp. | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | =cut | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 1000 | ▶ | sub get_timepiece { | ||||||||||||||||||||||||||
|
Subroutine
get_timepiece: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 370 | 1000 | my $self = shift; | |||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 1000 | return $self->{trailer_timepiece}; | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | =back | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | =head1 UTILITY FUNCTIONS | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | =over 4 | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | =item $bool = match_header($line) | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | Checks if the line matches a valid changelog header line. | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | =cut | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 3780 | ▶ | sub match_header { | ||||||||||||||||||||||||||
|
Subroutine
match_header: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 388 | 3780 | my $line = shift; | |||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | 3780 | return $line =~ /$regex_header/; | |||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | =item $bool = match_trailer($line) | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | Checks if the line matches a valid changelog trailing line. | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | =cut | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | 3524 | ▶ | sub match_trailer { | ||||||||||||||||||||||||||
|
Subroutine
match_trailer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 400 | 3524 | my $line = shift; | |||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | 3524 | return $line =~ /$regex_trailer/; | |||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | =item @closed_bugs = find_closes($changes) | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | Takes one string as argument and finds "Closes: #123456, #654321" statements | ||||||||||||||||||||||||||||
| 408 | as supported by the Debian Archive software in it. Returns all closed bug | ||||||||||||||||||||||||||||
| 409 | numbers in an array. | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | =cut | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 1478 | ▶ | sub find_closes { | ||||||||||||||||||||||||||
|
Subroutine
find_closes: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 414 | 1478 | my $changes = shift; | |||||||||||||||||||||||||||
| 415 | 1478 | my %closes; | |||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | 1478 | ▶ | while ($changes && ($changes =~ m{ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$changes and $changes =~ /
closes:\s*
(?:bug)?\#?\s?\d+
(?:,\s*(?:bug)?\#?\s?\d+)*
/gipux
MC/DC50%1/2
$changes and $changes =~ /
closes:\s*
(?:bug)?\#?\s?\d+
(?:,\s*(?:bug)?\#?\s?\d+)*
/gipux
$changes
$changes =~ /
closes:\s*
(?:bug)?\#?\s?\d+
(?:,\s*(?:bug)?\#?\s?\d+)*
/gipux
Truth table66%2/3
A and B
A= $changesB= $changes =~ /
closes:\s*
(?:bug)?\#?\s?\d+
(?:,\s*(?:bug)?\#?\s?\d+)*
/gipux
| |||||||||||||||||||||||||||||
| 418 | closes:\s* | ||||||||||||||||||||||||||||
| 419 | (?:bug)?\#?\s?\d+ | ||||||||||||||||||||||||||||
| 420 | (?:,\s*(?:bug)?\#?\s?\d+)* | ||||||||||||||||||||||||||||
| 421 | }pigx)) { | ||||||||||||||||||||||||||||
| 422 | 5822 | $closes{$_} = 1 foreach (${^MATCH} =~ /\#?\s?(\d+)/g); | |||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | 1478 | my @closes = sort { $a <=> $b } keys %closes; | |||||||||||||||||||||||||||
| 426 | 1478 | return @closes; | |||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | =back | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | =head1 CHANGES | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | =head2 Version 2.00 (dpkg 1.20.0) | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | Remove methods: $entry->check_header(), $entry->check_trailer(). | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | Hide variables: $regex_header, $regex_trailer. | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | =head2 Version 1.03 (dpkg 1.18.8) | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | New methods: $entry->get_timepiece(). | ||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | =head2 Version 1.02 (dpkg 1.18.5) | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | New methods: $entry->parse_header(), $entry->parse_trailer(). | ||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | Deprecated methods: $entry->check_header(), $entry->check_trailer(). | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | =head2 Version 1.01 (dpkg 1.17.2) | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | New functions: match_header(), match_trailer() | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | Deprecated variables: $regex_header, $regex_trailer | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | =head2 Version 1.00 (dpkg 1.15.6) | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | Mark the module as public. | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | =cut | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | 2 | 1; | |||||||||||||||||||||||||||