Skip to content

Commit d48df4d

Browse files
committed
[update] : Fully customizable AUR helper
1 parent 9954a30 commit d48df4d

5 files changed

Lines changed: 80 additions & 35 deletions

File tree

build.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ prepare_build() {
382382
for_module load_config "${module_dir}/{}/config.any" "${module_dir}/{}/config.${arch}"
383383
msg_debug "Loaded modules: ${modules[*]}"
384384
! printf "%s\n" "${modules[@]}" | grep -x "share" >/dev/null 2>&1 && msg_warn "The share module is not loaded."
385+
! printf "%s\n" "${modules[@]}" | grep -x "base" >/dev/null 2>&1 && msg_error "The base module is not loaded." 1
385386

386387
# Set kernel
387388
[[ "${customized_kernel}" = false ]] && kernel="${defaultkernel}"
@@ -440,9 +441,8 @@ prepare_build() {
440441
pkglist_args+=("${modules[@]}")
441442

442443
# Set argument of aur.sh and pkgbuild.sh
443-
makepkg_script_args+=("-a" "${aur_helper}" "-p" "$(printf "%s\n" "${aur_helper_depends[@]}" | tr "\n" ",")" )
444444
[[ "${bash_debug}" = true ]] && makepkg_script_args+=("-x")
445-
[[ "${pacman_debug}" = true ]] && makepkg_script_args+=("-d")
445+
[[ "${pacman_debug}" = true ]] && makepkg_script_args+=("-c")
446446

447447
return 0
448448
}
@@ -525,6 +525,12 @@ make_packages_repo() {
525525
make_packages_aur() {
526526
readarray -t _pkglist_aur < <("${tools_dir}/pkglist.sh" --aur "${pkglist_args[@]}")
527527
_pkglist_aur=("${_pkglist_aur[@]}" "${norepopkg[@]}")
528+
_aursh_args=(
529+
"-a" "${aur_helper_command}" -e "${aur_helper_package}"
530+
"-d" "$(printf "%s\n" "${aur_helper_depends[@]}" | tr "\n" ",")"
531+
"-p" "$(printf "%s\n" "${_pkglist_aur[@]}" | tr "\n" ",")"
532+
"${makepkg_script_args[@]}" -- "${aur_helper_args[@]}"
533+
)
528534

529535
# Create a list of packages to be finally installed as packages.list directly under the working directory.
530536
echo -e "\n# AUR packages.\n#\n" >> "${build_dir}/packages.list"
@@ -535,7 +541,7 @@ make_packages_aur() {
535541
_pacstrap --asdeps --needed "${aur_helper_depend[@]}"
536542

537543
# Run aur script
538-
_run_with_pacmanconf _chroot_run "bash" "/root/aur.sh" -a "${aur_helper}" "${makepkg_script_args[@]}" "${_pkglist_aur[@]}"
544+
_run_with_pacmanconf _chroot_run "bash" "/root/aur.sh" "${_aursh_args[@]}"
539545

540546
# Remove script
541547
remove "${airootfs_dir}/root/aur.sh"

default.conf

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,21 @@ norescue_entry=false
134134
#modules=("share")
135135

136136
# AUR Helper config
137-
aur_helper="yay"
137+
aur_helper_command="yay"
138+
aur_helper_package="yay"
138139
aur_helper_depends=("go")
140+
aur_helper_args=(
141+
--useask
142+
--mflags "-AcC"
143+
--aur
144+
--nocleanmenu
145+
--nodiffmenu
146+
--noeditmenu
147+
--noupgrademenu
148+
--noprovides
149+
--removemake
150+
--mflags "--skippgpcheck"
151+
)
139152

140153
#-- kernel config --#
141154
# Set the kernel that live session use.

modules/base/config.i686

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Yamada Hayao
4+
# Twitter: @Hayao0819
5+
# Email : hayao@fascode.net
6+
#
7+
# (c) 2019-2021 Fascode Network.
8+
#
9+
# Config files for all i686 channel
10+
#
11+
12+
aur_helper_command="pikaur"
13+
aur_helper_package="pikaur"
14+
aur_helper_depends=(
15+
'pyalpm'
16+
'git'
17+
'python-commonmark'
18+
'asp'
19+
)
20+
aur_helper_args=(
21+
#--useask
22+
--mflags "-AcC,--skippgpcheck"
23+
--aur
24+
--noedit
25+
--nodiff
26+
)

system/aur.sh

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,38 @@ pacman_args=()
1414
failedpkg=()
1515
remove_list=()
1616
aur_helper_depends=("go")
17-
aur_helper="yay"
17+
aur_helper_command="yay"
18+
aur_helper_package="yay"
19+
aur_helper_args=()
20+
pkglist=()
1821

1922
trap '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
5158
done
5259

5360
shift "$((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
8897
fi
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}"
119128
fi
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
124133
fi
125134

126135
installpkg(){
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
175175
userdel "${aur_username}"

system/pkgbuild.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ _help() {
1919
echo "Build and install PKGBUILD"
2020
echo
2121
echo " General options:"
22-
echo " -d Enable pacman debug message"
22+
echo " -c Enable pacman debug message"
2323
echo " -u [user] Set the user name to build packages"
2424
echo " -x Enable bash debug message"
2525
echo " -h This help message"
2626
}
2727

28-
while getopts "du:xh" arg; do
28+
while getopts "cu:xh" arg; do
2929
case "${arg}" in
30-
d) pacman_debug=true ;;
30+
c) pacman_debug=true ;;
3131
u) build_username="${OPTARG}" ;;
3232
x) set -xv ;;
3333
h)

0 commit comments

Comments
 (0)