summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2019-02-20 09:58:20 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2019-02-20 16:24:21 +0100
commitba3505051fc3f46347eca7c7da677cf0c0881774 (patch)
tree2d264f16038ddc6ddd4cceee241ad5f99e9145ca
parentbd3c30891b523312c9cb583a179704ca715fad3a (diff)
downloadptxdist-ba3505051fc3f46347eca7c7da677cf0c0881774.tar.gz
ptxdist-ba3505051fc3f46347eca7c7da677cf0c0881774.tar.xz
ptx/collection: validate collection files
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r--rules/post/ptxd_make_collection.make32
-rw-r--r--scripts/lib/ptxd_make_collection.sh22
2 files changed, 53 insertions, 1 deletions
diff --git a/rules/post/ptxd_make_collection.make b/rules/post/ptxd_make_collection.make
index 4b2a55997..c49bae88e 100644
--- a/rules/post/ptxd_make_collection.make
+++ b/rules/post/ptxd_make_collection.make
@@ -8,6 +8,36 @@
# see the README file.
#
-ptx/collection = $(PACKAGES-y) $(filter $(foreach PKG,$(call ptx/force-shell, sed -n 's/^PTXCONF_\([^_][^=]*\)=y$$/\1/p' "$(strip $(1))"),$(PTX_MAP_TO_package_$(PKG))), $(PACKAGES-m))
+# calculate a unique temporary file name
+define _ptx_collection_mangle
+$(PTXDIST_TEMPDIR)/.$(subst /,-,$(subst $(PTXDIST_WORKSPACE)/,,$(strip $(1))))
+endef
+# generate the actual package list
+define _ptx_collection_do
+$(PACKAGES-y) $(filter $(foreach PKG,$(call ptx/force-shell, sed -n 's/^PTXCONF_\([^_][^=]*\)=y$$/\1/p' "$(strip $(1))"),$(PTX_MAP_TO_package_$(PKG))), $(PACKAGES-m))
+endef
+# mark the collection for verification and save the package list
+define _ptx_collection_write
+$(eval ACTIVE_COLLECTIONS += $(1))
+$(file >$(2),_pkg := $(3))
+$(3)
+endef
+# load the package list if available, otherwise generate it
+define _ptx_collection_once
+$(if $(wildcard $(2)),$(eval include $(2))$(_pkg),$(call _ptx_collection_write,$(1),$(2),$(call _ptx_collection_do,$(1))))
+endef
+define _ptx_collection
+$(call _ptx_collection_once,$(1),$(call _ptx_collection_mangle,$(1)))
+endef
+
+ptx/collection = $(strip $(call _ptx_collection,$(strip $(1))))
+
+PHONY += ptx-validate-collections
+$(STATEDIR)/virtual-host-tools.install: | ptx-validate-collections
+
+ptx-validate-collections:
+ @$(ptx/env) \
+ ptx_collections="$(ACTIVE_COLLECTIONS)" \
+ ptxd_make_validate_collection
# vim: syntax=make
diff --git a/scripts/lib/ptxd_make_collection.sh b/scripts/lib/ptxd_make_collection.sh
new file mode 100644
index 000000000..4d4c23136
--- /dev/null
+++ b/scripts/lib/ptxd_make_collection.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# Copyright (C) 2018 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+ptxd_make_validate_collection() {
+ local file_dotconfig relative_file_dotconfig
+ ptxd_make_world_init || return
+
+ exec 2>&1 >/dev/null
+ for file_dotconfig in ${ptx_collections}; do
+ ptxd_normalize_config &&
+ ptxd_kconfig_setup_config run "${PTXDIST_TEMPDIR}/.collection-config" \
+ "${relative_file_dotconfig}" "${file_dotconfig}"
+ done
+}
+export -f ptxd_make_validate_collection