forked from tfgrid/zosbuilder
feat: Add firmware installation and module dependency resolution
- Add Alpine firmware package installation support - Implement recursive module dependency resolution using modinfo - Add config/firmware.conf for NIC firmware selection - Enhanced initramfs_setup_modules with dependency tracking - Firmware installation integrated into main build process Features: - Automatic dependency resolution for kernel modules - Alpine's separate firmware APK packages for optimal size - Stage1/Stage2 module loading with complete dependencies - No duplicate modules between stages
This commit is contained in:
@@ -348,7 +348,73 @@ EOF
|
||||
log_info "Alpine system configuration complete"
|
||||
}
|
||||
|
||||
# Install firmware packages for hardware support
|
||||
function alpine_install_firmware() {
|
||||
local initramfs_dir="$1"
|
||||
local firmware_conf="$2"
|
||||
|
||||
section_header "Installing Alpine Firmware Packages"
|
||||
|
||||
if [[ ! -f "$firmware_conf" ]]; then
|
||||
log_warn "Firmware configuration not found: ${firmware_conf}"
|
||||
log_info "Skipping firmware installation"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Setup chroot environment
|
||||
alpine_setup_chroot "$initramfs_dir"
|
||||
|
||||
# Read firmware packages from config (excluding comments and empty lines)
|
||||
local firmware_packages=()
|
||||
while IFS=: read -r package description; do
|
||||
# Skip comments and empty lines
|
||||
if [[ "$package" =~ ^[[:space:]]*# ]] || [[ -z "${package// }" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Trim whitespace
|
||||
package=$(echo "$package" | xargs)
|
||||
description=$(echo "$description" | xargs)
|
||||
|
||||
if [[ -n "$package" ]]; then
|
||||
firmware_packages+=("$package")
|
||||
log_info " - ${package}: ${description}"
|
||||
fi
|
||||
done < "$firmware_conf"
|
||||
|
||||
if [[ ${#firmware_packages[@]} -eq 0 ]]; then
|
||||
log_warn "No firmware packages found in ${firmware_conf}"
|
||||
alpine_cleanup_chroot "$initramfs_dir"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log_info "Installing ${#firmware_packages[@]} firmware packages"
|
||||
|
||||
# Install firmware packages
|
||||
safe_execute chroot "$initramfs_dir" apk add --no-cache "${firmware_packages[@]}"
|
||||
|
||||
# List installed firmware files
|
||||
log_info "Checking installed firmware files:"
|
||||
local firmware_count=0
|
||||
if [[ -d "${initramfs_dir}/lib/firmware" ]]; then
|
||||
firmware_count=$(find "${initramfs_dir}/lib/firmware" -type f | wc -l)
|
||||
local firmware_size=$(du -sh "${initramfs_dir}/lib/firmware" 2>/dev/null | cut -f1 || echo "0B")
|
||||
log_info " Firmware files: ${firmware_count} (${firmware_size})"
|
||||
|
||||
# Log some example firmware files for verification
|
||||
log_debug "Sample firmware files:"
|
||||
find "${initramfs_dir}/lib/firmware" -type f | head -10 | while read -r fw; do
|
||||
log_debug " $(basename "$fw")"
|
||||
done
|
||||
else
|
||||
log_warn "No firmware directory found after installation"
|
||||
fi
|
||||
|
||||
alpine_cleanup_chroot "$initramfs_dir"
|
||||
log_info "Firmware installation complete: ${firmware_count} files"
|
||||
}
|
||||
|
||||
# Export functions
|
||||
export -f alpine_extract_miniroot alpine_setup_chroot alpine_cleanup_chroot
|
||||
export -f alpine_install_packages alpine_aggressive_cleanup
|
||||
export -f alpine_install_packages alpine_install_firmware alpine_aggressive_cleanup
|
||||
export -f alpine_configure_repos alpine_configure_system
|
||||
Reference in New Issue
Block a user