couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Installing_on_Android" by MattAdams
Date Sun, 27 Feb 2011 14:03:40 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "Installing_on_Android" page has been changed by MattAdams.
The comment on this change is: Updated build instructions for Android.
http://wiki.apache.org/couchdb/Installing_on_Android?action=diff&rev1=21&rev2=22

--------------------------------------------------

  = Installing CouchDB on Android (from source) =
  
+ == Update February 27th, 2011 ==
+ 
+ Below are updated instructions that produce a build that is better organized for Android,
somewhat more lightweight in the final product and slightly more straightforward to understand
(and with support for replications over a SSH reverse proxy!).  This build requires updates
to the Android installer that have not yet been pushed upstream so please don't expect this
to work out-of-the-box. -- MattAdams
+ 
  == Caveats ==
  
   * Please note that the following instructions for Android produce a build that mostly works
but is not entirely bug free.  Any help tracking down and resolving problems with this procedure
and the resulting build would be greatly appreciated.
@@ -10, +14 @@

  
   * As alluded to below, I was unable to get Couch to agree to link with the static Spidermonkey
library.  This is due to the fact that C++ support in more recent official releases of the
Google SDK/NDK is lacking.  It would be preferable to link statically because it would remove
the need for a separate file ({{{libmozjs.so}}}) and thus one less thing to go wrong (there
are several workarounds below & in related patches for the fact that we need to worry
about dynamic linking with regards to the default couch query server, {{{couchjs}}}).
  
-  * Pay close attention to the instructions.  You will need to replace {{{com.your.namespace}}}
with something appropriate for your project through the instructions below and in the related
patches.  Also, '''if you are not producing an official build of Couch, be sure to configure
Couch and the packaging steps to install it in somewhere other than''' {{{/sdcard/couch}}}
'''and use a port other than''' {{{5984}}} '''to avoid clobbering the official builds'''.
+  * Pay close attention to the instructions:
+    * You will need to replace {{{com.your.namespace}}} with something appropriate for your
project throughout the instructions below and in the related patches.
+    * Due to Android's preferences for where files "should be placed" you will need to update
several paths below related to {{{com.your.namespace}}}.  
+    * Also, '''if you are not producing an official build of Couch, be sure use a port other
than''' {{{5984}}} '''to avoid clobbering the official builds'''.
  
