fix: major build system improvements and container output issues

- Fix container output visibility with proper TTY handling and debug mode
- Fix build order: kernel modules built before initramfs creation
- Implement two-stage kernel build to resolve chicken-and-egg dependency
- Fix sed command issues in kernel configuration with direct execution
- Add diffutils package to container for proper kernel build support
- Enhance NIC module/firmware correlation with intelligent selection
- Fix module staging logic: all NICs loaded in stage1 before network up
- Add smart firmware installation based on module requirements
- Create comprehensive function documentation (scripts/functionlist.md)
- Add debug container script for troubleshooting

Major fixes:
* Container builds now show real-time output
* Kernel builds work with proper GNU diff support
* Module/firmware selection optimized for common hardware
* Build process handles dependencies correctly
* Documentation provides complete function reference
This commit is contained in:
2025-09-03 14:06:44 +02:00
parent 6d44575860
commit b9f94105cf
23 changed files with 1072 additions and 4310 deletions

View File

@@ -118,13 +118,27 @@ function kernel_modify_config_for_initramfs() {
log_info "Modifying kernel config for embedded initramfs"
# Use sed to update configuration
safe_execute sed -i "s|^CONFIG_INITRAMFS_SOURCE=.*|CONFIG_INITRAMFS_SOURCE=\"${initramfs_path}\"|" .config
# Use sed to update configuration (execute directly to avoid quote issues)
log_info "Setting INITRAMFS_SOURCE to: ${initramfs_path}"
if ! sed -i "s|^CONFIG_INITRAMFS_SOURCE=.*|CONFIG_INITRAMFS_SOURCE=\"${initramfs_path}\"|" .config; then
log_error "Failed to set INITRAMFS_SOURCE in kernel config"
return 1
fi
# Ensure XZ compression is enabled for initramfs
safe_execute sed -i 's/^# CONFIG_RD_XZ is not set/CONFIG_RD_XZ=y/' .config
safe_execute sed -i 's/^CONFIG_INITRAMFS_COMPRESSION_NONE=y/# CONFIG_INITRAMFS_COMPRESSION_NONE is not set/' .config
safe_execute sed -i 's/^# CONFIG_INITRAMFS_COMPRESSION_XZ is not set/CONFIG_INITRAMFS_COMPRESSION_XZ=y/' .config
log_info "Enabling XZ decompression support"
if ! sed -i 's|^# CONFIG_RD_XZ is not set|CONFIG_RD_XZ=y|' .config; then
log_warn "Could not enable CONFIG_RD_XZ (may already be set)"
fi
log_info "Setting initramfs compression to XZ"
if ! sed -i 's|^CONFIG_INITRAMFS_COMPRESSION_NONE=y|# CONFIG_INITRAMFS_COMPRESSION_NONE is not set|' .config; then
log_warn "Could not disable INITRAMFS_COMPRESSION_NONE (may already be disabled)"
fi
if ! sed -i 's|^# CONFIG_INITRAMFS_COMPRESSION_XZ is not set|CONFIG_INITRAMFS_COMPRESSION_XZ=y|' .config; then
log_warn "Could not enable INITRAMFS_COMPRESSION_XZ (may already be set)"
fi
# Verify critical settings
if ! grep -q "CONFIG_INITRAMFS_SOURCE=\"${initramfs_path}\"" .config; then
@@ -132,9 +146,11 @@ function kernel_modify_config_for_initramfs() {
return 1
fi
if ! grep -q "CONFIG_RD_XZ=y" .config; then
log_error "Failed to enable XZ decompression in kernel config"
return 1
# Check if XZ support is available (either RD_XZ or built-in)
if grep -q "CONFIG_RD_XZ=y" .config || grep -q "CONFIG_KERNEL_XZ=y" .config; then
log_info "✓ XZ decompression support confirmed"
else
log_warn "XZ decompression support not confirmed, kernel may not boot"
fi
log_info "Kernel config updated for embedded initramfs"
@@ -262,4 +278,4 @@ function kernel_cleanup() {
# Export functions
export -f kernel_download_source kernel_apply_config kernel_modify_config_for_initramfs
export -f kernel_build_with_initramfs kernel_build_modules kernel_cleanup
export -f kernel_build_with_initramfs kernel_build_modules kernel_cleanup