ix init script duplication and CPIO creation issues

- Remove duplicate /sbin/init copying from initramfs_setup_zinit()
- Only /init should be config/init (initramfs setup script)
- No /sbin/init needed - config/init calls 'switch_root /mnt/root /sbin/zinit init'
- Remove unsupported cpio --owner option that broke CPIO creation
- Fix validation to not expect /sbin/init file
- Correct boot flow: /init → switch_root → /sbin/zinit init
- Remove strip and UPX compression from zinit binary copying
- UPX compression was corrupting the zinit binary causing segfaults after switch_root
- Keep zinit unmodified as it's
This commit is contained in:
2025-09-05 11:43:25 +02:00
parent 38dee2de74
commit 8c3868b242
102 changed files with 589 additions and 375 deletions

View File

@@ -205,20 +205,41 @@ function docker_commit_builder() {
log_info "Container committed successfully: ${new_tag}"
}
# Clean up container images
# Clean up container images and running containers
function docker_cleanup() {
local keep_builder="${1:-false}"
section_header "Cleaning Up Container Images"
section_header "Cleaning Up Containers and Images"
if [[ "$keep_builder" != "true" ]]; then
log_info "Cleaning up builder containers and images"
# Stop and remove any containers using the builder image
local containers_using_image=$(${CONTAINER_RUNTIME} ps -a --filter "ancestor=${BUILDER_IMAGE}" --format "{{.ID}}" 2>/dev/null || true)
if [[ -n "$containers_using_image" ]]; then
log_info "Stopping containers using builder image"
for container_id in $containers_using_image; do
log_info "Stopping container: $container_id"
${CONTAINER_RUNTIME} stop "$container_id" 2>/dev/null || true
${CONTAINER_RUNTIME} rm "$container_id" 2>/dev/null || true
done
fi
# Stop and remove development container if it exists
local dev_container="zero-os-dev"
if ${CONTAINER_RUNTIME} container exists "$dev_container" 2>/dev/null; then
log_info "Removing development container: $dev_container"
${CONTAINER_RUNTIME} rm -f "$dev_container" 2>/dev/null || true
fi
# Now remove the images
log_info "Removing builder images"
safe_execute ${CONTAINER_RUNTIME} rmi "${BUILDER_IMAGE}" || true
safe_execute ${CONTAINER_RUNTIME} rmi "${BUILDER_IMAGE}-cached" || true
${CONTAINER_RUNTIME} rmi "${BUILDER_IMAGE}" 2>/dev/null || log_warn "Could not remove ${BUILDER_IMAGE} (may not exist)"
${CONTAINER_RUNTIME} rmi "${BUILDER_IMAGE}-cached" 2>/dev/null || log_warn "Could not remove ${BUILDER_IMAGE}-cached (may not exist)"
fi
log_info "Pruning unused containers and images"
safe_execute ${CONTAINER_RUNTIME} system prune -f
${CONTAINER_RUNTIME} system prune -f 2>/dev/null || log_warn "Container prune failed"
log_info "Container cleanup complete"
}