public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] genini.pl: create SHA512 instead of MD5 checksums
@ 2015-03-31 19:33 Achim Gratz
  2015-06-22 20:27 ` Achim Gratz
  0 siblings, 1 reply; 4+ messages in thread
From: Achim Gratz @ 2015-03-31 19:33 UTC (permalink / raw)
  To: cygwin-apps

diff --git a/genini.pl b/genini.pl
index 973ecfd..f5b13ea 100755
--- a/genini.pl                                                                                                                                                                
+++ b/genini.pl                                                                                                                                                                
@@ -6,7 +6,7 @@
 # for details.                                                                                                                                                                
 #                                                                                                                                                                             
 use File::Basename;                                                                                                                                                           
-use Digest::MD5;                                                                                                                                                              
+use Digest::SHA;                                                                                                                                                              
 use Getopt::Long;                                                                                                                                                             
                                                                                                                                                                               
 use strict;                                                                                                                                                                   
@@ -228,9 +228,9 @@ 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 $sha512 = Digest::SHA->new(512);                                                                                                                                       
+    $sha512->addfile(\*F);                                                                                                                                                    
+    $x->{$what} = join(' ', $f, -s $f, $sha512->hexdigest);                                                                                                                   
 }                                                                                                                                                                             
                                                                                                                                                                               
 sub tarball {                                                                                                                                                                 


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Q+, Q and microQ:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] genini.pl: create SHA512 instead of MD5 checksums
  2015-03-31 19:33 [PATCH] genini.pl: create SHA512 instead of MD5 checksums Achim Gratz
@ 2015-06-22 20:27 ` Achim Gratz
  2015-06-23  7:57   ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Achim Gratz @ 2015-06-22 20:27 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 146 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: genini.cvs.diff --]
[-- Type: text/x-patch, Size: 4998 bytes --]

? 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;
 }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]



Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

DIY Stuff:
http://Synth.Stromeko.net/DIY.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] genini.pl: create SHA512 instead of MD5 checksums
  2015-06-22 20:27 ` Achim Gratz
@ 2015-06-23  7:57   ` Corinna Vinschen
  2015-06-23 17:53     ` Achim Gratz
  0 siblings, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2015-06-23  7:57 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

On Jun 22 22:27, Achim Gratz wrote:
> 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.

Yes, please go ahead.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] genini.pl: create SHA512 instead of MD5 checksums
  2015-06-23  7:57   ` Corinna Vinschen
@ 2015-06-23 17:53     ` Achim Gratz
  0 siblings, 0 replies; 4+ messages in thread
From: Achim Gratz @ 2015-06-23 17:53 UTC (permalink / raw)
  To: cygwin-apps

Corinna Vinschen writes:
> On Jun 22 22:27, Achim Gratz wrote:
>> 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.
>
> Yes, please go ahead.

Done.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-23 17:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-31 19:33 [PATCH] genini.pl: create SHA512 instead of MD5 checksums Achim Gratz
2015-06-22 20:27 ` Achim Gratz
2015-06-23  7:57   ` Corinna Vinschen
2015-06-23 17:53     ` Achim Gratz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).