2017-12-25 02:06:54 +00:00
|
|
|
.PHONY: ami
|
2018-09-07 15:15:19 +00:00
|
|
|
|
|
|
|
ami: convert
|
|
|
|
packer build -var-file=build/variables.json build/alpine-ami.json
|
|
|
|
|
|
|
|
edge: convert
|
2019-02-03 22:53:40 +00:00
|
|
|
@echo '{ "version": "edge", "release": "edge", "revision": "'-`date +%Y%m%d%H%M%S`'" }' > build/edge.json
|
2018-09-07 15:15:19 +00:00
|
|
|
packer build -var-file=build/variables.json -var-file=build/edge.json build/alpine-ami.json
|
|
|
|
|
|
|
|
convert: build/convert
|
2018-09-05 05:23:24 +00:00
|
|
|
[ -f variables.yaml ] || cp variables.yaml-default variables.yaml
|
|
|
|
build/convert variables.yaml > build/variables.json
|
2017-12-25 02:06:54 +00:00
|
|
|
build/convert alpine-ami.yaml > build/alpine-ami.json
|
|
|
|
|
|
|
|
build/convert:
|
|
|
|
[ -d ".py3" ] || python3 -m venv .py3
|
2017-12-25 04:53:29 +00:00
|
|
|
.py3/bin/pip install pyyaml boto3
|
2017-12-25 02:06:54 +00:00
|
|
|
|
|
|
|
[ -d "build" ] || mkdir build
|
|
|
|
|
|
|
|
# Make stupid simple little YAML/JSON converter so we can maintain our
|
|
|
|
# packer configs in a sane format that allows comments but also use packer
|
|
|
|
# which only supports JSON
|
|
|
|
@echo "#!`pwd`/.py3/bin/python" > build/convert
|
|
|
|
@echo "import yaml, json, sys" >> build/convert
|
2018-09-05 05:23:24 +00:00
|
|
|
@echo "y = yaml.load(open(sys.argv[1]))" >> build/convert
|
2019-01-26 21:32:54 +00:00
|
|
|
@echo "for k in ['ami_access','deploy_regions','add_repos','add_pkgs','add_svcs']:" >> build/convert
|
2018-09-05 05:23:24 +00:00
|
|
|
@echo " if k in y and isinstance(y[k], list):" >> build/convert
|
|
|
|
@echo " y[k] = ','.join(str(x) for x in y[k])" >> build/convert
|
2019-01-26 21:32:54 +00:00
|
|
|
@echo " if k in y and isinstance(y[k], dict):" >> build/convert
|
|
|
|
@echo " y[k] = ':'.join(str(l) + '=' + ','.join(str(s) for s in ss) for l, ss in y[k].items())" >> build/convert
|
2018-09-05 05:23:24 +00:00
|
|
|
@echo "json.dump(y, sys.stdout, indent=4, separators=(',', ': '))" >> build/convert
|
2017-12-25 02:06:54 +00:00
|
|
|
@chmod +x build/convert
|
|
|
|
|
2017-12-25 05:03:24 +00:00
|
|
|
%.py: %.py.in
|
2017-12-25 04:53:29 +00:00
|
|
|
sed "s|@PYTHON@|#!`pwd`/.py3/bin/python|" $< > $@
|
|
|
|
chmod +x $@
|
|
|
|
|
2017-12-25 02:06:54 +00:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2017-12-25 05:03:24 +00:00
|
|
|
rm -rf build .py3 scrub-old-amis.py gen-readme.py
|
2018-12-02 18:57:25 +00:00
|
|
|
|
|
|
|
distclean: clean
|
|
|
|
rm -f variables.yaml
|