# -*- makefile -*-
-buildout-net.cfg: buildout.cfg
- @sed -i -e '/\[buildout\]/ba' -eb -e:a \
- -ea\\ -e 'download-cache = $(DLCACHE)/downloads' \
- -ea\\ -e 'install-from-cache = true' \
- -ea\\ -e 'extends-cache = $(DLCACHE)/extends' \
- -ea\\ -e 'newest = false' \
- buildout.cfg || ( rm -f buildout.cfg; false )
- @mkdir -p $(DLCACHE)/downloads $(DLCACHE)/extends || ( rm -f buildout.cfg; false )
- @( \
- echo "[buildout]"; \
- echo "extends = buildout.cfg"; \
- echo "install-from-cache = false"; \
- echo "newest = true"; \
+# Usage:
+# @$(buildout_opt) <cfg-file> [set|add|append|remove] <section> <variable> [<value>]
+#
+# Change setting for <variable> in <section>. Actions are
+#
+# set Set <variable> to <value> replacing any existing value
+# add If <variable> is unset, set to <value>
+# append Append <value> to the end of the current value of <variable>
+# remove Remove any assignment to <variable>
+#
+define buildout_opt
+ _buildout_getopt_() { \
+ sed -n -e "/^\[$$1\]/,/^\[/ba" -eb -e:a -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/p" $$cfgfile | \
+ sed -e '$$d'; \
+ }; \
+ _buildout_haveopt() { \
+ [ -n "`_buildout_getopt_ "$$1" "$$2"`" ]; \
+ }; \
+ _buildout_getopt() { \
+ _buildout_checkopt_ "$$1" "$$2" | -e '1s/[^=]* *= *//'; \
+ }; \
+ _buildout_addopt() { \
+ sed -i -e "/\[$$1\]/ba" -eb -e:a -ea\\ -e "$$2 = $$3" $$cfgfile; \
+ }; \
+ _buildout_replaceopt() { \
+ sed -i -e "/^\[$$1\]/,/^\[/ba" -eb -e:a \
+ -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/bb" -eb -e:b \
+ -e "/^$$2 *=/bc" -ebd -e:c \
+ -ec\\ -e "$$2 = $$3" -eb -e:d \
+ -e "/^\([^ \t]\|\$$\)/b" -ed \
+ $$cfgfile; \
+ }; \
+ _buildout_appendopt() { \
+ sed -i -e "/^\[$$1\]/,/^\[/ba" -eb -e:a \
+ -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/bb" -eb -e:b \
+ -e /^\([^ \t]\|$$\)/bc -eb -e:c \
+ -ei\\ -e " $$3" \
+ $$cfgfile; \
+ }; \
+ _buildout_removeopt() { \
+ sed -i -e "/^\[$$1\]/,/^\[/ba" -eb -e:a \
+ -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/bb" -eb -e:b \
+ -e "/^\([^ \t]\|\$$\)/b" -ed \
+ $$cfgfile; \
+ }; \
+ _buildout_opt_set() { \
+ if _buildout_haveopt "$$1" "$$2"; then \
+ _buildout_replaceopt "$$1" "$$2" "$$3"; \
+ else \
+ _buildout_addopt "$$1" "$$2" "$$3"; \
+ fi; \
+ }; \
+ _buildout_opt_add() { \
+ if ! _buildout_haveopt "$$1" "$$2"; then \
+ _buildout_addopt "$$1" "$$2" "$$3"; \
+ fi; \
+ }; \
+ _buildout_opt_append() { \
+ if builout_haveopt "$$1" "$$2"; then \
+ _buildout_appendopt "$$1" "$$2" "$$3"; \
+ else \
+ _buildouT_addopt "$$1" "$$2" "$$3"; \
+ fi; \
+ }; \
+ _builout_opt_remove() { \
+ if buildout_haveopt "$$1" "$$2"; then \
+ _buildout_removeopt "$$1" "$$2"; \
+ fi; \
+ }; \
+ _buildout_opt() { \
+ echo "$$1: option '[$$3]/$$4' $$2 '$$5'"; \
+ cfgfile="$$1"; \
+ _buildout_opt_$$2 "$$3" "$$4" "$$5"; \
+ }; \
+ _buildout_opt
+endef
+
+buildout-net.cfg buildout-nonet.cfg: buildout.cfg
+ mkdir -p $(DLCACHE)/downloads $(DLCACHE)/extends
+ @( \
+ echo "[buildout]"; \
+ echo "extends = buildout.cfg"; \
+ echo "download-cache = $(DLCACHE)/downloads"; \
+ echo "extends-cache = $(DLCACHE)/extends"; \
+ echo "install-from-cache = true"; \
+ echo "newest = false"; \
+ ) > buildout-nonet.cfg
+ @( \
+ echo "[buildout]"; \
+ echo "extends = buildout.cfg"; \
+ echo "download-cache = $(DLCACHE)/downloads"; \
+ echo "extends-cache = $(DLCACHE)/extends"; \
+ echo "install-from-cache = false"; \
+ echo "newest = true"; \
) > buildout-net.cfg
BUILDOUT_OPTS = -c buildout-net.cfg
-init-nonet: BUILDOUT_OPTS =
-update-nonet: BUILDOUT_OPTS =
+init-nonet: BUILDOUT_OPTS = -c buildout-nonet.cfg
+update-nonet: BUILDOUT_OPTS = -c buildout-nonet.cfg
bootstrap::
sed -i -e '1s/^#!.*\/python/#!$(subst /,\/,$(PYTHON))/' $(PYTHON_DIR)/bin/*
$(PYTHON) -c 'from zc.buildout.buildout import main; main(["bootstrap"])'
+update::
+ bin/buildout $(BUILDOUT_OPTS)
+
.gitignore::
+ @$(gitignore) "*.egg-info/"
@$(gitignore) "/buildout-net.cfg"
+ @$(gitignore) "/buildout-nonet.cfg"
+
+clean::
+ rm -f buildout-net.cfg buildout-nonet.cfg
+
+versions:
+ @echo "# Add the following lines to [versions] in buildout.cfg to pin all packages"
+ @bin/buildout -vvvvv | sed -ne 's/^Picked: //p' | sort | uniq
+.PHONY: versions
+
+fullhelp::
+ @echo " versions"
+ @echo " Generate lines to be added to 'buildout.cfg' to pin all package"
+ @echo " versions."
+ @echo