alpine-zdt-images/Makefile
Mike Crute 7e60c7fb6a Combine all commands into a meta-command
There is an increasing need to share components among the various
commands, especially with the introduction of the identity broker API.
Rather than trying to assemble an importable python library of code for
the build process I think we can just combine everything into one file
and use argparse sub-commands to integrate them into a set of
individually callable scripts. This change does that integration.
2020-05-28 17:55:36 -07:00

61 lines
1.6 KiB
Makefile

# vim: ts=8 noet:
NVME_SCRIPTS := $(subst scripts/,build/,$(wildcard scripts/nvme/*))
CORE_PROFILES := $(wildcard profiles/*/*)
TARGET_PROFILES := $(wildcard profiles/*.conf)
PROFILE :=
BUILD :=
BUILDS := $(BUILD)
LEVEL :=
# by default, use the 'packer' in the path
PACKER := packer
export PACKER
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))$(if $(value @), \
required by target `$@')))
.PHONY: amis prune release-readme clean
amis: build/packer.json build/profile/$(PROFILE) build
@:$(call check_defined, PROFILE, target profile name)
build/builder make-amis $(PROFILE) $(BUILDS)
prune: build
@:$(call check_defined, LEVEL, pruning level)
@:$(call check_defined, PROFILE, target profile name)
build/builder prune-amis $(LEVEL) $(PROFILE) $(BUILD)
release-readme: releases/README.md
releases/README.md: build
@:$(call check_defined, PROFILE, target profile name)
@:$(call require_var, PROFILE)
build/builder gen-release-readme $(PROFILE)
build:
python3 -m venv build
[ -d build/profile ] || mkdir -p build/profile
build/bin/pip install -U pip pyhocon pyyaml boto3
echo -e "#!/bin/sh\n$$(pwd)/build/bin/python scripts/builder.py \$$@" > $@
chmod +x $@
build/packer.json: packer.conf build
build/builder convert-packer-config
.PHONY: build/profile/$(PROFILE)
build/profile/$(PROFILE): build $(CORE_PROFILES) $(TARGET_PROFILES)
@:$(call check_defined, PROFILE, target profile name)
build/builder resolve-profiles $(PROFILE)
clean:
rm -rf build