Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 148 lines (112 sloc) 4.23 KB
#!/bin/bash -x
source scripts/env
# Build release numbers should follow the convention expected by couch-android-launcher.
# E.g., 8-1.1 which translates to "build for froyo, version 1.1"
if [ -z "$1" ]; then
echo "Give me a release number bub!"
exit 1
DATE=$(date +"%Y-%m-%d_%H-%M-%S")
mkdir -p $REL_PATH
# Configure and package Erlang/OTP
cp -Rdp build/deps/otp_rel build/deps/otp_rel.package
cd build/deps/otp_rel.package
./Install -cross -sasl /data/data/%app_name%/erlang
rm Install
# Remove unnecessary files
shopt -s extglob
rm -rf erts-5.7.5/doc erts-5.7.5/include erts-5.7.5/man erts-5.7.5/src misc releases usr
rm bin/dialyzer bin/erlc bin/escript bin/run_erl bin/to_erl bin/typer
rm erts-5.7.5/bin/dialyzer erts-5.7.5/bin/erlc erts-5.7.5/bin/escript erts-5.7.5/bin/run_erl erts-5.7.5/bin/to_erl erts-5.7.5/bin/typer
cd lib
rm -rf !(crypto-1.6.4|erts-5.7.5|inets-5.3|kernel-2.13.5|public_key-0.5|sasl-2.1.9|ssl-3.10.8|stdlib-1.16.5|xmerl-1.2.4)
cd xmerl-1.2.4/ebin/
rm !(xmerl_ucs.beam)
cd ../..
cd inets-5.3/ebin/
rm !(httpd_util.beam|httpd_util|
cd ../..
rm -rf inets-5.3/priv
rm public_key-0.5/asn1/OTP-PUB-KEY.erl
rm ssl-3.10.8/pkix/OTP-PKIX.erl
# Remove vestigal files
find . -depth -name src -type d -exec rm -rf {} \;
find . -depth -name doc -type d -exec rm -rf {} \;
find . -depth -name examples -type d -exec rm -rf {} \;
find . -depth -name include -type d -exec rm -rf {} \;
# Finally move things into place
cp -Rdp /data/data/%app_name%/couchdb $REL_PATH/couchdb
mv build/deps/otp_rel.package $REL_PATH/erlang
# We need the shared lib because our toolchain does not support the static lib (libstdc++ stuff)
cp build/deps/mozilla-current/mozilla-central/js/src/ $REL_PATH/couchdb/bin
# 2) Create couchjs_wrapper script (because we can't link to libmozjs.a and so need LD_LIBRARY_PATH set)
# 3) Update #!/bin/sh in data/data/$APP_NAME/erlang/lib/couch-1.0.1/priv/couchspawnkillable
# 4) Reflect new locations and the Android environment
[[ -f release ]] && rm release
ln -s $REL_PATH release
mkdir -p release/couchdb/lib/couchdb/android_icu
cp -r android_icu release/couchdb/lib/couchdb
patch -lp0 < patches/release.patch
rm release
chmod +x $REL_PATH/couchdb/bin/couchjs_wrapper
# Install geocouch
mkdir $REL_PATH/erlang/lib/geocouch
cp $COUCH_ANDROID_HOME/build/deps/geocouch/build/*.beam $REL_PATH/erlang/lib/geocouch
spatial_manager={couch_spatial, start_link, []}
_spatial_cleanup = {couch_httpd_spatial, handle_spatial_cleanup_req}
_spatial = {couch_httpd_spatial, handle_spatial_req}
_spatial/_list = {couch_httpd_spatial_list, handle_spatial_list_req}
_spatial/_info = {couch_httpd_spatial, handle_design_info_req}
_spatial/_compact = {couch_httpd_spatial, handle_compact_req}
;deprecated API
_spatiallist = {couch_httpd_spatial_list, handle_spatial_list_req_deprecated}'
echo "$GEOCOUCH" >> $REL_PATH/couchdb/etc/couchdb/local.ini
# Build ICU for whatever version of Android was compiled in ~/software/android/sdk/sources
agcc \
-shared \
-o $REL_PATH/couchdb/lib/couchdb/ $COUCH_ANDROID_HOME/build/deps/couchdb/src/couchdb/priv/.libs/libcouch_icu_driver.a \
-licuuc \
-licudata \
-licui18n \
-L$COUCH_ANDROID_HOME/build/deps/otp_rel/erts-5.7.5/bin \
# Remove vestigal files from Couch directory
# (Futon is in www)
cd $REL_PATH/couchdb
rm -rf share/couchdb/www share/doc
rm -rf share/man
rm -rf var
rm -rf etc/init.d
rm -rf etc/logrotate.d
rm -rf lib/couchdb/erlang/lib/etap/
# Location to ICU will be determined dynamically when Couch is initialized by the Couch-dependant app.
# See libcouch-android and android_icu/ for more information.
rm lib/couchdb/
cd ..
# Strip beam files of debugging symbols
$COUCH_ANDROID_HOME/build/deps/otp/bootstrap/bin/erl -eval "erlang:display(beam_lib:strip_release(\"couchdb/lib/couchdb/erlang\"))" -s init stop
$COUCH_ANDROID_HOME/build/deps/otp/bootstrap/bin/erl -eval "erlang:display(beam_lib:strip_release(\"erlang\"))" -s init stop
# Archive the release
touch filecount.$(find | wc -l)
tar -czf ../release-$1.tgz filecount.* !(filecount.*)
cd ..
Something went wrong with that request. Please try again.