meta: Add Makefile
When developing Butane/Ignition files, I frequently forget to update the parent files after making a change to an included file. This causes a lot of wasted time re-provisioning, only to discover that my change did not take effect. To alleviate this, we'll use `make` with some macro magic to scan the Butane files for their dependencies, and let it generate whatever Ignition files need updating any time a dependant file changes. I've also added a "publish" step to the Makefile, since I also frequently forget to upload the regenerated Ignition files to the server, causing the same headaches.master
parent
2efce551ba
commit
2a0b23c9a8
|
@ -0,0 +1,22 @@
|
|||
.PHONY: \
|
||||
all \
|
||||
clean \
|
||||
publish
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
clean:
|
||||
rm -f *.ign
|
||||
|
||||
define genrules
|
||||
$(patsubst %.yaml,%.ign,$(1)): $(1) $$(shell sed -rn 's/.*local: (.*)/\1/p' $(1))
|
||||
butane -d . $$< > $$@
|
||||
|
||||
all: $(patsubst %.yaml,%.ign,$(1))
|
||||
endef
|
||||
|
||||
$(foreach t,$(wildcard *.yaml),$(eval $(call genrules,$(t))))
|
||||
|
||||
publish: \
|
||||
nvr1.ign
|
||||
rsync -rti $^ files.pyrocufflink.blue:public_html/
|
|
@ -2,8 +2,9 @@
|
|||
# vim: set sw=4 ts=4 sts=4 et :
|
||||
|
||||
inotifywait -e CLOSE_WRITE -m . \
|
||||
| stdbuf -o 0 grep -F .yaml \
|
||||
| stdbuf -o 0 grep -v .ign \
|
||||
| while read _ _ f; do
|
||||
printf 'Regenerating %s from %s ...\n' "${f%.yaml}.ign" "${f}"
|
||||
butane -d . ${f} > ${f%.yaml}.ign
|
||||
[ -f "${f}" ] || continue
|
||||
printf '%s changed, running make ...\n' "${f}"
|
||||
make && make publish
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue