From 775028475b7377c1d21dfcc333fcf0e5a1d570ab Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 19 Jan 2018 12:32:32 +0100 Subject: [PATCH] check_site: move site loading logic to check_site_lib (which is renamed to check_site.lua) --- package/gluon.mk | 9 ++------- scripts/{check_site_lib.lua => check_site.lua} | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) rename scripts/{check_site_lib.lua => check_site.lua} (92%) diff --git a/package/gluon.mk b/package/gluon.mk index 94170305..0d005e13 100644 --- a/package/gluon.mk +++ b/package/gluon.mk @@ -11,13 +11,8 @@ shell-verbatim = $(call shell-unescape,$(call shell-escape,$(1))) define GluonCheckSite -[ -z "$$IPKG_INSTROOT" ] || "${TOPDIR}/staging_dir/hostpkg/bin/lua" -e 'dofile()' <<'END__GLUON__CHECK__SITE' -local f = assert(io.open(os.getenv('IPKG_INSTROOT') .. '/lib/gluon/site.json')) -local site_json = f:read('*a') -f:close() - -site = require('cjson').decode(site_json) -$(call shell-verbatim,cat '$(TOPDIR)/../scripts/check_site_lib.lua' '$(1)') +[ -z "$$IPKG_INSTROOT" ] || "${TOPDIR}/staging_dir/hostpkg/bin/lua" "${TOPDIR}/../scripts/check_site.lua" <<'END__GLUON__CHECK__SITE' +$(call shell-verbatim,cat '$(1)') END__GLUON__CHECK__SITE endef diff --git a/scripts/check_site_lib.lua b/scripts/check_site.lua similarity index 92% rename from scripts/check_site_lib.lua rename to scripts/check_site.lua index c5296f93..3f3ed546 100644 --- a/scripts/check_site_lib.lua +++ b/scripts/check_site.lua @@ -1,3 +1,15 @@ +local cjson = require 'cjson' + +local function load_json(filename) + local f = assert(io.open(filename)) + local json = cjson.decode(f:read('*a')) + f:close() + return json +end + +local site = load_json(os.getenv('IPKG_INSTROOT') .. '/lib/gluon/site.json') + + function in_site(var) return var end @@ -170,3 +182,6 @@ end function need_array_of(path, array, required) return need_array(path, function(e) need_one_of(e, array) end, required) end + + +dofile()