check_site: move site loading logic to check_site_lib (which is renamed to check_site.lua)

This commit is contained in:
Matthias Schiffer 2018-01-19 12:32:32 +01:00
parent 43628c1679
commit 775028475b
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
2 changed files with 17 additions and 7 deletions

View File

@ -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

View File

@ -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()