From 7793b4db04d327e82f0c91bdad843af33cf068ed Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Sat, 3 May 2025 01:31:26 +0800 Subject: [PATCH] fix linux install: arch linux install yay in root user --- ...un_onchange_before_linux-install-packages.sh.tmpl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl b/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl index 5e5d84e..0108693 100644 --- a/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl +++ b/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl @@ -160,7 +160,17 @@ if ! is_installed "yay"; then fi {{ else -}} if ! command -v yay &> /dev/null; then - git clone https://aur.archlinux.org/yay-bin.git && cd yay-bin && makepkg -si + if [ "$EUID" -ne 0 ]; then + mkdir -p /tmp/yay-build + useradd -m -G wheel builder && passwd -d builder + chown -R builder:builder /tmp/yay-build + echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers + su - builder -c "git clone https://aur.archlinux.org/yay-bin.git /tmp/yay-build/yay" + su - builder -c "cd /tmp/yay-build/yay && makepkg -si --noconfirm" + rm -rf /tmp/yay-build + else + git clone https://aur.archlinux.org/yay-bin.git && cd yay-bin && makepkg -si + fi fi {{ end -}}