- iso/build.sh: Debian/Ubuntu host builder using debootstrap + xorriso Bootstraps Debian bookworm, compiles OrionOS in chroot, produces bootable hybrid ISO with GRUB (BIOS + EFI), auto-login root on tty1 - iso/build-arch.sh: Arch Linux host builder using mkarchiso Compiles OrionOS, installs into archiso profile, runs mkarchiso - iso/README.md: instructions for all three paths (Docker/Debian/Arch) including dd and Ventoy USB flashing - Makefile: iso target auto-detects available tool (docker/debootstrap/mkarchiso)
170 lines
6.2 KiB
Bash
Executable File
170 lines
6.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# OrionOS ISO builder (Debian-based live system)
|
|
# Run as root from the repo root: sudo bash iso/build.sh
|
|
set -euo pipefail
|
|
|
|
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
|
WORK="/tmp/orionos-build"
|
|
OUT="$REPO/iso/output"
|
|
FS="$WORK/rootfs"
|
|
ISO_STAGE="$WORK/iso"
|
|
|
|
echo "==> OrionOS ISO builder"
|
|
echo " repo: $REPO"
|
|
echo " work: $WORK"
|
|
echo " output: $OUT"
|
|
|
|
mkdir -p "$FS" "$ISO_STAGE/live" "$ISO_STAGE/boot/grub" "$OUT"
|
|
|
|
# ── 1. Bootstrap minimal Debian base ────────────────────────────────────
|
|
echo "==> [1/7] Bootstrapping Debian bookworm..."
|
|
if [[ ! -f "$FS/bin/bash" ]]; then
|
|
debootstrap --arch=amd64 \
|
|
--include=linux-image-amd64,live-boot,systemd-sysv,sudo,bash,\
|
|
coreutils,util-linux,procps,grep,gawk,sed,tar,gzip,less,vim,git,\
|
|
xorg,xinit,xterm,feh,picom,alsa-utils,libx11-6,libxft2,libxfixes3,\
|
|
libxext6,libpng16-16,dbus,libpam0g,fontconfig,fonts-dejavu,\
|
|
fonts-noto,libdbus-1-3,notify-send,bash-completion,network-manager \
|
|
bookworm "$FS" 2>&1 | grep -E '(I:|W:|E:|error|warn)' || true
|
|
else
|
|
echo " (rootfs already exists, skipping bootstrap)"
|
|
fi
|
|
|
|
# ── 2. Compile OrionOS inside chroot ────────────────────────────────────
|
|
echo "==> [2/7] Compiling OrionOS components..."
|
|
mkdir -p "$FS/build"
|
|
cp -r "$REPO"/{wm,deskbar,launcher,orionnotify,orionlock,orionshot,orionclip,orionpkg,themes} "$FS/build/" 2>/dev/null || true
|
|
|
|
chroot "$FS" /bin/bash -c '
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
apt-get install -y --no-install-recommends \
|
|
gcc make pkg-config \
|
|
libx11-dev libxft-dev libxfixes-dev libxext-dev \
|
|
libpng-dev libdbus-1-dev libpam0g-dev \
|
|
2>&1 | tail -3
|
|
|
|
cd /build
|
|
for dir in wm deskbar launcher orionnotify orionlock orionshot orionclip orionpkg; do
|
|
if [[ -d "$dir" ]]; then
|
|
echo " building $dir..."
|
|
make -C "$dir" 2>&1 | tail -2 || echo " WARNING: $dir build failed"
|
|
fi
|
|
done
|
|
' 2>&1
|
|
|
|
# ── 3. Install OrionOS binaries ──────────────────────────────────────────
|
|
echo "==> [3/7] Installing OrionOS binaries..."
|
|
chroot "$FS" /bin/bash -c '
|
|
set -e
|
|
install_if() { [[ -f "/build/$1" ]] && install -Dm755 "/build/$1" "/usr/local/bin/$2"; }
|
|
install_if wm/orionwm orionwm
|
|
install_if deskbar/oriondeskbar oriondeskbar
|
|
install_if launcher/orionlauncher orionlauncher
|
|
install_if orionnotify/orionnotify orionnotify
|
|
install_if orionlock/orionlock orionlock
|
|
install_if orionshot/orionshot orionshot
|
|
install_if orionclip/orionclip orionclip
|
|
install_if orionpkg/orionpkg orionpkg
|
|
install -Dm755 /build/themes/orionwallpaper /usr/local/bin/orionwallpaper
|
|
mkdir -p /usr/share/themes
|
|
cp -r /build/themes/OrionOS /usr/share/themes/ 2>/dev/null || true
|
|
mkdir -p /etc/orionos
|
|
cp /build/themes/picom.conf /etc/orionos/ 2>/dev/null || true
|
|
mkdir -p /usr/share/orionos/wallpapers
|
|
bash /build/themes/wallpapers/generate-default.sh 2>/dev/null || true
|
|
cp -f /build/themes/wallpapers/orionos-default.png /usr/share/orionos/wallpapers/ 2>/dev/null || true
|
|
' 2>&1
|
|
|
|
# ── 4. Configure live session ────────────────────────────────────────────
|
|
echo "==> [4/7] Configuring live session..."
|
|
|
|
cat > "$FS/etc/orionos/xinitrc" <<'XINITRC'
|
|
#!/bin/bash
|
|
picom --config /etc/orionos/picom.conf &
|
|
orionwallpaper &
|
|
orionnotify &
|
|
orionclip &
|
|
oriondeskbar &
|
|
exec orionwm
|
|
XINITRC
|
|
chmod 755 "$FS/etc/orionos/xinitrc"
|
|
|
|
cat > "$FS/root/.xinitrc" <<'XINIRC'
|
|
#!/bin/bash
|
|
source /etc/orionos/xinitrc
|
|
XINIRC
|
|
chmod 755 "$FS/root/.xinitrc"
|
|
|
|
# Auto-login and startx on tty1
|
|
mkdir -p "$FS/etc/systemd/system/getty@tty1.service.d"
|
|
cat > "$FS/etc/systemd/system/getty@tty1.service.d/autologin.conf" <<'UNIT'
|
|
[Service]
|
|
ExecStart=
|
|
ExecStart=-/sbin/agetty --autologin root --noclear %I $TERM
|
|
UNIT
|
|
|
|
cat > "$FS/root/.bash_profile" <<'PROFILE'
|
|
[[ -z "$DISPLAY" && "$XDG_VTNR" == 1 ]] && exec startx
|
|
PROFILE
|
|
|
|
# hostname
|
|
echo "orionos" > "$FS/etc/hostname"
|
|
|
|
# Clean up build artifacts to save space
|
|
chroot "$FS" /bin/bash -c '
|
|
apt-get remove -y gcc make pkg-config \
|
|
libx11-dev libxft-dev libxfixes-dev libxext-dev \
|
|
libpng-dev libdbus-1-dev libpam0g-dev 2>&1 | tail -2 || true
|
|
apt-get autoremove -y 2>&1 | tail -2 || true
|
|
apt-get clean
|
|
rm -rf /build /var/cache/apt /tmp/*
|
|
' 2>&1
|
|
|
|
# ── 5. Build squashfs ────────────────────────────────────────────────────
|
|
echo "==> [5/7] Building squashfs filesystem..."
|
|
mksquashfs "$FS" "$ISO_STAGE/live/filesystem.squashfs" \
|
|
-comp zstd -Xcompression-level 6 \
|
|
-e boot -noappend 2>&1 | tail -3
|
|
|
|
# ── 6. Copy kernel + initrd ──────────────────────────────────────────────
|
|
echo "==> [6/7] Copying kernel and initrd..."
|
|
VMLINUZ="$(ls "$FS/boot/vmlinuz-"* 2>/dev/null | head -1)"
|
|
INITRD="$(ls "$FS/boot/initrd.img-"* 2>/dev/null | head -1)"
|
|
|
|
if [[ -z "$VMLINUZ" || -z "$INITRD" ]]; then
|
|
echo "ERROR: kernel or initrd not found in $FS/boot/"
|
|
ls "$FS/boot/" || true
|
|
exit 1
|
|
fi
|
|
|
|
cp "$VMLINUZ" "$ISO_STAGE/boot/vmlinuz"
|
|
cp "$INITRD" "$ISO_STAGE/boot/initrd.img"
|
|
|
|
# ── 7. GRUB bootloader + ISO ─────────────────────────────────────────────
|
|
echo "==> [7/7] Building bootable ISO with GRUB..."
|
|
|
|
cat > "$ISO_STAGE/boot/grub/grub.cfg" <<'GRUB'
|
|
set default=0
|
|
set timeout=5
|
|
|
|
menuentry "OrionOS Live" {
|
|
linux /boot/vmlinuz boot=live quiet splash
|
|
initrd /boot/initrd.img
|
|
}
|
|
|
|
menuentry "OrionOS Live (safe mode)" {
|
|
linux /boot/vmlinuz boot=live nomodeset
|
|
initrd /boot/initrd.img
|
|
}
|
|
GRUB
|
|
|
|
ISOFILE="$OUT/OrionOS-$(date +%Y%m%d).iso"
|
|
|
|
grub-mkrescue -o "$ISOFILE" "$ISO_STAGE" \
|
|
--modules="normal iso9660 linux ext2 squash4 biosdisk" \
|
|
2>&1 | grep -v "^$" | tail -10
|
|
|
|
SIZE="$(du -sh "$ISOFILE" | cut -f1)"
|
|
echo ""
|
|
echo "✓ ISO built: $ISOFILE ($SIZE)"
|