initramfs+kernel: path anchors, helper, and init debug hook

initramfs: anchor relative paths to PROJECT_ROOT in [bash.initramfs_validate()](scripts/lib/initramfs.sh:799) and [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:688) to avoid CWD drift. Add diagnostics logs.

kernel: anchor kernel output path to PROJECT_ROOT in [bash.kernel_build_with_initramfs()](scripts/lib/kernel.sh:174) to ensure dist/vmlinuz.efi is under PROJECT_ROOT/dist.

helper: add [scripts/rebuild-after-zinit.sh](scripts/rebuild-after-zinit.sh) to incrementally rebuild after zinit/modules.conf/init changes. Default: initramfs-only (recreates cpio). Flags: --with-kernel, --refresh-container-mods, --run-tests. Uses --rebuild-from=initramfs_create when rebuilding kernel.

init: add early debug shell on kernel param initdebug=true; prefer /init-debug when present else spawn /bin/sh -l. See [config/init](config/init:1).

modules(stage1): add USB keyboard support (HID + host controllers) in [config/modules.conf](config/modules.conf:1): usbhid, hid_generic, hid, xhci/ehci/ohci/uhci.
This commit is contained in:
2025-09-20 16:11:44 +02:00
parent 310e11d2bf
commit 2fba2bd4cd
5 changed files with 194 additions and 8 deletions

View File

@@ -691,6 +691,24 @@ function initramfs_create_cpio() {
local compression="${3:-$INITRAMFS_COMPRESSION}"
section_header "Creating initramfs.cpio.${compression}"
# Diagnostics and path normalization (anchor relative to PROJECT_ROOT)
log_info "Create CPIO debug: input='${initramfs_dir}' PWD=$(pwd) PROJECT_ROOT=${PROJECT_ROOT:-unset}"
local _initramfs_dir_resolved
if is_absolute_path "${initramfs_dir}"; then
_initramfs_dir_resolved="${initramfs_dir}"
log_debug "Create CPIO path strategy: absolute input honored"
else
if [[ -n "${PROJECT_ROOT:-}" ]]; then
_initramfs_dir_resolved="${PROJECT_ROOT}/${initramfs_dir#./}"
log_debug "Create CPIO path strategy: relative input anchored to PROJECT_ROOT"
else
_initramfs_dir_resolved="$(pwd)/${initramfs_dir}"
log_warn "PROJECT_ROOT unset; falling back to PWD anchoring"
fi
fi
log_info "Create CPIO debug: resolved initramfs_dir='${_initramfs_dir_resolved}'"
initramfs_dir="${_initramfs_dir_resolved}"
if [[ ! -d "$initramfs_dir" ]]; then
log_error "Initramfs directory not found: ${initramfs_dir}"