Separate component building from copying for better architecture
- Remove component copying from build functions (build_zinit, build_rfs, etc) - Add initramfs_copy_components() function to copy built components to initramfs - Add components_copy stage between init_script and modules_setup - Fix components_verify to check built components (not initramfs locations) - Now supports partial builds: build components separately, copy later - All 4 components (zinit 8.1M, rfs 13M, mycelium 21M, corex 4.0M) working
This commit is contained in:
@@ -102,6 +102,87 @@ function initramfs_install_init_script() {
|
||||
log_info " Boot flow: /init -> setup environment -> switch_root -> /sbin/zinit init"
|
||||
}
|
||||
|
||||
# Copy built components to initramfs (separate from building)
|
||||
function initramfs_copy_components() {
|
||||
local initramfs_dir="$1"
|
||||
local components_dir="${2:-${PROJECT_ROOT}/components}"
|
||||
|
||||
section_header "Copying Built Components to Initramfs"
|
||||
|
||||
if [[ ! -d "$components_dir" ]]; then
|
||||
log_error "Components directory not found: ${components_dir}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local copied_count=0
|
||||
local missing_count=0
|
||||
|
||||
# Copy zinit to /sbin
|
||||
local zinit_binary="${components_dir}/zinit/target/x86_64-unknown-linux-musl/release/zinit"
|
||||
if [[ -f "$zinit_binary" ]]; then
|
||||
safe_mkdir "${initramfs_dir}/sbin"
|
||||
safe_execute cp "$zinit_binary" "${initramfs_dir}/sbin/zinit"
|
||||
safe_execute chmod +x "${initramfs_dir}/sbin/zinit"
|
||||
local size=$(get_file_size "${initramfs_dir}/sbin/zinit")
|
||||
log_info "✓ Copied zinit (${size}) to /sbin/zinit"
|
||||
((copied_count++))
|
||||
else
|
||||
log_error "✗ zinit binary not found: ${zinit_binary}"
|
||||
((missing_count++))
|
||||
fi
|
||||
|
||||
# Copy rfs to /usr/bin
|
||||
local rfs_binary="${components_dir}/rfs/rfs"
|
||||
if [[ -f "$rfs_binary" ]]; then
|
||||
safe_mkdir "${initramfs_dir}/usr/bin"
|
||||
safe_execute cp "$rfs_binary" "${initramfs_dir}/usr/bin/rfs"
|
||||
safe_execute chmod +x "${initramfs_dir}/usr/bin/rfs"
|
||||
local size=$(get_file_size "${initramfs_dir}/usr/bin/rfs")
|
||||
log_info "✓ Copied rfs (${size}) to /usr/bin/rfs"
|
||||
((copied_count++))
|
||||
else
|
||||
log_error "✗ rfs binary not found: ${rfs_binary}"
|
||||
((missing_count++))
|
||||
fi
|
||||
|
||||
# Copy mycelium to /usr/bin
|
||||
local mycelium_binary="${components_dir}/mycelium/myceliumd/target/x86_64-unknown-linux-musl/release/mycelium"
|
||||
if [[ -f "$mycelium_binary" ]]; then
|
||||
safe_mkdir "${initramfs_dir}/usr/bin"
|
||||
safe_execute cp "$mycelium_binary" "${initramfs_dir}/usr/bin/mycelium"
|
||||
safe_execute chmod +x "${initramfs_dir}/usr/bin/mycelium"
|
||||
local size=$(get_file_size "${initramfs_dir}/usr/bin/mycelium")
|
||||
log_info "✓ Copied mycelium (${size}) to /usr/bin/mycelium"
|
||||
((copied_count++))
|
||||
else
|
||||
log_error "✗ mycelium binary not found: ${mycelium_binary}"
|
||||
((missing_count++))
|
||||
fi
|
||||
|
||||
# Copy corex to /usr/bin
|
||||
local corex_binary="${components_dir}/corex/corex"
|
||||
if [[ -f "$corex_binary" ]]; then
|
||||
safe_mkdir "${initramfs_dir}/usr/bin"
|
||||
safe_execute cp "$corex_binary" "${initramfs_dir}/usr/bin/corex"
|
||||
safe_execute chmod +x "${initramfs_dir}/usr/bin/corex"
|
||||
local size=$(get_file_size "${initramfs_dir}/usr/bin/corex")
|
||||
log_info "✓ Copied corex (${size}) to /usr/bin/corex"
|
||||
((copied_count++))
|
||||
else
|
||||
log_error "✗ corex binary not found: ${corex_binary}"
|
||||
((missing_count++))
|
||||
fi
|
||||
|
||||
log_info "Component copy complete: ${copied_count} copied, ${missing_count} missing"
|
||||
|
||||
if [[ $missing_count -gt 0 ]]; then
|
||||
log_error "Some components missing - build may have failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Setup 2-stage module loading system with dependency resolution and firmware correlation
|
||||
function initramfs_setup_modules() {
|
||||
local initramfs_dir="$1"
|
||||
@@ -784,5 +865,6 @@ function initramfs_copy_resolved_modules() {
|
||||
|
||||
# Export all functions at the end after they're all defined
|
||||
export -f initramfs_setup_zinit initramfs_setup_modules initramfs_resolve_module_dependencies
|
||||
export -f initramfs_install_init_script initramfs_create_module_scripts initramfs_strip_and_upx
|
||||
export -f initramfs_create_cpio initramfs_validate initramfs_test_archive initramfs_copy_resolved_modules
|
||||
export -f initramfs_install_init_script initramfs_copy_components initramfs_create_module_scripts
|
||||
export -f initramfs_strip_and_upx initramfs_create_cpio initramfs_validate initramfs_test_archive
|
||||
export -f initramfs_copy_resolved_modules
|
||||
Reference in New Issue
Block a user