Notes.md, absolute path normalizing
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

- edit NOTES.md for updating line numbers
- add check for using normalized path in initramfs normalization
This commit is contained in:
2025-09-18 21:45:21 +02:00
parent d649b7e6bf
commit 79ed723303
5 changed files with 41 additions and 30 deletions

View File

@@ -46,13 +46,13 @@ Configuration build.conf
- FIRMWARE_TAG optional for reproducible firmware flist naming. - FIRMWARE_TAG optional for reproducible firmware flist naming.
Absolute Path Normalization Absolute Path Normalization
- Location: [bash.common.sh](scripts/lib/common.sh:225) - Location: [bash.common.sh](scripts/lib/common.sh:236)
- After sourcing build.conf, the following variables are normalized to absolute paths anchored at PROJECT_ROOT: - After sourcing build.conf, the following variables are normalized to absolute paths anchored at PROJECT_ROOT:
- INSTALL_DIR, COMPONENTS_DIR, KERNEL_DIR, DIST_DIR - INSTALL_DIR, COMPONENTS_DIR, KERNEL_DIR, DIST_DIR
- Rationale: Prevents path resolution errors when CWD changes (e.g., when kernel build operates in /workspace/kernel/current, validation now resolves to /workspace/initramfs instead of /workspace/kernel/current/initramfs). - Rationale: Prevents path resolution errors when CWD changes (e.g., when kernel build operates in /workspace/kernel/current, validation now resolves to /workspace/initramfs instead of /workspace/kernel/current/initramfs).
Build Pipeline High Level Build Pipeline High Level
- Orchestrator: [bash.main_build_process()](scripts/build.sh:213) - Orchestrator: [bash.main_build_process()](scripts/build.sh:214)
- Stage list: - Stage list:
- alpine_extract - alpine_extract
- alpine_configure - alpine_configure
@@ -92,16 +92,16 @@ Initramfs Assembly Key Functions
- Binary size optimization: [bash.initramfs_strip_and_upx()](scripts/lib/initramfs.sh:491) - Binary size optimization: [bash.initramfs_strip_and_upx()](scripts/lib/initramfs.sh:491)
- Final customization: [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:575) - Final customization: [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:575)
- See “Branding behavior” below. - See “Branding behavior” below.
- Create archive: [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:662) - Create archive: [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:688)
- Calls finalize, runs sanity checks, and creates initramfs.cpio.xz. - Calls finalize, runs sanity checks, and creates initramfs.cpio.xz.
- Validate: [bash.initramfs_validate()](scripts/lib/initramfs.sh:790) - Validate: [bash.initramfs_validate()](scripts/lib/initramfs.sh:799)
- Ensures essential items exist, logs debug info: - Ensures essential items exist, logs debug info:
- Prints “Validation debug:” lines showing input, PWD, PROJECT_ROOT, INSTALL_DIR, and resolved path. - Prints “Validation debug:” lines showing input, PWD, PROJECT_ROOT, INSTALL_DIR, and resolved path.
Kernel Integration Kernel Integration
- Get full kernel version: [bash.kernel_get_full_version()](scripts/lib/kernel.sh:13) - Get full kernel version: [bash.kernel_get_full_version()](scripts/lib/kernel.sh:13)
- Apply config (embed initramfs): [bash.kernel_apply_config()](scripts/lib/kernel.sh:81) - Apply config (embed initramfs): [bash.kernel_apply_config()](scripts/lib/kernel.sh:81)
- Updates CONFIG_INITRAMFS_SOURCE to the archives absolute path via [bash.kernel_modify_config_for_initramfs()](scripts/lib/kernel.sh:129). - Updates CONFIG_INITRAMFS_SOURCE to the archives absolute path via [bash.kernel_modify_config_for_initramfs()](scripts/lib/kernel.sh:130).
- Build kernel: [bash.kernel_build_with_initramfs()](scripts/lib/kernel.sh:173) - Build kernel: [bash.kernel_build_with_initramfs()](scripts/lib/kernel.sh:173)
- Build and install modules in container: [bash.kernel_build_modules()](scripts/lib/kernel.sh:228) - Build and install modules in container: [bash.kernel_build_modules()](scripts/lib/kernel.sh:228)
- Installs modules to /lib/modules/$FULL_VERSION in container, runs depmod -a. - Installs modules to /lib/modules/$FULL_VERSION in container, runs depmod -a.
@@ -139,8 +139,8 @@ Validation Diagnostics and Triage
- Root cause: - Root cause:
- INSTALL_DIR re-sourced in a different CWD and interpreted as relative. - INSTALL_DIR re-sourced in a different CWD and interpreted as relative.
- Fix: - Fix:
- Absolute path normalization of INSTALL_DIR/COMPONENTS_DIR/KERNEL_DIR/DIST_DIR after sourcing build.conf in [bash.common.sh](scripts/lib/common.sh:225). - Absolute path normalization of INSTALL_DIR/COMPONENTS_DIR/KERNEL_DIR/DIST_DIR after sourcing build.conf in [bash.common.sh](scripts/lib/common.sh:236).
- Additional “Validation debug” prints added in [bash.initramfs_validate()](scripts/lib/initramfs.sh:790). - Additional “Validation debug” prints added in [bash.initramfs_validate()](scripts/lib/initramfs.sh:799).
- Expected logs now: - Expected logs now:
- “Validation debug: input='initramfs' PWD=/workspace PROJECT_ROOT=/workspace INSTALL_DIR=/workspace/initramfs” - “Validation debug: input='initramfs' PWD=/workspace PROJECT_ROOT=/workspace INSTALL_DIR=/workspace/initramfs”
- Resolves correctly even if called from a different stage CWD. - Resolves correctly even if called from a different stage CWD.
@@ -172,10 +172,10 @@ File Pointers (quick jump)
- Orchestrator: [scripts/build.sh](scripts/build.sh) - Orchestrator: [scripts/build.sh](scripts/build.sh)
- Common and config loading: [bash.common.sh](scripts/lib/common.sh:1) - Common and config loading: [bash.common.sh](scripts/lib/common.sh:1)
- Finalization hook: [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:575) - Finalization hook: [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:575)
- Passwordless deletion: [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:616) - Passwordless deletion: [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:592)
- Validation entry: [bash.initramfs_validate()](scripts/lib/initramfs.sh:790) - Validation entry: [bash.initramfs_validate()](scripts/lib/initramfs.sh:799)
- CPIO creation: [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:662) - CPIO creation: [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:688)
- Kernel embed config: [bash.kernel_modify_config_for_initramfs()](scripts/lib/kernel.sh:129) - Kernel embed config: [bash.kernel_modify_config_for_initramfs()](scripts/lib/kernel.sh:130)
- RFS packers: [bash.pack-modules.sh](scripts/rfs/pack-modules.sh:1), [bash.pack-firmware.sh](scripts/rfs/pack-firmware.sh:1) - RFS packers: [bash.pack-modules.sh](scripts/rfs/pack-modules.sh:1), [bash.pack-firmware.sh](scripts/rfs/pack-firmware.sh:1)
Change Log Change Log

