From 19c2abc117368aa99a45a2a50508f6c2b23f7df1 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 17 Oct 2025 23:01:34 +0200 Subject: [PATCH] Add automatic aur_builder and yay setup for Arch-based systems - Added aur_builder_setup target to Makefile - Automatically detects Arch/Manjaro via pacman - Creates aur_builder user and group with sudoers permissions - Installs yay if not already present - Skips AUR setup gracefully on non-Arch systems https://chatgpt.com/share/68f2a922-63f8-800f-a6d6-18b8d06b7139 --- Makefile | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1a7e9bf..ea4a6fa 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: install setup uninstall +.PHONY: install setup uninstall aur_builder_setup setup: install @python3 main.py install @@ -23,8 +23,33 @@ install: rc_line='if [ -d "$${HOME}/.venvs/pkgmgr" ]; then . "$${HOME}/.venvs/pkgmgr/bin/activate"; echo "Global Python virtual environment '\''~/.venvs/pkgmgr'\'' activated."; fi'; \ grep -qxF "$${rc_line}" $$rc || echo "$${rc_line}" >> $$rc; \ done + @echo "Arch/Manjaro detection and optional AUR setup..." + @if command -v pacman >/dev/null 2>&1; then \ + $(MAKE) aur_builder_setup; \ + else \ + echo "Not Arch-based (no pacman). Skipping aur_builder/yay setup."; \ + fi @echo "Installation complete. Please restart your shell (or 'exec bash' or 'exec zsh') for the changes to take effect." +# Only runs on Arch/Manjaro +aur_builder_setup: + @echo "Setting up aur_builder and yay (Arch/Manjaro)..." + @sudo pacman -Syu --noconfirm + @sudo pacman -S --needed --noconfirm base-devel git sudo + @# group & user + @if ! getent group aur_builder >/dev/null; then sudo groupadd -r aur_builder; fi + @if ! id -u aur_builder >/dev/null 2>&1; then sudo useradd -m -r -g aur_builder -s /bin/bash aur_builder; fi + @# sudoers rule for pacman + @echo '%aur_builder ALL=(ALL) NOPASSWD: /usr/bin/pacman' | sudo tee /etc/sudoers.d/aur_builder >/dev/null + @sudo chmod 0440 /etc/sudoers.d/aur_builder + @# yay install (if missing) + @if ! sudo -u aur_builder bash -lc 'command -v yay >/dev/null'; then \ + sudo -u aur_builder bash -lc 'cd ~ && rm -rf yay && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si --noconfirm'; \ + else \ + echo "yay already installed."; \ + fi + @echo "aur_builder/yay setup complete." + uninstall: @echo "Removing global user virtual environment if it exists..." @rm -rf ~/.venvs/pkgmgr