From 1dd9845db1f11c5b9e75e6b3fa6d1c4fc9e0f00d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 19 Jan 2018 01:38:56 +0100 Subject: [PATCH] package/gluon.mk: use nicer escaping in GluonCheckSite --- package/gluon.mk | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package/gluon.mk b/package/gluon.mk index ab46dc22..94170305 100644 --- a/package/gluon.mk +++ b/package/gluon.mk @@ -3,15 +3,21 @@ PKG_BUILD_DEPENDS += luci-base/host include $(INCLUDE_DIR)/package.mk + # Annoyingly, make's shell function replaces all newlines with spaces, so we have to do some escaping work. Yuck. +shell-escape = $(shell $(1) | sed -ne '1h; 1!H; $$ {g; s/@/@1/g; s/\n/@2/g; p}') +shell-unescape = $(subst @1,@,$(subst @2,$(newline),$(1))) +shell-verbatim = $(call shell-unescape,$(call shell-escape,$(1))) + + define GluonCheckSite -[ -z "$$IPKG_INSTROOT" ] || sed -e 's/-@/\n/g' -e 's/+@/@/g' <<'END__GLUON__CHECK__SITE' | "${TOPDIR}/staging_dir/hostpkg/bin/lua" -e 'dofile()' +[ -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) -$(shell cat '$(TOPDIR)/../scripts/check_site_lib.lua' '$(1)' | sed -ne '1h; 1!H; $$ {g; s/@/+@/g; s/\n/-@/g; p}') +$(call shell-verbatim,cat '$(TOPDIR)/../scripts/check_site_lib.lua' '$(1)') END__GLUON__CHECK__SITE endef