- cdtest takes one lock around release, iso and the VM test; the nested make calls reuse it through BUILD_LOCK_HELD (re-entrant). MAKE_CMD keeps make -n cdtest from executing the recipe: GNU make runs a recipe with $(MAKE) even under -n, and the rest of the line starts a VM. - mcde-linux and mcde-host take the lock too; they read ext/src/mcde and the distfiles a release reads. - build-lock.sh: --held for the tools, --check for read-only callers, pid plus process start time for stale locks, the child is killed on INT/TERM, and nested calls reuse the outer lock. - build-stamp, cd2, cd3, cd-source, images, srctree-stage, userland, mcde-linux and mcde-host refuse to run outside the lock (the file and the message name the way in: make or tools/build-lock.sh).
73 lines
2.5 KiB
Bash
Executable File
73 lines
2.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
# images.sh -- the install images of the release directory: raw, or packed.
|
|
#
|
|
# usage: images.sh unpack | pack | sums FILE...
|
|
# unpack every images/*.img.gz becomes images/*.img
|
|
# pack every images/*.img becomes images/*.img.gz (`make compress')
|
|
# sums renew the lines of the named files in images/MD5 and images/SHA512
|
|
#
|
|
# Konrad, 2026-11-08: nothing is compressed unless it is asked for in a step of
|
|
# its own. The build of NetBSD (distrib/common/bootimage/Makefile.bootimage)
|
|
# writes `*.img.gz'; since t0246 (2026-11-15) `make usb' asks for the raw image
|
|
# (INSTIMG_RAW=yes) instead, so `unpack' is only for images built by hand, the
|
|
# way a person wants them to dd or to boot, and `make compress' packs them for
|
|
# a download. The checksum lists follow the files: the lines of
|
|
# a file that is gone are removed, the lines of the new one are written, in the
|
|
# format of makesums(8) (`MD5 (name) = hash'). A shell script in the tree
|
|
# writes into images/ here as tools/cd2.sh and tools/cd3.sh do.
|
|
#
|
|
# POSIX sh. Exit 0 when done.
|
|
|
|
set -eu
|
|
|
|
TOP=${TOP:-$(cd "$(dirname "$0")/.." && pwd)}
|
|
# This tool writes build/obj or releasedir: only inside the build lock.
|
|
if [ -z "${BUILD_LOCK_HELD:-}" ] || [ ! -d "$BUILD_LOCK_HELD" ]; then
|
|
echo "${0##*/}: run this through make or tools/build-lock.sh" >&2
|
|
exit 1
|
|
fi
|
|
|
|
REL=$(ls -d "$TOP"/build/obj/rel*/images 2>/dev/null | head -1)
|
|
[ -d "$REL" ] || { echo "images: no release directory" >&2; exit 1; }
|
|
|
|
# drop the lines of NAME in the checksum lists, then, if the file is there, add its lines
|
|
renew()
|
|
{
|
|
n=$1
|
|
for a in MD5:md5sum SHA512:sha512sum; do
|
|
l=${a%%:*}; c=${a#*:}
|
|
[ -f "$REL/$l" ] || continue
|
|
grep -v "($n)" "$REL/$l" > "$REL/$l.new" || true
|
|
if [ -f "$REL/$n" ]; then
|
|
echo "$l ($n) = $($c "$REL/$n" | cut -d' ' -f1)" >> "$REL/$l.new"
|
|
fi
|
|
cat "$REL/$l.new" > "$REL/$l"
|
|
rm -f "$REL/$l.new"
|
|
done
|
|
}
|
|
|
|
case ${1:-} in
|
|
unpack)
|
|
for f in "$REL"/*.img.gz; do
|
|
[ -f "$f" ] || continue
|
|
out=${f%.gz}
|
|
echo "images: unpack ${f##*/}"
|
|
gzip -dc "$f" > "$out.tmp" && mv "$out.tmp" "$out" && rm -f "$f"
|
|
renew "${f##*/}"; renew "${out##*/}"
|
|
done ;;
|
|
pack)
|
|
for f in "$REL"/*.img; do
|
|
[ -f "$f" ] || continue
|
|
echo "images: pack ${f##*/}"
|
|
gzip -c "$f" > "$f.gz.tmp" && mv "$f.gz.tmp" "$f.gz" && rm -f "$f"
|
|
renew "${f##*/}"; renew "${f##*/}.gz"
|
|
done ;;
|
|
sums)
|
|
shift
|
|
for f in "$@"; do renew "${f##*/}"; done ;;
|
|
*)
|
|
echo "usage: ${0##*/} unpack | pack | sums FILE..." >&2
|
|
exit 1 ;;
|
|
esac
|