>From df44cf35a5e5c539a8406d4dd5b57823f26a84be Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Tue, 16 Jul 2019 22:49:47 +0300 Subject: [PATCH 2/4] image.in/functions.mk: automatic profiles2groups It dawned on me this evening that there was no such thing as automatic group (and then list) names extraction from pkg.in/profiles in m-p; and I sort of assumed there was one implemented already. Here it is, actually being _the_ reason to finally factor out that archdep-filter script. --- image.in/functions.mk | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/image.in/functions.mk b/image.in/functions.mk index 17e4a3a..548a6a6 100644 --- a/image.in/functions.mk +++ b/image.in/functions.mk @@ -20,12 +20,26 @@ profile = $(addprefix $(PKGDIR)/,$(call rprofile,$(1))) # map first argument (a function) onto second one (an argument list) map = $(foreach a,$(2),$(call $(1),$(a))) -# happens at least twice, and variables are the same by design +# needed once, split out for readability +profiles2groups = $(shell $(profiles2groups_body)) +define profiles2groups_body +{ if [ -n "$(THE_PROFILES)" ]; then \ + sed -rn 's,^X-Alterator-Groups=(.*)$$,\1,p' \ + $(call map,profile,$(THE_PROFILES)) \ + /dev/null \ + | archdep-filter; \ +fi; } +endef + +# happens at least thrice, and variables are the same by design groups2lists = $(shell $(groups2lists_body)) define groups2lists_body -{ if [ -n "$(THE_GROUPS)$(MAIN_GROUPS)" ]; then \ - sed -rn 's,^X-Alterator-PackageList=(.*)$$,\1,p' \ - $(call map,group,$(THE_GROUPS) $(MAIN_GROUPS)); \ +{ if [ -n "$(THE_GROUPS)$(MAIN_GROUPS)$(THE_PROFILES)" ]; then \ + sed -rn 's,^X-Alterator-PackageList=(.*)$$,\1,p' \ + $(call map,group, \ + $(THE_GROUPS) $(MAIN_GROUPS) \ + $(call profiles2groups)) \ + /dev/null; \ fi; } endef -- 2.10.4