updater: Fix parsing package version (APK)

This commit is contained in:
remittor
2025-12-19 10:23:52 +03:00
parent 08e6776a81
commit c6e2e79683

View File

@@ -72,7 +72,7 @@ function download_json
function get_pkg_version function get_pkg_version
{ {
local pkg_name="$1" local pkg_name="$1"
local ver line pkg_prefix local ver line base
if [ "$PKG_MGR" = opkg ]; then if [ "$PKG_MGR" = opkg ]; then
ver=$( opkg list-installed "$pkg_name" 2>/dev/null | awk -F' - ' '{print $2}' | tr -d '\r' ) ver=$( opkg list-installed "$pkg_name" 2>/dev/null | awk -F' - ' '{print $2}' | tr -d '\r' )
if [ -n "$ver" ]; then if [ -n "$ver" ]; then
@@ -83,16 +83,16 @@ function get_pkg_version
if [ "$PKG_MGR" = apk ]; then if [ "$PKG_MGR" = apk ]; then
line=$( apk info -e "$pkg_name" 2>/dev/null || true ) line=$( apk info -e "$pkg_name" 2>/dev/null || true )
if [ -n "$line" ]; then if [ -n "$line" ]; then
pkg_prefix="${pkg_name}-" base=${line%-r[0-9]*}
ver=${base##*-}
case "$line" in case "$line" in
"$pkg_prefix"*) *-r[0-9]*)
ver=${line#"$pkg_prefix"} echo -n "$ver${line#$base}"
;; ;;
*) *)
ver=${line##*-} echo -n "$ver"
;; ;;
esac esac
echo -n "$ver"
return 0 return 0
fi fi
fi fi
@@ -106,7 +106,7 @@ function normalize_version
local base local base
local major minor rel local major minor rel
case "$ver" in case "$ver" in
*-r*) *-r[0-9]*)
rel="${ver##*-r}" rel="${ver##*-r}"
base="${ver%-r*}" base="${ver%-r*}"
;; ;;