CPAN-Checksums
view release on metacpan or search on metacpan
* Version 2.14
* fix test t/updatedir.t for old CPAN versions: we cannot predict the
name of the parent directory, so simplify the test;
2021-11-20 k <andk@cpan.org>
* Version 2.13
* add new key 'cpan_path' to specify the relative path to the well known
CPAN directory '/authors/id'.
2016-06-14 k <andk@cpan.org>
* Version 2.12
* more on #113615: Fix recalc being too lazy (bug analysis by Ralf
Neubauer, code by Andreas Koenig)
2016-04-09 k <andk@cpan.org>
still be turned on by setting the global variable $TRY_SHORTNAME to a
true value.
DESCRIPTION
$success = updatedir($dir[, $root])
$dir is a directory. Updatedir() writes a "CHECKSUMS" file into that
directory, unless a previously written "CHECKSUMS" file is there that
is still valid. Returns 2 if a new "CHECKSUMS" file has been written,
1 if a valid "CHECKSUMS" file is already there, otherwise dies.
If $root is given, the hash entry with the key "cpan_path" is relative
to this root directory.
Note: since version 2.0 updatedir on empty directories behaves just
the same. In older versions it silently did nothing.
Global Variables in package CPAN::Checksums
$IGNORE_MATCH
If the global variable $IGNORE_MATCH is set, then all files matching
this expression will be completely ignored and will not be included
in the CPAN "CHECKSUMS" files. Per default this variable is set to
lib/CPAN/Checksums.pm view on Meta::CPAN
use Compress::Bzip2();
use Compress::Zlib ();
use File::Spec ();
use File::Temp;
use Data::Dumper ();
use Data::Compare ();
use Digest::SHA ();
sub _dir_to_dref {
my($dirname,$old_dref,$root) = @_;
my $cpan_path = File::Spec->abs2rel( $dirname, $root ) ;
my($dref) = {};
my($dh)= DirHandle->new;
my($fh) = new IO::File;
$dh->open($dirname) or die "Couldn't opendir $dirname\: $!";
my(%shortnameseen);
DIRENT: for my $de ($dh->read) {
next DIRENT if $de =~ /^\./;
next DIRENT if substr($de,0,9) eq "CHECKSUMS";
next DIRENT if $IGNORE_MATCH && $de =~ $IGNORE_MATCH;
lib/CPAN/Checksums.pm view on Meta::CPAN
if ( $can_reuse_old_md5 ) {
MD5KEY: for my $param (qw(md5 md5-ungz md5-unbz2)) {
next MD5KEY unless exists $old_dref->{$de}{$param};
$dref->{$de}{$param} = $old_dref->{$de}{$param};
}
} else {
_add_digests($de,$dref,"Digest::MD5",[],"md5",$abs,$old_dref);
}
} # ! -d
$dref->{$de}{cpan_path} = $cpan_path;
}
$dh->close;
$dref;
}
sub _read_old_ddump {
my($ckfn) = @_;
my $is_signed = 0;
my($fh) = new IO::File;
lib/CPAN/Checksums.pm view on Meta::CPAN
=over 2
=item $success = updatedir($dir[, $root])
$dir is a directory. Updatedir() writes a C<CHECKSUMS> file into that
directory, unless a previously written C<CHECKSUMS> file is there that
is still valid. Returns 2 if a new C<CHECKSUMS> file has been written,
1 if a valid C<CHECKSUMS> file is already there, otherwise dies.
If $root is given, the hash entry with the key C<cpan_path> is
relative to this root directory.
Note: since version 2.0 updatedir on empty directories behaves just
the same. In older versions it silently did nothing.
=back
=head2 Global Variables in package CPAN::Checksums
=over
t/CHECKSUMS view on Meta::CPAN
# CHECKSUMS file written on Sat Dec 4 09:50:24 2021 GMT by CPAN::Checksums (v2.14)
$cksum = {
'00signature.t' => {
'cpan_path' => 't',
'md5' => '9cf677f32e958d6b4f869387bb6b2f89',
'mtime' => '2021-11-20',
'sha256' => '0a7eb8f011b252d11252f9e2629b0509c6031f95564ac2694f9f7b91c1c47d48',
'size' => 2990
},
'42.gz' => {
'cpan_path' => 't',
'md5' => '915cdde7181ab542763969e063b7a9a9',
'md5-ungz' => '50a2fabfdd276f573ff97ace8b11c5f4',
'mtime' => '2014-04-04',
'sha256' => '787e758a975d04560f6a9d4671646a48c4e9da4f40d4e102bc4562cd15c71ab5',
'sha256-ungz' => '084c799cd551dd1d8d5c5f9a5d593b2e931f5e36122ee5c793c1d08a19839cc0',
'size' => 26
},
'43' => {
'cpan_path' => 't',
'md5' => 'f0287f33eba7192e2a9c6a14f829aa1a',
'mtime' => '2021-12-04',
'sha256' => '0e55092af0746630c98d1b2e0d960617c33f8ea7b55739fd18cb7cd5342a28ca',
'size' => 3
},
'44.bz2' => {
'cpan_path' => 't',
'md5' => 'b3c551bfbf1d15ce93b47346a11cc87a',
'md5-unbz2' => 'e760668b6273d38c832c153fde5725da',
'mtime' => '2014-04-04',
'sha256' => '09f646275a0b0622418ed364affe3c2df7dbb02c01862d84d7d06e6b6605c790',
'sha256-unbz2' => 'b1ce0aa6fdf3cf349d773243dab9fbbe09d30619f38b0c1e8977e28c4f0bc495',
'size' => 39
},
'45.tgz' => {
'cpan_path' => 't',
'md5' => '451f5c94254854f9b50e0e0d815efc25',
'md5-ungz' => '40b724cf2b5b077219e99409e33f233f',
'mtime' => '2021-12-03',
'sha256' => '00a153865e3f7bd5dd0627767a1763404d36fa34793db95ba6d403530d09cdfd',
'sha256-ungz' => '75e63a955767ae72abf0675e666ae6f3774dce667cb3503d5af6b936ae05a785',
'size' => 115
},
'52podcover.t' => {
'cpan_path' => 't',
'md5' => '9845f6c5f049d637c92ae34e67328c77',
'mtime' => '2014-04-04',
'sha256' => '558d9083fe9dfa6aa66806caf4545bee35f2cac36592627aeed3b8cf0ca4fdf2',
'size' => 567
},
'pod.t' => {
'cpan_path' => 't',
'md5' => '45b17e11a9736a0c485f861f95f063b9',
'mtime' => '2014-04-04',
'sha256' => '6109dadab614d170fc3db10b00a4c41c221860b1b1085a54af9a5f9f52480494',
'size' => 152
},
'updatedir.t' => {
'cpan_path' => 't',
'md5' => 'ae0611d75e829ff8e7b873787e93a81b',
'mtime' => '2021-12-04',
'sha256' => '0b20f57520fcbfc97f7fcfee65d6fb155f69c00de6fc161e6d7f2aaa474b22e9',
'size' => 3223
}
};
t/updatedir.t view on Meta::CPAN
is($ret,2,"tdir with files returns 2");
my $checksums = do {
open $fh, "<", _f"t/tdir/CHECKSUMS" or die "Could not open: $!";
local $/;
<$fh>
};
my $cksum;
eval $checksums;
ok exists $cksum->{1}, "checksums file contains file 1";
is $cksum->{1}{size}, 1, "size of file 1 is 1";
like $cksum->{1}{cpan_path}, qr{t/tdir$},
"cpan_path is as expected" or diag explain $cksum;
ok exists $cksum->{2}, "checksums file contains file 2";
is $cksum->{2}{size}, 2, "size of file 2 is 2";
unlink, _f"t/tdir/2";
$ret = CPAN::Checksums::updatedir(_d"t/tdir", $absroot);
is($ret,1,"tdir with one deleted file returns 1");
@stat = stat _f"t/tdir/CHECKSUMS";
$CPAN::Checksums::MIN_MTIME_CHECKSUMS = $stat[9]+1;
$ret = CPAN::Checksums::updatedir(_d"t/tdir", $absroot);
is($ret,2,"tdir with bumped minimum mtime returns 2");
}
( run in 0.378 second using v1.01-cache-2.11-cpan-f79bc02f770 )