52 lines
1.9 KiB
Bash
Executable File
52 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
# build-root.sh — build a full Keru rootfs from scratch using Kama
|
|
#
|
|
# Given a make.conf (or the profile default), this:
|
|
# 1. bootstraps the minimal toolchain (host -> cross/self)
|
|
# 2. installs the base package set into $ROOT via Kama
|
|
# 3. applies profile choices (init, libc, fs, net)
|
|
#
|
|
# This is the "fully from scratch" path — no binary base image is seeded.
|
|
|
|
set -eu
|
|
. "$(dirname "$0")/common.sh"
|
|
|
|
# the target rootfs is the "$ROOT" from make.conf; default it here
|
|
ROOT="${ROOT:-/tmp/keru/root}"
|
|
MAKE_CONF="${1:-$KERU_ROOT/profile/make.conf}"
|
|
[ -f "$MAKE_CONF" ] || die "make.conf not found: $MAKE_CONF"
|
|
. "$MAKE_CONF"
|
|
ROOT="${ROOT:-/tmp/keru/root}"
|
|
|
|
KAMA="$KAMA_DIR/kama"
|
|
[ -x "$KAMA" ] || die "kama not found at $KAMA (clone the kama repo or set KAMA_DIR)"
|
|
[ -d "$PKGS_DIR" ] || die "kama-packages repo not found at $PKGS_DIR (set PKGS_DIR)"
|
|
|
|
info "building Keru rootfs into $ROOT"
|
|
info "profile: init=$INIT libc=$LIBC fs=$TARGET_FS kernel=$KERNEL sudo=$SUDO"
|
|
|
|
# stage 0 — bootstrap toolchain
|
|
info "stage 0: bootstrap toolchain (gcc binutils glibc/musl)"
|
|
for p in binutils gcc "$LIBC" toolchain; do
|
|
PKGDIR="$PKGS_DIR" "$KAMA" make "$p" || die "toolchain stage failed on $p"
|
|
done
|
|
|
|
# stage 1 — base system
|
|
info "stage 1: base system"
|
|
for p in "${BASE_PACKAGES[@]}"; do
|
|
PKGDIR="$PKGS_DIR" "$KAMA" make "$p" || die "base stage failed on $p"
|
|
done
|
|
|
|
# stage 2 — kernel + init + swappables
|
|
info "stage 2: kernel + init + sudo + net"
|
|
PKGDIR="$PKGS_DIR" "$KAMA" make "$KERNEL" || die "kernel build failed"
|
|
PKGDIR="$PKGS_DIR" "$KAMA" make "$INIT" || die "init build failed ($INIT)"
|
|
PKGDIR="$PKGS_DIR" "$KAMA" make "$SUDO" || die "sudo tool build failed ($SUDO)"
|
|
PKGDIR="$PKGS_DIR" "$KAMA" make "$NET" || die "net tool build failed ($NET)"
|
|
|
|
# stage 3 — fstab/mkinitramfs for the chosen FS
|
|
info "stage 3: finalize $TARGET_FS root"
|
|
ROOT="$ROOT" "$KERU_ROOT/scripts/mkfs-root.sh" "$TARGET_FS"
|
|
|
|
info "rootfs ready: $ROOT"
|