diff --git a/Makefile b/Makefile index bc9b842..3aa7464 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ # vim: ts=8 noet: -ALL_SCRIPTS := $(wildcard scripts/*) +NVME_SCRIPTS := $(subst scripts/,build/,$(wildcard scripts/nvme/*)) CORE_PROFILES := $(wildcard profiles/*/*) TARGET_PROFILES := $(wildcard profiles/*.conf) + PROFILE := BUILD := BUILDS := $(BUILD) @@ -24,36 +25,36 @@ __check_defined = \ .PHONY: amis prune release-readme clean -amis: build build/packer.json build/profile/$(PROFILE) build/update-release.py build/make-amis.py +amis: build/packer.json build/profile/$(PROFILE) build build/setup-ami $(NVME_SCRIPTS) @:$(call check_defined, PROFILE, target profile name) - build/make-amis.py $(PROFILE) $(BUILDS) + build/builder make-amis $(PROFILE) $(BUILDS) -prune: build build/prune-amis.py +prune: build @:$(call check_defined, LEVEL, pruning level) @:$(call check_defined, PROFILE, target profile name) - build/prune-amis.py $(LEVEL) $(PROFILE) $(BUILD) + build/builder prune-amis $(LEVEL) $(PROFILE) $(BUILD) -release-readme: build build/gen-release-readme.py +release-readme: releases/README.md +releases/README.md: build @:$(call check_defined, PROFILE, target profile name) @:$(call require_var, PROFILE) - build/gen-release-readme.py $(PROFILE) + build/builder gen-release-readme $(PROFILE) -build: $(ALL_SCRIPTS) +build: + python3 -m venv build [ -d build/profile ] || mkdir -p build/profile - python3 -m venv build/.py3 - build/.py3/bin/pip install pyhocon pyyaml boto3 - (cd build; for i in $(ALL_SCRIPTS); do ln -sf ../$$i .; done) + build/bin/pip install -U pip pyhocon pyyaml boto3 -build/packer.json: build packer.conf - build/.py3/bin/pyhocon -i packer.conf -f json > build/packer.json - -build/profile/$(PROFILE): build build/resolve-profile.py $(CORE_PROFILES) $(TARGET_PROFILES) - @:$(call check_defined, PROFILE, target profile name) - build/resolve-profile.py $(PROFILE) - -%.py: %.py.in build - sed "s|@PYTHON@|#!`pwd`/build/.py3/bin/python|" $< > $@ + 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-profile $(PROFILE) + clean: rm -rf build