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.
This commit is contained in:
Matthias Schiffer 2020-07-04 11:17:29 +02:00
parent 26f02a4eb3
commit ee53357580
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
4 changed files with 24 additions and 12 deletions

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -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)