From 487926eb9eaf5e909b3f81b28cac2a1c74de3699 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= <karel.koci@nic.cz>
Date: Wed, 31 Jan 2018 13:08:26 +0100
Subject: Update updater-ng to latest version of package

---
 updater-ng-auto/Makefile | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/updater-ng-auto/Makefile b/updater-ng-auto/Makefile
index 051d04c..7bf4782 100644
--- a/updater-ng-auto/Makefile
+++ b/updater-ng-auto/Makefile
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=updater-ng
-PKG_VERSION:=60.0.2
+PKG_VERSION:=60.0.7
 PKG_RELEASE:=1
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://gitlab.labs.nic.cz/turris/updater.git
@@ -25,7 +25,7 @@ include $(INCLUDE_DIR)/host-build.mk
 
 define Package/$(PKG_NAME)
 	TITLE:=The next generation updater
-	DEPENDS:=+liblua +libevent2 +usign +libcurl +vixie-cron
+	DEPENDS:=+liblua +libevent2 +usign +libcurl +vixie-cron +ca-certificates
 endef
 
 define Package/$(PKG_NAME)/install
@@ -77,20 +77,24 @@ endef
 
 define Package/$(PKG_NAME)/postinst
 #!/bin/sh
-[ -n "$$IPKG_INSTROOT" ] || {
+if [ -z "$$IPKG_INSTROOT" ]; then
 	/etc/init.d/updater enable || true
-}
+fi
 
 # Remove morphered syntax from auto.lua
 # This matches all Install and Package commands not followed by brackets. Whole
 # line is enclosed with brackets and between strings and tables are added commas.
-AUTOTMP="$$(mktemp)"
-sed -E '/^(Install|Package) +[^(]/{
-		s/(Install|Package) +(.*)/\1(\2)/;
-		s/("|\}) ("|\{)/\1, \2/g
-	}' "$$IPKG_INSTROOT/etc/updater/auto.lua" > "$$AUTOTMP"
-# Note: Edit in place in busybox limits regexp syntax so we are using our temporally file
-mv "$$AUTOTMP" "$$IPKG_INSTROOT/etc/updater/auto.lua"
+# Note: we don't have to check opkg-auto.lua as we do this migration before we
+# move auto.lua to that name.
+if [ -f "$$IPKG_INSTROOT/etc/updater/auto.lua" ]; then
+	AUTOTMP="$$(mktemp)"
+	sed -E '/^(Install|Package) +[^(]/{
+			s/(Install|Package) +(.*)/\1(\2)/;
+			s/("|\}) ("|\{)/\1, \2/g
+		}' "$$IPKG_INSTROOT/etc/updater/auto.lua" > "$$AUTOTMP"
+	# Note: Edit in place in busybox limits regexp syntax so we are using our temporally file
+	mv "$$AUTOTMP" "$$IPKG_INSTROOT/etc/updater/auto.lua"
+fi
 
 # With updater version 60.0 all configurations were moved to /etc/updater/conf.d/
 conf_move() {
@@ -132,6 +136,15 @@ define Package/$(PKG_NAME)-localrepo/install
 	$(INSTALL_CONF) $(PKG_BUILD_DIR)/src/localrepo/localrepo.lua $(1)/etc/updater/conf.d/localrepo.lua
 endef
 
+# Repository should be consistent when updater is executed successfully but this
+# ensures that we will fix any problems that can be caused by older version of
+# localrepo
+define Package/$(PKG_NAME)-localrepo/postinst
+[ -n "$$IPKG_INSTROOT" ] || {
+	localrepo check --fix
+}
+endef
+
 
 define Package/$(PKG_NAME)-opkg
 	TITLE:=OPKG compatibility wrapper for next generation updater
-- 
cgit v1.2.3