New Lua-based site configuration

This commit is contained in:
Matthias Schiffer 2014-05-13 16:49:22 +02:00
parent 5c92684abe
commit 3a6561a40c
5 changed files with 14 additions and 6 deletions

View File

@ -148,7 +148,7 @@ gluon_prepared_stamp := $(BOARD_BUILDDIR)/prepared
include $(INCLUDE_DIR)/target.mk 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 prepare-tmpinfo: FORCE
mkdir -p tmp/info mkdir -p tmp/info
@ -237,7 +237,7 @@ prepare-image: FORCE
cp $(KERNEL_BUILD_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf $(BOARD_KDIR)/ 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)" +$(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 prepare: FORCE
@$(CheckSite) @$(CheckSite)

View File

@ -36,7 +36,9 @@ export CONFIG_VERSION_REPO
GLUON_SITE_CODE := $(shell $(GLUONDIR)/scripts/site.sh site_code) GLUON_SITE_CODE := $(shell $(GLUONDIR)/scripts/site.sh site_code)
export GLUON_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 export GLUON_RELEASE
endif endif

View File

@ -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; my $script = shift @ARGV;
do $script; do $script;

7
scripts/load_site.lua Normal file
View File

@ -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')), {})()

View File

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