Browse Source

New Lua-based site configuration

Matthias Schiffer 10 years ago
parent
commit
3a6561a40c
5 changed files with 14 additions and 6 deletions
  1. 2 2
      Makefile
  2. 3 1
      include/gluon.mk
  3. 1 1
      scripts/configure.pl
  4. 7 0
      scripts/load_site.lua
  5. 1 2
      scripts/site.sh

+ 2 - 2
Makefile

@@ -148,7 +148,7 @@ gluon_prepared_stamp := $(BOARD_BUILDDIR)/prepared
 include $(INCLUDE_DIR)/target.mk
 
 
-gluon-tools: $(STAGING_DIR_HOST)/bin/stat
+gluon-tools: $(STAGING_DIR_HOST)/bin/stat package/lua/host/install
 
 prepare-tmpinfo: FORCE
 	mkdir -p tmp/info
@@ -237,7 +237,7 @@ prepare-image: FORCE
 	cp $(KERNEL_BUILD_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf $(BOARD_KDIR)/
 	+$(SUBMAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image -f $(GLUONDIR)/include/Makefile.image prepare KDIR="$(BOARD_KDIR)"
 
-CheckSite := (perl $(GLUON_SITEDIR)/site.conf 2>&1) > /dev/null || (echo 'Your site configuration did not pass validation; please verify yourself with `perl site.conf` and fix the problems.';false)
+CheckSite := $(STAGING_DIR_HOST)/bin/lua $(GLUONDIR)/scripts/load_site.lua || (echo 'Your site configuration did not pass validation.';false)
 
 prepare: FORCE
 	@$(CheckSite)

+ 3 - 1
include/gluon.mk

@@ -36,7 +36,9 @@ export CONFIG_VERSION_REPO
 GLUON_SITE_CODE := $(shell $(GLUONDIR)/scripts/site.sh site_code)
 export GLUON_SITE_CODE
 
-GLUON_RELEASE ?= $(shell $(GLUONDIR)/scripts/site.sh release)
+ifeq ($(GLUON_RELEASE),)
+$(error GLUON_RELEASE not set. GLUON_RELEASE can be set in site.mk or on the command line.)
+endif
 export GLUON_RELEASE
 
 endif

+ 1 - 1
scripts/configure.pl

@@ -10,7 +10,7 @@ sub nightly {
 }
 
 
-our $CONFIG = do $ENV{GLUONDIR} . '/site/site.conf';
+our $CONFIG = do $ENV{GLUONDIR} . '/site/site.conf.pl';
 
 my $script = shift @ARGV;
 do $script;

+ 7 - 0
scripts/load_site.lua

@@ -0,0 +1,7 @@
+local function loader()
+   coroutine.yield('return ')
+   coroutine.yield(io.open(os.getenv('GLUONDIR') .. '/site/site.conf'):read('*a'))
+end
+
+-- setfenv doesn't work with Lua 5.2 anymore, but we're using 5.1
+config = setfenv(assert(load(coroutine.wrap(loader), 'site.conf')), {})()

+ 1 - 2
scripts/site.sh

@@ -2,5 +2,4 @@
 
 export GLUONDIR="$(dirname "$0")/.."
 
-RESULT=$(echo "@$1@" | $GLUONDIR/scripts/configure.pl $GLUONDIR/scripts/generate.pl)
-test ! "$RESULT" = "@$1@" && echo $RESULT
+"$GLUONDIR"/openwrt/staging_dir/host/bin/lua -e "dofile(os.getenv('GLUONDIR') .. '/scripts/load_site.lua') print(assert(config.$1))" 2>/dev/null