OSDN Git Service

fixed pacman key
[alterlinux/alterlinux.git] / system / aur.sh
1 #!/usr/bin/env bash
2 #
3 # Yamada Hayao
4 # Twitter: @Hayao0819
5 # Email  : hayao@fascode.net
6 #
7 # (c) 2019-2020 Fascode Network.
8 #
9 set -e -u
10
11 # Delete file only if file exists
12 # remove <file1> <file2> ...
13 function remove () {
14     local _list
15     local _file
16     _list=($(echo "$@"))
17     for _file in "${_list[@]}"; do
18         if [[ -f ${_file} ]]; then
19             rm -f "${_file}"
20         elif [[ -d ${_file} ]]; then
21             rm -rf "${_file}"
22         fi
23         echo "${_file} was deleted."
24     done
25 }
26
27 # user_check <name>
28 function user_check () {
29     if [[ $(getent passwd $1 > /dev/null ; printf $?) = 0 ]]; then
30         if [[ -z $1 ]]; then
31             echo -n "false"
32         fi
33         echo -n "true"
34     else
35         echo -n "false"
36     fi
37 }
38
39 # Creating a aur user.
40 if [[ $(user_check aurbuild) = false ]]; then
41     useradd -m -d "/aurbuild_temp" aurbuild
42 fi
43 mkdir -p "/aurbuild_temp"
44 chmod 700 -R "/aurbuild_temp"
45 chown aurbuild:aurbuild -R "/aurbuild_temp"
46 echo "aurbuild ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/aurbuild"
47
48
49 # Build and install
50 chmod +s /usr/bin/sudo
51 yes | sudo -u aurbuild yay -Sy  --nocleanmenu --nodiffmenu --noeditmenu --noupgrademenu --noprovides --removemake --config "/etc/alteriso-pacman.conf" ${*}
52
53
54 # remove user and file
55 userdel aurbuild
56 remove /aurbuild_temp
57 remove /etc/sudoers.d/aurbuild
58 remove "/etc/pacman.d/gnupg/"
59 remove "/etc/alteriso-pacman.conf"