From 13d632acb8689552464c24966103750dfedd3b51 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Tue, 11 Mar 2014 20:32:58 +0100
Subject: [PATCH] gluon-autoupdater: fix version comparison

---
 package/gluon-autoupdater/Makefile                   | 2 +-
 package/gluon-autoupdater/files/usr/sbin/autoupdater | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/package/gluon-autoupdater/Makefile b/package/gluon-autoupdater/Makefile
index 046a1bcba..ee977d672 100644
--- a/package/gluon-autoupdater/Makefile
+++ b/package/gluon-autoupdater/Makefile
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/package.mk
 define Package/gluon-autoupdater
   SECTION:=gluon
   CATEGORY:=Gluon
-  DEPENDS:=+gluon-core +gluon-cron +ecdsautils +!BUSYBOX_CONFIG_SHA512SUM:coreutils-sha512sum
+  DEPENDS:=+gluon-core +gluon-cron +opkg +ecdsautils +!BUSYBOX_CONFIG_SHA512SUM:coreutils-sha512sum
   TITLE:=Automatically update firmware
 endef
 
diff --git a/package/gluon-autoupdater/files/usr/sbin/autoupdater b/package/gluon-autoupdater/files/usr/sbin/autoupdater
index 641e437b7..fc44d3c2d 100755
--- a/package/gluon-autoupdater/files/usr/sbin/autoupdater
+++ b/package/gluon-autoupdater/files/usr/sbin/autoupdater
@@ -28,9 +28,10 @@ GOOD_SIGNATURES=$(uci get autoupdater.${BRANCH}.good_signatures)
 
 VERSION_FILE=/lib/gluon/release
 
+# returns 0 when $1 is a higher version number than $2
 newer_than() {
-  local old="$(printf '%s\n%s\n' "$1" "$2" | sort -n | head -n 1)"
-  test "$1" != "$old"
+	# negate the return value as opkg returns 1 when the proposition is true
+	! opkg compare-versions "$1" '>>' "$2"
 }
 
 fetch_manifest() {
-- 
GitLab