Skip to content

Commit 75ee5da

Browse files
committed
[update] : If the installation fails, try again
1 parent 0081048 commit 75ee5da

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

system/aur.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set -e -u
1111
aur_username="aurbuild"
1212
pacman_debug=false
1313
pacman_args=()
14+
failedpkg=()
1415

1516
trap 'exit 1' 1 2 3 15
1617

@@ -102,12 +103,7 @@ if ! type -p yay > /dev/null; then
102103
exit 1
103104
fi
104105

105-
106-
# Build and install
107-
chmod +s /usr/bin/sudo
108-
for _pkg in "${@}"; do
109-
pacman -Qq "${_pkg}" > /dev/null 2>&1 && continue
110-
106+
installpkg(){
111107
yes | sudo -u "${aur_username}" \
112108
yay -Sy \
113109
--mflags "-AcC" \
@@ -123,8 +119,25 @@ for _pkg in "${@}"; do
123119
--mflags "--skippgpcheck" \
124120
"${pacman_args[@]}" \
125121
--cachedir "/var/cache/pacman/pkg/" \
126-
"${_pkg}"
122+
"${@}"
123+
}
124+
127125

126+
# Build and install
127+
chmod +s /usr/bin/sudo
128+
for _pkg in "${@}"; do
129+
pacman -Qq "${_pkg}" > /dev/null 2>&1 && continue
130+
installpkg "${_pkg}"
131+
132+
if ! pacman -Qq "${_pkg}" > /dev/null 2>&1; then
133+
echo -e "\n[aur.sh] Failed to install ${_pkg}\n"
134+
failedpkg+=("${_pkg}")
135+
fi
136+
done
137+
138+
# Reinstall failed package
139+
for _pkg in "${@}"; do
140+
installpkg "${_pkg}"
128141
if ! pacman -Qq "${_pkg}" > /dev/null 2>&1; then
129142
echo -e "\n[aur.sh] Failed to install ${_pkg}\n"
130143
exit 1

0 commit comments

Comments
 (0)