From ba3505051fc3f46347eca7c7da677cf0c0881774 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Wed, 20 Feb 2019 09:58:20 +0100 Subject: ptx/collection: validate collection files Signed-off-by: Michael Olbrich --- rules/post/ptxd_make_collection.make | 32 +++++++++++++++++++++++++++++++- scripts/lib/ptxd_make_collection.sh | 22 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 scripts/lib/ptxd_make_collection.sh 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 +# +# 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 -- cgit v1.2.3