Initial scaffold
This commit is contained in:
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/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"
|
||||
|
||||
# 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"
|
||||
PKGDIR="$PKGS_DIR" "$KAMA" make "$KERNEL" || die "kernel build failed"
|
||||
PKGDIR="$PKGS_DIR" "$KAMA" make "$INIT" || die "init build failed ($INIT)"
|
||||
|
||||
# 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"
|
||||
Reference in New Issue
Block a user