Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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