* Add more checksum types to generated Release files; go from md5 only
to md5, sha1, sha256 and sha512. Initial checkin, untested code yet!
This commit is contained in:
parent
192ab9e1e6
commit
569e188f04
|
@ -19,6 +19,8 @@ debian-cd (3.1.6) UNRELEASED; urgency=low
|
||||||
* Path to sparc daily builds has changed.
|
* Path to sparc daily builds has changed.
|
||||||
* armel hasn't booted off CD in ages for us; comment out the DI_WWW_HOME
|
* armel hasn't booted off CD in ages for us; comment out the DI_WWW_HOME
|
||||||
definition to stop the mirror script complaining.
|
definition to stop the mirror script complaining.
|
||||||
|
* Add more checksum types to generated Release files; go from md5 only
|
||||||
|
to md5, sha1, sha256 and sha512.
|
||||||
|
|
||||||
[ Otavio Salvador ]
|
[ Otavio Salvador ]
|
||||||
* Add btrfs-tools on required packages by installer. Closes: #612007.
|
* Add btrfs-tools on required packages by installer. Closes: #612007.
|
||||||
|
|
|
@ -11,7 +11,7 @@ Vcs-Browser: http://svn.debian.org/wsvn/debian-cd/trunk?op=log
|
||||||
|
|
||||||
Package: debian-cd
|
Package: debian-cd
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: ${misc:Depends}, curl, perl, dpkg-dev, cpp, libdigest-md5-perl, tofrodos, apt (>= 0.3.11.1), make, genisoimage, lynx-cur | lynx, grep-dctrl, bc, libcompress-zlib-perl
|
Depends: ${misc:Depends}, curl, perl, dpkg-dev, cpp, libdigest-md5-perl, libdigest-sha-perl, tofrodos, apt (>= 0.3.11.1), make, genisoimage, lynx-cur | lynx, grep-dctrl, bc, libcompress-zlib-perl
|
||||||
Recommends: hfsutils, netpbm, syslinux-common
|
Recommends: hfsutils, netpbm, syslinux-common
|
||||||
Description: Tools for building (Official) Debian CD set
|
Description: Tools for building (Official) Debian CD set
|
||||||
Debian-cd is the official tool for building Debian CD set since the potato
|
Debian-cd is the official tool for building Debian CD set since the potato
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Digest::MD5;
|
use Digest::MD5;
|
||||||
|
use Digest::SHA;
|
||||||
use File::stat;
|
use File::stat;
|
||||||
use File::Find;
|
use File::Find;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
|
@ -20,6 +21,7 @@ my $mkisofs_dirs = "";
|
||||||
my (@arches, @arches_nosrc, @overflowlist, @pkgs_added);
|
my (@arches, @arches_nosrc, @overflowlist, @pkgs_added);
|
||||||
my (@exclude_packages, @unexclude_packages, @excluded_package_list);
|
my (@exclude_packages, @unexclude_packages, @excluded_package_list);
|
||||||
my %firmware_package;
|
my %firmware_package;
|
||||||
|
my $current_checksum_type = "";
|
||||||
|
|
||||||
undef @pkgs_added;
|
undef @pkgs_added;
|
||||||
undef @exclude_packages;
|
undef @exclude_packages;
|
||||||
|
@ -499,16 +501,23 @@ sub add_missing_Packages {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub md5_file {
|
sub checksum_file {
|
||||||
my $filename = shift;
|
my $filename = shift;
|
||||||
my ($md5, $st);
|
my $alg = shift;
|
||||||
|
my ($checksum, $st);
|
||||||
|
|
||||||
open(MD5FILE, $filename) or die "Can't open '$filename': $!\n";
|
open(CHECKFILE, $filename) or die "Can't open '$filename': $!\n";
|
||||||
binmode(MD5FILE);
|
binmode(CHECKFILE);
|
||||||
$md5 = Digest::MD5->new->addfile(*MD5FILE)->hexdigest;
|
if ($alg eq "md5") {
|
||||||
close(MD5FILE);
|
$checksum = Digest::MD5->new->addfile(*CHECKFILE)->hexdigest;
|
||||||
|
} elsif ($alg =~ /^sha\d+$/) {
|
||||||
|
$checksum = Digest::SHA->new($alg)->addfile(*CHECKFILE)->hexdigest;
|
||||||
|
} else {
|
||||||
|
die "checksum_file: unknown alorithm $alg!\n";
|
||||||
|
}
|
||||||
|
close(CHECKFILE);
|
||||||
$st = stat($filename) || die "Stat error on '$filename': $!\n";
|
$st = stat($filename) || die "Stat error on '$filename': $!\n";
|
||||||
return ($md5, $st->size);
|
return ($checksum, $st->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub recompress {
|
sub recompress {
|
||||||
|
@ -523,24 +532,42 @@ sub recompress {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub md5_files_for_release {
|
sub checksum_files_for_release {
|
||||||
my ($md5, $size, $filename);
|
my ($checksum, $size, $filename);
|
||||||
|
|
||||||
$filename = $File::Find::name;
|
$filename = $File::Find::name;
|
||||||
|
|
||||||
if ($filename =~ m/\/.*\/(Packages|Sources|Release)/o) {
|
if ($filename =~ m/\/.*\/(Packages|Sources|Release)/o) {
|
||||||
$filename =~ s/^\.\///g;
|
$filename =~ s/^\.\///g;
|
||||||
($md5, $size) = md5_file($_);
|
($checksum, $size) = checksum_file($_, $current_checksum_type);
|
||||||
printf RELEASE " %s %8d %s\n", $md5, $size, $filename;
|
printf RELEASE " %s %8d %s\n", $checksum, $size, $filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub checksum_files_for_release {
|
||||||
|
# ICK: no way to pass arguments to the
|
||||||
|
# checksum_files_for_release() function that I can see, so using a
|
||||||
|
# global here...
|
||||||
|
print RELEASE "MD5Sum:\n";
|
||||||
|
current_checksum_type = "md5";
|
||||||
|
find (\&checksum_files_for_release, ".");
|
||||||
|
print RELEASE "SHA1:\n";
|
||||||
|
current_checksum_type = "sha1";
|
||||||
|
find (\&checksum_files_for_release, ".");
|
||||||
|
print RELEASE "SHA256:\n";
|
||||||
|
current_checksum_type = "sha256";
|
||||||
|
find (\&checksum_files_for_release, ".");
|
||||||
|
print RELEASE "SHA512:\n";
|
||||||
|
current_checksum_type = "sha512";
|
||||||
|
find (\&checksum_files_for_release, ".");
|
||||||
|
}
|
||||||
|
|
||||||
sub md5_files_for_md5sum {
|
sub md5_files_for_md5sum {
|
||||||
my ($md5, $size, $filename);
|
my ($md5, $size, $filename);
|
||||||
|
|
||||||
$filename = $File::Find::name;
|
$filename = $File::Find::name;
|
||||||
if (-f $_) {
|
if (-f $_) {
|
||||||
($md5, $size) = md5_file($_);
|
($md5, $size) = checksum_file($_, "md5");
|
||||||
printf MD5LIST "%s %s\n", $md5, $filename;
|
printf MD5LIST "%s %s\n", $md5, $filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -739,9 +766,8 @@ sub finish_disc {
|
||||||
print " Finishing off the Release file\n";
|
print " Finishing off the Release file\n";
|
||||||
chdir "dists/$codename";
|
chdir "dists/$codename";
|
||||||
open(RELEASE, ">>Release") or die "Failed to open Release file: $!\n";
|
open(RELEASE, ">>Release") or die "Failed to open Release file: $!\n";
|
||||||
print RELEASE "MD5Sum:\n";
|
|
||||||
find (\&recompress, ".");
|
find (\&recompress, ".");
|
||||||
find (\&md5_files_for_release, ".");
|
checksum_files_for_release();
|
||||||
close(RELEASE);
|
close(RELEASE);
|
||||||
chdir("../..");
|
chdir("../..");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue