diff options
author | edwin <edwin@FreeBSD.org> | 2006-01-24 15:30:07 +0800 |
---|---|---|
committer | edwin <edwin@FreeBSD.org> | 2006-01-24 15:30:07 +0800 |
commit | 5109a125615de41f2cd47caad8359c6f582f05e2 (patch) | |
tree | 5cc90ea6454878cace63aedea83e8d31b5f78a49 | |
parent | 8dd8b7912e45dcb2061f525aa631b778cc759675 (diff) | |
download | freebsd-ports-gnome-5109a125615de41f2cd47caad8359c6f582f05e2.tar.gz freebsd-ports-gnome-5109a125615de41f2cd47caad8359c6f582f05e2.tar.zst freebsd-ports-gnome-5109a125615de41f2cd47caad8359c6f582f05e2.zip |
Small tool to check the necessary lines in the distinfo files, based
on the contents of the distinfo files.
#
# Small tool to find distinfo with missing MD5/SHA256/SIZE statements,
# based on the assumption that if there is one of the MD5/SHA256/SIZE
# statements, then there should be all of them (except for SIZE
# when MD5/SHA256 is set to IGNORE).
#
# Usage: distinfochecker [-v] [-d directory]
# -v - verbose (print)
# -d - use directory instead of /usr/ports
#
-rwxr-xr-x | Tools/scripts/distinfochecker | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/Tools/scripts/distinfochecker b/Tools/scripts/distinfochecker new file mode 100755 index 000000000000..1cb249a40406 --- /dev/null +++ b/Tools/scripts/distinfochecker @@ -0,0 +1,105 @@ +#!/usr/bin/perl -w + +# +# $FreeBSD$ +# +# Author: Edwin Groothuis <edwin@FreeBSD.org> +# + +# +# Small tool to find distinfo with missing MD5/SHA256/SIZE statements, +# based on the assumption that if there is one of the MD5/SHA256/SIZE +# statements, then there should be all of them (except for SIZE +# when MD5/SHA256 is set to IGNORE). +# +# Usage: distinfochecker [-v] [-d directory] +# -v - verbose (print) +# -d - use directory instead of /usr/ports +# + +use Getopt::Std; +use strict; +use Data::Dumper; + +my $UP="/usr/ports"; +my $verbose=0; + +my %opts=(); +getopt('d:v',\%opts); + +$UP=$opts{d} if (defined $opts{d}); +$verbose=1 if (defined $opts{v}); + +opendir(DHUP,$UP); +while (my $c=readdir(DHUP)) { + + next if ($c=~/^\./); + next if ($c=~/^[A-Z]/); + next if ($c=~/^distfiles/); + + opendir(DHUPC,"$UP/$c"); + while (my $p=readdir(DHUPC)) { + next if ($p=~/^\./); + next if ($p=~/^Makefile/); + + if (!-f "$UP/$c/$p/distinfo") { + print "$c/$p - No distinfo found\n" if ($verbose); + next; + } + open(FIN,"$UP/$c/$p/distinfo"); + my @lines=<FIN>; + chomp(@lines); + close(FIN); + + my %MD5=(); + my %SHA256=(); + my %SIZE=(); + + foreach my $line (@lines) { + $MD5{$1}=$2 if ($line=~/^MD5 \((.+?)\) = (.+?)$/); + $SHA256{$1}=$2 if ($line=~/^SHA256 \((.+?)\) = (.+?)$/); + $SIZE{$1}=$2 if ($line=~/^SIZE \((.+?)\) = (.+?)$/); + } + + foreach my $f (sort(keys(%MD5))) { + if (!defined ($SHA256{$f})) { + print "$c/$p - Missing SHA256 for $f\n"; + $SHA256{$f}="missing"; + } + if ($MD5{$f} ne "IGNORE") { + if (!defined ($SIZE{$f})) { + print "$c/$p - Missing SIZE for $f\n"; + $SIZE{$f}="missing"; + } + } + } + + foreach my $f (sort(keys(%SHA256))) { + if (!defined ($MD5{$f})) { + print "$c/$p - Missing MD5 for $f\n"; + $MD5{$f}="missing"; + } + if ($SHA256{$f} ne "IGNORE") { + if (!defined ($SIZE{$f})) { + print "$c/$p - Missing SIZE for $f\n"; + $SIZE{$f}="missing"; + } + } + } + + foreach my $f (sort(keys(%SIZE))) { + if (!defined ($MD5{$f})) { + print "$c/$p - Missing MD5 for $f\n"; + $MD5{$f}="missing"; + } + if (!defined ($SHA256{$f})) { + print "$c/$p - Missing SHA256 for $f\n"; + $SHA256{$f}="missing"; + } + } + + + } + closedir(DHUPC); +} +closedir(DHUP); |