From e16bfbe309f995f272b044a15e9bae8ce0e80a84 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 14 May 2014 20:46:31 +0200 Subject: [PATCH] gluon-autoupdater: replace config script generator with Lua script --- gluon/gluon-autoupdater/Makefile | 11 +++-- .../autoupdater/invariant/010-autoupdater | 42 +++++++++++++++++ gluon/gluon-autoupdater/invariant.pl | 46 ------------------- 3 files changed, 48 insertions(+), 51 deletions(-) create mode 100755 gluon/gluon-autoupdater/files/lib/gluon/upgrade/autoupdater/invariant/010-autoupdater delete mode 100644 gluon/gluon-autoupdater/invariant.pl diff --git a/gluon/gluon-autoupdater/Makefile b/gluon/gluon-autoupdater/Makefile index ee977d6..a93f83f 100644 --- a/gluon/gluon-autoupdater/Makefile +++ b/gluon/gluon-autoupdater/Makefile @@ -1,8 +1,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gluon-autoupdater -PKG_VERSION:=0.1 -PKG_RELEASE:=1.$(GLUON_CONFIG_VERSION)$(if $(GLUON_BRANCH),.$(GLUON_BRANCH)) +PKG_VERSION:=2 +PKG_RELEASE:=$(GLUON_BRANCH) PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) @@ -28,9 +28,10 @@ endef define Package/gluon-autoupdater/install $(CP) ./files/* $(1)/ - $(INSTALL_DIR) $(1)/lib/gluon/upgrade/autoupdater/invariant - 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 + if [ '$(GLUON_BRANCH)' ]; then \ + $(INSTALL_DIR) $(1)/lib/gluon/autoupdater; \ + echo '$(GLUON_BRANCH)' > $(1)/lib/gluon/autoupdater/default_branch; \ + fi endef $(eval $(call BuildPackage,gluon-autoupdater)) diff --git a/gluon/gluon-autoupdater/files/lib/gluon/upgrade/autoupdater/invariant/010-autoupdater b/gluon/gluon-autoupdater/files/lib/gluon/upgrade/autoupdater/invariant/010-autoupdater new file mode 100755 index 0000000..29cef88 --- /dev/null +++ b/gluon/gluon-autoupdater/files/lib/gluon/upgrade/autoupdater/invariant/010-autoupdater @@ -0,0 +1,42 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' +local uci = require 'luci.model.uci' + +local c = uci.cursor() + + +for name, config in pairs(site.autoupdater.branches) do + c:delete('autoupdater', name) + c:section('autoupdater', 'branch', name, + { + name = config.name, + mirror = config.mirrors, + probability = config.probability, + good_signatures = config.good_signatures, + pubkey = config.pubkeys, + } + ) +end + +if not c:get('autoupdater', 'settings') then + local enabled = 0 + local branch = site.autoupdater.branch + + local f = io.open('/lib/gluon/autoupdater/default_branch') + if f then + enabled = 1 + branch = f:read('*line') + f:close() + end + + c:section('autoupdater', 'autoupdater', 'settings', + { + enabled = enabled, + branch = branch, + } + ) +end + +c:save('autoupdater') +c:commit('autoupdater') diff --git a/gluon/gluon-autoupdater/invariant.pl b/gluon/gluon-autoupdater/invariant.pl deleted file mode 100644 index 7c5a0a5..0000000 --- a/gluon/gluon-autoupdater/invariant.pl +++ /dev/null @@ -1,46 +0,0 @@ -my $cfg = $CONFIG->{autoupdater}; - -my $branch = $ENV{GLUON_BRANCH} || $cfg->{branch}; -my $enabled = $ENV{GLUON_BRANCH} ? 1 : 0; - -print <{branches}) { - my $branch = $cfg->{branches}->{$name}; - - print <{$_}\n"; - } - - for (@{$branch->{mirrors}}) { - print "add_list autoupdater.$name.mirror=$_\n"; - } - - for (@{$branch->{pubkeys}}) { - print "add_list autoupdater.$name.pubkey=$_\n"; - } -} - -print <