--check now passes when the caller is inside the lock (make test/cdtest -> tools/test.sh) and still refuses when another build holds it. test.sh, mediacheck.sh, install-simple.sh and install-cgd.sh call it before they touch the media or start a VM; a direct test beside a build stops with the holder's pid.
73 lines
2.8 KiB
Bash
Executable File
73 lines
2.8 KiB
Bash
Executable File
#!/bin/sh
|
|
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
# mediacheck.sh -- the CDs hold the same files as the DVD.
|
|
#
|
|
# usage: mediacheck.sh
|
|
#
|
|
# One full installation test runs on the DVD (tools/install-simple.sh -S). It
|
|
# stands for the other media only if their files are the DVD's files. This
|
|
# proves it: every file under /amd64 of CD 1, 2, 3 (and 4, 5, ...) must be on
|
|
# the DVD at the same path with the same MD5. The files that describe one
|
|
# medium -- boot.cfg, `disc', `top.list', TRANS.TBL, the INSTALL.* texts and the
|
|
# checksum lists MD5 and SHA512 (a CD lists only the sets it carries) -- are
|
|
# the medium's own and are not compared.
|
|
#
|
|
# Not covered: the USB images. Their sets and packages sit in a FFS inside a
|
|
# GPT image that this host cannot read; they are copied from the same release
|
|
# directory and the same build/cd3 by the build (patch 0014), and their boot
|
|
# path is tested by `install-simple.sh -B -U'.
|
|
#
|
|
# Exit status: 0 all files equal, 1 a difference or a missing medium. The
|
|
# temporary trees go to build/mediacheck and are removed.
|
|
|
|
set -u
|
|
|
|
TOP=${TOP:-$(cd "$(dirname "$0")/.." && pwd)}
|
|
# Tests do not run beside a build (make test/cdtest hold the lock).
|
|
"$TOP/tools/build-lock.sh" --check || exit 1
|
|
|
|
IMG=$TOP/build/obj/releasedir/images
|
|
VER=$(cat "$TOP/src/sys/conf/makronix-release")
|
|
T=$TOP/build/mediacheck
|
|
|
|
command -v xorriso > /dev/null || { echo "mediacheck: xorriso not found" >&2; exit 1; }
|
|
DVD=$IMG/Makronix-$VER-amd64-dvd.iso
|
|
[ -r "$DVD" ] || { echo "mediacheck: no $DVD" >&2; exit 1; }
|
|
|
|
rm -rf "$T"; mkdir -p "$T/dvd"
|
|
# the files of a medium: "md5 path" for everything under amd64 that is not
|
|
# the medium's own description
|
|
sums()
|
|
{
|
|
iso=$1 dir=$2
|
|
xorriso -osirrox on -indev "$iso" -extract /amd64 "$dir" > /dev/null 2>&1 || return 1
|
|
(cd "$dir" && find . -type f \
|
|
! -name boot.cfg ! -name TRANS.TBL ! -name disc ! -name top.list \
|
|
! -name MD5 ! -name SHA512 ! -name 'INSTALL.*' | sort | xargs -r md5sum)
|
|
}
|
|
|
|
echo "mediacheck: reading the DVD"
|
|
sums "$DVD" "$T/dvd" > "$T/dvd.sums" || { echo "FAIL: cannot read the DVD"; exit 1; }
|
|
rm -rf "$T/dvd"
|
|
|
|
status=0
|
|
for iso in "$IMG/Makronix-$VER-amd64.iso" "$IMG"/Makronix-$VER-amd64-cd[0-9]*.iso; do
|
|
[ -r "$iso" ] || continue
|
|
n=${iso##*/}
|
|
mkdir -p "$T/m"
|
|
sums "$iso" "$T/m" > "$T/m.sums" || { echo "FAIL: cannot read $n"; status=1; continue; }
|
|
rm -rf "$T/m"
|
|
total=$(wc -l < "$T/m.sums" | tr -d ' ')
|
|
# lines of this medium that the DVD does not have, verbatim
|
|
bad=$(grep -v -x -F -f "$T/dvd.sums" "$T/m.sums" | wc -l | tr -d ' ')
|
|
if [ "$bad" -eq 0 ]; then
|
|
echo "PASS: $n: $total files, all on the DVD with the same MD5"
|
|
else
|
|
echo "FAIL: $n: $bad of $total files differ from the DVD or are not on it:"
|
|
grep -v -x -F -f "$T/dvd.sums" "$T/m.sums" | head -5
|
|
status=1
|
|
fi
|
|
done
|
|
rm -rf "$T"
|
|
exit $status
|