build: guard INITRAMFS_ARCHIVE in stage_kernel_build for incremental runs
Some checks failed
Build Zero OS Initramfs / build (push) Has been cancelled
Build Zero OS Initramfs / test-matrix (qemu, basic) (push) Has been cancelled
Build Zero OS Initramfs / test-matrix (qemu, serial) (push) Has been cancelled

initramfs: ensure essential dirs incl. /home exist during finalize and validate 'home' as essential item
This commit is contained in:
2025-09-09 17:00:38 +02:00
parent 998e40c2e5
commit 16955ea84f
2 changed files with 21 additions and 2 deletions

View File

@@ -630,7 +630,15 @@ EOF
else
log_info "Branding disabled: leaving /etc/motd, /etc/issue and root password unchanged"
fi
# Ensure essential Linux filesystem directories exist (defensive), including /home
# Some earlier stages or cleanups may have run in previous builds; enforce presence now.
log_info "Ensuring essential directories exist (including /home)"
local _ensure_dirs=("dev" "proc" "sys" "tmp" "run" "mnt" "home" "root" "opt" "srv" "media" "media/cdrom" "media/floppy" "media/usb")
for _d in "${_ensure_dirs[@]}"; do
safe_mkdir "${initramfs_dir}/${_d}"
done
# Ensure ntp.conf exists for hooks. Create only if absent, do not overwrite.
if [[ ! -f "${initramfs_dir}/etc/ntp.conf" ]]; then
log_info "Creating ntp.conf with Google NTP servers (absent)"
@@ -735,7 +743,7 @@ function initramfs_create_cpio() {
local pre_cpio_file_count
pre_cpio_file_count=$(find "${initramfs_dir}" -mindepth 1 | wc -l || echo "0")
log_info "Pre-CPIO sanity: ${pre_cpio_file_count} files under ${initramfs_dir}"
local _essential_items=("init" "sbin/zinit" "bin/busybox" "etc/zinit" "lib" "usr/bin" "var" "tmp" "proc" "sys" "dev")
local _essential_items=("init" "sbin/zinit" "bin/busybox" "etc/zinit" "lib" "usr/bin" "home" "var" "tmp" "proc" "sys" "dev")
for _item in "${_essential_items[@]}"; do
if [[ -e "${initramfs_dir}/${_item}" ]]; then
log_debug "pre-cpio OK: ${_item}"