Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 316 lines (277 sloc) 6.389 kB
808262d initial commit
Jan Lehnardt authored
1 #!/bin/sh -ex
2 # CouchDBX-Core-Builder
3 # Downloads, Install Erlang & CouchDB into a package
4 # Copyright 2009 Jan Lehnardt <jan@apache.org>
5 # Apache 2.0 Licensed
6
7
8 # customise here:
9
10 # use full svn path for branches like "branches/0.9.x"
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
11 if [ -z "$COUCHDB_VERSION" ]; then
12 COUCHDB_VERSION="0.11.0a"
13 fi
14
15 if [ -z "$COUCHDB_SVNPATH" ]; then
16 COUCHDB_SVNPATH="trunk"
17 fi
808262d initial commit
Jan Lehnardt authored
18
19 # or R12B-5
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
20 if [ -z "$ERLANG_VERSION" ]; then
21 ERLANG_VERSION="R13B02"
22 fi
808262d initial commit
Jan Lehnardt authored
23
24 # make options
25 MAKE_OPTS="-j4"
26
27
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
28 # stop customising
808262d initial commit
Jan Lehnardt authored
29
30 # internal vars
31 DIRS="src dist"
32 WORKDIR=`pwd`
33
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
34 ERLANGSRCDIR="erlang_$ERLANG_VERSION"
35 ERLANGDISTDIR="$ERLANGSRCDIR"
36
37 COUCHDBSRCDIR="couchdb_$COUCHDB_VERSION"
38 COUCHDBDISTDIR="$COUCHDBSRCDIR"
39
40 #functions
808262d initial commit
Jan Lehnardt authored
41 erlang_download()
42 {
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
43 if [ ! -e .erlang-$ERLANG_VERSION-downloaded ]; then
808262d initial commit
Jan Lehnardt authored
44 FILE_NAME="otp_src_$ERLANG_VERSION"
45 BASE_URL="http://www.csd.uu.se/ftp/mirror/erlang/download"
46 cd src
47 if [ ! -e $FILE_NAME.tar.gz ]; then
48 curl -O $BASE_URL/$FILE_NAME.tar.gz
49 fi
50 tar xzf $FILE_NAME.tar.gz
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
51 mv $FILE_NAME $ERLANGSRCDIR
808262d initial commit
Jan Lehnardt authored
52 cd ..
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
53 touch .erlang-$ERLANG_VERSION-downloaded
808262d initial commit
Jan Lehnardt authored
54 fi
55 }
56
57 erlang_install()
58 {
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
59 if [ ! -e .erlang-$ERLANG_VERSION-installed ]; then
60 cd src/$ERLANGSRCDIR
808262d initial commit
Jan Lehnardt authored
61 ./configure \
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
62 --prefix=$WORKDIR/dist/$ERLANGDISTDIR \
ff47372 add path hack for jan, fix darwin build issue, add spidermonkey patch
Jan Lehnardt authored
63 --enable-hipe \
b9deb37 more erlang compile options
Jan Lehnardt authored
64 --without-wxwidgets \
65 --enable-dynamic-ssl-lib \
66 --with-ssl=/usr \
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
67 --without-java \
68 --enable-darwin-64bit
808262d initial commit
Jan Lehnardt authored
69 make # can't have -jN so no $MAKEOPTS
70 make install
71 cd ../../
1df4dfc keep a backup of the erlang sources without mangling around to use fo…
Jan Lehnardt authored
72 cd dist
73 rm -rf erlang
74 cp -r $ERLANGDISTDIR erlang
2e8d9e3 fix path traversal, thanks ejeklint & tisba
Jan Lehnardt authored
75 cd ..
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
76 touch .erlang-$ERLANG_VERSION-installed
808262d initial commit
Jan Lehnardt authored
77 fi
78 }
79
80 erlang_post_install()
81 {
1df4dfc keep a backup of the erlang sources without mangling around to use fo…
Jan Lehnardt authored
82 cd dist/$ERLANGDISTDIR
808262d initial commit
Jan Lehnardt authored
83 # change absolute paths to relative paths
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
84 perl -pi -e "s@$WORKDIR/dist@\`pwd\`@" bin/erl
85 # add quotes for paths with spaces
86 perl -pi -e \
87 's@`pwd`/erlang/lib/erlang@"`pwd`/erlang/lib/erlang"@' \
808262d initial commit
Jan Lehnardt authored
88 bin/erl
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
89 perl -pi -e 's@\$BINDIR/erlexec@"\$BINDIR/erlexec"@' bin/erl
808262d initial commit
Jan Lehnardt authored
90
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
91 cd ../../
92 }
93
94 strip_erlang_dist()
95 {
808262d initial commit
Jan Lehnardt authored
96 # strip unused erlang crap^Wlibs
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
97 cd $WORKDIR/dist/$ERLANGDISTDIR/lib/erlang/lib
808262d initial commit
Jan Lehnardt authored
98 rm -rf \
99 appmon-*/ \
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
100 asn1-*/ \
808262d initial commit
Jan Lehnardt authored
101 common_test-*/ \
102 compiler-*/ \
103 cosEvent-*/ \
104 cosEventDomain-*/ \
105 cosFileTransfer-*/ \
106 cosNotification-*/ \
107 cosProperty-*/ \
108 cosTime-*/ \
109 cosTransactions-*/ \
110 debugger-*/ \
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
111 dialyzer-*/ \
808262d initial commit
Jan Lehnardt authored
112 docbuilder-*/ \
113 edoc-*/ \
114 erl_interface-*/ \
115 erts-*/ \
116 et-*/ \
117 eunit-*/ \
118 gs-*/ \
119 hipe-*/ \
120 ic-*/ \
121 inviso-*/ \
122 jinterface-*/ \
123 megaco-*/ \
124 mnesia-*/ \
125 observer-*/ \
126 odbc-*/ \
127 orber-*/ \
128 os_mon-*/ \
129 otp_mibs-*/ \
130 parsetools-*/ \
131 percept-*/ \
132 pman-*/ \
133 public_key-*/ \
134 reltool-*/ \
135 runtime_tools-*/ \
136 snmp-*/ \
137 ssh-*/ \
138 syntax_tools-*/ \
139 test_server-*/ \
140 toolbar-*/ \
141 tools-*/ \
142 tv-*/ \
143 typer-*/ \
144 webtool-*/ \
145 wx-*/
b9deb37 more erlang compile options
Jan Lehnardt authored
146
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
147 find . -name "src" | xargs rm -rf
148 cd ../../../../../
808262d initial commit
Jan Lehnardt authored
149
7d2b893 make rm not fail unnecessarily, fix naming of final tarball
Jan Lehnardt authored
150 rm -f js/lib/libjs.a
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
151 rm -rf js/bin
152 rm -rf Darwin_DBG.OBJ
808262d initial commit
Jan Lehnardt authored
153 }
154
155 erlang()
156 {
157 erlang_download
158 erlang_install
159 }
160
161 couchdb_download()
162 {
163 cd src
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
164 if [ ! -d "$COUCHDBSRCDIR" ]; then
165 svn checkout http://svn.apache.org/repos/asf/couchdb/$COUCHDB_SVNPATH $COUCHDBSRCDIR
808262d initial commit
Jan Lehnardt authored
166 fi
167 cd ..
168 }
169
170 couchdb_install()
171 {
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
172 # if [ ! -e .couchdb-installed ]; then
173 cd src/$COUCHDBSRCDIR
ff47372 add path hack for jan, fix darwin build issue, add spidermonkey patch
Jan Lehnardt authored
174 # PATH hack for jan's machine
175 PATH=/usr/bin:$PATH ./bootstrap
176 export ERLC_FLAGS="+native"
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
177 export ERL=$WORKDIR/dist/$ERLANGDISTDIR/bin/erl
178 export ERLC=$WORKDIR/dist/$ERLANGDISTDIR/bin/erlc
808262d initial commit
Jan Lehnardt authored
179 ./configure \
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
180 --prefix=$WORKDIR/dist/$COUCHDBDISTDIR \
181 --with-erlang=$WORKDIR/dist/$ERLANGDISTDIR/lib/erlang/usr/include/ \
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
182 --with-js-include=$WORKDIR/dist/js/include \
183 --with-js-lib=$WORKDIR/dist/js/lib
808262d initial commit
Jan Lehnardt authored
184 unset ERL_EXECUTABLE
185 unset ERLC_EXECUTABLE
186
187 make $MAKE_OPTS
188 make install
189 couchdb_post_install
190 cd ../../
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
191 # touch .couchdb-installed
192 # fi
808262d initial commit
Jan Lehnardt authored
193 }
194
195 couchdb_link_erl_driver()
196 {
197 cd src/couchdb
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
198 gcc -I$WORKDIR/src/icu -I/usr/include -L/usr/lib \
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
199 -I$WORKDIR/dist/$ERLANGDISTDIR/lib/erlang/usr/include/ \
808262d initial commit
Jan Lehnardt authored
200 -lpthread -lm -licucore \
201 -flat_namespace -undefined suppress -bundle \
202 -o couch_erl_driver.so couch_erl_driver.c -fPIC
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
203 mv couch_erl_driver.so \
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
204 ../../../../dist/$COUCHDBDISTDIR/lib/couchdb/erlang/lib/couch-*/priv/lib
808262d initial commit
Jan Lehnardt authored
205 cd ../../
206 }
207
208 couchdb_post_install()
209 {
ff47372 add path hack for jan, fix darwin build issue, add spidermonkey patch
Jan Lehnardt authored
210 if [ "`uname`" = "Darwin" ]; then
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
211 # build couch_erl_driver.so against bundled ICU
737bb4a make compile on linux
Jan Lehnardt authored
212 couchdb_link_erl_driver
213 fi
808262d initial commit
Jan Lehnardt authored
214
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
215 cd ../../dist/$COUCHDBDISTDIR
808262d initial commit
Jan Lehnardt authored
216 # replace absolute to relative paths
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
217 perl -pi -e "s@$WORKDIR/dist/@@g" bin/couchdb bin/couchjs etc/couchdb/default.ini
218
219 # remove icu-config call
220 perl -pi -e "s@command=\"\`/usr/local/bin/icu-config --invoke\`@command=\"@" bin/couchdb
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
221 cd ../../src/$COUCHDBSRCDIR
808262d initial commit
Jan Lehnardt authored
222 }
223
224 couchdb()
225 {
226 couchdb_download
227 couchdb_install
228 }
229
230 create_dirs()
231 {
232 mkdir -p $DIRS
233 }
234
235 cleanup()
236 {
237 rm -rf $DIRS \
238 .erlang-downloaded .erlang-installed \
239 .couchdb-downloaded .couchdb-installed
240 }
241
242
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
243 download_js()
244 {
245 if [ ! -e .js-downloaded ]; then
246 cd src
247 if [ ! -e js-1.7.0.tar.gz ]; then
248 curl -O http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
249 fi
250 tar xzf js-1.7.0.tar.gz
251 cd ..
252 touch .js-downloaded
253 fi
254 }
255
256 install_js()
257 {
258 if [ ! -e .js-installed ]; then
737bb4a make compile on linux
Jan Lehnardt authored
259 uname=`uname`
ff47372 add path hack for jan, fix darwin build issue, add spidermonkey patch
Jan Lehnardt authored
260 if [ "$uname" = "Darwin" ]; then
737bb4a make compile on linux
Jan Lehnardt authored
261 soext="dylib"
262 else
263 soext="so"
264 fi
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
265 cd src/js
266 cd src
ff47372 add path hack for jan, fix darwin build issue, add spidermonkey patch
Jan Lehnardt authored
267 patch -N -p0 < ../../../patches/js/patch-jsprf.c
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
268 make $MAKEOPTS -f Makefile.ref
269 JS_DIST=$WORKDIR/dist/js make -f Makefile.ref export
270 cd ../../../
737bb4a make compile on linux
Jan Lehnardt authored
271 mkdir -p dist/${uname}_DBG.OBJ/
272 cp dist/js/lib*/libjs.$soext dist/${uname}_DBG.OBJ/libjs.$soext
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
273 touch .js-installed
274 fi
275 }
276
277 js()
278 {
279 download_js
280 install_js
281 }
282
808262d initial commit
Jan Lehnardt authored
283 package()
284 {
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
285 PACKAGEDIR="couchdbx-core-$ERLANG_VERSION-$COUCHDB_VERSION"
286 rm -rf $PACKAGEDIR
287 mkdir $PACKAGEDIR
1df4dfc keep a backup of the erlang sources without mangling around to use fo…
Jan Lehnardt authored
288 cp -r dist/$ERLANGDISTDIR \
289 dist/$COUCHDBDISTDIR \
290 dist/js \
291 $PACKAGEDIR
292 cd $PACKAGEDIR
293 ln -s $COUCHDBDISTDIR couchdb
294 cd ..
123c354 per-version downloads and builds, allow passing in of env vars for bu…
Jan Lehnardt authored
295 tar czf $PACKAGEDIR.tar.gz $PACKAGEDIR
296 # mv $PACKAGEDIR ../couchdbx-dist
297 # mv $PACKAGEDIR.tar.gz ../couchdbx-dist
298
299 cd dist/
300 rm -rf $ERLANGDISTDIR
301 mv erlang $ERLANGDISTDIR
1df4dfc keep a backup of the erlang sources without mangling around to use fo…
Jan Lehnardt authored
302 cd ..
808262d initial commit
Jan Lehnardt authored
303 }
304
305 # main:
306
307 create_dirs
308 erlang
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
309 js
808262d initial commit
Jan Lehnardt authored
310 couchdb
41b036a remove more erlang crap, merge patch by Per Ejeklint that adds $WORKD…
Jan Lehnardt authored
311 erlang_post_install
312 strip_erlang_dist
808262d initial commit
Jan Lehnardt authored
313 package
314
315 echo "Done, kthxbye."
Something went wrong with that request. Please try again.