5 # Email : hayao@fascode.net
7 # (c) 2019-2021 Fascode Network.
11 aur_username="aurbuild"
13 trap 'exit 1' 1 2 3 15
15 # Delete file only if file exists
16 # remove <file1> <file2> ...
21 for _file in "${_list[@]}"; do
22 if [[ -f ${_file} ]]; then
24 elif [[ -d ${_file} ]]; then
27 echo "${_file} was deleted."
32 function user_check () {
33 if [[ $(getent passwd $1 > /dev/null ; printf $?) = 0 ]]; then
43 # Creating a aur user.
44 if [[ $(user_check ${aur_username}) = false ]]; then
45 useradd -m -d "/aurbuild_temp" "${aur_username}"
47 mkdir -p "/aurbuild_temp"
48 chmod 700 -R "/aurbuild_temp"
49 chown ${aur_username}:${aur_username} -R "/aurbuild_temp"
50 echo "${aur_username} ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/aurbuild"
54 #eval $(cat "/etc/systemd/system/pacman-init.service" | grep 'ExecStart' | sed "s|ExecStart=||g" )
55 ls "/usr/share/pacman/keyrings/"*".gpg" | sed "s|.gpg||g" | xargs | pacman-key --populate
57 # Un comment the mirror list.
58 sed -i "s/#Server/Server/g" "/etc/pacman.d/mirrorlist"
61 if pacman -Qq yay 1> /dev/null 2>&1; then
66 pacman -Syy --noconfirm
67 pacman --noconfirm -S --asdeps --needed go --config "/etc/alteriso-pacman.conf"
68 sudo -u aurbuild git clone "https://aur.archlinux.org/yay.git" "/tmp/yay"
70 sudo -u aurbuild makepkg --ignorearch --clean --cleanbuild --force --skippgpcheck --noconfirm
71 pacman --noconfirm --config "/etc/alteriso-pacman.conf" -U $(makepkg --packagelist)
78 if ! type -p yay > /dev/null; then
79 echo "Failed to install yay"
85 chmod +s /usr/bin/sudo
86 for _pkg in "${@}"; do
87 yes | sudo -u aurbuild \
100 --config "/etc/alteriso-pacman.conf" \
101 --cachedir "/var/cache/pacman/pkg/" \
104 if ! pacman -Qq "${_pkg}" > /dev/null 2>&1; then
105 echo -e "\n[aur.sh] Failed to install ${_pkg}\n"
110 yay -Sccc --noconfirm --config "/etc/alteriso-pacman.conf"
112 # remove user and file
114 remove /aurbuild_temp
115 remove /etc/sudoers.d/aurbuild
116 remove "/etc/alteriso-pacman.conf"
117 remove "/var/cache/pacman/pkg/"