-  * Once installed you will probably want to interact with Futon on Android from your workstation.
 Run {{{$ adb forward tcp:5985 tcp:5984}}} and point your web browser to {{{http://localhost:5985}}}
to access Couch.  Note that some of the test suite expects to be run from {{{:5984}}} and
will fail when accessed through this configuration.  To run the complete set of tests you
will need to stop your local Couch instance (if any) and set the forward up on {{{:5984}}}
on both ends.
+  * Once installed you will probably want to interact with Futon on Android from your workstation.
 Run {{{$ adb forward tcp:5985 tcp:5984}}} and point your web browser to {{{http://localhost:5985}}}
to access Couch.  Note that some of the test suite expects to be run from {{{:5984}}} and
will fail when accessed through this configuration (although we only noticed this when building
Couch 1.0.1 -- the problem appears to have disappeared in Couch 1.0.2).  To run the complete
set of tests you will need to stop your local Couch instance (if any) and set the forward
up on {{{:5984}}} on both ends.  You will also need to stop {{{www}}} from being removed from
the build (we got rid of Futon to save space -- at this point it is only useful to developers
anyway).
  
  == Credits ==
  
@@ -26, +33 @@

  
  See [[https://github.com/couchone/couch-android-launcher|couch-android-launcher]] and [[https://github.com/couchone/libcouch-android|libcouch-android]]
for the end-user Android application that will use the package produced by this build.
  
- Supporting these builds are a number of helper scripts and patches: AndroidEnv, AndroidAgcc,
AndroidCouchPatch, AndroidMozillaPatch, AndroidOtpPatch, AndroidReleasePatch, AndroidSdCardPatch
+ Supporting these builds are a number of helper scripts and patches: AndroidEnv, AndroidAgcc,
AndroidCouchPatch, AndroidMozillaPatch, AndroidOtpPatch, AndroidReleasePatch
  
  === Step 1: Build Android from Source ===
  
@@ -57, +64 @@

  tar jxf curl-$VERSION.tar.bz2
  cd curl-$VERSION
  
+ # See AndroidEnv in Installing_on_Android wiki topic
  source $HOME/software/android/scripts/env
  ANDROID_SDK=$HOME/software/android/sdk
  
@@ -91, +99 @@

  
  === Step 3: Build Mozilla NSPR & Spidermonkey ===
  
- The following instructions are based on the Fennec instructions [[https://wiki.mozilla.org/Mobile/Fennec/Android#JS.2FNSPR_only|for
building JS/NSPR only]].  I also used [[http://ftp.mozilla.org/pub/mozilla.org/mobile/source/android-ndk-r4c-0moz3.tar.bz2|their
Android NDK package]] for the builds. 
+ The following instructions are based on the Fennec instructions [[https://wiki.mozilla.org/Mobile/Fennec/Android#JS.2FNSPR_only|for
building JS/NSPR only]].  We used [[http://ftp.mozilla.org/pub/mozilla.org/mobile/source/android-ndk-r4c-0moz3.tar.bz2|their
Android NDK package]] for the builds.
  
  ==== Retrieve mozilla-current ====
  
@@ -116, +124 @@

  
  NSPR isn't technically required but it is heavily integrated into current versions of Spidermonkey
and future versions will almost certainly require it.
  
- Also, NSPR will compile against current NDKs but I choose to use the recommended one for
the sake of consistency.  The next step (Spidermonkey) most certainly requires the specified
NDK version.
+ Also, NSPR will compile against current NDKs but I choose to use the recommended one (ndk-r4c-0moz3)
for the sake of consistency.  The next step (Spidermonkey) requires the specified NDK version.
  
  {{{
  source $HOME/software/android/scripts/env
@@ -127, +135 @@

  ./configure \
  --target=arm-android-eabi \
  --with-android-ndk=$ANDROID_NDK \
- --with-android-platform=$ANDROID_NDK/build/platforms/android-8/arch-arm
+ --with-android-platform=$ANDROID_NDK/build/platforms/android-8/arch-arm \
+ --enable-strip
  
  make -s
  
@@ -137, +146 @@

  
  ==== Spidermonkey ====
  
- Be aware that Spidermonkey '''[[https://bugzilla.mozilla.org/show_bug.cgi?id=617115|will
not]]''' build against Android NDK r5.
+ Be aware that Spidermonkey '''[[https://bugzilla.mozilla.org/show_bug.cgi?id=617115|will
not]]''' build against Android NDK r5 (we haven't checked this issue recently, it may have
changed).
  
  {{{
  ANDROID_NDK=$HOME/software/android/android-ndk-r4c
  
  cd mozilla-central/js/src
- rm config.cache
  autoconf2.13
  
  ./configure \
@@ -153, +161 @@

  --with-android-version=8 \
  --disable-tests \
  --disable-shared \
- --enable-debug \
- --disable-optimizations \
  --enable-static \
+ --enable-strip \
  --enable-endian=little \
  --with-arm-kuser \
  --enable-threadsafe \
@@ -172, +179 @@

  #mv libjs_static.a libmozjs.a
  }}}
  
- You should remove {{{--enable-debug}}} and {{{--disable-optimizations}}} for production
builds.
+ You should add {{{--enable-debug}}} and {{{--disable-optimizations}}} for development builds
or when running the Futon test suite for the first time (assertions matter).
  
  === Step 4: Build Erlang/OTP ===
+ 
+ An updated port of Erlang that will work on Android would be greatly appreciated!  I know
there has been some work on this by the Erlang folks but I am not aware of the location of
the build instructions, source code or patches.
  
  {{{
  rm -rf otp
@@ -205, +214 @@

  
  {{{
  rm -rf couchdb
+ rm -rf /sdcard/*
  git clone git://github.com/apache/couchdb.git
  cd couchdb
- git checkout 1.0.1
+ git checkout 1.0.2
  
  ##
  # 1) Android Build Support from https://github.com/apage43/couchdb/tree/0.11.x-android
@@ -226, +236 @@

  CC=agcc \
  ./configure \
  --host=arm-eabi \
- --prefix=/sdcard/couch \
+ --prefix=/sdcard/Android/data/com.your.namespace/couchdb \
  --with-android=$ANDROID_SDK/sources \
  --with-android-curl=$(pwd)/../curl-7.20.0 \
  --with-erlang=$(pwd)/../otp_rel/usr/include \
@@ -239, +249 @@

  
  === Step 6: Package for use on Android ===
  
- A lot of the code below was written simply to package things in a manner similar to Aaron's
original layout of [[http://couchdb-android.s3.amazonaws.com/couch-erl-1.0.tgz|couch-erl-1.0.tgz]].
 There is no need for a separate {{{dns-fix.tgz}}} or {{{fixup-1.0.tgz}}} with this package.
- 
  {{{
  #!/bin/bash -x
- # 
+ 
  if [ -z "$1" ]; then
      echo "Give me a release number bub!"
      exit 1
@@ -252, +260 @@

  DATE=$(date +"%Y-%m-%d_%H-%M-%S")
  RELEASE="release-$DATE"
  
- mkdir -p $RELEASE/data/data/com.your.namespace/bin
+ mkdir -p $RELEASE/data/data/com.your.namespace
  
  ##
- # Configure and package Erlang/OTP 
+ # Configure and package Erlang/OTP
  #
  
  cp -Rdp otp_rel otp_rel.package
@@ -265, +273 @@

  ./Install -cross -sasl /data/data/com.your.namespace/erlang
  rm Install
  
- rm -rf erts-5.7.5/include/* misc releases usr
+ # Necessary?
+ chmod -x erts-5.7.5/bin/start_erl.src erts-5.7.5/bin/start.src
+ 
+ # Remove unnecessary files
+ 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
+ 
+ # Pare lib directory
+ libs_to_keep="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 lib
- 
- libs_to_keep="crypto-1.6.4 erts-5.7.5 inets-5.3 kernel-2.13.5 sasl-2.1.9 ssl-3.10.8 stdlib-1.16.5
xmerl-1.2.4"
- 
  mkdir backuplib
  
  for i in $libs_to_keep
@@ -285, +297 @@

  rmdir ../backuplib
  
  # Remove vestigal files
+ find . -depth -name src -type d -exec rm -rf {} \;
+ find . -depth -name examples -type d -exec rm -rf {} \;
+ find . -depth -name include -type d -exec rm -rf {} \;
- rm -rf crypto-1.6.4/src/*.erl
- rm -rf erts-5.7.5/src/*.erl
- rm -rf inets-5.3/examples/* inets-5.3/src/*.erl
- rm -rf kernel-2.13.5/examples/* kernel-2.13.5/include/* kernel-2.13.5/src/*.erl
- rm -rf sasl-2.1.9/src/*.erl
- rm -rf ssl-3.10.8/examples/certs ssl-3.10.8/examples/ebin ssl-3.10.8/examples/src ssl-3.10.8/include/*
ssl-3.10.8/pkix/*.erl ssl-3.10.8/src/*.erl
- rm -rf stdlib-1.16.5/examples/* stdlib-1.16.5/include/* stdlib-1.16.5/src/*.erl
- rm -rf xmerl-1.2.4/include xmerl-1.2.4/src 
  
- cd ..
- 
- # Update path to Android sh -- replace with a nice patch at some point
- for i in bin/erl bin/start bin/start_erl erts-5.7.5/bin/erl erts-5.7.5/bin/erl.src erts-5.7.5/bin/start
erts-5.7.5/bin/start_erl.src erts-5.7.5/bin/start.src lib/inets-5.3/priv/bin/runcgi.sh
- do
-     sed -e "s;#!/bin/sh;#!/system/bin/sh;" $i > $i.new
-     mv $i.new $i
-     chmod 755 $i
- done
- 
- chmod -x erts-5.7.5/bin/start_erl.src erts-5.7.5/bin/start.src
- 
- cd ..
- 
- ##
- # Configure and package CouchDB
- # 
- 
- cp -Rdp /sdcard sdcard.package
- 
- mv sdcard.package/couch/lib/couchdb/erlang/lib/couch-1.0.1 otp_rel.package/lib
- mv sdcard.package/couch/lib/couchdb/bin/couchjs $RELEASE/data/data/com.your.namespace/bin
- cp mozilla-central/js/src/libmozjs.so $RELEASE/data/data/com.your.namespace/bin
- #cp mozilla-central/js/src/shell/js $RELEASE/data/data/com.your.namespace/bin
- 
- cd sdcard.package/couch
- 
- # Reflect updated locations and the Android environment
- patch -p1 < ../../../sdcard.patch
- 
- cd ../../..
+ cd ../..
  
  ##
  # Finally move things into place
  #
  
+ cp -Rdp /sdcard $RELEASE/sdcard
- mv otp_rel.package $RELEASE/data/data/com.your.namespace/erlang
+ mv otp_rel.package $RELEASE/sdcard/Android/data/com.your.namespace/erlang
- mv sdcard.package $RELEASE/sdcard
  
- cd $RELEASE
+ # We need the shared lib because our toolchain does not support the static lib (libstdc++
stuff)
+ cp mozilla-central/js/src/libmozjs.so $RELEASE/sdcard/Android/data/com.your.namespace/couchdb/lib/couchdb/bin
  
  ###
  # 1) DNS fixes from apage43's couchdb-android.s3.amazonaws.com/dns-fix.tgz
  # 2) Create couchjs_wrapper script (because we can't link to libmozjs.a and so need LD_LIBRARY_PATH
set)
- # 2) Update #!/bin/sh in data/data/com.your.namespace/erlang/lib/couch-1.0.1/priv/couchspawnkillable
+ # 3) Update #!/bin/sh in data/data/com.your.namespace/erlang/lib/couch-1.0.1/priv/couchspawnkillable
+ # 4) Reflect new locations and the Android environment
  #
+ rm release
+ ln -s $RELEASE release
- patch -p1 < ../release.patch
+ patch -p0 < release.patch
  
- chmod +x data/data/com.your.namespace/bin/couchjs_wrapper
+ chmod +x $RELEASE/sdcard/Android/data/com.your.namespace/couchdb/bin/couchjs_wrapper
  
- # Build ICU for whatever version of Android was compiled in ~/rdinc/software/android/sdk/sources
+ # Build ICU for whatever version of Android was compiled in ~/software/android/sdk/sources
- source $HOME/rdinc/software/android/scripts/env
+ source $HOME/software/android/scripts/env
  
  agcc \
  -shared \
- -o data/data/com.your.namespace/couch_icu_driver.so ../couchdb/src/couchdb/priv/.libs/libcouch_icu_driver.a
\
+ -o $RELEASE/sdcard/Android/data/com.your.namespace/couchdb/lib/couchdb/couch_icu_driver.so
couchdb/src/couchdb/priv/.libs/libcouch_icu_driver.a \
  -licuuc \
  -licudata \
  -licui18n \
@@ -357, +338 @@

  -lbeam
  
  ##
+ # Remove vestigal files from Couch directory
+ # (Futon is in www)
+ #
+ cd $RELEASE/sdcard/Android/data/com.your.namespace/couchdb
+ rm -rf share/couchdb/www share/doc share/man
+ cd ../../../../../..
+ 
+ ##
  # Archive the release
  #
- tar -czf ../release-$1.tgz *
- 
+ cd $RELEASE
+ touch filecount.$(find | wc -l)
+ tar -czf ../release-$1.tgz filecount.* data sdcard
  cd ..
  }}}
  

Mime
View raw message