Files
makronix/tools/kernel-install.sh
lotherkandClaude Sonnet 5.5 a09daa2093 make: the kernel is built by 'make' and installed by 'make install'
installworld puts no kernel on the system.  build now ends with build.sh kernel=$(KERNEL), install
runs tools/kernel-install.sh on the result: /netbsd with /netbsd.old kept, and the same on
/cgdboot of an encrypted installation, as mxupgrade(8) does.  No restart.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 11:36:55 +00:00

39 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# $Makronix$
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
#
# kernel-install.sh -- put a built kernel where the running system boots from
#
# usage: tools/kernel-install.sh <path to the built netbsd>
#
# `make install' (installworld) installs the sets and no kernel. This is the
# kernel half of it, the way src/BUILDING and mxupgrade(8) do it: the old
# kernel stays as /netbsd.old, and on an encrypted installation (/cgdboot in
# fstab) the boot loader starts the kernel from that small partition, so the
# same copy goes there with netbsd.old kept (mxupgrade.sh does the same
# after sysupgrade). The system is not restarted.
#
# POSIX sh.
set -eu
k=${1:?usage: kernel-install.sh <path to the built netbsd>}
CGDBOOT=${MXUPGRADE_CGDBOOT:-/cgdboot}
[ -f "$k" ] || { echo "kernel-install: $k is not a file" >&2; exit 1; }
[ "$(uname -s)" = NetBSD ] || { echo "kernel-install: NetBSD only" >&2; exit 1; }
echo "kernel-install: $k -> /netbsd (old one: /netbsd.old)"
[ ! -f /netbsd ] || cp -p /netbsd /netbsd.old
cp -p "$k" /netbsd.new
mv -f /netbsd.new /netbsd
if grep -q "[[:space:]]$CGDBOOT[[:space:]]" /etc/fstab 2>/dev/null; then
echo "kernel-install: boot partition $CGDBOOT"
mount "$CGDBOOT"
[ ! -f "$CGDBOOT/netbsd" ] || cp -p "$CGDBOOT/netbsd" "$CGDBOOT/netbsd.old"
cp -p /netbsd "$CGDBOOT/netbsd"
umount "$CGDBOOT"
fi
echo "kernel-install: done; reboot to run it (shutdown -r now)"