From ee533575802b376da07fae4f3e853613d3a0e945 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 4 Jul 2020 11:17:29 +0200 Subject: [PATCH] gluon-autoupdater: split CONFIG_GLUON_BRANCH into two separate options The new options are CONFIG_GLUON_AUTOUPDATER_BRANCH and CONFIG_GLUON_AUTOUPDATER_ENABLED and allow to control the default branch and default enable status separately. The `or ''` fallback in targets/generic is removed, as GLUON_ENV will set all variables in GLUON_VARS, making previously non-existing variables exist with an empty value. --- package/gluon-autoupdater/Config.in | 10 ++++++++++ package/gluon-autoupdater/Makefile | 16 ++++++++-------- .../luasrc/lib/gluon/upgrade/500-autoupdater | 6 +++--- targets/generic | 4 +++- 4 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 package/gluon-autoupdater/Config.in diff --git a/package/gluon-autoupdater/Config.in b/package/gluon-autoupdater/Config.in new file mode 100644 index 00000000..554314c9 --- /dev/null +++ b/package/gluon-autoupdater/Config.in @@ -0,0 +1,10 @@ +if PACKAGE_gluon-autoupdater + +config GLUON_AUTOUPDATER_BRANCH + string "Autoupdater branch" + default "" + +config GLUON_AUTOUPDATER_ENABLED + bool "Enable autoupdater by default" + +endif diff --git a/package/gluon-autoupdater/Makefile b/package/gluon-autoupdater/Makefile index d6e87499..368dce1b 100644 --- a/package/gluon-autoupdater/Makefile +++ b/package/gluon-autoupdater/Makefile @@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gluon-autoupdater PKG_VERSION:=4 -PKG_CONFIG_DEPENDS := CONFIG_GLUON_BRANCH +PKG_CONFIG_DEPENDS := CONFIG_GLUON_AUTOUPDATER_BRANCH CONFIG_GLUON_AUTOUPDATER_ENABLED include ../gluon.mk @@ -13,19 +13,19 @@ define Package/gluon-autoupdater endef define Package/gluon-autoupdater/config -config GLUON_BRANCH - string "Gluon autoupdater branch" - depends on PACKAGE_gluon-autoupdater - default "" + source "$(SOURCE)/Config.in" endef define Package/gluon-autoupdater/install $(Gluon/Build/Install) -ifneq ($(CONFIG_GLUON_BRANCH),"") $(INSTALL_DIR) $(1)/lib/gluon/autoupdater - echo '$(call qstrip,$(CONFIG_GLUON_BRANCH))' > $(1)/lib/gluon/autoupdater/default_branch -endif + ifneq ($(CONFIG_GLUON_AUTOUPDATER_BRANCH),"") + echo '$(call qstrip,$(CONFIG_GLUON_AUTOUPDATER_BRANCH))' > $(1)/lib/gluon/autoupdater/default_branch + endif + ifneq ($(CONFIG_GLUON_AUTOUPDATER_ENABLED),) + touch $(1)/lib/gluon/autoupdater/default_enabled + endif endef $(eval $(call BuildPackageGluon,gluon-autoupdater)) diff --git a/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater b/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater index 88214a86..2835d088 100755 --- a/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater +++ b/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater @@ -2,6 +2,7 @@ local site = require 'gluon.site' local uci = require('simple-uci').cursor() +local unistd = require 'posix.unistd' for name, config in pairs(site.autoupdater.branches()) do @@ -15,12 +16,11 @@ for name, config in pairs(site.autoupdater.branches()) do end if not uci:get('autoupdater', 'settings') then - local enabled = false - local branch = site.autoupdater.branch() + local enabled = unistd.access('/lib/gluon/autoupdater/default_enabled') ~= nil + local branch = site.autoupdater.branch() local f = io.open('/lib/gluon/autoupdater/default_branch') if f then - enabled = true branch = f:read('*line') f:close() end diff --git a/targets/generic b/targets/generic index 89aba6f2..e9328922 100644 --- a/targets/generic +++ b/targets/generic @@ -3,7 +3,9 @@ assert(env.GLUON_LANGS) config('GLUON_SITEDIR', env.GLUON_SITEDIR) config('GLUON_RELEASE', env.GLUON_RELEASE) -try_config('GLUON_BRANCH', env.GLUON_BRANCH or '') + +try_config('GLUON_AUTOUPDATER_BRANCH', env.GLUON_BRANCH) +try_config('GLUON_AUTOUPDATER_ENABLED', env.GLUON_BRANCH ~= '') for lang in string.gmatch(env.GLUON_LANGS, '%S+') do try_config('GLUON_WEB_LANG_' .. lang, true)