#!/usr/bin/env bash # ============================================================================ # build-end4-deps.sh — Build ALL end-4 (illogical-impulse) AUR dependencies # # This script builds every AUR package required by the end-4 dots-hyprland # dotfiles that is NOT in the official Arch repos or chaotic-aur. # # It uses --noconfirm throughout so the entire run is non-interactive. # # Usage: # ./localrepo/build-end4-deps.sh # build all # ./localrepo/build-end4-deps.sh --quick # skip large AUR pkgs (use existing) # # After building, run ./localrepo/update.sh to refresh the repo database. # ============================================================================ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_DIR="${SCRIPT_DIR}" WORK_DIR=$(mktemp -d /tmp/end4-build.XXXXXX) SKIP_LARGE=false for arg in "$@"; do case "$arg" in --quick) SKIP_LARGE=true ;; esac done # ── colours ────────────────────────────────────────────────────────────────── RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; CYAN='\033[0;36m'; NC='\033[0m' info() { echo -e "${CYAN}[INFO]${NC} $*"; } ok() { echo -e "${GREEN}[OK]${NC} $*"; } warn() { echo -e "${YELLOW}[WARN]${NC} $*"; } fail() { echo -e "${RED}[FAIL]${NC} $*"; } # ── helper: build a single AUR package ─────────────────────────────────────── build_aur_pkg() { local pkg="$1" local src_url="https://aur.archlinux.org/cgit/aur.git/snapshot/${pkg}.tar.gz" local pkg_dir="${WORK_DIR}/${pkg}" info "Building AUR package: ${pkg}" mkdir -p "${pkg_dir}" if ! curl -fsSL "${src_url}" | tar xz -C "${WORK_DIR}"; then fail "Failed to download ${pkg}"; return 1 fi if ! (cd "${pkg_dir}" && makepkg -sfi --noconfirm --cleanbuild); then fail "Failed to build ${pkg}"; return 1 fi # Move built packages to localrepo find "${pkg_dir}" -maxdepth 1 -name '*.pkg.tar.zst' -exec mv -f {} "${REPO_DIR}/" \; ok "Built: ${pkg}" return 0 } # ── helper: build from a local PKGBUILD directory ──────────────────────────── build_local_pkgbuild() { local pkg_dir="$1" local pkg_name pkg_name=$(basename "${pkg_dir}") if ls "${REPO_DIR}"/illogical-impulse-"${pkg_name}"-*.pkg.tar.zst 1>/dev/null 2>&1; then info "Package already exists in localrepo, skipping: ${pkg_name}" return 0 fi info "Building local PKGBUILD: ${pkg_name}" if ! (cd "${pkg_dir}" && makepkg -sfi --noconfirm --cleanbuild); then fail "Failed to build ${pkg_name}"; return 1 fi find "${pkg_dir}" -maxdepth 1 -name '*.pkg.tar.zst' -exec mv -f {} "${REPO_DIR}/" \; ok "Built: ${pkg_name}" return 0 } # ============================================================================ # 1. Build end-4 metapackages from local PKGBUILDs # ============================================================================ info "═══ Step 1: Building end-4 metapackages ═══" for pkg_dir in "${SCRIPT_DIR}"/end4-pkgbuilds/*/; do build_local_pkgbuild "${pkg_dir}" || true done # ============================================================================ # 2. Build AUR dependencies required by end-4 # ============================================================================ info "═══ Step 2: Building AUR dependencies ═══" # ── Theming & appearance ───────────────────────────────────────────────────── AUR_THEMING=( adw-gtk-theme-git darkly-bin ttf-material-symbols-variable-git ttf-readex-pro ttf-rubik-vf ttf-twemoji otf-space-grotesk kde-material-you-colors-git ) # ── end-4 specific / build-from-source packages ────────────────────────────── # matugen — material you color generation tool # speech-dispatcher — may need AUR build on some setups AUR_TOOLS=( matugen python-rpypostprocess tts ) # ── Packages not in any standard repo ──────────────────────────────────────── AUR_MISSING=( asciinema-agg davs2 syncthingtray-qt6 varia woeusb-ng ttf-ms-fonts ) # ── Large / complex builds (skipped with --quick) ──────────────────────────── AUR_LARGE=( # quickshell is already built from end4-pkgbuilds above ) # ── Run builds ─────────────────────────────────────────────────────────────── FAILED=() for pkg in "${AUR_THEMING[@]}" "${AUR_TOOLS[@]}" "${AUR_MISSING[@]}"; do build_aur_pkg "${pkg}" || FAILED+=("${pkg}") done if [[ "${SKIP_LARGE}" == false ]]; then for pkg in "${AUR_LARGE[@]}"; do build_aur_pkg "${pkg}" || FAILED+=("${pkg}") done fi # ============================================================================ # 3. Build end-4 setup script dependencies (from dots-hyprland/setup) # ============================================================================ info "═══ Step 3: Building end-4 setup helper packages ═══" DOTS_DIR="${HOME}/dots-hyprland" if [[ -d "${DOTS_DIR}" ]]; then # Build any remaining metapackages from the dist-arch directory for pkg_dir in "${DOTS_DIR}"/sdata/dist-arch/illogical-impulse-*/; do pkg_name=$(basename "${pkg_dir}") # Skip the ones we already built above if ls "${REPO_DIR}"/illogical-impulse-"${pkg_name#illogical-impulse-}"-*.pkg.tar.zst 1>/dev/null 2>&1; then info "Already built, skipping: ${pkg_name}" continue fi # Only build packages that have a PKGBUILD (metapackages with depends=()) if [[ -f "${pkg_dir}/PKGBUILD" ]]; then info "Building from dots-hyprland: ${pkg_name}" (cd "${pkg_dir}" && makepkg -sfi --noconfirm --cleanbuild) || { warn "Failed to build ${pkg_name} from dots-hyprland, skipping" continue } find "${pkg_dir}" -maxdepth 1 -name '*.pkg.tar.zst' -exec mv -f {} "${REPO_DIR}/" \; ok "Built: ${pkg_name}" fi done else warn "dots-hyprland not found at ${DOTS_DIR}, skipping dist-arch builds" fi # ============================================================================ # 4. Refresh local repository database # ============================================================================ info "═══ Step 4: Refreshing local repository database ═══" bash "${SCRIPT_DIR}/update.sh" # ============================================================================ # 5. Cleanup & summary # ============================================================================ rm -rf "${WORK_DIR}" echo "" echo "═══════════════════════════════════════════════════════════════" if [[ ${#FAILED[@]} -gt 0 ]]; then warn "Build completed with ${#FAILED[@]} failures:" for f in "${FAILED[@]}"; do echo " ✗ ${f}" done echo "" echo "The following packages were built successfully into localrepo:" else ok "All builds completed successfully!" fi echo "" echo "Packages in localrepo:" ls -1 "${REPO_DIR}"/*.pkg.tar.zst 2>/dev/null | while read -r p; do echo " ✓ $(basename "${p}")" done echo "═══════════════════════════════════════════════════════════════"