forked from tfgrid/zosbuilder
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:
@@ -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}"
|
||||
|
||||
@@ -206,15 +206,29 @@ function kernel_build_with_initramfs() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Resolve output path to absolute BEFORE cd side-effects influence relative paths
|
||||
local output_abs="$output_file"
|
||||
if [[ "$output_abs" != /* ]]; then
|
||||
if [[ -n "${PROJECT_ROOT:-}" ]]; then
|
||||
output_abs="${PROJECT_ROOT}/${output_abs#./}"
|
||||
log_debug "kernel_build_with_initramfs: output path anchored to PROJECT_ROOT: ${output_abs}"
|
||||
else
|
||||
output_abs="$(pwd)/${output_abs}"
|
||||
log_warn "kernel_build_with_initramfs: PROJECT_ROOT unset; output anchored to PWD: ${output_abs}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Copy to output location
|
||||
local output_dir=$(dirname "$output_file")
|
||||
local output_dir
|
||||
output_dir=$(dirname "$output_abs")
|
||||
safe_mkdir "$output_dir"
|
||||
safe_copy "$kernel_image" "$output_file"
|
||||
safe_copy "$kernel_image" "$output_abs"
|
||||
|
||||
# Verify final kernel
|
||||
local kernel_size=$(get_file_size "$output_file")
|
||||
local kernel_size
|
||||
kernel_size=$(get_file_size "$output_abs")
|
||||
log_info "Kernel build complete:"
|
||||
log_info " Output file: ${output_file}"
|
||||
log_info " Output file: ${output_abs}"
|
||||
log_info " Kernel size: ${kernel_size}"
|
||||
|
||||
# Verify initramfs is embedded
|
||||
|
||||
Reference in New Issue
Block a user