bigboy-alma-deploy/scripts/package-recon.sh

110 lines
No EOL
5.1 KiB
Bash

#!/usr/bin/env bash
# Built standing on the shoulders of billions of dwarves
# Created by John A. Hoeven with the ethical assistance of Claude AI
# Licence: The Unlicense — https://unlicense.org
# ---------------------------------------------------------------------------
# package-recon.sh
# Version: v0.0.1 | Status: DEVELOPMENT
# Role: Recon
# ---------------------------------------------------------------------------
# Purpose: Confirm exact package names, availability, and repo source for
# every package still needed across Phase 2-5, directly on
# BigBoy's live, network-connected AlmaLinux 10.2 install. Run
# this before finalizing task docs — don't assume package names
# carried over from RHEL8/9 conventions or Debian/Ubuntu habits
# still hold here.
# Target: BigBoy — AlmaLinux 10.2
# Entry: ./package-recon.sh
# Depends: dnf (present by default)
# Note: Read-only — this script only searches/queries, never installs
# anything. Safe to run anytime.
# ---------------------------------------------------------------------------
# No 'set -e' — every operation checked and logged explicitly (CE OS standard §1.8).
# ── Configuration ────────────────────────────────────────────────────────
LOG_DIR="${HOME}/.local/logs/package-recon"
LOG_FILE="${LOG_DIR}/recon-$(date '+%Y-%m-%d_%H%M%S').log"
mkdir -p "${LOG_DIR}"
# ── Logging ──────────────────────────────────────────────────────────────
_log() {
local level="${1}"
local msg="${2}"
local ts
ts="$(date '+%Y-%m-%d %H:%M:%S')"
printf '[%s] [%s] %s\n' "${ts}" "${level}" "${msg}" | tee -a "${LOG_FILE}"
}
log_info() { _log "INFO " "${1}"; }
log_warn() { _log "WARN " "${1}" >&2; }
# ── Candidate package list ────────────────────────────────────────────────
#
# Each entry: primary candidate name, plus space-separated alternates to
# also check in case naming differs from what's assumed. Grouped by which
# phase actually needs them.
declare -A PACKAGES=(
# Outstanding from Phase 1 (kickstart dropped vim due to the
# cross-repo vim-data mismatch during install — needs installing now
# that we're on a live, in-sync network rather than the installer's
# constrained resolver)
["vim (Phase 1 leftover)"]="vim vim-enhanced vim-common vim-minimal"
# Phase 4 — NVIDIA driver, precompiled open-kmod path
["nvidia bootstrap release pkg"]="almalinux-release-nvidia-driver"
["nvidia driver cuda userspace"]="nvidia-driver-cuda"
["nvidia open kernel module"]="nvidia-open-kmod"
["nvidia full driver (optional, if wanted beyond compute-only)"]="nvidia-open"
# Phase 5 — llama.cpp build requirements
["cmake (missing from kickstart pkg list)"]="cmake"
["libcurl dev headers (for llama-server -hf flag)"]="libcurl-devel curl-devel"
["openssl dev headers"]="openssl-devel"
["nginx reverse proxy"]="nginx"
# Sanity checks — already expected present via kickstart, confirm not
# assumed
["git (kickstart already lists this)"]="git"
["gcc (kickstart already lists this)"]="gcc"
["make (kickstart already lists this)"]="make"
["btrfs-progs (kickstart already lists this, Phase 3 needs it)"]="btrfs-progs"
["chrony/NTP (Phase 2 base-system check)"]="chrony"
)
# ── Recon ────────────────────────────────────────────────────────────────
log_info "Starting package recon on $(hostname), $(date -Iseconds)"
log_info "Enabled repos:"
dnf repolist enabled 2>&1 | tee -a "${LOG_FILE}"
log_info ""
for label in "${!PACKAGES[@]}"; do
log_info "── ${label} ──"
for candidate in ${PACKAGES[${label}]}; do
log_info " Checking: ${candidate}"
# dnf info tells us: does it exist, which repo, what version,
# and whether it's already installed
result="$(dnf info "${candidate}" 2>&1)"
if echo "${result}" | grep -q "^Name"; then
repo_line="$(echo "${result}" | grep -E "^Repo" | head -1)"
version_line="$(echo "${result}" | grep -E "^Version" | head -1)"
installed="$(echo "${result}" | grep -qi "Installed Packages" && echo "ALREADY INSTALLED" || echo "available, not installed")"
log_info " FOUND — ${version_line} | ${repo_line} | ${installed}"
else
log_warn " NOT FOUND — ${candidate} is not available from any enabled repo"
fi
done
log_info ""
done
log_info "Recon complete. Full log: ${LOG_FILE}"
log_info ""
log_info "Review any 'NOT FOUND' lines above before finalizing task docs —"
log_info "those need either a different package name, a different repo"
log_info "enabled, or a different install approach entirely."