From ebd6a5876bbec7ee8f53b37741c043010a7a2da4 Mon Sep 17 00:00:00 2001 From: Alex Malinovich Date: Fri, 9 Mar 2018 00:35:21 -0800 Subject: [PATCH] Fix RPM version parsing --- plexupdate-core | 10 +++++++++- plexupdate.sh | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plexupdate-core b/plexupdate-core index 208915d..4ef4cf4 100755 --- a/plexupdate-core +++ b/plexupdate-core @@ -224,13 +224,21 @@ isNewerVersion() { fi } +parseVersion() { + if [ "${REDHAT}" = "yes" ]; then + cut -f2- -d- <<< "$1" | cut -f1-4 -d. + else + cut -f2 -d_ <<< "$1" + fi +} + getPlexVersion() { if [ "${REDHAT}" != "yes" ]; then dpkg-query --showformat='${Version}' --show plexmediaserver 2>/dev/null elif hash rpm 2>/dev/null; then local rpmtemp if rpmtemp=$(rpm -q plexmediaserver); then - cut -f2 -d_ <<< "$rpmtemp" + parseVersion "$rpmtemp" else return 1 fi diff --git a/plexupdate.sh b/plexupdate.sh index f34f8ce..df3e2ae 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -420,7 +420,7 @@ fi SKIP_DOWNLOAD="no" INSTALLED_VERSION="$(getPlexVersion)" || warn "Unable to detect installed version, first time?" -FILE_VERSION="$(cut -f2 -d_ <<< "${FILENAME}")" +FILE_VERSION="$(parseVersion "${FILENAME}")" verboseOutput INSTALLED_VERSION FILE_VERSION if [ "${REDHAT}" = "yes" -a "${AUTOINSTALL}" = "yes" -a "${AUTOSTART}" = "no" ]; then