check-host-deps (and the build scripts themselves) reported build dependencies as missing even though the packages were installed. Several tools — debootstrap, sgdisk, losetup, partprobe, mkfs.vfat, grub-install — live in /usr/sbin or /sbin, which non-root users and CI runners often don't have on PATH, so `command -v` failed. - common.sh now prepends /usr/local/sbin:/usr/sbin:/sbin to PATH, so every script finds these tools no matter who invokes the build. - check-host-deps now distinguishes "package not installed" from "installed but not on PATH" via dpkg-query, so the message tells you exactly what is wrong instead of a misleading "missing package".
80 lines
4.2 KiB
Bash
Executable File
80 lines
4.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
# Arcline OS — shared build environment + helpers
|
|
#
|
|
# Every script under scripts/ sources this first. Values mirror versions.mk;
|
|
# when invoked through the Makefile the exported variables take precedence, so
|
|
# versions.mk stays the single source of truth.
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
set -euo pipefail
|
|
|
|
# ── identity ────────────────────────────────────────────────────────────────
|
|
: "${DISTRO_NAME:=Arcline OS}"
|
|
: "${DISTRO_ID:=arclineos}"
|
|
: "${VERSION:=0.1.0}"
|
|
: "${RELEASE_NAME:=arclines}"
|
|
: "${DEBIAN_SUITE:=bookworm}"
|
|
: "${DEBIAN_MIRROR:=http://deb.debian.org/debian}"
|
|
: "${SECURITY_MIRROR:=http://security.debian.org/debian-security}"
|
|
: "${ARCH:=amd64}"
|
|
: "${KERNEL_PACKAGE:=linux-image-amd64}"
|
|
: "${KERNEL_VERSION:=6.1}"
|
|
|
|
# Toolchain policy for image builds:
|
|
# auto (default) install the Arcline tools if build/debs/*.deb exist,
|
|
# otherwise build without them (with a warning)
|
|
# skip never install the tools, even if debs are present
|
|
# require fail the build if no toolchain debs are available
|
|
: "${ARCLINE_TOOLCHAIN:=auto}"
|
|
|
|
# ── paths (relative to the repo root) ───────────────────────────────────────
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
: "${BUILD_DIR:=$ROOT/build}"
|
|
: "${ROOTFS_DIR:=$BUILD_DIR/rootfs}"
|
|
: "${IMAGE_DIR:=$BUILD_DIR/iso}"
|
|
: "${DEB_DIR:=$BUILD_DIR/debs}"
|
|
: "${LOG_DIR:=$BUILD_DIR/logs}"
|
|
: "${ARTIFACT_DIR:=$BUILD_DIR/artifacts}"
|
|
|
|
# Valid edition names, mirroring versions.mk.
|
|
EDITIONS=(server workstation cloud)
|
|
|
|
# ── tool resolution ─────────────────────────────────────────────────────────
|
|
# Many build tools (debootstrap, sgdisk, losetup, partprobe, mkfs.vfat,
|
|
# grub-install, update-grub) live in /usr/sbin or /sbin. Non-root users and
|
|
# service accounts (CI runners, systemd timers) often omit those from PATH,
|
|
# which makes `command -v` report them as missing even though the packages are
|
|
# installed — and makes direct invocations fail. Prepend the sbin dirs so
|
|
# every script finds them regardless of who runs the build.
|
|
case ":$PATH:" in
|
|
*":/usr/local/sbin:"*|*":/usr/sbin:"*|*":/sbin:"*) ;;
|
|
*) export PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH" ;;
|
|
esac
|
|
|
|
# ── output helpers ──────────────────────────────────────────────────────────
|
|
log() { printf '\033[1;34m[arcline]\033[0m %s\n' "$*"; }
|
|
warn() { printf '\033[1;33m[arcline]\033[0m warning: %s\n' "$*" >&2; }
|
|
die() { printf '\033[1;31m[arcline]\033[0m error: %s\n' "$*" >&2; exit 1; }
|
|
|
|
# ── path helpers ────────────────────────────────────────────────────────────
|
|
edition_dir() { printf '%s/editions/%s' "$ROOT" "$1"; }
|
|
|
|
validate_edition() {
|
|
local e
|
|
for e in "${EDITIONS[@]}"; do [[ "$e" == "$1" ]] && return 0; done
|
|
die "unknown edition '$1' (expected: ${EDITIONS[*]})"
|
|
}
|
|
|
|
# ── privilege helper ────────────────────────────────────────────────────────
|
|
# Builds need root (debootstrap / chroot / mount). If we are not root and sudo
|
|
# is present, re-exec under sudo so the rest of the script can assume root.
|
|
require_root() {
|
|
if [[ $EUID -eq 0 ]]; then
|
|
return 0
|
|
elif command -v sudo >/dev/null; then
|
|
exec sudo -E "$0" "$@"
|
|
else
|
|
die "build requires root: run with sudo or as root (debootstrap + chroot need it)"
|
|
fi
|
|
}
|