mkimage-profiles/pkg.in/lists/Makefile
Michael Shigorin a86dd0c425 pkg/lists: uncrustify Makefile
The problem with the changed piece of code is that it would
- both call cp(1) multiple times if multiple *_LIST variables
  were non-empty (which is usually the case), and
- try to evaluate stdout of the called commands as a shell
  script (which would be empty unless someone passed e.g. -v
  to that cp(1) but it's crazy to rely on things like this).

So the functions should prepare arguments for a single copy
command that is predictable and could be made verbose.

Ouch.
2015-01-20 22:31:32 +03:00

48 lines
1.1 KiB
Makefile

# step 3: copy package lists referenced in distro configuration
# (and only those!) over to $(BUILDDIR)
ifndef BUILDDIR
pkgdups:
@find -type f ! -name README ! -name Makefile \
| grep -v '~$$' \
| sed 's,^\./,,g' \
| xargs ../../bin/pkgdups
%:
$(error BUILDDIR not defined)
else
include $(BUILDDIR)/distcfg.mk
SUFFIX := pkg/lists
TARGET := $(BUILDDIR)/$(SUFFIX)
all: $(TARGET) $(GLOBAL_DEBUG) $(DOTBASE) copy-lists copy-groups
@mp-commit "$(TARGET)" "requested $(SUFFIX) copied over"
# env | sort -u | grep _LISTS | xargs cp
copy-lists:
@cp --parents -at $(TARGET) -- \
$(foreach V, \
$(filter %_LISTS,$(sort $(.VARIABLES))), \
$(if $(filter environment% file,$(origin $V)),$($V)))
copy-groups:
@if [ -n "$(THE_GROUPS)$(MAIN_GROUPS)" ]; then \
cp -at $(TARGET) -- $(THE_GROUPS) $(MAIN_GROUPS); \
fi
# do beforehand as foreach gets expanded before recipe execution
$(TARGET):
@mkdir -p $(TARGET)
# figure out *_LISTS variables and print them out nicely
debug:
@echo -e $(foreach V, \
$(filter %_LISTS,$(sort $(.VARIABLES))), \
$(if $(filter environment% file,$(origin $V)),\
$(shell echo '\\n"**"' $V: $($V)))) '\n'
endif