Files
shellscripts/install-packages.sh
2026-02-26 16:56:50 +07:00

24 lines
686 B
Bash

#!/bin/bash
# Install all packages from this machine via pacman.
# --needed skips already-installed packages.
# Only leaf packages are listed; dependencies are pulled in automatically.
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PACKAGE_FILE="$SCRIPT_DIR/packages.txt"
if [[ ! -f "$PACKAGE_FILE" ]]; then
echo "Error: $PACKAGE_FILE not found"
exit 1
fi
# Read packages from file, skipping blank lines and comments
mapfile -t packages < <(grep -v '^\s*#' "$PACKAGE_FILE" | grep -v '^\s*$')
if [[ ${#packages[@]} -eq 0 ]]; then
echo "No packages found in $PACKAGE_FILE"
exit 1
fi
echo "Installing ${#packages[@]} packages..."
sudo pacman -S --needed "${packages[@]}"