Read hardware-specific packages properly for autoremoval
This commit is contained in:
@@ -1,20 +1,25 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o nounset
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
|
cpu="$(yaml2json < _machines/"$(hostname --short)".yml | jq --raw-output .cpu)"
|
||||||
|
gpu="$(yaml2json < _machines/"$(hostname --short)".yml | jq --raw-output .gpu)"
|
||||||
|
|
||||||
|
if [[ "${cpu}" ]] ; then
|
||||||
|
readarray -d $'\0' -t cpu_packages < <(<drivers.yml yaml2json | jq --raw-output0 ".cpu.${cpu}[]")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${gpu}" ]] ; then
|
||||||
|
readarray -d $'\0' -t gpu_packages < <(<drivers.yml yaml2json | jq --raw-output0 ".gpu.${gpu}[]")
|
||||||
|
fi
|
||||||
|
|
||||||
declare -a aurdeps=()
|
declare -a aurdeps=()
|
||||||
|
|
||||||
proctected=(
|
proctected=(
|
||||||
intel-ucode
|
|
||||||
amd-ucode
|
|
||||||
base
|
base
|
||||||
java-runtime-common
|
java-runtime-common
|
||||||
jdk17-openjdk
|
jdk17-openjdk
|
||||||
lib32-vulkan-radeon
|
|
||||||
vulkan-radeon
|
|
||||||
libva-mesa-driver
|
|
||||||
mesa-vdpau
|
|
||||||
lib32-mesa-vdpau
|
|
||||||
vulkan-mesa-layers
|
|
||||||
lib32-libva-mesa-driver
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for pkgbuild in pkgbuilds/*/PKGBUILD ; do
|
for pkgbuild in pkgbuilds/*/PKGBUILD ; do
|
||||||
@@ -22,12 +27,12 @@ for pkgbuild in pkgbuilds/*/PKGBUILD ; do
|
|||||||
aurdeps+=("${depends[@]%%[<=>]*}" "${makedepends[@]%%[<=>]*}" "${pkgname}")
|
aurdeps+=("${depends[@]%%[<=>]*}" "${makedepends[@]%%[<=>]*}" "${pkgname}")
|
||||||
done
|
done
|
||||||
|
|
||||||
packages_to_remove=()
|
declare -a packages_to_remove=()
|
||||||
|
|
||||||
readarray -d $'\0' -t packages_to_remove < <(comm --zero-terminated -13 \
|
readarray -d $'\0' -t packages_to_remove < <(comm --zero-terminated -13 \
|
||||||
<(cat \
|
<(cat \
|
||||||
<(<packages.yml yaml2json | jq --raw-output0 'map(.archlinux) | flatten[]') \
|
<(<packages.yml yaml2json | jq --raw-output0 'map(.archlinux) | flatten[]') \
|
||||||
<(for dep in "${aurdeps[@]}" ; do printf '%s\0' "${dep}" ; done) \
|
<(for dep in "${aurdeps[@]}" "${cpu_packages[@]}" "${gpu_packages[@]}" ; do printf '%s\0' "${dep}" ; done) \
|
||||||
| sort -zu) \
|
| sort -zu) \
|
||||||
<(pacman -Qq --explicit | xargs -I "{}" printf '%s\0' "{}" | sort -zu) \
|
<(pacman -Qq --explicit | xargs -I "{}" printf '%s\0' "{}" | sort -zu) \
|
||||||
| while IFS= read -r -d $'\0' package; do
|
| while IFS= read -r -d $'\0' package; do
|
||||||
@@ -43,7 +48,7 @@ readarray -d $'\0' -t packages_to_remove < <(comm --zero-terminated -13 \
|
|||||||
printf '%s\0' "${package}"
|
printf '%s\0' "${package}"
|
||||||
done)
|
done)
|
||||||
|
|
||||||
if (( "${#packages_to_remove}" > 0 )) ; then
|
if (( "${#packages_to_remove[@]}" > 0 )) ; then
|
||||||
sudo pacman -Rcns "${packages_to_remove[@]}" "${@}" || exit $?
|
sudo pacman -Rcns "${packages_to_remove[@]}" "${@}" || exit $?
|
||||||
exit 123
|
exit 123
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user