@@ -14,31 +14,38 @@ pacman_args=()
1414failedpkg=()
1515remove_list=()
1616aur_helper_depends=(" go" )
17- aur_helper=" yay"
17+ aur_helper_command=" yay"
18+ aur_helper_package=" yay"
19+ aur_helper_args=()
20+ pkglist=()
1821
1922trap ' exit 1' 1 2 3 15
2023
2124_help () {
22- echo " usage ${0} [option] [package1] [package2 ] ..."
25+ echo " usage ${0} [option] [aur helper args ] ..."
2326 echo
24- echo " Install aur packages with ${aur_helper } "
27+ echo " Install aur packages with ${aur_helper_command } "
2528 echo
2629 echo " General options:"
2730 echo " -a [command] Set the command of aur helper"
28- echo " -p [pkg1,pkg2...] Set the oackage of the depends of aur helper"
29- echo " -d Enable pacman debug message"
31+ echo " -c Enable pacman debug message"
32+ echo " -e [pkg] Set the package name of aur helper"
33+ echo " -d [pkg1,pkg2...] Set the oackage of the depends of aur helper"
34+ echo " -p [pkg1,pkg2...] Set the AUR package to install"
3035 echo " -u [user] Set the user name to build packages"
3136 echo " -x Enable bash debug message"
3237 echo " -h This help message"
3338}
3439
35- while getopts " a:p:du :xh" arg; do
40+ while getopts " a:cd:e:p:u :xh" arg; do
3641 case " ${arg} " in
3742 a) aur_helper=" ${OPTARG} " ;;
38- d) pacman_debug=true ;;
43+ c) pacman_debug=true ;;
44+ e) aur_helper_command=" ${OPTARG} " ;;
45+ p) readarray -t pkglist < <( tr " ," " \n" <<< " ${OPTARG}" ) ;;
46+ d) readarray -t aur_helper_depends < <( tr " ," " \n" <<< " ${OPTARG}" ) ;;
3947 u) aur_username=" ${OPTARG} " ;;
4048 x) set -xv ;;
41- p) readarray -t aur_helper_depends < <( tr " ," " \n" <<< " ${OPTARG}" ) ;;
4249 h)
4350 _help
4451 exit 0
@@ -51,6 +58,8 @@ while getopts "a:p:du:xh" arg; do
5158done
5259
5360shift " $(( OPTIND - 1 )) "
61+ aur_helper_args=(" ${@ } " )
62+ eval set -- " ${pkglist[@]} "
5463
5564# Show message when file is removed
5665# remove <file> <file> ...
@@ -88,7 +97,7 @@ if [[ "${pacman_debug}" = true ]]; then
8897fi
8998
9099# Install
91- if ! pacman -Qq " ${aur_helper } " 1> /dev/null 2>&1 ; then
100+ if ! pacman -Qq " ${aur_helper_package } " 1> /dev/null 2>&1 ; then
92101 # Update database
93102 _oldpwd=" $( pwd) "
94103 pacman -Syy " ${pacman_args[@]} "
@@ -98,13 +107,13 @@ if ! pacman -Qq "${aur_helper}" 1> /dev/null 2>&1; then
98107 if ! pacman -Qq " ${_pkg} " > /dev/null 2>&1 | grep -q " ${_pkg} " ; then
99108 # --asdepsをつけているのでaur.shで削除される --neededをつけているので明示的にインストールされている場合削除されない
100109 pacman -S --asdeps --needed " ${pacman_args[@]} " " ${_pkg} "
101- remove_list+=(" ${_pkg} " )
110+ # remove_list+=("${_pkg}")
102111 fi
103112 done
104113
105114 # Build
106- sudo -u " ${aur_username} " git clone " https://aur.archlinux.org/${aur_helper } .git" " /tmp/${aur_helper } "
107- cd " /tmp/${aur_helper } "
115+ sudo -u " ${aur_username} " git clone " https://aur.archlinux.org/${aur_helper_package } .git" " /tmp/${aur_helper_package } "
116+ cd " /tmp/${aur_helper_package } "
108117 sudo -u " ${aur_username} " makepkg --ignorearch --clean --cleanbuild --force --skippgpcheck --noconfirm
109118
110119 # Install
@@ -114,31 +123,22 @@ if ! pacman -Qq "${aur_helper}" 1> /dev/null 2>&1; then
114123
115124 # Remove debtis
116125 cd ..
117- remove " /tmp/${aur_helper } "
126+ remove " /tmp/${aur_helper_package } "
118127 cd " ${_oldpwd} "
119128fi
120129
121- if ! type -p " ${aur_helper } " > /dev/null; then
122- echo " Failed to install ${aur_helper } "
130+ if ! type -p " ${aur_helper_command } " > /dev/null; then
131+ echo " Failed to install ${aur_helper_package } "
123132 exit 1
124133fi
125134
126135installpkg (){
127136 yes | sudo -u " ${aur_username} " \
128- " ${aur_helper} " -Sy \
129- --mflags " -AcC" \
130- --aur \
131- --nocleanmenu \
132- --nodiffmenu \
133- --noeditmenu \
134- --noupgrademenu \
135- --noprovides \
136- --removemake \
137- --useask \
137+ " ${aur_helper_command} " -Sy \
138138 --color always \
139- --mflags " --skippgpcheck" \
140- " ${pacman_args[@]} " \
141139 --cachedir " /var/cache/pacman/pkg/" \
140+ " ${pacman_args[@]} " \
141+ " ${aur_helper_args[@]} " \
142142 " ${@ } " || true
143143}
144144
@@ -169,7 +169,7 @@ readarray -t -O "${#remove_list[@]}" remove_list < <(pacman -Qttdq)
169169(( "${# remove_list[@]} " != 0 )) && pacman -Rsnc " ${remove_list[@]} " " ${pacman_args[@]} "
170170
171171# Clean up
172- " ${aur_helper } " -Sccc " ${pacman_args[@]} "
172+ " ${aur_helper_command } " -Sccc " ${pacman_args[@]} "
173173
174174# remove user and file
175175userdel " ${aur_username} "
0 commit comments