diff options
-rw-r--r-- | Assistant/Install.hs | 3 | ||||
-rw-r--r-- | Assistant/Ssh.hs | 3 | ||||
-rw-r--r-- | Assistant/XMPP/Git.hs | 3 | ||||
-rw-r--r-- | Init.hs | 10 | ||||
-rw-r--r-- | Makefile | 21 | ||||
-rw-r--r-- | Utility/Shell.hs | 20 | ||||
-rw-r--r-- | doc/design/assistant/android.mdwn | 56 | ||||
-rw-r--r-- | doc/design/assistant/blog/day_187__porting_utilities.mdwn | 22 | ||||
-rw-r--r-- | doc/install.mdwn | 1 | ||||
-rw-r--r-- | doc/install/Android.mdwn | 37 | ||||
-rw-r--r-- | doc/install/Linux_standalone.mdwn | 5 | ||||
-rw-r--r-- | standalone/android/Makefile | 51 | ||||
-rw-r--r-- | standalone/android/dropbear.patch | 55 | ||||
-rw-r--r-- | standalone/android/rsync.patch | 40 | ||||
-rwxr-xr-x | standalone/android/runshell | 62 | ||||
-rw-r--r-- | standalone/licences.gz | bin | 55614 -> 56750 bytes |
16 files changed, 326 insertions, 63 deletions
diff --git a/Assistant/Install.hs b/Assistant/Install.hs index 989843e90..0db021ef7 100644 --- a/Assistant/Install.hs +++ b/Assistant/Install.hs @@ -14,6 +14,7 @@ import Assistant.Install.AutoStart import Assistant.Ssh import Locations.UserConfig import Utility.FileMode +import Utility.Shell #ifdef darwin_HOST_OS import Utility.OSX @@ -58,7 +59,7 @@ ensureInstalled = go =<< standaloneAppBase sshdir <- sshDir let shim = sshdir </> "git-annex-shell" let content = unlines - [ "#!/bin/sh" + [ shebang , "set -e" , "exec", base </> "runshell" ++ " git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\"" diff --git a/Assistant/Ssh.hs b/Assistant/Ssh.hs index 15c97ab53..753babad4 100644 --- a/Assistant/Ssh.hs +++ b/Assistant/Ssh.hs @@ -10,6 +10,7 @@ module Assistant.Ssh where import Common.Annex import Utility.TempFile import Utility.UserInfo +import Utility.Shell import Git.Remote import Data.Text (Text) @@ -155,7 +156,7 @@ addAuthorizedKeysCommand rsynconly dir pubkey = join "&&" echoval v = "echo " ++ shellEscape v wrapper = "~/.ssh/git-annex-shell" script = - [ "#!/bin/sh" + [ shebang , "set -e" , "exec git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\"" ] diff --git a/Assistant/XMPP/Git.hs b/Assistant/XMPP/Git.hs index d3c8343c2..8dba309a8 100644 --- a/Assistant/XMPP/Git.hs +++ b/Assistant/XMPP/Git.hs @@ -25,6 +25,7 @@ import qualified Git.Branch import Locations.UserConfig import qualified Types.Remote as Remote import Utility.FileMode +import Utility.Shell import Network.Protocol.XMPP import qualified Data.Text as T @@ -141,7 +142,7 @@ xmppPush cid gitpush = runPush SendPack cid handleDeferred $ do let wrapper = tmpdir </> "git-remote-xmpp" program <- readProgramFile writeFile wrapper $ unlines - [ "#!/bin/sh" + [ shebang , "exec " ++ program ++ " xmppgit" ] modifyFileMode wrapper $ addModes executeModes @@ -21,6 +21,7 @@ import Logs.UUID import Annex.Version import Annex.UUID import Utility.UserInfo +import Utility.Shell genDescription :: Maybe String -> Annex String genDescription (Just d) = return d @@ -92,7 +93,8 @@ preCommitHook :: Annex FilePath preCommitHook = (</>) <$> fromRepo Git.localGitDir <*> pure "hooks/pre-commit" preCommitScript :: String -preCommitScript = - "#!/bin/sh\n" ++ - "# automatically configured by git-annex\n" ++ - "git annex pre-commit .\n" +preCommitScript = unlines + [ shebang + , "# automatically configured by git-annex" + , "git annex pre-commit ." + ] @@ -152,6 +152,7 @@ docs: $(mans) clean: rm -rf $(GIT_ANNEX_TMP_BUILD_DIR) $(bins) $(mans) test configure *.tix .hpc $(sources) \ doc/.ikiwiki html dist $(clibs) build-stamp tags + $(MAKE) -f standalone/android clean sdist: clean $(mans) ./Build/make-sdist.sh @@ -237,6 +238,26 @@ android: FEATURES="-DWITH_ANDROID -DWITH_ASSISTANT -DWITH_GLOB -DWITH_DNS" \ OS=Android $(MAKE) fast +ANDROIDAPP_DEST=$(GIT_ANNEX_TMP_BUILD_DIR)/git-annex.android +androidapp: + $(MAKE) android + $(MAKE) -f standalone/android + + rm -rf "$(ANDROIDAPP_DEST)" + + cp -a standalone/android/runshell "$(ANDROIDAPP_DEST)" + cp -aR standalone/android/git-annex-bundle "$(ANDROIDAPP_DEST)" + install -d "$(ANDROIDAPP_DEST)/git-annex-bundle/bin" + cp git-annex "$(ANDROIDAPP_DEST)/git-annex-bundle/bin/" + + $$HOME/.ghc/android-14/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-strip "$(ANDROIDAPP_DEST)"/git-annex-bundle/bin/* + + ln -sf git-annex "$(ANDROIDAPP_DEST)/git-annex-bundle/bin/git-annex-shell" + zcat standalone/licences.gz > $(ANDROIDAPP_DEST)/git-annex-bundle/LICENSE + install -d "$(ANDROIDAPP_DEST)/git-annex-bundle/templates" + + cd $(ANDROIDAPP_DEST) && tar czf ../git-annex-android.tar.gz . + # used by ./ghci getflags: @echo $(ALLFLAGS) $(clibs) diff --git a/Utility/Shell.hs b/Utility/Shell.hs new file mode 100644 index 000000000..fecafe1a8 --- /dev/null +++ b/Utility/Shell.hs @@ -0,0 +1,20 @@ +{- /bin/sh handling + - + - Copyright 2013 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +{-# LANGUAGE CPP #-} + +module Utility.Shell where + +shellPath :: FilePath +#ifndef WITH_ANDROID +shellPath = "/bin/sh" +#else +shellPath = "/system/bin/sh" +#endif + +shebang :: String +shebang = "#!" ++ shellPath diff --git a/doc/design/assistant/android.mdwn b/doc/design/assistant/android.mdwn index c7fcb2c57..c972b5529 100644 --- a/doc/design/assistant/android.mdwn +++ b/doc/design/assistant/android.mdwn @@ -1,25 +1,10 @@ ### goals 1. Get git-annex working at the command line in Android, - along with all the programs it needs. + along with all the programs it needs. **done** 2. Get the webapp and assistant working. A hopefully small Java app will be developed, which runs the webapp daemon, and a web browser to display it. -Current status: git-annex can be built for Android, with `make android`. -You need <https://github.com/neurocyte/ghc-android> installed first, -and also have to `cabal install` all necessary dependencies. - -### TODO - -* port busybox, so it doesn't need KBOX's busybox -* Make a runshell wrapper for Android, setting paths, etc. -* Build a standalone tarball for Android. -* Make build system that can generate ports, and tarball, from source - checkouts. - -* git-annex sets `#!/bin/sh` in hook script, but that is not - a valid path on android, and the right path needs to be determined at runtime. - ### Android specific features The app should be aware of power status, and avoid expensive background @@ -32,42 +17,3 @@ transfers when not on wifi. This may need to be configurable. Due to use of the FAT filesystem, which doesn't do symlinks, [[desymlink]] is probably needed for at least older Android devices that have SD cards. - -### Porting notes - -#### git - -To build git, you can use the C cross compiler installed by ghc-android. -I did so like this: - - PATH=~/.ghc/android-14/arm-linux-androideabi-4.7/bin:$PATH NO_OPENSSL=1 NO_GETTEXT=1 NO_GECOS_IN_PWENT=1 NO_GETPASS=1 NO_NSEC=1 NO_MKDTEMP=1 NO_PTHREADS=1 NO_PERL=1 NO_CURL=1 NO_EXPAT=1 NO_TCLTK=1 NO_ICONV=1 make - -This required first making cc a symlink to arm-linux-androideabi-gcc - -#### rsync - -Copy in config.sub and config.guess from recent autoconf, and build: - - PATH=~/.ghc/android-14/arm-linux-androideabi-4.7/bin:$PATH ./configure --host=arm-linux-androideabi --disable-locale --disable-iconv-open --disable-iconv --disable-acl-support --disable-xattr-support - PATH=~/.ghc/android-14/arm-linux-androideabi-4.7/bin:$PATH make - -Build failures can be worked around by removing uses of `S_IEXEC` and -getpass. - -#### gnupg - - PATH=~/.ghc/android-14/arm-linux-androideabi-4.7/bin:$PATH ./configure --host=arm-linux-androideabi --disable-gnupg-iconv --enable-minimal --disable-card-support --disable-agent-support --disable-photo-viewers --disable-keyserver-helpers --disable-nls - PATH=~/.ghc/android-14/arm-linux-androideabi-4.7/bin:$PATH make - -Build fails in docs, but see `g10/gpg` - -#### dropbear - -Use git://github.com/android/platform_external_dropbear - -Copy in config.sub and config.guess from recent autoconf, and build: - - PATH=~/.ghc/android-14/arm-linux-androideabi-4.7/bin:$PATH ./configure --host=arm-linux-androideabi --disable-lastlog --disable-utmp --disable-utmpx --disable-wtmp --disable-wtmpx - PATH=~/.ghc/android-14/arm-linux-androideabi-4.7/bin:$PATH make - -TODO build fails diff --git a/doc/design/assistant/blog/day_187__porting_utilities.mdwn b/doc/design/assistant/blog/day_187__porting_utilities.mdwn new file mode 100644 index 000000000..496c74a1f --- /dev/null +++ b/doc/design/assistant/blog/day_187__porting_utilities.mdwn @@ -0,0 +1,22 @@ +Ported all the utilities git-annex needs to run on Android: +git, rsync, gnupg, dropbear (ssh client), busybox. Built a +Makefile that can download, patch, and cross build these from source. + +While all the utilities work, dropbear doesn't allow git-annex to use ssh +connection caching, which is rather annoying especially since these systems +tend to be rather slow and take a while to start up ssh connections. +I'd sort of like to try to get openssh's client working on Android instead. +Don't know how realistic that is. + +Dealt with several parts of git-annex that assumed `/bin/sh` exists, +so it instead uses `/system/bin/sh` on Android. Also adapted `runshell` +for Android. + +Now I have a 8 mb compressed tarball for Android. +Uncompressed it's 25 mb. This includes a lot of git and busybox +commands that won't be used, so it could be trimmed down further. +16 mb of it is git-annex itself. + +[[Instructions for using the Android tarball|install/Android]] +This is for users who are rather brave, not afraid of command line and +keyboard usage. Good first step. diff --git a/doc/install.mdwn b/doc/install.mdwn index 8a3091d8b..e1e055a75 100644 --- a/doc/install.mdwn +++ b/doc/install.mdwn @@ -14,6 +14,7 @@ detailed instructions | quick install [[ScientificLinux5]] | (and other RHEL5 clones like CentOS5) [[openSUSE]] | Windows | [[sorry, Windows not supported yet|todo/windows_support]] +[[Android]] | """]] ## Using cabal diff --git a/doc/install/Android.mdwn b/doc/install/Android.mdwn new file mode 100644 index 000000000..120e2453b --- /dev/null +++ b/doc/install/Android.mdwn @@ -0,0 +1,37 @@ +git-annex can be used on Android, however you need to know your way around +the command line to install and use it. (An Android app may be developed +eventually.) + +## prebuilt tarball + +Download the [prebuilt tarball](http://downloads.kitenet.net/git-annex/android/). +Instructions below assume it was downloaded to `/sdcard/Download`, which +is the default if you use the web browser for the download. + +To use this tarball, you need to install either +[KBOX](http://kevinboone.net/kbox.html) or +[Terminal IDE](https://play.google.com/store/apps/details?id=com.spartacusrex.spartacuside) +(available in Google Play). +This is both to get a shell console, as well as a location under +`/data` where git-annex can be installed. + +Open the console app you installed, and enter this command: + + cd $(which sh)/..; tar xf /sdcard/Download/git-annex-android.tar.gz + +Now git-annex is installed, but to use it you need to enter a special +shell environment: + + runshell + +Now you have git-annex, git, and some other utilities available, and can +do everything in the [[walkthrough]] and more. + +## building it yourself + +git-annex can be built for Android, with `make android`. +You need <https://github.com/neurocyte/ghc-android> installed first, +and also have to `cabal install` all necessary dependencies. This is not +yet an easy process. + +You also need to install git and all the utilities listed on [[fromscratch]]. diff --git a/doc/install/Linux_standalone.mdwn b/doc/install/Linux_standalone.mdwn index 5db6510fa..ef0ded8d5 100644 --- a/doc/install/Linux_standalone.mdwn +++ b/doc/install/Linux_standalone.mdwn @@ -6,6 +6,9 @@ This tarball should work on most Linux systems. It does not depend on anything except for glibc. [download tarball](http://downloads.kitenet.net/git-annex/linux/) - + +To use, just unpack the tarball, `cd git-annex.linux` and run `./runshell` +-- this sets up an environment where you can use `git annex` + Warning: This is a last resort. Most Linux users should instead [[install]] git-annex from their distribution of choice. diff --git a/standalone/android/Makefile b/standalone/android/Makefile new file mode 100644 index 000000000..81f76749a --- /dev/null +++ b/standalone/android/Makefile @@ -0,0 +1,51 @@ +# Cross-compiles utilities needed for git-annex on Android. + +# Add Android cross-compiler to PATH (as installed by ghc-android) +PATH:=$(HOME)/.ghc/android-14/arm-linux-androideabi-4.7/bin:$(PATH) + +build: source + mkdir -p git-annex-bundle/bin + + cd source/git && $(MAKE) install NO_OPENSSL=1 NO_GETTEXT=1 NO_GECOS_IN_PWENT=1 NO_GETPASS=1 NO_NSEC=1 NO_MKDTEMP=1 NO_PTHREADS=1 NO_PERL=1 NO_CURL=1 NO_EXPAT=1 NO_TCLTK=1 NO_ICONV=1 prefix= DESTDIR=../../git-annex-bundle + + cp source/busybox/configs/android2_defconfig source/busybox/.config + echo 'CONFIG_FEATURE_INSTALLER=y' >> source/busybox/.config + cd source/busybox && yes '' | $(MAKE) oldconfig + cd source/busybox && $(MAKE) + cp -a source/busybox/busybox git-annex-bundle/bin/ + + cd source/dropbear && git reset --hard origin/master && git am < ../../dropbear.patch + cp source/automake/lib/config.sub source/automake/lib/config.guess source/dropbear/ + cd source/dropbear && ./configure --host=arm-linux-androideabi --disable-lastlog --disable-utmp --disable-utmpx --disable-wtmp --disable-wtmpx + cd source/dropbear && $(MAKE) dbclient + cp -a source/dropbear/dbclient git-annex-bundle/bin/ssh + + cd source/rsync && git reset --hard origin/master && git am < ../../rsync.patch + cp source/automake/lib/config.sub source/automake/lib/config.guess source/rsync/ + cd source/rsync && ./configure --host=arm-linux-androideabi --disable-locale --disable-iconv-open --disable-iconv --disable-acl-support --disable-xattr-support + cd source/rsync && $(MAKE) + cp -a source/rsync/rsync git-annex-bundle/bin/ + + cd source/gnupg && scripts/autogen.sh + cd source/gnupg && ./configure --host=arm-linux-androideabi --disable-gnupg-iconv --enable-minimal --disable-card-support --disable-agent-support --disable-photo-viewers --disable-keyserver-helpers --disable-nls + cd source/gnupg; $(MAKE) || true # expected failure in doc build + cp -a source/gnupg/g10/gpg git-annex-bundle/bin/ + +source: + mkdir -p source + git clone git://git.savannah.gnu.org/automake.git source/automake + git clone git://git.debian.org/git/d-i/busybox source/busybox + git clone git://github.com/android/platform_external_dropbear source/dropbear + git clone git://git.kernel.org/pub/scm/git/git.git source/git + git clone git://git.samba.org/rsync.git source/rsync + git clone git://git.gnupg.org/gnupg.git source/gnupg + +clean: + cd source/busybox && $(MAKE) clean + cd source/dropbear && $(MAKE) clean + cd source/git && $(MAKE) clean + cd source/rsync && $(MAKE) clean + cd source/gnupg && $(MAKE) clean + +reallyclean: + rm -rf source diff --git a/standalone/android/dropbear.patch b/standalone/android/dropbear.patch new file mode 100644 index 000000000..84c7dfb6d --- /dev/null +++ b/standalone/android/dropbear.patch @@ -0,0 +1,55 @@ +From 014dadb02fd984828a6232534c47dba8e2f7818a Mon Sep 17 00:00:00 2001 +From: Joey Hess <joey@kitenet.net> +Date: Wed, 13 Feb 2013 15:29:52 -0400 +Subject: [PATCH] android patch for dropbear + +* Disable HOME override +* Use urandom to avoid blocking on every ssh connection. +* Enable use of netbsd_getpass.c +--- + cli-auth.c | 1 + + cli-main.c | 2 -- + options.h | 2 +- + 3 files changed, 2 insertions(+), 3 deletions(-) + +diff --git a/cli-auth.c b/cli-auth.c +index 4c17a21..91dfdf8 100644 +--- a/cli-auth.c ++++ b/cli-auth.c +@@ -31,6 +31,7 @@ + #include "ssh.h" + #include "packet.h" + #include "runopts.h" ++#include "netbsd_getpass.c" + + void cli_authinitialise() { + +diff --git a/cli-main.c b/cli-main.c +index 106006b..68cf023 100644 +--- a/cli-main.c ++++ b/cli-main.c +@@ -47,8 +47,6 @@ int main(int argc, char ** argv) { + _dropbear_exit = cli_dropbear_exit; + _dropbear_log = cli_dropbear_log; + +- putenv("HOME=/data/local"); +- + disallow_core(); + + cli_getopts(argc, argv); +diff --git a/options.h b/options.h +index 7625151..48e404d 100644 +--- a/options.h ++++ b/options.h +@@ -159,7 +159,7 @@ etc) slower (perhaps by 50%). Recommended for most small systems. */ + * however significantly reduce the security of your ssh connections + * if the PRNG state becomes guessable - make sure you know what you are + * doing if you change this. */ +-#define DROPBEAR_RANDOM_DEV "/dev/random" ++#define DROPBEAR_RANDOM_DEV "/dev/urandom" + + /* prngd must be manually set up to produce output */ + /*#define DROPBEAR_PRNGD_SOCKET "/var/run/dropbear-rng"*/ +-- +1.7.10.4 + diff --git a/standalone/android/rsync.patch b/standalone/android/rsync.patch new file mode 100644 index 000000000..692e9cabb --- /dev/null +++ b/standalone/android/rsync.patch @@ -0,0 +1,40 @@ +From f91df535053958600d57f9df78d9ce84c8718655 Mon Sep 17 00:00:00 2001 +From: Joey Hess <joey@kitenet.net> +Date: Wed, 13 Feb 2013 15:51:40 -0400 +Subject: [PATCH] android portability + +--- + authenticate.c | 3 ++- + batch.c | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/authenticate.c b/authenticate.c +index 7650377..626dec6 100644 +--- a/authenticate.c ++++ b/authenticate.c +@@ -296,7 +296,8 @@ void auth_client(int fd, const char *user, const char *challenge) + * + * OpenBSD has a readpassphrase() that might be more suitable. + */ +- pass = getpass("Password: "); ++ /*pass = getpass("Password: "); */ ++ exit(1); + } + + if (!pass) +diff --git a/batch.c b/batch.c +index a3e9dca..ee31532 100644 +--- a/batch.c ++++ b/batch.c +@@ -221,7 +221,7 @@ void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt) + stringjoin(filename, sizeof filename, + batch_name, ".sh", NULL); + fd = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC, +- S_IRUSR | S_IWUSR | S_IEXEC); ++ S_IRUSR | S_IWUSR); + if (fd < 0) { + rsyserr(FERROR, errno, "Batch file %s open error", + filename); +-- +1.7.10.4 + diff --git a/standalone/android/runshell b/standalone/android/runshell new file mode 100755 index 000000000..b2cb8ee2f --- /dev/null +++ b/standalone/android/runshell @@ -0,0 +1,62 @@ +#!/system/bin/sh +# Runs a shell command (or interactive shell) using the binaries and +# libraries bundled with this app. + +set -e + +base="$(dirname $0)"/git-annex-bundle + +if [ ! -d "$base" ]; then + echo "** cannot find base directory (I seem to be $0)" >&2 + exit 1 +fi + +if [ ! -e "$base/bin/git-annex" ]; then + echo "** base directory $base does not contain bin/git-annex" >&2 + exit 1 +fi +if [ ! -e "$base/bin/git" ]; then + echo "** base directory $base does not contain bin/git" >&2 + exit 1 +fi + +# Install busybox links. +if [ ! -e "$base/bin/sh" ]; then + echo "(First run detected ... setting up busybox ...)" + "$base/bin/busybox" --install "$base/bin" +fi + +# Get absolute path to base, to avoid breakage when things change directories. +orig="$(pwd)" +cd "$base" +base="$(pwd)" +cd "$orig" + +# Put our binaries first, to avoid issues with out of date or incompatable +# system or App binaries. +ORIG_PATH="$PATH" +export ORIG_PATH +PATH=$base/bin:$PATH +export PATH + +ORIG_GIT_EXEC_PATH="$GIT_EXEC_PATH" +export ORIG_GIT_EXEC_PATH +GIT_EXEC_PATH=$base/libexec/git-core +export GIT_EXEC_PATH + +ORIG_GIT_TEMPLATE_DIR="$GIT_TEMPLATE_DIR" +export ORIG_GIT_TEMPLATE_DIR +GIT_TEMPLATE_DIR="$base/templates" +export GIT_TEMPLATE_DIR + +# Indicate which variables were exported above. +GIT_ANNEX_STANDLONE_ENV="PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR" +export GIT_ANNEX_STANDLONE_ENV + +if [ "$1" ]; then + cmd="$1" + shift 1 + exec "$cmd" "$@" +else + sh +fi diff --git a/standalone/licences.gz b/standalone/licences.gz Binary files differindex 01b5d556e..4b6b5661f 100644 --- a/standalone/licences.gz +++ b/standalone/licences.gz |