vitorpy's Dotfiles
at main 69 lines 1.8 kB view raw
1#!/bin/bash 2set -e 3 4PACKAGES_FILE="$HOME/.config/arch/packages.txt" 5 6echo "==> Installing Arch packages from $PACKAGES_FILE" 7 8# Install yay (AUR helper) if not present 9if ! command -v yay &> /dev/null; then 10 echo "==> Installing yay AUR helper..." 11 sudo pacman -S --needed base-devel git 12 git clone https://aur.archlinux.org/yay.git /tmp/yay 13 cd /tmp/yay && makepkg -si --noconfirm 14 cd - 15fi 16 17# Parse package list and install 18pacman_packages=() 19aur_packages=() 20flatpak_packages=() 21 22while IFS='|' read -r package source; do 23 # Skip comments and empty lines 24 [[ "$package" =~ ^#.*$ ]] && continue 25 [[ -z "$package" ]] && continue 26 27 # Trim whitespace 28 package=$(echo "$package" | xargs) 29 source=$(echo "$source" | xargs) 30 31 case "$source" in 32 pacman) 33 pacman_packages+=("$package") 34 ;; 35 aur) 36 aur_packages+=("$package") 37 ;; 38 flatpak) 39 flatpak_packages+=("$package") 40 ;; 41 esac 42done < "$PACKAGES_FILE" 43 44# Install pacman packages 45if [ ${#pacman_packages[@]} -gt 0 ]; then 46 echo "==> Installing pacman packages: ${pacman_packages[*]}" 47 sudo pacman -S --needed --noconfirm "${pacman_packages[@]}" 48fi 49 50# Install AUR packages 51if [ ${#aur_packages[@]} -gt 0 ]; then 52 echo "==> Installing AUR packages: ${aur_packages[*]}" 53 yay -S --needed --noconfirm "${aur_packages[@]}" 54fi 55 56# Install flatpak packages 57if [ ${#flatpak_packages[@]} -gt 0 ]; then 58 if ! command -v flatpak &> /dev/null; then 59 echo "==> Installing flatpak..." 60 sudo pacman -S --needed --noconfirm flatpak 61 fi 62 63 echo "==> Installing flatpak packages: ${flatpak_packages[*]}" 64 for pkg in "${flatpak_packages[@]}"; do 65 flatpak install -y flathub "$pkg" 66 done 67fi 68 69echo "==> All packages installed successfully!"