diff --git a/dist/pacman.sh b/dist/pacman.sh index 21020f5..9433ca8 100755 --- a/dist/pacman.sh +++ b/dist/pacman.sh @@ -28,7 +28,20 @@ if command -v paru &> /dev/null; then else git clone https://aur.archlinux.org/paru.git cd paru - makepkg -si --noconfirm + + # Check if $USER is root and if so add a temporary non-root user for building paru + if [ "$EUID" -eq 0 ]; then + echo "Building paru as root is not allowed. Creating a temporary user for building..." + TEMP_USER="tempuser" + useradd -m "$TEMP_USER" + chown -R "$TEMP_USER":"$TEMP_USER" . + su -u "$TEMP_USER" -c "makepkg -si --noconfirm" + userdel -r "$TEMP_USER" + else + echo "Building paru as user $USER..." + makepkg -si --noconfirm + fi + cd .. rm -rf paru fi