Commit 643d4a75 authored by Michael Shigorin's avatar Michael Shigorin

p/l/Makefile: refactor repetitive actions

*_PACKAGES and *_LISTS shouldn't inflict copypasted blocks; we can iterate over these just fine. NB: dump-*, not dump_*, due to namespace pollution hurting debug target if done the latter way (in case someone misses the morning tea as wel).
parent 90d7a614
......@@ -24,32 +24,20 @@ all: $(TARGET) $(GLOBAL_DEBUG) $(DOTBASE)
$(shell cp --parents -at $(TARGET) \
-- $(value $V))))
### FIXME: move to iterator/static pattern rule
# args: name, suffix, command
define dump-THEM
if [ -n "$($(1)_$(2))" ]; then echo -e "\n## $(1)_$(2)"; $(3) $($(1)_$(2)); fi;
endef
dump-PACKAGES = $(call dump-THEM,$(1),PACKAGES,echo)
dump-LISTS = $(call dump-THEM,$(1),LISTS,cat)
dot-base:
@# construct .base packagelist for alterator-pkg
@{ \
echo "## generated by pkg.in/lists/Makefile"; \
if [ -n "$(BRANDING)" ]; then \
echo "branding-$(BRANDING)-release"; \
fi; \
if [ -n "$(SYSTEM_PACKAGES)" ]; then \
echo -e "\n## SYSTEM_PACKAGES\n$(SYSTEM_PACKAGES)"; \
fi; \
if [ -n "$(COMMON_PACKAGES)" ]; then \
echo -e "\n## COMMON_PACKAGES\n$(COMMON_PACKAGES)"; \
fi; \
if [ -n "$(THE_PACKAGES)" ]; then \
echo -e "\n## THE_PACKAGES\n$(THE_PACKAGES)"; \
fi; \
if [ -n "$(BASE_PACKAGES)" ]; then \
echo -e "\n## BASE_PACKAGES\n$(BASE_PACKAGES)"; \
fi; \
if [ -n "$(THE_LISTS)" ]; then \
echo -e "\n## THE_LISTS"; cat $(THE_LISTS); \
fi; \
if [ -n "$(BASE_LISTS)" ]; then \
echo -e "\n## BASE_LISTS"; cat $(BASE_LISTS); \
fi; \
$(foreach p,SYSTEM COMMON THE BASE,$(call dump-PACKAGES,$(p))) \
$(foreach l,THE BASE,$(call dump-LISTS,$(l))) \
} | sed -re '/^[^[:space:]#]/ s/[[:space:]]+/\n/g' >$(TARGET)/.base
@if [ -n "$(THE_GROUPS)$(MAIN_GROUPS)" ]; then \
cp -at $(TARGET) -- $(THE_GROUPS) $(MAIN_GROUPS); \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment