fix: version comparison in Arch keyring upgrade check

Replaces string comparison with proper version comparison using sort -V.
This ensures correct handling of package versions like 1.2.3-1 vs 1.2.3-2.
This commit is contained in:
mnv 2024-10-26 16:43:53 +05:30 committed by GitHub
parent 6a5e4c3801
commit 7c85120799
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -181,7 +181,8 @@ function upgrade() {
echo ":: Checking Arch Linux PGP Keyring..." echo ":: Checking Arch Linux PGP Keyring..."
local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')" local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')" local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
if [ $installedver != $currentver ]; then
if ! printf '%s\n' "$currentver" "$installedver" | sort -VC; then
echo " Arch Linux PGP Keyring is out of date." echo " Arch Linux PGP Keyring is out of date."
echo " Updating before full system upgrade." echo " Updating before full system upgrade."
sudo pacman -Sy --needed --noconfirm archlinux-keyring sudo pacman -Sy --needed --noconfirm archlinux-keyring
@ -189,6 +190,7 @@ function upgrade() {
echo " Arch Linux PGP Keyring is up to date." echo " Arch Linux PGP Keyring is up to date."
echo " Proceeding with full system upgrade." echo " Proceeding with full system upgrade."
fi fi
if (( $+commands[yay] )); then if (( $+commands[yay] )); then
yay -Syu yay -Syu
elif (( $+commands[trizen] )); then elif (( $+commands[trizen] )); then