#!/bin/bash # --- 1. Safety Check: Ensure NOT running as root --- if [ "$EUID" -eq 0 ]; then echo -e "\033[0;31mERROR: Do not run this script as root (sudo).\033[0m" echo "The build process uses 'fakeroot' which conflicts with actual root privileges." echo "Please run as a normal user: ./install_howdy_safe.sh" exit 1 fi # --- Configuration --- PKG_DLIB="python-dlib" PKG_HOWDY="howdy-git" AUR_HELPER="yay" # --- Colors --- GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' echo -e "${GREEN}=== Howdy 3 Installer (Fakeroot/Non-Root Safe Mode) ===${NC}" # --- 2. Install Dependencies (Requires sudo here only) --- echo -e "${YELLOW}[1/5] Requesting sudo for dependency installation...${NC}" sudo pacman -Sy --needed base-devel git v4l-utils python-pip || exit 1 # --- 3. Install AUR Helper (if missing) --- if ! command -v $AUR_HELPER &> /dev/null; then echo -e "${YELLOW}[2/5] Installing yay...${NC}" rm -rf /tmp/yay-bin git clone https://aur.archlinux.org/yay-bin.git /tmp/yay-bin cd /tmp/yay-bin # makepkg handles fakeroot automatically here makepkg -si --noconfirm cd ~ fi # --- 4. Build python-dlib (No CUDA, using proper fakeroot) --- echo -e "${YELLOW}[3/5] Building python-dlib (CPU Only)...${NC}" rm -rf /tmp/$PKG_DLIB git clone https://aur.archlinux.org/$PKG_DLIB.git /tmp/$PKG_DLIB cd /tmp/$PKG_DLIB # Patch for No-CUDA sed -i 's/_build_cuda=1/_build_cuda=0/g' PKGBUILD if ! grep -q "_build_cuda=0" PKGBUILD; then sed -i '2i_build_cuda=0' PKGBUILD fi # MAKEPKG MAGIC: # -s: Sync deps (uses sudo internally just for installs) # -i: Install (uses sudo internally just for installs) # The build itself happens in a fakeroot environment automatically. makepkg -si --noconfirm # --- 5. Install Howdy --- echo -e "${YELLOW}[4/5] Installing Howdy...${NC}" $AUR_HELPER -S --needed $PKG_HOWDY # --- 6. Final Config --- echo -e "${YELLOW}[5/5] Setup Complete.${NC}" echo "Run 'sudo howdy config' and 'sudo howdy add' to finish." echo "Don't forget to edit /etc/pam.d/sudo with: auth sufficient pam_howdy.so"