Skip to content

Commit 83e6fdd

Browse files
committed
[update] : Finally remove unnecessary packages
1 parent ec21122 commit 83e6fdd

1 file changed

Lines changed: 33 additions & 14 deletions

File tree

system/aur.sh

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ aur_username="aurbuild"
1212
pacman_debug=false
1313
pacman_args=()
1414
failedpkg=()
15+
remove_list=()
16+
yay_depends=("go")
1517

1618
trap 'exit 1' 1 2 3 15
1719

@@ -82,20 +84,32 @@ fi
8284

8385
# Install yay
8486
if ! pacman -Qq yay 1> /dev/null 2>&1; then
85-
(
86-
_oldpwd="$(pwd)"
87-
pacman -Syy "${pacman_args[@]}"
88-
pacman -S --asdeps --needed "${pacman_args[@]}" go
89-
sudo -u "${aur_username}" git clone "https://aur.archlinux.org/yay.git" "/tmp/yay"
90-
cd "/tmp/yay"
91-
sudo -u "${aur_username}" makepkg --ignorearch --clean --cleanbuild --force --skippgpcheck --noconfirm
92-
for _pkg in $(sudo -u "${aur_username}" makepkg --packagelist); do
93-
pacman "${pacman_args[@]}" -U "${_pkg}"
94-
done
95-
cd ..
96-
remove "/tmp/yay"
97-
cd "${_oldpwd}"
98-
)
87+
# Update database
88+
_oldpwd="$(pwd)"
89+
pacman -Syy "${pacman_args[@]}"
90+
91+
# Install depends
92+
for _pkg in "${yay_depends[@]}"; do
93+
if ! pacman -Qq "${_pkg}" | grep -q "${_pkg}"; then
94+
pacman -S --asdeps --needed "${pacman_args[@]}" "${_pkg}"
95+
remove_list+=("${_pkg}")
96+
fi
97+
done
98+
99+
# Build yay
100+
sudo -u "${aur_username}" git clone "https://aur.archlinux.org/yay.git" "/tmp/yay"
101+
cd "/tmp/yay"
102+
sudo -u "${aur_username}" makepkg --ignorearch --clean --cleanbuild --force --skippgpcheck --noconfirm
103+
104+
# Install yay
105+
for _pkg in $(sudo -u "${aur_username}" makepkg --packagelist); do
106+
pacman "${pacman_args[@]}" -U "${_pkg}"
107+
done
108+
109+
# Remove debtis
110+
cd ..
111+
remove "/tmp/yay"
112+
cd "${_oldpwd}"
99113
fi
100114

101115
if ! type -p yay > /dev/null; then
@@ -144,6 +158,11 @@ for _pkg in "${failedpkg[@]}"; do
144158
fi
145159
done
146160

161+
# Remove packages
162+
readarray -t -O "${#remove_list[@]}" remove_list < <(pacman -Qttdq)
163+
pacman -Rsnc "${pacman_args[@]}" "${remove_list[@]}"
164+
165+
# Clean up
147166
yay -Sccc "${pacman_args[@]}"
148167

149168
# remove user and file

0 commit comments

Comments
 (0)