| 1 | # Copyright © 2008 Frank Lichtenheld <djpig@debian.org> | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyright © 2008, 2012-2015 Guillem Jover <guillem@debian.org> | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright © 2010 Raphaël Hertzog <hertzog@debian.org> | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | Dpkg::Checksums - generate and manipulate file checksums | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | This module provides a class that can generate and manipulate | ||||||||||||||||||||||||||||||||||||||||||
| 27 | various file checksums as well as some methods to query information | ||||||||||||||||||||||||||||||||||||||||||
| 28 | about supported checksums. | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | package Dpkg::Checksums 1.04; | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||
| 37 | checksums_is_supported | ||||||||||||||||||||||||||||||||||||||||||
| 38 | checksums_get_list | ||||||||||||||||||||||||||||||||||||||||||
| 39 | checksums_get_property | ||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | use Digest; | ||||||||||||||||||||||||||||||||||||||||
|
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::ErrorHandling; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | my $CHECKSUMS = { | |||||||||||||||||||||||||||||||||||||||||
| 55 | md5 => { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | name => 'MD5', | ||||||||||||||||||||||||||||||||||||||||||
| 57 | regex => qr/[0-9a-f]{32}/, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | strong => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | sha1 => { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | name => 'SHA-1', | ||||||||||||||||||||||||||||||||||||||||||
| 62 | regex => qr/[0-9a-f]{40}/, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | strong => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | sha256 => { | ||||||||||||||||||||||||||||||||||||||||||
| 66 | name => 'SHA-256', | ||||||||||||||||||||||||||||||||||||||||||
| 67 | regex => qr/[0-9a-f]{64}/, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | strong => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | =item @list = checksums_get_list() | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | Returns the list of supported checksums algorithms. | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 6 | ▶ | sub checksums_get_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checksums_get_list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 6 | my @list = sort keys %{$CHECKSUMS}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 6 | return @list; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | =item $bool = checksums_is_supported($alg) | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | Returns a boolean indicating whether the given checksum algorithm is | ||||||||||||||||||||||||||||||||||||||||||
| 86 | supported. The checksum algorithm is case-insensitive. | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 21 | ▶ | sub checksums_is_supported { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checksums_is_supported: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 21 | my $alg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 21 | return exists $CHECKSUMS->{lc($alg)}; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | =item $value = checksums_get_property($alg, $property) | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | Returns the requested property of the checksum algorithm. Returns undef if | ||||||||||||||||||||||||||||||||||||||||||
| 98 | either the property or the checksum algorithm doesn't exist. Valid | ||||||||||||||||||||||||||||||||||||||||||
| 99 | properties currently include "name" (returns the name of the digest | ||||||||||||||||||||||||||||||||||||||||||
| 100 | algorithm), "regex" for the regular expression describing the common | ||||||||||||||||||||||||||||||||||||||||||
| 101 | string representation of the checksum, and "strong" for a boolean describing | ||||||||||||||||||||||||||||||||||||||||||
| 102 | whether the checksum algorithm is considered cryptographically strong. | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 15 | ▶ | sub checksums_get_property { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checksums_get_property: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 15 | my ($alg, $property) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 15 | ▶ | return unless checksums_is_supported($alg); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 15 | return $CHECKSUMS->{lc($alg)}{$property}; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | =item $ck = Dpkg::Checksums->new() | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | Create a new Dpkg::Checksums object. This object is able to store | ||||||||||||||||||||||||||||||||||||||||||
| 122 | the checksums of several files to later export them or verify them. | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | my ($this, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | ▶ | my $class = ref($this) || $this; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table33%1/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | $self->reset(); | |||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | =item $ck->reset() | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | Forget about all checksums stored. The object is again in the same state | ||||||||||||||||||||||||||||||||||||||||||
| 140 | as if it was newly created. | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | ▶ | sub reset { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | $self->{files} = []; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | $self->{checksums} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | $self->{size} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | =item $ck->add_from_file($filename, %opts) | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | Add or verify checksums information for the file $filename. The file must | ||||||||||||||||||||||||||||||||||||||||||
| 155 | exists for the call to succeed. By default if the $filename is known and | ||||||||||||||||||||||||||||||||||||||||||
| 156 | the checksums do not match, the function will error out. | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | Options: | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | =item B<key> | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | Set to the public name to use when exporting the checksums, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | instead of using $filename. | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | =item B<checksums> | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | Set an array reference with the list of wanted checksums to generate instead | ||||||||||||||||||||||||||||||||||||||||||
| 170 | of generating all of them. | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | =item B<update> | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | Set a boolean on whether the object should update the checksums information | ||||||||||||||||||||||||||||||||||||||||||
| 175 | associated with the $filename (or key), instead of emitting an error if | ||||||||||||||||||||||||||||||||||||||||||
| 176 | it does not match. | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 3 | ▶ | sub add_from_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_from_file: called CC=13 SCAR=32.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 3 | my ($self, $file, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 3 | ▶ | my $key = exists $opts{key} ? $opts{key} : $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | my @alg; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 3 | ▶ | if (exists $opts{checksums}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | push @alg, map { lc } @{$opts{checksums}}; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 3 | push @alg, checksums_get_list(); | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | ▶ | push @{$self->{files}}, $key unless exists $self->{size}{$key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | ▶ | stat $file or syserr(g_('cannot fstat file %s'), $file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | ▶ | if (not $opts{update} and exists $self->{size}{$key} and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $opts{"update"} and exists $self->{"size"}{$key} and $self->{"size"}{$key} != -s _
not $opts{"update"} and exists $self->{"size"}{$key}
MC/DC0%0/3
not $opts{"update"} and exists $self->{"size"}{$key} and $self->{"size"}{$key} != -s _
not $opts{"update"}
exists $self->{"size"}{$key}
$self->{"size"}{$key} != -s _
Truth table25%1/4
not(A) and B and C
A= not $opts{"update"}B= exists $self->{"size"}{$key}C= $self->{"size"}{$key} != -s _
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | $self->{size}{$key} != -s _) { | ||||||||||||||||||||||||||||||||||||||||||
| 196 | error(g_('file %s has size %u instead of expected %u'), | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $file, -s _, $self->{size}{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 3 | $self->{size}{$key} = -s _; | |||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 3 | foreach my $alg (@alg) { | |||||||||||||||||||||||||||||||||||||||||
| 202 | 9 | my $digest = Digest->new($CHECKSUMS->{$alg}{name}); | |||||||||||||||||||||||||||||||||||||||||
| 203 | 9 | ▶ | open my $fh, '<', $file or syserr(g_('cannot open file %s'), $file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 9 | $digest->addfile($fh); | |||||||||||||||||||||||||||||||||||||||||
| 205 | 9 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 9 | my $newsum = $digest->hexdigest; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 9 | ▶ | if (not $opts{update} and exists $self->{checksums}{$key}{$alg} and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $opts{"update"} and exists $self->{"checksums"}{$key}{$alg} and $self->{"checksums"}{$key}{$alg} ne $newsum
not $opts{"update"} and exists $self->{"checksums"}{$key}{$alg}
MC/DC0%0/3
not $opts{"update"} and exists $self->{"checksums"}{$key}{$alg} and $self->{"checksums"}{$key}{$alg} ne $newsum
not $opts{"update"}
exists $self->{"checksums"}{$key}{$alg}
$self->{"checksums"}{$key}{$alg} ne $newsum
Truth table25%1/4
not(A) and B and C
A= not $opts{"update"}B= exists $self->{"checksums"}{$key}{$alg}C= $self->{"checksums"}{$key}{$alg} ne $newsum
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | $self->{checksums}{$key}{$alg} ne $newsum) { | ||||||||||||||||||||||||||||||||||||||||||
| 210 | error(g_('file %s has checksum %s instead of expected %s (algorithm %s)'), | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $file, $newsum, $self->{checksums}{$key}{$alg}, $alg); | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 9 | $self->{checksums}{$key}{$alg} = $newsum; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | =item $ck->add_from_string($alg, $value, %opts) | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | Add checksums of type $alg that are stored in the $value variable. | ||||||||||||||||||||||||||||||||||||||||||
| 220 | $value can be multi-lines, each line should be a space separated list | ||||||||||||||||||||||||||||||||||||||||||
| 221 | of checksum, file size and filename. Leading or trailing spaces are | ||||||||||||||||||||||||||||||||||||||||||
| 222 | not allowed. | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | Options: | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | =item B<update> | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | Set a boolean on whether the object should update the checksums information | ||||||||||||||||||||||||||||||||||||||||||
| 231 | associated with the $filename (or key), instead of emitting an error if | ||||||||||||||||||||||||||||||||||||||||||
| 232 | it does not match. | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 6 | ▶ | sub add_from_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_from_string: called CC=11 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 6 | my ($self, $alg, $fieldtext, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 6 | $alg = lc($alg); | |||||||||||||||||||||||||||||||||||||||||
| 241 | 6 | my $rx_fname = qr/[0-9a-zA-Z][-+:.,=0-9a-zA-Z_~]+/; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 6 | my $regex = checksums_get_property($alg, 'regex'); | |||||||||||||||||||||||||||||||||||||||||
| 243 | 6 | my $checksums = $self->{checksums}; | |||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 6 | for my $checksum (split /\n */, $fieldtext) { | |||||||||||||||||||||||||||||||||||||||||
| 246 | 18 | ▶ | next if $checksum eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 12 | ▶ | unless ($checksum =~ m/^($regex)\s+(\d+)\s+($rx_fname)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | error(g_('invalid line in %s checksums string: %s'), | |||||||||||||||||||||||||||||||||||||||||
| 249 | $alg, $checksum); | ||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | ## no critic (RegularExpressions::ProhibitCaptureWithoutTest) | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 12 | my ($sum, $size, $file) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||
| 253 | 12 | ▶ | if (not $opts{update} and exists($checksums->{$file}{$alg}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not $opts{"update"} and exists $checksums->{$file}{$alg} and $checksums->{$file}{$alg} ne $sum
not $opts{"update"} and exists $checksums->{$file}{$alg}
MC/DC0%0/3
not $opts{"update"} and exists $checksums->{$file}{$alg} and $checksums->{$file}{$alg} ne $sum
not $opts{"update"}
exists $checksums->{$file}{$alg}
$checksums->{$file}{$alg} ne $sum
Truth table50%2/4
not(A) and B and C
A= not $opts{"update"}B= exists $checksums->{$file}{$alg}C= $checksums->{$file}{$alg} ne $sum
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | and $checksums->{$file}{$alg} ne $sum) { | ||||||||||||||||||||||||||||||||||||||||||
| 255 | error(g_("conflicting checksums '%s' and '%s' for file '%s'"), | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $checksums->{$file}{$alg}, $sum, $file); | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 12 | ▶ | if (not $opts{update} and exists $self->{size}{$file} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not $opts{"update"} and exists $self->{"size"}{$file} and $self->{"size"}{$file} != $size
not $opts{"update"} and exists $self->{"size"}{$file}
MC/DC0%0/3
not $opts{"update"} and exists $self->{"size"}{$file} and $self->{"size"}{$file} != $size
not $opts{"update"}
exists $self->{"size"}{$file}
$self->{"size"}{$file} != $size
Truth table50%2/4
not(A) and B and C
A= not $opts{"update"}B= exists $self->{"size"}{$file}C= $self->{"size"}{$file} != $size
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | and $self->{size}{$file} != $size) { | ||||||||||||||||||||||||||||||||||||||||||
| 260 | error(g_("conflicting file sizes '%u' and '%u' for file '%s'"), | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->{size}{$file}, $size, $file); | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 12 | ▶ | push @{$self->{files}}, $file unless exists $self->{size}{$file}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 12 | $checksums->{$file}{$alg} = $sum; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 12 | $self->{size}{$file} = $size; | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | =item $ck->add_from_control($control, %opts) | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | Read checksums from Checksums-* fields stored in the L<Dpkg::Control> object | ||||||||||||||||||||||||||||||||||||||||||
| 272 | $control. It uses $self->add_from_string() on the field values to do the | ||||||||||||||||||||||||||||||||||||||||||
| 273 | actual work. The default field used is B<Checksums-Md5>. | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | Options: | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | =item B<use_files_for_md5> | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | Set to true to use the B<Files> field instead of B<Checksums-Md5>. | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | Defaults to false. | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | ▶ | sub add_from_control { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_from_control: called CC=6 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | my ($self, $control, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | ▶ | $opts{use_files_for_md5} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"use_files_for_md5"} //= 0
MC/DC0%0/1
$opts{"use_files_for_md5"} //= 0
$opts{"use_files_for_md5"}
Truth table50%1/2
A
A= $opts{"use_files_for_md5"}
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | foreach my $alg (checksums_get_list()) { | |||||||||||||||||||||||||||||||||||||||||
| 293 | 3 | my $key = "Checksums-$alg"; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 3 | ▶ | $key = 'Files' if ($opts{use_files_for_md5} and $alg eq 'md5'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opts{"use_files_for_md5"} and $alg eq "md5"
MC/DC0%0/2
$opts{"use_files_for_md5"} and $alg eq "md5"
$opts{"use_files_for_md5"}
$alg eq "md5"
Truth table33%1/3
A and B
A= $opts{"use_files_for_md5"}B= $alg eq "md5"
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 3 | ▶ | if (exists $control->{$key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 3 | $self->add_from_string($alg, $control->{$key}, %opts); | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | =item @files = $ck->get_files() | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | Return the list of files whose checksums are stored in the object. | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 14 | ▶ | sub get_files { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_files: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 14 | return @{$self->{files}}; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | =item $bool = $ck->has_file($file) | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | Return true if we have checksums for the given file. Returns false | ||||||||||||||||||||||||||||||||||||||||||
| 315 | otherwise. | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 12 | ▶ | sub has_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 12 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 12 | return exists $self->{size}{$file}; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | =item $ck->remove_file($file) | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | Remove all checksums of the given file. | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | ▶ | sub remove_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_file: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | ▶ | return unless $self->has_file($file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | delete $self->{checksums}{$file}; | |||||||||||||||||||||||||||||||||||||||||
| 334 | 1 | delete $self->{size}{$file}; | |||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | @{$self->{files}} = grep { $_ ne $file } $self->get_files(); | |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | =item $checksum = $ck->get_checksum($file, $alg) | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | Return the checksum of type $alg for the requested $file. This will not | ||||||||||||||||||||||||||||||||||||||||||
| 341 | compute the checksum but only return the checksum stored in the object, if | ||||||||||||||||||||||||||||||||||||||||||
| 342 | any. | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | If $alg is not defined, it returns a reference to a hash: keys are | ||||||||||||||||||||||||||||||||||||||||||
| 345 | the checksum algorithms and values are the checksums themselves. The | ||||||||||||||||||||||||||||||||||||||||||
| 346 | hash returned must not be modified, it's internal to the object. | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 36 | ▶ | sub get_checksum { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_checksum: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 36 | my ($self, $file, $alg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 352 | 36 | ▶ | $alg = lc($alg) if defined $alg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 36 | ▶ | if (exists $self->{checksums}{$file}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 36 | ▶ | return $self->{checksums}{$file} unless defined $alg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 27 | return $self->{checksums}{$file}{$alg}; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | =item $size = $ck->get_size($file) | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | Return the size of the requested file if it's available in the object. | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 36 | ▶ | sub get_size { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 36 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 36 | return $self->{size}{$file}; | |||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | =item $bool = $ck->has_strong_checksums($file) | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | Return a boolean on whether the file has a strong checksum. | ||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub has_strong_checksums { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_strong_checksums: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | foreach my $alg (checksums_get_list()) { | |||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | return 1 if defined $self->get_checksum($file, $alg) and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->get_checksum($file, $alg) and checksums_get_property($alg, "strong")
MC/DC0%0/2
defined $self->get_checksum($file, $alg) and checksums_get_property($alg, "strong")
defined $self->get_checksum($file, $alg)
checksums_get_property($alg, "strong")
Truth table0%0/3
A and B
A= defined $self->get_checksum($file, $alg)B= checksums_get_property($alg, "strong")
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | checksums_get_property($alg, 'strong'); | ||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | =item $ck->export_to_string($alg, %opts) | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | Return a multi-line string containing the checksums of type $alg. The | ||||||||||||||||||||||||||||||||||||||||||
| 391 | string can be stored as-is in a Checksum-* field of a L<Dpkg::Control> | ||||||||||||||||||||||||||||||||||||||||||
| 392 | object. | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 9 | ▶ | sub export_to_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export_to_string: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 9 | my ($self, $alg, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 398 | 9 | my $res = ''; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 9 | foreach my $file ($self->get_files()) { | |||||||||||||||||||||||||||||||||||||||||
| 400 | 27 | my $sum = $self->get_checksum($file, $alg); | |||||||||||||||||||||||||||||||||||||||||
| 401 | 27 | my $size = $self->get_size($file); | |||||||||||||||||||||||||||||||||||||||||
| 402 | 27 | ▶ | next unless defined $sum and defined $size; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $sum and defined $size
MC/DC0%0/2
defined $sum and defined $size
defined $sum
defined $size
Truth table33%1/3
A and B
A= defined $sumB= defined $size
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 27 | $res .= "\n$sum $size $file"; | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 9 | return $res; | |||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | =item $ck->export_to_control($control, %opts) | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | Export the checksums in the Checksums-* fields of the L<Dpkg::Control> | ||||||||||||||||||||||||||||||||||||||||||
| 411 | $control object. | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | Options: | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | =item B<use_files_for_md5> | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | Set to true to use the B<Files> field instead of B<Checksums-Md5>. | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | Defaults to false. | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 1 | ▶ | sub export_to_control { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export_to_control: called CC=5 SCAR=17.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | my ($self, $control, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | ▶ | $opts{use_files_for_md5} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"use_files_for_md5"} //= 0
MC/DC0%0/1
$opts{"use_files_for_md5"} //= 0
$opts{"use_files_for_md5"}
Truth table50%1/2
A
A= $opts{"use_files_for_md5"}
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 1 | foreach my $alg (checksums_get_list()) { | |||||||||||||||||||||||||||||||||||||||||
| 431 | 3 | my $key = "Checksums-$alg"; | |||||||||||||||||||||||||||||||||||||||||
| 432 | 3 | ▶ | $key = 'Files' if ($opts{use_files_for_md5} and $alg eq 'md5'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opts{"use_files_for_md5"} and $alg eq "md5"
MC/DC0%0/2
$opts{"use_files_for_md5"} and $alg eq "md5"
$opts{"use_files_for_md5"}
$alg eq "md5"
Truth table33%1/3
A and B
A= $opts{"use_files_for_md5"}B= $alg eq "md5"
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 3 | $control->{$key} = $self->export_to_string($alg, %opts); | |||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | =head1 CHANGES | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | =head2 Version 1.04 (dpkg 1.20.0) | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | Remove warning: For obsolete property 'program'. | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | =head2 Version 1.03 (dpkg 1.18.5) | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | New property: Add new 'strong' property. | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | New member: $ck->has_strong_checksums(). | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | =head2 Version 1.02 (dpkg 1.18.0) | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | Obsolete property: Getting the 'program' checksum property will warn and | ||||||||||||||||||||||||||||||||||||||||||
| 454 | return undef, the Digest module is used internally now. | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | New property: Add new 'name' property with the name of the Digest algorithm | ||||||||||||||||||||||||||||||||||||||||||
| 457 | to use. | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | =head2 Version 1.01 (dpkg 1.17.6) | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | New argument: Accept an options argument in $ck->export_to_string(). | ||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | New option: Accept new option 'update' in $ck->add_from_file() and | ||||||||||||||||||||||||||||||||||||||||||
| 464 | $ck->add_from_control(). | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | =head2 Version 1.00 (dpkg 1.15.6) | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | Mark the module as public. | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||