Amended for switchable digest algorithm (default is SHA-512) as discussed during the setup changes. If OK to commit, I'll add a ChageLog entry.
? genini.cvs.diff Index: genini =================================================================== RCS file: /cvs/cygwin-apps/genini/genini,v retrieving revision 1.15 diff -u -p -r1.15 genini --- genini 7 Oct 2013 21:11:35 -0000 1.15 +++ genini 22 Jun 2015 20:13:41 -0000 @@ -7,6 +7,7 @@ # use File::Basename; use Digest::MD5; +use Digest::SHA; use Getopt::Long; use strict; @@ -19,10 +20,17 @@ sub arch_handler(@); my @okmissing = qw'message ldesc'; my ($outfile, $help, $recursive); my $arch = 'x86'; +my $digest = 'sha512'; my $release; -my @cmp_fmts = qw(gz bz2 lzma xz); +my @cmp_fmts = qw(xz bz2 lzma gz); -GetOptions('okmissing=s'=>\@okmissing, 'output=s'=>\$outfile, 'help'=>\$help, 'release=s'=>\$release, 'arch=s'=>\&arch_handler, 'recursive'=>\$recursive) or usage; +GetOptions('okmissing=s'=>\@okmissing, + 'output=s'=>\$outfile, + 'help'=>\$help, + 'release=s'=>\$release, + 'arch=s'=>\&arch_handler, + 'digest=s'=>\&digest_handler, + 'recursive'=>\$recursive) or usage; $help and usage; @main::okmissing{@okmissing} = @okmissing; @@ -31,7 +39,14 @@ sub arch_handler (@) { my ($opt_name, $opt_value) = @_; die "invalid arch specified: '$opt_value'" unless $main::valid_arch{lc $opt_value}; - $arch = $opt_value; + $arch = lc $opt_value; +} + +sub digest_handler (@) { + my ($opt_name, $opt_value) = @_; + die "invalid digest specified: '$opt_value'" + unless $main::valid_digest{lc $opt_value}; + $digest = lc $opt_value; } if (defined($outfile)) { @@ -190,6 +205,7 @@ sub parsedir { my $setup_hint = "$d/setup.hint"; return unless -e $setup_hint; parse("$setup_hint", $pname); + next unless exists $pkg{$pname}; my $explicit = 0; for my $what ('', "[prev]\n", "[test]\n") { my $x = $pkg{$pname}{$what}; @@ -246,9 +262,20 @@ sub filer { myerror "can't open $f - $!" unless $main::okmissing{$what}; return undef; }; - my $md5 = Digest::MD5->new; - $md5->addfile(\*F); - $x->{$what} = join(' ', $f, -s $f, $md5->hexdigest); + my ( $chk, $sum ); + if ('md5' eq $digest) { + $chk = Digest::MD5->new; + } elsif ('sha512' eq substr($digest, 0, 6)) { + $chk = Digest::SHA->new(512); + } + $chk->addfile(\*F); + if ('sha512b64url' eq $digest) { + $sum = $chk->b64digest; + $sum =~ tr:+/:-_:; # convert to base64url as defined in RFC4648 + } else { + $sum = $chk->hexdigest; + } + $x->{$what} = join(' ', $f, -s $f, $sum); } sub tarball { @@ -260,8 +287,8 @@ sub tarball { return "$f"; } } - # default to .bz2 (even though we know it is missing) - return "$d/" . "$b" . "bz2"; + # default to .nf (because we know it is missing) + return "$d/" . "$b" . "nf"; } sub fnln { @@ -291,17 +318,18 @@ sub usage() { Usage: genini [--okmissing=key ...] [--recursive] [--output=file] [--help] [setup.ini] [dir ...] Create cygwin setup.ini from setup.ini, setup.hint and tar ball information. - --okmissing=key don't warn if key is missing from setup.ini or setup.hint + --okmissing=key Don't warn if key is missing from setup.ini or setup.hint or if some expected `source' or `install' tarballs are missing. Option may be repeated. --okmissing=install is useful if hint files contain `prev' or `test' entries for missing tarballs. --okmissing=source is useful for LOCAL-ONLY[*] srcless install media. - --recursive recurse all subdirectories of specified dirs + --recursive Recurse all subdirectories of specified dirs. --arch=x86|x86_64 Must be either x86 or x86_64. Defaults to x86. --release=string Optional repository id: cygwin, cygwinports, etc. - --output=file output setup.ini info to file - --help display this message + --digest=string Digest algorithm: sha512 (default), sha512b64url or md5. + --output=file Output setup.ini info to file. + --help Display this message. [*] You wouldn't want to violate the GPL, now would you? @@ -312,13 +340,17 @@ EOF BEGIN { my @cats = qw' - Admin Archive Audio Base Comm Database Debug Devel Doc Editors Games - Gnome Graphics Interpreters KDE Libs Mail Math Mingw Net Perl - Publishing Python Science Shells Sound System Text Utils Web X11 - _obsolete _PostInstallLast + Accessibility Admin Archive Audio Base Comm Database Devel Doc + Editors Games GNOME Graphics Interpreters KDE Libs LXDE Mail MATE + Math Mingw Net Perl PHP Python Publishing Ruby Science Shells + System Text Utils Video Web X11 Xfce + Debug _obsolete _PostInstallLast '; @main::categories{map {lc $_} @cats} = @cats; my @archs = qw'x86 x86_64'; @main::valid_arch{map {lc $_} @archs} = @archs; + + my @digests = qw'md5 sha512 sha512b64url'; + @main::valid_digest{map {lc $_} @digests} = @digests; }
Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ DIY Stuff: http://Synth.Stromeko.net/DIY.html