View File

@@ -10,22 +10,22 @@ Mission
Repository map (jump-points) Repository map (jump-points)
- Build entrypoint and stages: - Build entrypoint and stages:
- [scripts/build.sh](scripts/build.sh) - [scripts/build.sh](scripts/build.sh)
- Orchestrator main: [bash.main_build_process()](scripts/build.sh:213) - Orchestrator main: [bash.main_build_process()](scripts/build.sh:214)
- Kernel build stage wrapper: [bash.stage_kernel_build()](scripts/build.sh:398) - Kernel build stage wrapper: [bash.stage_kernel_build()](scripts/build.sh:398)
- Initramfs create stage: [bash.stage_initramfs_create()](scripts/build.sh:374) - Initramfs create stage: [bash.stage_initramfs_create()](scripts/build.sh:374)
- Initramfs test stage: [bash.stage_initramfs_test()](scripts/build.sh:385) - Initramfs test stage: [bash.stage_initramfs_test()](scripts/build.sh:385)
- Stages infra: [bash.stage_run()](scripts/lib/stages.sh:99), [scripts/lib/stages.sh](scripts/lib/stages.sh) - Stages infra: [bash.stage_run()](scripts/lib/stages.sh:99), [scripts/lib/stages.sh](scripts/lib/stages.sh)
- Common utilities and config: - Common utilities and config:
- Config load, logging, path normalization: [bash.common.sh](scripts/lib/common.sh:1) - Config load, logging, path normalization: [bash.common.sh](scripts/lib/common.sh:1)
- Absolute path normalization for INSTALL_DIR, COMPONENTS_DIR, KERNEL_DIR, DIST_DIR: [bash.common.sh](scripts/lib/common.sh:225) - Absolute path normalization for INSTALL_DIR, COMPONENTS_DIR, KERNEL_DIR, DIST_DIR: [bash.common.sh](scripts/lib/common.sh:236)
- Initramfs assembly: - Initramfs assembly:
- All initramfs functions: [scripts/lib/initramfs.sh](scripts/lib/initramfs.sh) - All initramfs functions: [scripts/lib/initramfs.sh](scripts/lib/initramfs.sh)
- Final customization hook (branding, dirs, ntp): [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:575) - Final customization hook (branding, dirs, ntp): [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:575)
- Create archive (pre-CPIO checks, call finalize): [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:680) - Create archive (pre-CPIO checks, call finalize): [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:688)
- Validate contents (with new diagnostics): [bash.initramfs_validate()](scripts/lib/initramfs.sh:791) - Validate contents (with new diagnostics): [bash.initramfs_validate()](scripts/lib/initramfs.sh:799)
- Kernel integration: - Kernel integration:
- Kernel helpers: [scripts/lib/kernel.sh](scripts/lib/kernel.sh) - Kernel helpers: [scripts/lib/kernel.sh](scripts/lib/kernel.sh)
- Embed initramfs in config: [bash.kernel_modify_config_for_initramfs()](scripts/lib/kernel.sh:129) - Embed initramfs in config: [bash.kernel_modify_config_for_initramfs()](scripts/lib/kernel.sh:130)
- Zinit config and init scripts (inside initramfs): - Zinit config and init scripts (inside initramfs):
- zinit YAML/services: [config/zinit/](config/zinit/) - zinit YAML/services: [config/zinit/](config/zinit/)
- Modules mount script: [sh.modules.sh](config/zinit/init/modules.sh:1) - Modules mount script: [sh.modules.sh](config/zinit/init/modules.sh:1)
@@ -44,7 +44,7 @@ High-priority behaviors and policies
2) Path normalization (prevents “resolved under kernel/current” errors) 2) Path normalization (prevents “resolved under kernel/current” errors)
- After loading [config/build.conf](config/build.conf), key directories are normalized to absolute paths: - After loading [config/build.conf](config/build.conf), key directories are normalized to absolute paths:
- [bash.common.sh](scripts/lib/common.sh:225) - [bash.common.sh](scripts/lib/common.sh:236)
- Prevents validation resolving INSTALL_DIR relative to CWD (e.g., /workspace/kernel/current/initramfs). - Prevents validation resolving INSTALL_DIR relative to CWD (e.g., /workspace/kernel/current/initramfs).
3) Initramfs essential directories guarantee 3) Initramfs essential directories guarantee
@@ -97,8 +97,8 @@ Diagnostics-first workflow (strict)
- Example: rm -f .build-stages/validation.done && DEBUG=1 ./scripts/build.sh --skip-tests - Example: rm -f .build-stages/validation.done && DEBUG=1 ./scripts/build.sh --skip-tests
- Use existing diagnostics: - Use existing diagnostics:
- Branding debug lines: [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:575) - Branding debug lines: [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:575)
- Validation debug lines (input, PWD, PROJECT_ROOT, INSTALL_DIR, resolved): [bash.initramfs_validate()](scripts/lib/initramfs.sh:791) - Validation debug lines (input, PWD, PROJECT_ROOT, INSTALL_DIR, resolved): [bash.initramfs_validate()](scripts/lib/initramfs.sh:799)
- Pre-CPIO sanity listing and essential checks: [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:680) - Pre-CPIO sanity listing and essential checks: [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:688)
- Only after validation confirms the hypothesis, apply the minimal fix. - Only after validation confirms the hypothesis, apply the minimal fix.
Common tasks and commands Common tasks and commands
@@ -122,13 +122,13 @@ A) Diagnose “passwordless root not working”
- Extract dist/initramfs.cpio.xz to a temp dir and grep '^root:' etc/shadow; expect root:: - Extract dist/initramfs.cpio.xz to a temp dir and grep '^root:' etc/shadow; expect root::
- If not present: - If not present:
- Ensure passwd is available in container (comes from shadow package): [Dockerfile](Dockerfile) - Ensure passwd is available in container (comes from shadow package): [Dockerfile](Dockerfile)
- Check we use chroot ${initramfs_dir} passwd -d root (not --root or direct file edits): [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:589) - Check we use chroot ${initramfs_dir} passwd -d root (not --root or direct file edits): [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:592)
B) Fix “Initramfs directory not found: initramfs (resolved: /workspace/kernel/current/initramfs)” B) Fix “Initramfs directory not found: initramfs (resolved: /workspace/kernel/current/initramfs)”
- Confirm absolute path normalization after config load: - Confirm absolute path normalization after config load:
- [bash.common.sh](scripts/lib/common.sh:225) - [bash.common.sh](scripts/lib/common.sh:236)
- Confirm validation prints “Validation debug:” with resolved absolute path: - Confirm validation prints “Validation debug:” with resolved absolute path:
- [bash.initramfs_validate()](scripts/lib/initramfs.sh:791) - [bash.initramfs_validate()](scripts/lib/initramfs.sh:799)
C) INITRAMFS_ARCHIVE unbound during kernel build stage C) INITRAMFS_ARCHIVE unbound during kernel build stage
- stage_kernel_build now defaults INITRAMFS_ARCHIVE if unset: - stage_kernel_build now defaults INITRAMFS_ARCHIVE if unset:
@@ -154,9 +154,9 @@ Project conventions
Key files to keep in sync with behavior decisions Key files to keep in sync with behavior decisions
- Branding and finalization: [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:575) - Branding and finalization: [bash.initramfs_finalize_customization()](scripts/lib/initramfs.sh:575)
- Validation diagnostics: [bash.initramfs_validate()](scripts/lib/initramfs.sh:791) - Validation diagnostics: [bash.initramfs_validate()](scripts/lib/initramfs.sh:799)
- Archive creation (pre-CPIO checks): [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:680) - Archive creation (pre-CPIO checks): [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:688)
- Path normalization after config: [bash.common.sh](scripts/lib/common.sh:225) - Path normalization after config: [bash.common.sh](scripts/lib/common.sh:236)
- Modules/firmware remote fallback: [sh.modules.sh](config/zinit/init/modules.sh:1), [sh.firmware.sh](config/zinit/init/firmware.sh:1) - Modules/firmware remote fallback: [sh.modules.sh](config/zinit/init/modules.sh:1), [sh.firmware.sh](config/zinit/init/firmware.sh:1)
- Kernel stage defaulting for archive: [bash.stage_kernel_build()](scripts/build.sh:398) - Kernel stage defaulting for archive: [bash.stage_kernel_build()](scripts/build.sh:398)
- Operational notes: [docs/NOTES.md](docs/NOTES.md) - Operational notes: [docs/NOTES.md](docs/NOTES.md)

