summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-13 16:23:06 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-13 16:38:03 -0400
commit36fe7618acf4c602781f28f0cfd084b7a4e641be (patch)
treecd802ea1a9cf3c6283480827dfd113d72605de71
parent4951472e2eac968fff91e08de3e173e7d7d53b99 (diff)
Makefile and patches for reproducible build of utilities for android
-rw-r--r--Makefile11
-rw-r--r--doc/design/assistant/android.mdwn56
-rw-r--r--standalone/android/Makefile51
-rw-r--r--standalone/android/dropbear.patch55
-rw-r--r--standalone/android/rsync.patch40
5 files changed, 153 insertions, 60 deletions
diff --git a/Makefile b/Makefile
index 420344d97..3241b1068 100644
--- a/Makefile
+++ b/Makefile
@@ -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
@@ -240,15 +241,17 @@ android:
ANDROIDAPP_DEST=$(GIT_ANNEX_TMP_BUILD_DIR)/git-annex.android
androidapp:
$(MAKE) android
+ $(MAKE) -f standalone/android
rm -rf "$(ANDROIDAPP_DEST)"
- cp -R standalone/android "$(ANDROIDAPP_DEST)"
-
- cp -aR $(GIT_ANNEX_TMP_BUILD_DIR)/android-utilities/ $(ANDROIDAPP_DEST)/git-annex-bundle
+ 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/git-annex"
+
+ $$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"
diff --git a/doc/design/assistant/android.mdwn b/doc/design/assistant/android.mdwn
index 4dab366d1..c972b5529 100644
--- a/doc/design/assistant/android.mdwn
+++ b/doc/design/assistant/android.mdwn
@@ -17,59 +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.
-
-### Utility porting notes
-
-#### TODO
-
-* Make build system that can generate ports, and tarball, from source
- checkouts.
-* Remove git commands and busybox builtins that are not used, to reduce
- size.
-
-#### 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.
-
-Edit `cli-auth.c`, and add: `#include "netbsd_getpass.c"`
-
-Edit `cli-main.c` and remove the HOME setting.
-
-Edit options.h and set `DROPBEAR_RANDOM_DEV "/dev/urandom"`
-
- 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 dbclient
-
-#### busybox
-
- cp configs/android2_defconfig .config
- # edit config and set CONFIG_FEATURE_INSTALLER=y
- PATH=~/.ghc/android-14/arm-linux-androideabi-4.7/bin:$PATH CROSS_COMPILE=arm-linux-androideabi- make
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
+