From a09daa2093e8b265cd053094c12025cda242bc3b Mon Sep 17 00:00:00 2001 From: lotherk Date: Tue, 24 Nov 2026 11:36:55 +0000 Subject: [PATCH] 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 --- Makefile | 4 ++-- tools/kernel-install.sh | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100755 tools/kernel-install.sh diff --git a/Makefile b/Makefile index 32eaba18b0..e09c46a322 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ stamp: # `make all install' on a running Makronix is the whole update (Konrad, # 2026-11-24); `release' adds the kernels' media on top of the same two steps. build: - @tools/build-lock.sh 'tools/build-stamp.sh && tools/userland.sh && $(BUILD_SH) distribution' + @tools/build-lock.sh 'tools/build-stamp.sh && tools/userland.sh && $(BUILD_SH) distribution && $(BUILD_SH) kernel=$(KERNEL)' # A release is everything: the packages of the makronix set (tools/userland.sh # fills destdir/usr/pkg and src/distrib/sets/lists/makronix/mi -- without it @@ -196,7 +196,7 @@ install: echo "make install: which only makes sense on Makronix/NetBSD."; \ echo "make install: on $$(uname -s), build with 'make' instead."; \ exit 1; } - @tools/build-lock.sh '$(BUILD_SH) install=/' + @tools/build-lock.sh '$(BUILD_SH) install=/ && $(TOP)/tools/kernel-install.sh $(OBJ)/sys/arch/$(MACHINE)/compile/$(KERNEL)/netbsd' tools: @tools/build-lock.sh '$(BUILD_SH) tools' diff --git a/tools/kernel-install.sh b/tools/kernel-install.sh new file mode 100755 index 0000000000..9624dcb08a --- /dev/null +++ b/tools/kernel-install.sh @@ -0,0 +1,38 @@ +#!/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 +# +# `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 } +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)"