Is there a way to automate pkg install with yay and pacman
Hey everyone, I have a list of pkgs I want to install. Some of them are from the aur other are official. also I noticed even though yay doesn't require sudo, it does ask for password during installation. I'd apprecihate if someone can recommend a way I can automate the process of installing packages without worrying about is it part of aur or official
Thanks
About this post
- Posted
- Archived
- Score
- 0 · 50% up
- Kind
- Text
- ID
- jtaraj
17 comments
yay's --sudoloop option will solve one of the issues you're talking about here. Just enter your password once and come back when it's all done. Add --noconfirm for even more automated decision making.
Deleted before we saved it.
Create a user. Add that user to sudoers with NOPASSWD. Run yay as that user. It will not ask for password that. Creating and adding a user can be automated too.
Oh that very new. Seems logical. Can you please elaborate more or kindly add steps so I can translate to a script. It would help a lot
Like this https://gitlab.com/Kamcuk/yio/-/blob/master/pkg/archlinux/docker-setup.sh#L17 Also see setups for other archlinux docker builders there are many on docker hub. To set password from script use
chpasswd. And i am updating first keyrings then the rest, otherwise after a looong time there were problems with keys, like so https://gitlab.com/Kamcuk/kamilscripts/-/blob/master/etc/bash.d/archlinux.sh#L30 .yay can install packages from both the Official repos and the AUR. Just give put all the packages you want to install at the end of
yay -SNice, can I pass sudo with it ? since almost all the time it ask for pass .
echo password | sudo -S yay -S pkg?Dont use yay with sudo. it explicitly tells you not to, as it can cause problems since yay uses fakeroot to limit security flaws.
You would probably have to read the manual entry for it to figure out how to automate it, im not sure on that as I prefer knowing what my packages are doing.
to do that, use
man yayIs
sudo sh -c "cmd1 && cmd2 && cmd3 && ..."an option?If yay asks for a password and times out, you can either re-run the yay command and the package will be reinstalled, or run
pacman -U <package>on the package that was compiled but not installed because of the timeout.Since I'm creating an automation script this won't be an option. But thanks for your thoughts.
Deleted before we saved it.
Just wanted to add that one the developers of yay abandoned it in favor of paru, which does the same thing but in Rust instead of Go.
EDIT: One of the developers.
One of the developers abandoned it. There's still an active developer working on yay.
Edited, thanks.
Deleted before we saved it.