View File

@@ -1,3 +1,2 @@
# Generated by dhcpcd nameserver 169.254.1.1
# /etc/resolv.conf.head can replace this line nameserver 192.168.64.254
# /etc/resolv.conf.tail can replace this line

View File

@@ -1,4 +1,4 @@
root::20340:0::::: root::20349:0:::::
bin:!::0::::: bin:!::0:::::
daemon:!::0::::: daemon:!::0:::::
lp:!::0::::: lp:!::0:::::

View File

@@ -803,7 +803,19 @@ function initramfs_validate() {
# Diagnostics to catch path/WD issues during validation # Diagnostics to catch path/WD issues during validation
log_info "Validation debug: input='${initramfs_dir_in}' PWD=$(pwd) PROJECT_ROOT=${PROJECT_ROOT:-unset} INSTALL_DIR=${INSTALL_DIR:-unset}" log_info "Validation debug: input='${initramfs_dir_in}' PWD=$(pwd) PROJECT_ROOT=${PROJECT_ROOT:-unset} INSTALL_DIR=${INSTALL_DIR:-unset}"
initramfs_dir=$(resolve_path "${initramfs_dir_in}") # Normalize initramfs path independent of CWD: anchor relative paths to PROJECT_ROOT
if is_absolute_path "${initramfs_dir_in}"; then
initramfs_dir="${initramfs_dir_in}"
log_debug "Validation path strategy: absolute input honored"
else
if [[ -n "${PROJECT_ROOT:-}" ]]; then
initramfs_dir="${PROJECT_ROOT}/${initramfs_dir_in#./}"
log_debug "Validation path strategy: relative input anchored to PROJECT_ROOT"
else
initramfs_dir="$(pwd)/${initramfs_dir_in}"
log_warn "PROJECT_ROOT unset; falling back to PWD anchoring"
fi
fi
log_info "Validation debug: resolved initramfs_dir='${initramfs_dir}'" log_info "Validation debug: resolved initramfs_dir='${initramfs_dir}'"
section_header "Validating initramfs contents" section_header "Validating initramfs contents"