From a3ed0dde1fe936fdcccb67e26b7027b39fb81de9 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 --- package/gluon-autoupdater/Makefile | 11 +++-- .../autoupdater/invariant/010-autoupdater | 42 +++++++++++++++++ package/gluon-autoupdater/invariant.pl | 46 ------------------- 3 files changed, 48 insertions(+), 51 deletions(-) create mode 100755 package/gluon-autoupdater/files/lib/gluon/upgrade/autoupdater/invariant/010-autoupdater delete mode 100644 package/gluon-autoupdater/invariant.pl diff --git a/package/gluon-autoupdater/Makefile b/package/gluon-autoupdater/Makefile index ee977d67..a93f83f5 100644 --- a/package/gluon-autoupdater/Makefile +++ b/package/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/package/gluon-autoupdater/files/lib/gluon/upgrade/autoupdater/invariant/010-autoupdater b/package/gluon-autoupdater/files/lib/gluon/upgrade/autoupdater/invariant/010-autoupdater new file mode 100755 index 00000000..29cef882 --- /dev/null +++ b/package/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/package/gluon-autoupdater/invariant.pl b/package/gluon-autoupdater/invariant.pl deleted file mode 100644 index 7c5a0a5c..00000000 --- a/package/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 <