Update plone3 skeleton
[zope-bootstrap.git] / Makefile.buildout
1 # -*- makefile -*-
2
3 # Usage:
4 #     @$(buildout_opt) <cfg-file> [set|add|append|remove] <section> <variable> [<value>]
5 #
6 # Change setting for <variable> in <section>. Actions are
7 #
8 #    set       Set <variable> to <value> replacing any existing value
9 #    add       If <variable> is unset, set to <value>
10 #    append    Append <value> to the end of the current value of <variable>
11 #    remove    Remove any assignment to <variable>
12 #
13 define buildout_opt
14     _buildout_getopt_() {                                                                       \
15         sed -n -e "/^\[$$1\]/,/^\[/ba" -eb -e:a -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/p" $$cfgfile |  \
16             sed -e '$$d';                                                                       \
17     };                                                                                          \
18     _buildout_haveopt() {                                                                       \
19         [ -n "`_buildout_getopt_ "$$1" "$$2"`" ];                                               \
20     };                                                                                          \
21     _buildout_getopt() {                                                                        \
22         _buildout_checkopt_ "$$1" "$$2" | -e '1s/[^=]* *= *//';                                 \
23     };                                                                                          \
24     _buildout_addopt() {                                                                        \
25         sed -i -e "/\[$$1\]/ba" -eb -e:a -ea\\ -e "$$2 = $$3" $$cfgfile;                        \
26     };                                                                                          \
27     _buildout_replaceopt() {                                                                    \
28         sed -i -e "/^\[$$1\]/,/^\[/ba" -eb -e:a                                                 \
29             -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/bb" -eb -e:b                                        \
30             -e "/^$$2 *=/bc" -ebd -e:c                                                          \
31             -ec\\ -e "$$2 = $$3" -eb -e:d                                                       \
32             -e "/^\([^ \t]\|\$$\)/b" -ed                                                        \
33                 $$cfgfile;                                                                      \
34     };                                                                                          \
35     _buildout_appendopt() {                                                                     \
36         sed -i -e "/^\[$$1\]/,/^\[/ba" -eb -e:a                                                 \
37             -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/bb" -eb -e:b                                        \
38             -e /^\([^ \t]\|$$\)/bc -eb -e:c                                                     \
39             -ei\\ -e "    $$3"                                                                  \
40                 $$cfgfile;                                                                      \
41     };                                                                                          \
42     _buildout_removeopt() {                                                                     \
43         sed -i -e "/^\[$$1\]/,/^\[/ba" -eb -e:a                                                 \
44             -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/bb" -eb -e:b                                        \
45             -e "/^\([^ \t]\|\$$\)/b" -ed                                                        \
46                 $$cfgfile;                                                                      \
47     };                                                                                          \
48     _buildout_opt_set() {                                                                       \
49         if _buildout_haveopt "$$1" "$$2"; then                                                  \
50             _buildout_replaceopt "$$1" "$$2" "$$3";                                             \
51         else                                                                                    \
52             _buildout_addopt "$$1" "$$2" "$$3";                                                 \
53         fi;                                                                                     \
54     };                                                                                          \
55     _buildout_opt_add() {                                                                       \
56         if ! _buildout_haveopt "$$1" "$$2"; then                                                \
57             _buildout_addopt "$$1" "$$2" "$$3";                                                 \
58         fi;                                                                                     \
59     };                                                                                          \
60     _buildout_opt_append() {                                                                    \
61         if builout_haveopt "$$1" "$$2"; then                                                    \
62             _buildout_appendopt "$$1" "$$2" "$$3";                                              \
63         else                                                                                    \
64             _buildouT_addopt "$$1" "$$2" "$$3";                                                 \
65         fi;                                                                                     \
66     };                                                                                          \
67     _builout_opt_remove() {                                                                     \
68         if buildout_haveopt "$$1" "$$2"; then                                                   \
69             _buildout_removeopt "$$1" "$$2";                                                    \
70         fi;                                                                                     \
71     };                                                                                          \
72     _buildout_opt() {                                                                           \
73         echo "$$1: option '[$$3]/$$4' $$2 '$$5'";                                               \
74         cfgfile="$$1";                                                                          \
75         _buildout_opt_$$2 "$$3" "$$4" "$$5";                                                    \
76     };                                                                                          \
77     _buildout_opt
78 endef
79
80 buildout-net.cfg buildout-nonet.cfg: buildout.cfg
81         mkdir -p $(DLCACHE)/downloads $(DLCACHE)/extends
82         @(                                                      \
83             echo "[buildout]";                                  \
84             echo "extends = buildout.cfg";                      \
85             echo "download-cache = $(DLCACHE)/downloads";       \
86             echo "extends-cache = $(DLCACHE)/extends";          \
87             echo "install-from-cache = true";                   \
88             echo "newest = false";                              \
89         ) > buildout-nonet.cfg
90         @(                                                      \
91             echo "[buildout]";                                  \
92             echo "extends = buildout.cfg";                      \
93             echo "download-cache = $(DLCACHE)/downloads";       \
94             echo "extends-cache = $(DLCACHE)/extends";          \
95             echo "install-from-cache = false";                  \
96             echo "newest = true";                               \
97         ) >  buildout-net.cfg
98
99 BUILDOUT_OPTS = -c buildout-net.cfg
100
101 init-nonet: BUILDOUT_OPTS = -c buildout-nonet.cfg
102 update-nonet: BUILDOUT_OPTS = -c buildout-nonet.cfg
103
104 bootstrap::
105         sed -i -e '1s/^#!.*\/python/#!$(subst /,\/,$(PYTHON))/' $(PYTHON_DIR)/bin/*
106         $(PYTHON) -c 'from zc.buildout.buildout import main; main(["bootstrap"])'
107
108 update::
109         bin/buildout $(BUILDOUT_OPTS)
110
111 .gitignore::
112         @$(gitignore) "*.egg-info/"
113         @$(gitignore) "/buildout-net.cfg"
114         @$(gitignore) "/buildout-nonet.cfg"
115
116 clean::
117         rm -f buildout-net.cfg buildout-nonet.cfg
118
119 versions:
120         @echo "# Add the following lines to [versions] in buildout.cfg to pin all packages"
121         @bin/buildout -vvvvv | sed -ne 's/^Picked: //p' | sort | uniq 
122 .PHONY: versions
123
124 fullhelp::
125         @echo "    versions"
126         @echo "        Generate lines to be added to 'buildout.cfg' to pin all package"
127         @echo "        versions."
128         @echo