CPAN::Checksums(3pm)

πŸ“¦
version 2.14 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– CPAN::Checksums β€” bestie edition πŸ’–

okay so bestie, this is CPAN::Checksums, a Perl module that writes a CHECKSUMS file for a directory, exactly like the ones on CPAN. queen behavior honestly πŸ‘‘


✨ SYNOPSIS ✨

use CPAN::Checksums qw(updatedir);
my $success = updatedir($directory, $root);

that's it. that's the whole vibe check. πŸ’…


🚨 INCOMPATIBILITY ALERT 🚨

not me having to deliver bad news 😭 since version 1.0, the generation of the attribute shortname is turned off by default. why? because it was too slow, and as far as the author knows nobody even used it, and on top of all that it could straight up fail on large directories πŸ’€

but bestie, it's not gone forever!! you can still turn the shortname feature back on by setting the global variable $TRY_SHORTNAME to a true value. she's still there if you want her 🫢


🌸 DESCRIPTION 🌸

$success = updatedir($dir[, $root])

so $dir is a directory, right? and updatedir() writes a CHECKSUMS file into that directory β€” unless a previously written CHECKSUMS file is already sitting there and is still valid, in which case she just chills. ✨

here's the return value tea:

  • returns 2 if a brand new CHECKSUMS file has been written πŸŽ€
  • returns 1 if a valid CHECKSUMS file is already there πŸ‘‘
  • otherwise dies πŸ’€

if $root is given, then 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. so if you were relying on the old silence… nope, not anymore bestie πŸ™ˆ

πŸ¦‹ 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
qr{(?i-xsm:readme$)}
  • $CAUTION β€” setting the global variable $CAUTION causes updatedir() to report changes of files in the attributes "size", "mtime", "md5", or "md5-ungz" to STDERR. like she's snitching but in a helpful way πŸ’…
  • $TRY_SHORTNAME β€” by setting the global variable $TRY_SHORTNAME to a true value, you can tell updatedir() to include an attribute "shortname" in the resulting hash that is 8.3-compatible. but please note, that updatedir() in this case may be slow and may even fail on large directories, because it will always only try 1000 iterations to find a name that is not yet taken and then give up. she's trying her best okay 😭 one thousand attempts and then she's done, periodt.
  • $SIGNING_KEY β€” setting the global variable $SIGNING_KEY makes the generated CHECKSUMS file to be clear-signed by the command specified in $SIGNING_PROGRAM (defaults to gpg --clearsign --default-key ), passing the signing key as an extra argument. the resulting CHECKSUMS file should look like:
0&&<<''; # this PGP-signed message is also valid perl
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

# CHECKSUMS file written on ... by CPAN::Checksums (v...)
$cksum = {
    ...
};

__END__
-----BEGIN PGP SIGNATURE-----
...
-----END PGP SIGNATURE-----

note that the actual data remains intact, but two extra lines are added to make it legal for both OpenPGP and perl syntax. dual citizenship, iconic 🌈

  • $MIN_MTIME_CHECKSUMS β€” if the global variable $MIN_MTIME_CHECKSUMS is set, then updatedir will renew signatures on checksum files that have an older mtime than the given value. out with the old, in with the new ✨

πŸŽ€ PREREQUISITES πŸŽ€

the girlies she needs to function: DirHandle, IO::File, Digest::MD5, Digest::SHA, Compress::Bzip2, Compress::Zlib, File::Spec, Data::Dumper, Data::Compare, File::Temp

a whole squad fr fr 🫢


πŸ’€ BUGS πŸ’€

if updatedir is interrupted, it may leave a temporary file lying around. these files have the File::Temp template CHECKSUMS.XXXX and should be harvested by a cronjob. so like… she's messy, sorry, set up a cronjob to clean up after her 🧹


πŸ‘‘ AUTHOR πŸ‘‘

Andreas Koenig, andreas.koenig@anima.de; GnuPG support by Autrijus Tang


Copyright (c) 2002-2008 Andreas Koenig, Audrey Tang, Steve Peters.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


🌈 SEE ALSO 🌈


and that's the whole page bestie!! this was lifted from the CPAN::Checksums(3pm) page β€” User Contributed Perl Documentation, no cap, and it's perl v5.38.2 dated 2024-01-21. go write some CHECKSUMS files and slay πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from