5 # Email : hayao@fascode.net
7 # (c) 2019-2021 Fascode Network.
11 aur_username="aurbuild"
13 trap 'exit 1' 1 2 3 15
15 # Show message when file is removed
16 # remove <file> <file> ...
19 for _file in "${@}"; do echo "Removing ${_file}" >&2; rm -rf "${_file}"; done
23 function user_check () {
24 if [[ ! -v 1 ]]; then return 2; fi
25 getent passwd "${1}" > /dev/null
28 # Creating a aur user.
29 if user_check "${aur_username}"; then
30 useradd -m -d "/aurbuild_temp" "${aur_username}"
32 mkdir -p "/aurbuild_temp"
33 chmod 700 -R "/aurbuild_temp"
34 chown ${aur_username}:${aur_username} -R "/aurbuild_temp"
35 echo "${aur_username} ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/aurbuild"
41 # Un comment the mirror list.
42 #sed -i "s/#Server/Server/g" "/etc/pacman.d/mirrorlist"
45 if ! pacman -Qq yay 1> /dev/null 2>&1; then
48 pacman -Syy --noconfirm --config "/etc/alteriso-pacman.conf"
49 pacman --noconfirm -S --asdeps --needed go --config "/etc/alteriso-pacman.conf"
50 sudo -u "${aur_username}" git clone "https://aur.archlinux.org/yay.git" "/tmp/yay"
52 sudo -u "${aur_username}" makepkg --ignorearch --clean --cleanbuild --force --skippgpcheck --noconfirm
53 pacman --noconfirm --config "/etc/alteriso-pacman.conf" -U $(sudo -u "${aur_username}" makepkg --packagelist)
60 if ! type -p yay > /dev/null; then
61 echo "Failed to install yay"
67 chmod +s /usr/bin/sudo
68 for _pkg in "${@}"; do
69 yes | sudo -u "${aur_username}" \
82 --mflags "--skippgpcheck" \
83 --config "/etc/alteriso-pacman.conf" \
84 --cachedir "/var/cache/pacman/pkg/" \
87 if ! pacman -Qq "${_pkg}" > /dev/null 2>&1; then
88 echo -e "\n[aur.sh] Failed to install ${_pkg}\n"
93 yay -Sccc --noconfirm --config "/etc/alteriso-pacman.conf"
95 # remove user and file
96 userdel "${aur_username}"
98 remove /etc/sudoers.d/aurbuild
99 remove "/etc/alteriso-pacman.conf"
100 remove "/var/cache/pacman/pkg/"