tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Adding SHA-512 to the list of digests

On Thu, Oct 08, 2015 at 11:14:50PM +0200, Joerg Sonnenberger wrote:
> On Thu, Oct 08, 2015 at 11:21:55AM -0700, Alistair Crooks wrote:
> > In this way, pkgsrc distinfo files will be updated over time to have 3
> > digests, with a mopping up operation for some of the packages which
> > aren't so volatile.
> I'd like to see someone prepare a script to semi-automatically update
> all the distinfo files first. E.g. assuming access to a distinfo mirror,
> build a table with file size and all interesting digests and then just
> go over the distinfo files and patch them up.

Here's a simple perl script that
* parses a distinfo file
* for every distfile, removes the SHA1 line and adds the SHA512 one
* prints the new file to stdout

It has a few assumptions:
* distfiles location (variable at the top, change to your liking)
* pkgsrc patches are in patches/ (to avoid running make(1))
* all existing distfiles have correct checksum

I.e., usage is:

cd /usr/pkgsrc/category/package && recompute > && mv distinfo

Can one of the bulk builders please use this (or another) script to
update all distinfos?

We can fix any fallout using the results of followup bulk builds.
use Digest::SHA(sha512_hex);

my $distdir="/archive/distfiles";

my $IN;
open $IN, "<distinfo";
my $found = 0;
my $dump = "";
while (<$IN>) {
	$found = 1 if (m/SHA512/);
	if (m/SHA1 \((.*)\) =/) {
		print $_ if (-e "patches/$1");
	if (m/Size \((.*)\) =/) {
		if ($found == 0) {
			my $sha = Digest::SHA->new(512);
			print "SHA512 ($1) = " . $sha->hexdigest . "\n";
		$found = 0;
	print $_;

Home | Main Index | Thread Index | Old Index