Skip to content

Commit 97b614c

Browse files
committed
[update] : Made yay replaceable
1 parent 70b227e commit 97b614c

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

system/aur.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ pacman_debug=false
1313
pacman_args=()
1414
failedpkg=()
1515
remove_list=()
16-
yay_depends=("go")
16+
aur_helper_depends=("go")
17+
aur_helper="yay"
1718

1819
trap 'exit 1' 1 2 3 15
1920

2021
_help() {
2122
echo "usage ${0} [option]"
2223
echo
23-
echo "Install aur packages with yay"
24+
echo "Install aur packages with ${aur_helper}"
2425
echo
2526
echo " General options:"
2627
echo " -d Enable pacman debug message"
@@ -82,44 +83,44 @@ if [[ "${pacman_debug}" = true ]]; then
8283
pacman_args+=("--debug")
8384
fi
8485

85-
# Install yay
86-
if ! pacman -Qq yay 1> /dev/null 2>&1; then
86+
# Install
87+
if ! pacman -Qq "${aur_helper}" 1> /dev/null 2>&1; then
8788
# Update database
8889
_oldpwd="$(pwd)"
8990
pacman -Syy "${pacman_args[@]}"
9091

9192
# Install depends
92-
for _pkg in "${yay_depends[@]}"; do
93+
for _pkg in "${aur_helper_depends[@]}"; do
9394
if ! pacman -Qq "${_pkg}" > /dev/null 2>&1 | grep -q "${_pkg}"; then
9495
pacman -S --asdeps --needed "${pacman_args[@]}" "${_pkg}"
9596
remove_list+=("${_pkg}")
9697
fi
9798
done
9899

99-
# Build yay
100-
sudo -u "${aur_username}" git clone "https://aur.archlinux.org/yay.git" "/tmp/yay"
101-
cd "/tmp/yay"
100+
# Build
101+
sudo -u "${aur_username}" git clone "https://aur.archlinux.org/${aur_helper}.git" "/tmp/${aur_helper}"
102+
cd "/tmp/${aur_helper}"
102103
sudo -u "${aur_username}" makepkg --ignorearch --clean --cleanbuild --force --skippgpcheck --noconfirm
103104

104-
# Install yay
105+
# Install
105106
for _pkg in $(sudo -u "${aur_username}" makepkg --packagelist); do
106107
pacman "${pacman_args[@]}" -U "${_pkg}"
107108
done
108109

109110
# Remove debtis
110111
cd ..
111-
remove "/tmp/yay"
112+
remove "/tmp/${aur_helper}"
112113
cd "${_oldpwd}"
113114
fi
114115

115-
if ! type -p yay > /dev/null; then
116-
echo "Failed to install yay"
116+
if ! type -p "${aur_helper}" > /dev/null; then
117+
echo "Failed to install ${aur_helper}"
117118
exit 1
118119
fi
119120

120121
installpkg(){
121122
yes | sudo -u "${aur_username}" \
122-
yay -Sy \
123+
"${aur_helper}" -Sy \
123124
--mflags "-AcC" \
124125
--aur \
125126
--nocleanmenu \
@@ -163,7 +164,7 @@ readarray -t -O "${#remove_list[@]}" remove_list < <(pacman -Qttdq)
163164
(( "${#remove_list[@]}" != 0 )) && pacman -Rsnc "${remove_list[@]}" "${pacman_args[@]}"
164165

165166
# Clean up
166-
yay -Sccc "${pacman_args[@]}"
167+
"${aur_helper}" -Sccc "${pacman_args[@]}"
167168

168169
# remove user and file
169170
userdel "${aur_username}"

0 commit comments

Comments
 (0)