Files
os-build/scripts/check-host-deps.sh
Blake Ridgway 90f1e4cc77 fix: find build tools in /usr/sbin regardless of PATH
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".
2026-08-21 14:02:41 -05:00

74 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────────────────────
# Arcline OS — host build-dependency check
#
# scripts/check-host-deps.sh → report what's missing
# scripts/check-host-deps.sh --install → apt-get install what's missing
#
# Builds run debootstrap (rootfs), copy overlays (standard tools), and produce
# a hybrid ISO via grub-mkrescue + mksquashfs.
# ─────────────────────────────────────────────────────────────────────────────
set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
NEEDED=(
"debootstrap|debootstrap"
"grub-mkrescue|grub2-common"
"mksquashfs|squashfs-tools"
"xorriso|xorriso"
"cpio|cpio"
"bash|bash"
# disk images / installer
"sgdisk|gdisk"
"partprobe|parted"
"rsync|rsync"
"mkfs.vfat|dosfstools"
"qemu-img|qemu-utils"
"losetup|util-linux"
# vendor packaging + secure boot
"unzip|unzip"
"dpkg-deb|dpkg"
"openssl|openssl"
"sbsign|sbsigntool"
"sbverify|sbsigntool"
)
MISSING=()
for entry in "${NEEDED[@]}"; do
bin="${entry%%|*}"; pkg="${entry##*|}"
if ! command -v "$bin" >/dev/null 2>&1; then
# Distinguish "package not installed" from "installed but not on PATH".
if command -v dpkg-query >/dev/null 2>&1 && \
dpkg-query -W -f='${Status}' "$pkg" 2>/dev/null | grep -q "install ok installed"; then
warn "missing: $bin — package $pkg IS installed but '$bin' is not on PATH (check for /usr/sbin or /sbin in PATH)"
MISSING+=("$pkg") # still require a working resolution before building
else
MISSING+=("$pkg")
warn "missing: $bin (package: $pkg)"
fi
fi
done
if [[ ${#MISSING[@]} -eq 0 ]]; then
log "all host build dependencies present ✓"
exit 0
fi
if [[ "${1:-}" == "--install" ]]; then
log "installing: ${MISSING[*]}"
if [[ $EUID -ne 0 ]] && command -v sudo >/dev/null; then
sudo apt-get update
sudo apt-get install -y "${MISSING[@]}"
else
apt-get update
apt-get install -y "${MISSING[@]}"
fi
log "dependencies installed ✓"
else
echo
echo "Run the following to install them:"
echo " sudo apt-get install -y ${MISSING[*]}"
echo "or: scripts/check-host-deps.sh --install"
exit 1
fi