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"
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
# common.sh — shared helpers for Keru scripts (installer, iso, kama)
|
||||
PREFIX="\033[1;35m[ keru ]\033[0m"
|
||||
msg() { printf '%b %s\n' "$PREFIX" "$*"; }
|
||||
info() { printf '%b \033[1;34m==>\033[0m %s\n' "$PREFIX" "$*"; }
|
||||
warn() { printf '%b \033[1;33mwarning:\033[0m %s\n' "$PREFIX" "$*"; }
|
||||
die() { printf '%b \033[1;31merror:\033[0m %s\n' "$PREFIX" "$*" >&2; exit 1; }
|
||||
|
||||
banner() { printf '\033[1;36m%s\033[0m\n' "------------------------------------------"; printf '\033[1;36m %s\033[0m\n' "$*"; printf '\033[1;36m%s\033[0m\n' "------------------------------------------"; }
|
||||
|
||||
have() { command -v "$1" >/dev/null 2>&1; }
|
||||
|
||||
# KeruOS source root (this repo)
|
||||
KERU_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
|
||||
# Sibling repos (clone next to this one by default)
|
||||
# kama -> the package manager
|
||||
# kama-packages -> the recipe repository
|
||||
# Override with env if you keep them somewhere else.
|
||||
KAMA_DIR="${KAMA_DIR:-$(dirname "$KERU_ROOT")/kama}"
|
||||
PKGS_DIR="${PKGS_DIR:-$(dirname "$KERU_ROOT")/kama-packages}"
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env sh
|
||||
# mkfs-root.sh — format/seed the target root for the chosen filesystem
|
||||
# Usage: mkfs-root.sh [ext4|btrfs|xfs|zfs|f2fs]
|
||||
. "$(dirname "$0")/common.sh"
|
||||
|
||||
FS="${1:-ext4}"
|
||||
|
||||
# Keru builds to a plain directory staged by Kama; the filesystem choice is
|
||||
# applied at install/flash time. This script writes the fstab + initramfs
|
||||
# config so the built system knows how to mount its own root.
|
||||
ROOT="${ROOT:-/tmp/keru/root}"
|
||||
case "$FS" in
|
||||
ext4) FSTYPE=ext4; MK="mkfs.ext4" ;;
|
||||
btrfs) FSTYPE=btrfs; MK="mkfs.btrfs" ;;
|
||||
xfs) FSTYPE=xfs; MK="mkfs.xfs" ;;
|
||||
zfs) FSTYPE=zfs; MK="zpool" ;;
|
||||
f2fs) FSTYPE=f2fs; MK="mkfs.f2fs" ;;
|
||||
*) die "unsupported filesystem: $FS" ;;
|
||||
esac
|
||||
info "target filesystem: $FSTYPE ($MK)"
|
||||
|
||||
# drop fstab template
|
||||
mkdir -p "$ROOT/etc"
|
||||
cat > "$ROOT/etc/fstab" <<EOF
|
||||
# Keru generated fstab — root filesystem: $FSTYPE
|
||||
# /dev/ROOT / $FSTYPE rw,relatime 0 1
|
||||
EOF
|
||||
info "wrote fstab for $FSTYPE"
|
||||
Reference in New Issue
Block a user