From 30869d9080c6389a43a7ac4e290c283943efa62f Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Tue, 11 Feb 2014 17:10:11 +0100
Subject: [PATCH] gluon-autoupdater: enable by default only if GLUON_BRANCH is
 set, set default branch accordingly

---
 package/gluon-autoupdater/Makefile     |  4 ++--
 package/gluon-autoupdater/invariant.pl | 14 ++++++--------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/package/gluon-autoupdater/Makefile b/package/gluon-autoupdater/Makefile
index 93b080679..046a1bcba 100644
--- a/package/gluon-autoupdater/Makefile
+++ b/package/gluon-autoupdater/Makefile
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=gluon-autoupdater
 PKG_VERSION:=0.1
-PKG_RELEASE:=1.$(GLUON_CONFIG_VERSION)
+PKG_RELEASE:=1.$(GLUON_CONFIG_VERSION)$(if $(GLUON_BRANCH),.$(GLUON_BRANCH))
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
@@ -29,7 +29,7 @@ define Package/gluon-autoupdater/install
 	$(CP) ./files/* $(1)/
 
 	$(INSTALL_DIR) $(1)/lib/gluon/upgrade/autoupdater/invariant
-	$(GLUON_CONFIGURE) invariant.pl > $(1)/lib/gluon/upgrade/autoupdater/invariant/010-autoupdater
+	GLUON_BRANCH='$(GLUON_BRANCH)' $(GLUON_CONFIGURE) invariant.pl > $(1)/lib/gluon/upgrade/autoupdater/invariant/010-autoupdater
 	chmod +x $(1)/lib/gluon/upgrade/autoupdater/invariant/010-autoupdater
 endef
 
diff --git a/package/gluon-autoupdater/invariant.pl b/package/gluon-autoupdater/invariant.pl
index c6bb3b720..7c5a0a5ce 100644
--- a/package/gluon-autoupdater/invariant.pl
+++ b/package/gluon-autoupdater/invariant.pl
@@ -1,18 +1,16 @@
 my $cfg = $CONFIG->{autoupdater};
 
-print <<'END';
+my $branch = $ENV{GLUON_BRANCH} || $cfg->{branch};
+my $enabled = $ENV{GLUON_BRANCH} ? 1 : 0;
+
+print <<END;
 #/bin/sh
 
 uci -q get autoupdater.settings || {
 uci -q batch <<EOF
 set autoupdater.settings=autoupdater
-END
-
-for (qw(enabled branch)) {
-  print "set autoupdater.settings.$_=$cfg->{$_}\n";
-}
-
-print <<'END';
+set autoupdater.settings.branch=$branch
+set autoupdater.settings.enabled=$enabled
 EOF
 }
 
-- 
GitLab