Fix critical build pipeline and update documentation

CRITICAL FIXES:
- Fix build-initramfs.sh early exit preventing zinit installation
- Add binary detection/installation logic to setup-initramfs.sh
- Ensure compiled components are properly installed to initramfs

DOCUMENTATION:
- Update README.md to reflect actual implementation
- Document source compilation approach with git submodules
- Add development workflow and caching documentation
- Remove outdated GitHub releases references

This fixes the 'zinit not found' boot error by ensuring the build
pipeline completes all phases including initramfs assembly.
This commit is contained in:
2025-08-16 21:04:07 +02:00
parent e3db295eb9
commit 7eb27ff376
3 changed files with 140 additions and 39 deletions

134
README.md
View File

@@ -1,15 +1,16 @@
# Alpine-based Zero-OS Initramfs
Modern Alpine Linux based approach to building Zero-OS initramfs, replacing the complex build-from-source system with Alpine packages.
Modern Alpine Linux based approach to building Zero-OS initramfs with source compilation for Zero-OS components and Alpine packages for system tools.
## Architecture Overview
This system uses:
- **Alpine Linux LTS** as base system (latest packages, no building from source)
- **Alpine kernel** with embedded essential storage/ethernet modules
- **GitHub components**: zinit, core-x, seektime, rfs (only custom builds needed)
- **Same init flow**: tmpfs copy approach for compatibility
- **Alpine packages**: All standard tools (busybox, openssh, btrfs-progs, etc.)
- **Alpine Linux 3.22** as base system with latest packages
- **Git submodules** for Zero-OS components (zinit, mycelium, rfs, corex)
- **Source compilation** for Zero-OS components (Rust/Go with musl static linking)
- **Alpine packages** for system tools (busybox, openssh, btrfs-progs, etc.)
- **Smart caching** with Docker layers and volumes
- **Same init flow** as original Zero-OS
## Directory Structure
@@ -17,51 +18,108 @@ This system uses:
alpine-initramfs/
├── build/ # Build orchestration
│ ├── Dockerfile.alpine # Alpine build environment
│ ├── docker-compose.yml # Build orchestration
│ └── build-initramfs.sh # Main build script
│ ├── Dockerfile.cached # Multi-stage cached build
│ └── docker-compose.yml # Build orchestration with caching
├── components/ # Git submodules
│ ├── zinit/ # Init system (Rust)
│ ├── mycelium/ # Networking layer (Rust)
│ ├── rfs/ # Filesystem (Rust)
│ └── corex/ # Container control (static binary)
├── configs/ # Configuration files
│ ├── packages.txt # Alpine packages to install
│ ├── kernel-modules.txt # Essential modules to embed
│ ├── init # Custom init script (Alpine → zinit)
── zinit/ # Zinit service configs (from ../config/etc/zinit/)
├── scripts/ # Build helper scripts
│ ├── fetch-github.sh # Download zinit, core-x, seektime, rfs
│ ├── install-packages.sh # Install Alpine packages to initramfs
│ ├── packages-alpine.txt # Alpine packages to install
│ ├── kernel-version # Kernel version to build
│ ├── kernel-config-generic # Kernel configuration
── init # Init script (Alpine → zinit)
│ └── zinit/ # Zinit service configurations
├── scripts/ # Build scripts
│ ├── build-initramfs.sh # Main build orchestrator
│ ├── compile-components.sh # Compile Zero-OS components from source
│ ├── install-packages.sh # Install Alpine packages
│ ├── setup-initramfs.sh # Create initramfs structure
── build-kernel.sh # Build kernel with embedded initramfs
── build-kernel.sh # Build kernel with embedded initramfs
│ ├── build-smart.sh # Smart build with caching
│ ├── setup-submodules.sh # Initialize git submodules
│ └── cleanup.sh # Clean build artifacts
├── output/ # Build artifacts
│ ├── initramfs.cpio.xz # Generated initramfs
│ ├── vmlinuz.efi # Final bootable kernel
── modules/ # Kernel modules
── initramfs.cpio.xz # Generated initramfs
│ └── version.txt # Build information
└── docs/ # Documentation
├── PACKAGES.md # Package mapping (old build → Alpine)
├── MODULES.md # Kernel modules reference
└── BUILD.md # Build process guide
├── BUILD.md # Build process guide
├── OVERVIEW.md # Architecture overview
└── *.md # Additional documentation
```
## Build Flow
1. **Alpine Environment**: Setup Alpine LTS build container
2. **Package Installation**: Install all required Alpine packages
3. **GitHub Components**: Fetch zinit, core-x, seektime, rfs from releases
4. **Initramfs Assembly**: Create filesystem structure with same tmpfs approach
5. **Kernel Build**: Compile Alpine kernel with embedded essential modules
6. **Output**: Generate bootable vmlinuz.efi with embedded initramfs
1. **Environment Setup**: Alpine Docker container with Rust, Go, and build tools
2. **Component Compilation**: Build zinit, mycelium, rfs from source (musl static)
3. **Package Installation**: Install Alpine packages to initramfs root
4. **Initramfs Assembly**: Create filesystem structure with compiled binaries
5. **Kernel Build**: Compile kernel with embedded initramfs
6. **Output**: Generate bootable vmlinuz.efi
## Quick Start
### Full Build
```bash
cd alpine-initramfs/build
docker compose build
docker compose run --rm builder
# Output: ../output/vmlinuz.efi
# Build everything
./build.sh
# Or with Docker Compose
cd build/
docker-compose up
```
## Key Advantages
### Development Build
```bash
cd build/
# Interactive development shell
docker-compose run dev-shell
-**No source compilation** - Use Alpine's maintained packages
-**Latest versions** - Always current with Alpine package updates
-**Faster builds** - Minutes vs hours
-**Smaller footprint** - Alpine's minimal design
-**Same functionality** - Identical init flow and service management
- ✅ **Better maintenance** - Package updates handled by Alpine team
# Build specific component (e.g., mycelium)
cd /build/components/mycelium/myceliumd
cargo build --release --target x86_64-unknown-linux-musl
```
### Smart Build (with caching)
```bash
cd build/
docker-compose run builder # Uses build-smart.sh automatically
```
## Key Features
-**Source compilation** - Latest Zero-OS components with static linking
-**Smart caching** - Docker layer and volume caching for fast rebuilds
-**Alpine packages** - System tools from Alpine repositories
-**Multi-stage builds** - Efficient Docker builds with minimal layers
-**Development mode** - Interactive shell for component development
-**Same functionality** - 100% compatible with original Zero-OS
-**Modern toolchain** - Rust 1.x, Go latest, Alpine 3.22
## Development
### Building Individual Components
```bash
cd build/
docker-compose run dev-shell
# Inside container:
cd /build/components/mycelium/myceliumd && cargo build --release --target x86_64-unknown-linux-musl
cd /build/components/zinit && cargo build --release --target x86_64-unknown-linux-musl
cd /build/components/rfs && cargo build --release --target x86_64-unknown-linux-musl
```
### Cleanup
```bash
# Clean all build artifacts
./scripts/cleanup.sh
```
### Cache Management
Smart build uses Docker volumes for caching:
- `build-cache`: Build state markers
- `source-cache`: Downloaded sources
- `kernel-cache`: Kernel builds
- `target-cache`: Rust build artifacts