to check the update matches the manifest you can probably run something like this:
#!/usr/bin/perl
#
# parses ALLDATA.VER manifest
# lists files, sizes, and verifies crc32b
#
use Digest::CRC;
my $crc = Digest::CRC->new(type=>"crc32");
my $filename = "ALLDATA.VER";
if (@ARGV) {
$filename = $ARGV[0];
}
open(my $fh, $filename) or die "can't open $filename";
binmode($fh);
## check file crc
# get crc from end
seek($fh, -4, 2);
my $filecrcpos = tell($fh);
read($fh, my $filecrcraw, 4);
my $filecrc = unpack("L", $filecrcraw);
# check actual crc of file
seek($fh, 0, 0);
read($fh, my $filecontents, $filecrcpos);
$crc->add($filecontents);
my $crccalc = $crc->digest();
$crc->reset();
if ($filecrc == $crccalc) {
print "File CRC check OK. ";
} else {
printf("File CRC check FAILED. File crc: %08x, calculated crc: %08x\n", $filecrc, $crccalc);
}
## now begin read
# skip magic,
seek($fh, 4, 0);
# filesize
read($fh, my $filesize, 4);
# skip something?
seek($fh, 36, 1);
# total file records
read($fh, my $numrecsraw, 4);
my $numrecs = unpack("l", $numrecsraw);
my $fcounter = 0;
my $isdir = 1; # track directory/filename mode
my $currdir = "";
while ($fcounter < $numrecs) {
read($fh, my $sectionsizeraw, 4);
my $sectsize = unpack("i", $sectionsizeraw);
for (my $j=0; $j < $sectsize; $j++) {
read($fh, my $rawtext, 56);
my @fnameraw = unpack("C*", $rawtext);
read($fh, my $rawdata, ;
my ($fsize, $fcrc) = unpack("L L", $rawdata);
# cant figure out the multibyte magic needed to make perl unpack this to ascii, so must hack/map
my $fname = join("", map { if ($_ > 0x0 && $_ < 0x80) { chr($_) } } @fnameraw);
if ($isdir) {
# build directory path
$currdir = $currdir . "$fname/";
} else {
# list files
printf(" %s, size: %d, crc: %08x, ", $fname, $fsize, $fcrc);
my $fullname = "$currdir$fname";
if ( -e $fullname ) {
open(my $testfh, $fullname) or die "can't read $fullname";
binmode($testfh);
$crc->addfile(*$testfh);
my $fcrccalc = $crc->digest();
$crc->reset();
if ($fcrc == $fcrccalc) {
print "CRC OK";
} else {
printf("CRC BAD. crc calculated: %08x", $fcrccalc);
}
} else {
print "FILE $fullname NOT FOUND.";
printf(" %x", $fullname);
}
print "\n";
$fcounter++;
}
}
# toggle dir/filename mode
if ($isdir) {
print "$currdir\n";
$isdir = 0;
} else {
$currdir = "";
$isdir = 1;
}
}