Add tools/fast_sums script that I'm using to create the md5sums on

cdimage.d.o
It's disabled by default, so this should not change the behaviour
for people that don't use it, although I don't think there's any reason
not to.
This commit is contained in:
Philip Hands 2002-05-05 12:08:27 +00:00
parent 70780934de
commit 487ac3dff4
3 changed files with 83 additions and 2 deletions

View File

@ -25,6 +25,7 @@ unset JIGDOCMD
unset JIGDOTEMPLATEURL
unset DEFBINSIZE
unset DEFSRCSIZE
unset FASTSUMS
# The debian-cd dir
@ -165,3 +166,8 @@ export DEFSRCSIZE=635
# in the .jigdo files, which you can edit easily if you want.
# No trailing slash.
#export JIGDOTEMPLATEURL="http://this-guy-didnt-configure-debiancd-correctly.com/debian-cd/templates/3.0BETA/%ARCH%"
# If set, use the md5sums from the main archive, rather than calculating
# them locally
#export FASTSUMS=1

View File

@ -81,6 +81,7 @@ set_mkisofs_opts=$(BASEDIR)/tools/set_mkisofs_opts
strip_nonus_bin=$(BASEDIR)/tools/strip-nonUS-bin
add_secured=$(BASEDIR)/tools/add_secured
md5sum=/usr/bin/md5sum.textutils
fastsums=$(BASEDIR)/tools/fast_sums
BDIR=$(TDIR)/$(CODENAME)-$(ARCH)
ADIR=$(APTTMP)/$(CODENAME)-$(ARCH)
@ -677,6 +678,7 @@ bin-md5list: ok packages bin-secured $(BDIR)/CD1/md5sum.txt
$(BDIR)/CD1/md5sum.txt:
@echo "Generating md5sum of files from all the binary CDs ..."
$(Q)set -e; \
if [ "$$FASTSUMS" != "1" ] ; then \
for file in $(BDIR)/*.packages; do \
dir=$${file%%.packages}; \
n=$${dir##$(BDIR)/}; \
@ -686,11 +688,15 @@ $(BDIR)/CD1/md5sum.txt:
find . -follow -type f | grep -v "\./md5sum" | grep -v \
"dists/stable" | grep -v "dists/frozen" | \
grep -v "dists/unstable" | xargs $(md5sum) > md5sum.txt ; \
done
done \
else \
$(fastsums) $(BDIR); \
fi
src-md5list: ok sources src-secured $(SDIR)/CD1/md5sum.txt
$(SDIR)/CD1/md5sum.txt:
@echo "Generating md5sum of files from all the source CDs ..."
$(Q)set -e; \
if [ "$$FASTSUMS" != "1" ] ; then \
for file in $(SDIR)/*.sources; do \
dir=$${file%%.sources}; \
dir=$${dir##$(SDIR)/}; \
@ -699,7 +705,11 @@ $(SDIR)/CD1/md5sum.txt:
find . -follow -type f | grep -v "\./md5sum" | grep -v \
"dists/stable" | grep -v "dists/frozen" | \
grep -v "dists/unstable" | xargs $(md5sum) > md5sum.txt ; \
done
done \
else \
$(fastsums) $(SDIR); \
fi
# Generate $CODENAME-secured tree with Packages and Release(.gpg) files
# from the official tree

65
tools/fast_sums Executable file
View File

@ -0,0 +1,65 @@
#! /usr/bin/perl -w
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; #$running_under_some_shell
# Copyright (c) 2002 Philip Hands <phil@hands.com>
# See the README file for the license
# This script creates the md5sums files, using the precalculated md5sums
# from the main archive
# First arg = the build directory
use strict;
use Digest::MD5;
# load up all the md5sums we need
my %md5 ;
my $BDIR = shift @ARGV ;
foreach my $sumsfile ($BDIR . "/indices/md5sums", $BDIR . "/indices-non-US/md5sums") {
open(MD5SUMS, $sumsfile) || die "Couldn't open file: $sumsfile" ;
while (<MD5SUMS>) {
chomp;
next if /Packages/ ;
next if /Sources/ ;
next if /Release/ ;
my ( $sum, $name ) = split(' ') ;
# printf "[%s] [%s]\n", $sum, $name ;
$md5{$name} = $sum ;
}
close(MD5SUMS);
}
#foreach my $f (keys(%md5)) {
# printf "[%s] [%s]\n", $f, $md5{$f} ;
#}
foreach my $dir (<$BDIR/CD*>) {
chdir $dir ;
open(FILES, "find . -follow \\( -path '*dists/stable*' \\
-o -path '*dists/frozen*' \\
-o -path '*dists/unstable*' \\) -prune \\
-o -type f ! -path '\./md5sum*' -print|" ) || die ;
open(MD5OUT, ">md5sum.txt") || die "Couldn't open file for writing: md5sums.txt, in $dir" ;
while(<FILES>) {
chomp;
s(^\./)() ;
if (!defined($md5{$_})) {
open(FILE, $_) or die "Can't open '$_': $!";
binmode(FILE);
# printf STDERR "md5-ing %s", $_ ;
#$md5{$_} = Digest::MD5->new->addfile(*FILE)->hexdigest ;
printf MD5OUT "%s ./%s\n",
Digest::MD5->new->addfile(*FILE)->hexdigest, $_;
# FIXME:
# the ./ in the printf above is only there to keep byte-for-byte compatibility
# with the find . output used before -- It should probably be removed
#
# printf STDERR ".\n" ;
close(FILE) ;
} else {
printf MD5OUT "%s ./%s\n", $md5{$_}, $_;
}
}
close(MD5OUT) ;
}