- make sourcesets signs RELEASEDIR/source/sets/SHA512 inside the build lock
when SIGNIFY_SECKEY is set (tools/sign-release.sh auto); a build without
the key says so and stays unsigned.
- make iso signs the package summary first; tools/cd3.sh puts
pkg_summary.gz.sig next to the summary on the DVD and on every package CD.
- tools/cd-source.sh carries SHA512.sig on the source DVD and the README
names the two verification commands.
- tools/upgrade-verify.sh: verifies root key -> release key -> SHA512 and
then the SHA512 of the set files; the upgrade command (tasksd t0055) calls
it before sysupgrade/pkg_add run as root.
Measured 2026-11-16: the source SHA512 signed with the release key verifies
through the chain ("signed by the root key", "good signature"), the copy
extracted from the source DVD too, the package summary verifies, and
upgrade-verify checks src.tgz (5.8 GB) against SHA512. `make iso` itself
was not run to the end: a commit in another session changed src/ during the
release, so build-stamp refused the packaging
(build/logs/release-iso-2026-11-16-signed.log).
80 lines
2.6 KiB
Bash
Executable File
80 lines
2.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
# upgrade-verify.sh -- verify a release's SHA512 before it is used as root.
|
|
#
|
|
# usage: upgrade-verify.sh SOURCE [FILE...]
|
|
#
|
|
# SOURCE is a directory or a file:/// URL that holds the release's SHA512,
|
|
# SHA512.sig and the set files. The chain is checked first (the root key in
|
|
# /etc/signify/makronix-root.pub signs the release key
|
|
# /etc/signify/makronix-0.99.pub, the release key signs SHA512), then each
|
|
# FILE with its line in SHA512 (all lines when no FILE is given).
|
|
#
|
|
# SIGNIFY_ROOT_PUBKEY, SIGNIFY_PUBKEY and SIGNIFY override the paths and the
|
|
# program; the upgrade command calls this before sysupgrade or pkg_add run as
|
|
# root (tasksd t0055, t0078).
|
|
#
|
|
# signify is not in the NetBSD base: the target needs security/signify (or
|
|
# the same program under another name); SIGNIFY names it.
|
|
|
|
set -eu
|
|
|
|
die()
|
|
{
|
|
echo "upgrade-verify: $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
[ $# -ge 1 ] || die "usage: $0 SOURCE [FILE...]"
|
|
src=$1
|
|
shift
|
|
case $src in
|
|
file://*) src=${src#file://} ;;
|
|
esac
|
|
[ -d "$src" ] || die "$src is not a directory"
|
|
|
|
SIGNIFY=${SIGNIFY:-$(command -v signify 2>/dev/null || command -v signify-openbsd 2>/dev/null)} \
|
|
|| die "no signify (security/signify)"
|
|
ROOT=${SIGNIFY_ROOT_PUBKEY:-/etc/signify/makronix-root.pub}
|
|
PUB=${SIGNIFY_PUBKEY:-/etc/signify/makronix-0.99.pub}
|
|
|
|
[ -f "$src/SHA512" ] || die "no $src/SHA512"
|
|
[ -f "$src/SHA512.sig" ] || die "no $src/SHA512.sig"
|
|
[ -r "$ROOT" ] || die "no root key $ROOT"
|
|
[ -r "$PUB" ] || die "no release key $PUB"
|
|
[ -r "$PUB.sig" ] || die "no signature of the release key $PUB.sig"
|
|
|
|
"$SIGNIFY" -V -p "$ROOT" -m "$PUB" -x "$PUB.sig" \
|
|
|| die "the release key is not signed by the root key"
|
|
"$SIGNIFY" -V -p "$PUB" -m "$src/SHA512" -x "$src/SHA512.sig" \
|
|
|| die "SHA512 is not signed by the release key"
|
|
|
|
# The hashes in SHA512 are "SHA512 (name) = hex"; check the named files.
|
|
check_one()
|
|
{
|
|
name=$1
|
|
line=$(awk -v n="$name" '$1 == "SHA512" && $2 == "(" n ")" { print $NF; exit }' "$src/SHA512")
|
|
[ -n "$line" ] || die "$name is not in $src/SHA512"
|
|
[ -f "$src/$name" ] || die "no $src/$name"
|
|
got=$(if command -v sha512 >/dev/null 2>&1; then
|
|
sha512 -q "$src/$name"
|
|
elif command -v sha512sum >/dev/null 2>&1; then
|
|
sha512sum "$src/$name" | awk '{print $1}'
|
|
else
|
|
cksum -a sha512 "$src/$name" | awk '{print $NF}'
|
|
fi)
|
|
[ "$got" = "$line" ] || die "$name: SHA512 does not match"
|
|
echo "upgrade-verify: $name: SHA512 matches"
|
|
}
|
|
|
|
if [ $# -gt 0 ]; then
|
|
for f in "$@"; do
|
|
check_one "${f##*/}"
|
|
done
|
|
else
|
|
awk '$1 == "SHA512" { sub(/^\(/, "", $2); sub(/\)$/, "", $2); print $2 }' \
|
|
"$src/SHA512" | while read -r name; do
|
|
check_one "$name"
|
|
done
|
|
fi
|