comodore-iec-emu/kernel/docker-entrypoint.sh
2026-06-18 22:25:42 +02:00

18 lines
718 B
Bash
Executable File

#!/bin/sh
# Resolve the installed Raspberry Pi kernel version and build against it.
#
# `uname -r` inside a container returns the HOST kernel (the container shares the
# host kernel), so we must derive KDIR from the headers actually installed in the
# image rather than from uname. Pick the newest installed module tree.
set -eu
KVER="$(ls -1 /lib/modules 2>/dev/null | sort -V | tail -n 1 || true)"
if [ -z "$KVER" ] || [ ! -d "/lib/modules/$KVER/build" ]; then
echo "error: no kernel headers found under /lib/modules/*/build" >&2
echo " (the HEADERS_PKG build-arg may be wrong for this image)" >&2
exit 1
fi
echo "==> building against kernel headers: $KVER"
exec make KDIR="/lib/modules/$KVER/build" "$@"