Is there no way to do an unattended install, like with sudo pacman -S - < pkglist.txt? With that example you just input your password once and leave the machine to do its thing. With all aur-helpers that I have tried, if you feed a file with a list of packages to the helper, they abort the whole operation after the first build that fails — and if there are more than a few packages in the list, some of them will fail to build, no question about it.
Obviously, I want such packages to be skipped, so that I can manually deal with them later, but the operation to proceed for the rest of the packages down the list. I have tried making a script that reads lines from a given file in a loop and feeds them as arguments for an aur helper. Then another problem arises: in that case I need to manually input my password for each instance of the helper.
And of course I can’t just run that whole script as root because makepkg can’t be run as root.
So is there no way to do an unattended installation of a list of AUR packages, where you can launch the script and come back several hours later to find everything (except the few packages that failed to build and that you can sort out manually) installed?
No, I wrote just what I wanted to write. It’s an illustration of the effect that I want: launch the command once, input the password once, come back later to find everything installed. Pacman does it for packages from repositories, I want to find some way to do the same thing for AUR packages, but so far nothing is working.
The above pamac command does what you’d expect - build packages - when build is done for all packages - install all …
Using makepkg in a loop and point to a specific folder - then you have to provide the admin pass to pacman in the end or you could use suid to give the script permission to run pacman as root
pseudo script
x = list
for x in list
git clone aur/x.git
cd x
makepkg --output /y
cd ..
cd /y
pacman -U *.pkg.tar.zst
In the end I did it this way: made a script that iterates in a loop over the list of packages stored in a file and build + installs them using yay. And to make the installation unattended I used a combination of --sudo CLI switch of yay that allows you to set an arbitrary command to fullfill the role of sudo, and a script I wrote specifically for this task.
So, the installation script:
#!/bin/bash
# Path to the text file containing AUR package names, one per line
input_file="$HOME/backup/pkg_frgn_list.txt"
# Create log file
timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
log_file="$XDG_RUNTIME_DIR/aur_install_${timestamp}.log"
touch $log_file
# Print the log file name to the console
echo "Log file: $log_file"
# Open the log file in a separate urxvt window with tail
urxvt -fn "xft:size=14" -letsp -4 -bg black -fg grey -e sh -c "tail -n +1 -f '$log_file'" &
# Function to log messages to the file
log() {
echo "$1" >> "$log_file"
}
#############################################
# Function to install packages
install_package() {
package="$1"
if yay -Q "$package" >/dev/null 2>&1; then
log "$package is already installed."
else
log "Installing $package..."
# use $HOME/bin/sudo_yay.sh to grant sudo privileges in unattended mode
yay -S --sudo "$HOME/bin/sudo_yay.sh" --noconfirm --needed "$package"
if [ $? -ne 0 ]; then
log "Installation of $package failed!"
else
log "$package installed successfully."
fi
fi
}
# Loop through each line in the file
while IFS= read -r package; do
if [ -z "$package" ]; then
log "Skipping empty line"
elif [[ $package == \#* ]]; then
log "Skipping commented line: $package"
else
install_package "$package"
fi
done < "$input_file"
And the script to grant you the permission to install those packages without the need to type your password for each instance of yay:
#!/bin/sh
password="" # your password goes here just before the installation and you should delete it afterwards
echo "$password" | exec /usr/bin/sudo -S -p 'auto-password
' "$@"
Before anyone says anything: I know myself that it’s not secure, but it’s the only way to do a completely unattended installation of a big list of AUR packages. Besides, like I pointed out in the comment, the actual password goes there just before the installation process is launched and is supposed to be deleted after that.