androidmercurial

How can mercurial be run on android?


This page documents running an old version (1.8.4) of mercurial but says

"(later versions need an unavaliable python module named grp)"


Solution

  • This is the way I did it (but am still interested to hear of alternative ways) using an Ubuntu 16.04 machine and a intel 64bit android emulator running on Windows 7, using mercurial 3.7.3

    1. Using an Ubuntu system, follow these instructions for creating 2.7 version of python capable of running hg.

    2. Copy python onto android device into an app files directory (so it can be executed)

      on windows host

      adb push python279.x86_64 /sdcard

      adb -e shell

      on android device

      cd /data/user/0/$SOMEAPPDIR/files

      cp -Rav /scard/python279.x86_64 .

      make python excutable

      chmod +x python279.x86_64/bin/python2.7

      set some env vars need to make python run on android

      export LD_LIBRARY_PATH=/data/user/0/$SOMEAPPDIR/files/python279.x86_64/lib

      export LD_PRELOAD=libffi.so:libbz2.so

      export PATH=$PATH:/data/user/0/$SOMEAPPDIR/files/python279.x86_64/bin

    Python should now be able to be run with python2.7

    enter image description here

    1. Build mercurial on Ubuntu host.

      download mercurial 3.7.3

      uz mercurial-3.7.3.tar.gz

      cd mercurial-3.7.3 && make all

      HOME=$PWD/dist make install

    2. Make minor modifications

      cd dist/mercurial-3.7.3/dist/lib/python/mercurial

      rm *.so

      cp pure/*.py .

      Edit posix.py and delete the "import grp" line.

    3. copy mercurial onto android device

      on windows host

      adb push dist /sdcard

      adb -e shell

      on android device

      cd /data/user/0/$SOMEAPPDIR/files

      cp /sdcard/dist .

      alias hg to make it easy to use

      alias hg='python2.7 /data/user/0/$SOMEAPPDIR/files/dist/bin/hg'

    Hg should now be possible to use on android device.

    It's even possible to clone remote repos but I also had to pass the --insecure flag to bypass ssl errors.

    enter image description here