Blob: scripts/check-c1.sh
Raw · Blame
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(dirname "$script_dir")
build_dir=${MOUSE_BUILD_DIR:-"$repo_dir/build"}
image="$build_dir/mouse-initramfs.cpio.gz"
for command in expect cpio gzip; do
if ! command -v "$command" >/dev/null 2>&1; then
printf '%s\n' "$command is required for the C1 integration check" >&2
exit 1
fi
done
if [ ! -f "$image" ]; then
printf '%s\n' "run 'make image' before checking MOUSE" >&2
exit 1
fi
"$script_dir/check-c1.exp" "$script_dir/run-qemu.sh" enabled
temporary=$(mktemp -d "${TMPDIR:-/tmp}/mouse-c1-check.XXXXXX")
trap 'rm -rf "$temporary"' EXIT HUP INT TERM
root="$temporary/root"
disabled_image="$temporary/mouse-initramfs-disabled.cpio.gz"
mkdir "$root"
gzip -dc "$image" | (cd "$root" && cpio -id 2>/dev/null)
printf '%s\n' \
'# MOUSE service enablement policy.' \
'enable_mouse_optional=NO' >"$root/etc/rc.conf"
(
cd "$root"
find . -print |
LC_ALL=C sort |
cpio -o --format newc -R 0:0 2>/dev/null |
gzip -9
) >"$disabled_image"
MOUSE_INITRAMFS="$disabled_image" \
"$script_dir/check-c1.exp" "$script_dir/run-qemu.sh" disabled