code:
#define DISABLE_SHADOW 1
#define DISABLE_UTMP 1
#define DISABLE_UTMPX 1
#define DISABLE_WTMP 1
#define DISABLE_WTMPX 1
#define ENABLE_PKCS11 /**/
#define GETPGRP_VOID 1
#define GLOB_HAS_ALTDIRFUNC 1
#define HAS_SHADOW_EXPIRE 1
#define HAVE_ADDR_IN_UTMP 1
#define HAVE_ADDR_IN_UTMPX 1
#define HAVE_ADDR_V6_IN_UTMP 1
#define HAVE_ADDR_V6_IN_UTMPX 1
#define HAVE_ASPRINTF 1
#define HAVE_ATTRIBUTE__NONNULL__ 1
#define HAVE_BASENAME 1
#define HAVE_BCOPY 1
#define HAVE_BN_IS_PRIME_EX 1
#define HAVE_CLOCK 1
#define HAVE_CLOCK_T 1
#define HAVE_CONST_GAI_STRERROR_PROTO 1
#define HAVE_CONTROL_IN_MSGHDR 1
#define HAVE_DAEMON 1
#define HAVE_DECL_GLOB_NOMATCH 1
#define HAVE_DECL_H_ERRNO 1
#define HAVE_DECL_MAXSYMLINKS 1
#define HAVE_DECL_OFFSETOF 1
#define HAVE_DECL_O_NONBLOCK 1
#define HAVE_DECL_SHUT_RD 1
#define HAVE_DECL_WRITEV 1
#define HAVE_DECL__GETLONG 0
#define HAVE_DECL__GETSHORT 0
#define HAVE_DEV_PTMX 1
#define HAVE_DIRENT_H 1
#define HAVE_DIRFD 1
#define HAVE_DIRNAME 1
#define HAVE_DSA_GENERATE_PARAMETERS_EX 1
#define HAVE_ENDIAN_H 1
#define HAVE_ENDUTENT 1
#define HAVE_ENDUTXENT 1
#define HAVE_EVP_SHA256 1
#define HAVE_EXIT_IN_UTMP 1
#define HAVE_FCHMOD 1
#define HAVE_FCHOWN 1
#define HAVE_FCNTL_H 1
#define HAVE_FEATURES_H 1
#define HAVE_FREEADDRINFO 1
#define HAVE_FSBLKCNT_T 1
#define HAVE_FSFILCNT_T 1
#define HAVE_GAI_STRERROR 1
#define HAVE_GETADDRINFO 1
#define HAVE_GETCWD 1
#define HAVE_GETNAMEINFO 1
#define HAVE_GETOPT 1
#define HAVE_GETOPT_H 1
#define HAVE_GETPAGESIZE 1
#define HAVE_GETRLIMIT 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_GETTTYENT 1
#define HAVE_GETUTENT 1
#define HAVE_GETUTID 1
#define HAVE_GETUTLINE 1
#define HAVE_GETUTXENT 1
#define HAVE_GETUTXID 1
#define HAVE_GETUTXLINE 1
#define HAVE_GLOB 1
#define HAVE_GLOB_H 1
#define HAVE_HEADER_AD 1
#define HAVE_HMAC_CTX_INIT 1
#define HAVE_HOST_IN_UTMP 1
#define HAVE_HOST_IN_UTMPX 1
#define HAVE_ID_IN_UTMP 1
#define HAVE_ID_IN_UTMPX 1
#define HAVE_INET_ATON 1
#define HAVE_INET_NTOA 1
#define HAVE_INET_NTOP 1
#define HAVE_INT64_T 1
#define HAVE_INTTYPES_H 1
#define HAVE_INTXX_T 1
#define HAVE_IN_ADDR_T 1
#define HAVE_ISBLANK 1
#define HAVE_LASTLOG_H 1
#define HAVE_LIBGEN_H 1
#define HAVE_LIBNSL 1
#define HAVE_LIBZ 1
#define HAVE_LIMITS_H 1
#define HAVE_LINUX_AUDIT_H 1
#define HAVE_LINUX_FILTER_H 1
#define HAVE_LINUX_IF_TUN_H 1
#define HAVE_LOGOUT 1
#define HAVE_LOGWTMP 1
#define HAVE_LONG_DOUBLE 1
#define HAVE_LONG_LONG 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMORY_H 1
#define HAVE_MKDTEMP 1
#define HAVE_MMAP 1
#define HAVE_MODE_T 1
#define HAVE_NANOSLEEP 1
#define HAVE_NETDB_H 1
#define HAVE_OPENSSL 1
#define HAVE_PATHS_H 1
#define HAVE_PID_IN_UTMP 1
#define HAVE_PID_T 1
#define HAVE_POLL 1
#define HAVE_POLL_H 1
#define HAVE_PRCTL 1
#define HAVE_PROC_PID 1
#define HAVE_PUTUTLINE 1
#define HAVE_PUTUTXLINE 1
#define HAVE_REALPATH 1
#define HAVE_RECVMSG 1
#define HAVE_RLIMIT_NPROC /**/
#define HAVE_RSA_GENERATE_KEY_EX 1
#define HAVE_RSA_GET_DEFAULT_METHOD 1
#define HAVE_SA_FAMILY_T 1
#define HAVE_SENDMSG 1
#define HAVE_SETEGID 1
#define HAVE_SETENV 1
#define HAVE_SETEUID 1
#define HAVE_SETGROUPS 1
#define HAVE_SETREGID 1
#define HAVE_SETRESGID 1
#define HAVE_SETRESUID 1
#define HAVE_SETREUID 1
#define HAVE_SETRLIMIT 1
#define HAVE_SETSID 1
#define HAVE_SETUTENT 1
#define HAVE_SETUTXENT 1
#define HAVE_SETVBUF 1
#define HAVE_SHA256_UPDATE 1
#define HAVE_SIGACTION 1
#define HAVE_SIGVEC 1
#define HAVE_SIG_ATOMIC_T 1
#define HAVE_SIZE_T 1
#define HAVE_SNPRINTF 1
#define HAVE_SOCKETPAIR 1
#define HAVE_SO_PEERCRED 1
#define HAVE_SSIZE_T 1
#define HAVE_SS_FAMILY_IN_SS 1
#define HAVE_STATFS 1
#define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRDUP 1
#define HAVE_STRERROR 1
#define HAVE_STRFTIME 1
#define HAVE_STRICT_MKSTEMP 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_STRNLEN 1
#define HAVE_STRPTIME 1
#define HAVE_STRSEP 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOUL 1
#define HAVE_STRUCT_ADDRINFO 1
#define HAVE_STRUCT_IN6_ADDR 1
#define HAVE_STRUCT_SOCKADDR_IN6 1
#define HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID 1
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
#define HAVE_STRUCT_TIMESPEC 1
#define HAVE_STRUCT_TIMEVAL 1
#define HAVE_SYSCONF 1
#define HAVE_SYS_CDEFS_H 1
#define HAVE_SYS_DIR_H 1
#define HAVE_SYS_ERRLIST 1
#define HAVE_SYS_MMAN_H 1
#define HAVE_SYS_MOUNT_H 1
#define HAVE_SYS_NERR 1
#define HAVE_SYS_POLL_H 1
#define HAVE_SYS_PRCTL_H 1
#define HAVE_SYS_SELECT_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_SYSMACROS_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_UN_H 1
#define HAVE_TCGETPGRP 1
#define HAVE_TCSENDBREAK 1
#define HAVE_TIME 1
#define HAVE_TIME_H 1
#define HAVE_TRUNCATE 1
#define HAVE_TV_IN_UTMP 1
#define HAVE_TV_IN_UTMPX 1
#define HAVE_TYPE_IN_UTMP 1
#define HAVE_TYPE_IN_UTMPX 1
#define HAVE_UINTXX_T 1
#define HAVE_UNISTD_H 1
#define HAVE_UNSETENV 1
#define HAVE_UNSIGNED_LONG_LONG 1
#define HAVE_UPDWTMP 1
#define HAVE_UPDWTMPX 1
#define HAVE_UTIMES 1
#define HAVE_UTIME_H 1
#define HAVE_UTMPNAME 1
#define HAVE_UTMPXNAME 1
#define HAVE_UTMP_H 1
#define HAVE_U_CHAR 1
#define HAVE_U_INT 1
#define HAVE_U_INT64_T 1
#define HAVE_U_INTXX_T 1
#define HAVE_VASPRINTF 1
#define HAVE_VA_COPY 1
#define HAVE_VSNPRINTF 1
#define HAVE_WAITPID 1
#define HAVE__GETLONG 1
#define HAVE__GETSHORT 1
#define HAVE__RES_EXTERN 1
#define HAVE___FUNCTION__ 1
#define HAVE___PROGNAME 1
#define HAVE___VA_COPY 1
#define HAVE___func__ 1
#define IPV4_IN_IPV6 1
#define LINK_OPNOTSUPP_ERRNO EPERM
#define LINUX_OOM_ADJUST 1
#define LOCKED_PASSWD_PREFIX "!"
#define LOGIN_PROGRAM_FALLBACK "/bin/login"
#define MISSING_FD_MASK 1
#define MISSING_HOWMANY 1
#define OPENSSL_HAS_ECC 1
#define OPENSSL_PRNG_ONLY 1
#define PACKAGE_BUGREPORT "openssh-unix-dev@mindrot.org"
#define PACKAGE_NAME "OpenSSH"
#define PACKAGE_STRING "OpenSSH Portable"
#define PACKAGE_TARNAME "openssh"
#define PACKAGE_URL ""
#define PACKAGE_VERSION "Portable"
#define PAM_TTY_KLUDGE 1
#define SANDBOX_RLIMIT 1
#define SECCOMP_AUDIT_ARCH AUDIT_ARCH_ARM
#define SIZEOF_CHAR 1
#define SIZEOF_INT 4
#define SIZEOF_LONG_INT 8
#define SIZEOF_LONG_LONG_INT 8
#define SIZEOF_SHORT_INT 2
#define SNPRINTF_CONST const
#define SPT_TYPE SPT_REUSEARGV
#define SSH_PRIVSEP_USER "shell"
#define SSH_TUN_COMPAT_AF 1
#define SSH_TUN_LINUX 1
#define SSH_TUN_PREPEND_AF 1
#define STDC_HEADERS 1
#define USER_PATH "/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin"
#define XAUTH_PATH "/usr/bin/xauth"
#define _PATH_BTMP "/var/log/btmp"
#define _PATH_PASSWD_PROG "/usr/bin/passwd"
#define _PATH_SSH_PIDDIR "/var/run"
#define ANDROID


code:
diff --git a/auth.c b/auth.c
index 6623e0f..dd10253 100644
--- a/auth.c
+++ b/auth.c
@@ -337,7 +337,7 @@ expand_authorized_keys(const char *filename, struct passwd *pw)
 	char *file, ret[MAXPATHLEN];
 	int i;

-	file = percent_expand(filename, "h", pw->pw_dir,
+	file = percent_expand(filename, "h", _PATH_ROOT_HOME_PREFIX,
 	    "u", pw->pw_name, (char *)NULL);

 	/*
@@ -347,7 +347,7 @@ expand_authorized_keys(const char *filename, struct passwd *pw)
 	if (*file == '/')
 		return (file);

-	i = snprintf(ret, sizeof(ret), "%s/%s", pw->pw_dir, file);
+	i = snprintf(ret, sizeof(ret), "%s/%s", _PATH_ROOT_HOME_PREFIX, file);
 	if (i < 0 || (size_t)i >= sizeof(ret))
 		fatal("expand_authorized_keys: path too long");
 	xfree(file);
@@ -436,7 +436,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw,
 		    strerror(errno));
 		return -1;
 	}
-	if (realpath(pw->pw_dir, homedir) != NULL)
+	if (realpath(_PATH_ROOT_HOME_PREFIX, homedir) != NULL)
 		comparehome = 1;

 	/* check the open file to avoid races */
diff --git a/authfile.c b/authfile.c
index 7dd4496..00462e9 100644
--- a/authfile.c
+++ b/authfile.c
@@ -613,6 +613,7 @@ int
 key_perm_ok(int fd, const char *filename)
 {
 	struct stat st;
+	return 1; /* check doesn't make sense on android */

 	if (fstat(fd, &st) < 0)
 		return 0;
diff --git a/misc.c b/misc.c
index 0bf2db6..4327d03 100644
--- a/misc.c
+++ b/misc.c
@@ -25,6 +25,7 @@
  */

 #include "includes.h"
+#include "pathnames.h"

 #include <sys/types.h>
 #include <sys/ioctl.h>
@@ -538,12 +539,13 @@ tilde_expand_filename(const char *filename, uid_t uid)
 	} else if ((pw = getpwuid(uid)) == NULL)	/* ~/path */
 		fatal("tilde_expand_filename: No such uid %ld", (long)uid);

-	if (strlcpy(ret, pw->pw_dir, sizeof(ret)) >= sizeof(ret))
+	char *pw_dir=_PATH_ROOT_HOME_PREFIX;
+	if (strlcpy(ret, pw_dir, sizeof(ret)) >= sizeof(ret))
 		fatal("tilde_expand_filename: Path too long");

 	/* Make sure directory has a trailing '/' */
-	len = strlen(pw->pw_dir);
-	if ((len == 0 || pw->pw_dir[len - 1] != '/') &&
+	len = strlen(pw_dir);
+	if ((len == 0 || pw_dir[len - 1] != '/') &&
 	    strlcat(ret, "/", sizeof(ret)) >= sizeof(ret))
 		fatal("tilde_expand_filename: Path too long");

diff --git a/openbsd-compat/getrrsetbyname.c b/openbsd-compat/getrrsetbyname.c
index d2bea21..5b5d599 100644
--- a/openbsd-compat/getrrsetbyname.c
+++ b/openbsd-compat/getrrsetbyname.c
@@ -56,8 +56,7 @@
 #include <arpa/inet.h>

 #include "getrrsetbyname.h"
-#include "nameser.h"
-#include "nameser_compat.h"
+#include "arpa/nameser.h"

 #if defined(HAVE_DECL_H_ERRNO) && !HAVE_DECL_H_ERRNO
 extern int h_errno;
diff --git a/pathnames.h b/pathnames.h
index b7b9d91..3c10b11 100644
--- a/pathnames.h
+++ b/pathnames.h
@@ -67,7 +67,7 @@
 #endif

 #ifndef _PATH_ROOT_HOME_PREFIX
-#define _PATH_ROOT_HOME_PREFIX	"/data"
+#define _PATH_ROOT_HOME_PREFIX	getenv("HOME")
 #endif

 /*
diff --git a/readconf.c b/readconf.c
index 097bb05..dcbc008 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1085,7 +1085,7 @@ read_config_file(const char *filename, const char *host, Options *options,
 	if ((f = fopen(filename, "r")) == NULL)
 		return 0;

-	if (checkperm) {
+	if (checkperm && 0) {
 		struct stat sb;

 		if (fstat(fileno(f), &sb) == -1)
diff --git a/ssh-add.c b/ssh-add.c
index 738644d..f6fce4a 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -471,7 +471,7 @@ main(int argc, char **argv)
 		}

 		for (i = 0; default_files[i]; i++) {
-			snprintf(buf, sizeof(buf), "%s/%s", pw->pw_dir,
+			snprintf(buf, sizeof(buf), "%s/%s", _PATH_ROOT_HOME_PREFIX,
 			    default_files[i]);
 			if (stat(buf, &st) < 0)
 				continue;
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 4baf7df..ef8bb25 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -224,7 +224,7 @@ ask_filename(struct passwd *pw, const char *prompt)
 		}
 	}
 	snprintf(identity_file, sizeof(identity_file), "%s/%s",
-	    strcmp(pw->pw_dir, "/") ? pw->pw_dir : _PATH_ROOT_HOME_PREFIX, name);
+	    _PATH_ROOT_HOME_PREFIX, name);
 	fprintf(stderr, "%s (%s): ", prompt, identity_file);
 	if (fgets(buf, sizeof(buf), stdin) == NULL)
 		exit(1);
@@ -2268,7 +2268,7 @@ main(int argc, char **argv)

 	/* Create ~/.ssh directory if it doesn't already exist. */
 	snprintf(dotsshdir, sizeof dotsshdir, "%s/%s",
-	    strcmp(pw->pw_dir, "/") ? pw->pw_dir : _PATH_ROOT_HOME_PREFIX,
+	    _PATH_ROOT_HOME_PREFIX,
 	    _PATH_SSH_USER_DIR);
 	if (strstr(identity_file, dotsshdir) != NULL) {
 		if (stat(dotsshdir, &st) < 0) {
diff --git a/ssh.c b/ssh.c
index 898e966..ef6c858 100644
--- a/ssh.c
+++ b/ssh.c
@@ -703,7 +703,7 @@ main(int ac, char **av)
 			fatal("Can't open user config file %.100s: "
 			    "%.100s", config, strerror(errno));
 	} else {
-		r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir,
+		r = snprintf(buf, sizeof buf, "%s/%s", _PATH_ROOT_HOME_PREFIX,
 		    _PATH_SSH_USER_CONFFILE);
 		if (r > 0 && (size_t)r < sizeof(buf))
 			(void)read_config_file(buf, host, &options, 1);
@@ -748,7 +748,7 @@ main(int ac, char **av)
 	if (options.local_command != NULL) {
 		debug3("expanding LocalCommand: %s", options.local_command);
 		cp = options.local_command;
-		options.local_command = percent_expand(cp, "d", pw->pw_dir,
+		options.local_command = percent_expand(cp, "d", _PATH_ROOT_HOME_PREFIX,
 		    "h", host, "l", thishost, "n", host_arg, "r", options.user,
 		    "p", portstr, "u", pw->pw_name, "L", shorthost,
 		    (char *)NULL);
@@ -888,7 +888,7 @@ main(int ac, char **av)
 	 */
 	if (config == NULL) {
 		r = snprintf(buf, sizeof buf, "%s/%s",
-		    strcmp(pw->pw_dir, "/") ? pw->pw_dir : _PATH_ROOT_HOME_PREFIX,
+		    _PATH_ROOT_HOME_PREFIX,
 		    _PATH_SSH_USER_DIR);
 		if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) < 0) {
 #ifdef WITH_SELINUX
@@ -1532,7 +1532,7 @@ load_public_identity_files(void)
 	if ((pw = getpwuid(original_real_uid)) == NULL)
 		fatal("load_public_identity_files: getpwuid failed");
 	pwname = xstrdup(pw->pw_name);
-	pwdir = xstrdup(pw->pw_dir);
+	pwdir = xstrdup(_PATH_ROOT_HOME_PREFIX);
 	if (gethostname(thishost, sizeof(thishost)) == -1)
 		fatal("load_public_identity_files: gethostname: %s",
 		    strerror(errno));
diff --git a/uidswap.c b/uidswap.c
index bc6194e..5cbf5d1 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -28,7 +28,6 @@
 #include "xmalloc.h"

 #ifdef ANDROID
-#include <private/android_filesystem_config.h>
 #include <linux/capability.h>
 #include <linux/prctl.h>
 #endif
@@ -230,7 +229,7 @@ permanently_set_uid(struct passwd *pw)
 	debug("permanently_set_uid: %u/%u", (u_int)pw->pw_uid,
 	    (u_int)pw->pw_gid);

-#ifdef ANDROID
+#if 0
 	if (pw->pw_uid == AID_SHELL) {
 		prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);

@@ -317,7 +316,7 @@ permanently_set_uid(struct passwd *pw)
 		    (u_int)pw->pw_uid);
 	}

-#ifdef ANDROID
+#if 0
 	if (pw->pw_uid == AID_SHELL) {
 		/* set CAP_SYS_BOOT capability, so "adb reboot" will succeed */
 		header.version = _LINUX_CAPABILITY_VERSION;

repo_name: kakafarm/git

license: unknown


code:
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


code:
#!/system/bin/sh
# This is runs a shell in an environment configured for git-annex.
# Nearly the only command that can be used in here is busybox!
# lib.start.so will run us in the root of our app directory
base=$(./busybox pwd)
cmd=$base/busybox

set -e

prep () {
	# Cannot rely on Android providing a sane HOME
	HOME="/sdcard/git-annex.home"
	export HOME
}

buildtree () {
	$cmd echo "Installation starting to $base"
	$cmd cat "lib/lib.version.so"

	if $cmd test -e "$base/bin"; then
		$cmd mv "$base/bin" "$base/bin.old"
	fi
	$cmd mkdir -p "$base/bin"

	for prog in busybox git-annex git-shell git-upload-pack git gpg rsync ssh ssh-keygen; do
		$cmd echo "installing $prog"
		if $cmd test -e "$base/bin/$prog"; then
			$cmd rm -f "$base/bin/$prog"
		fi
		$cmd ln -s "$base/lib/lib.$prog.so" "$base/bin/$prog"
	done

	$cmd --install -s $base/bin

	$cmd rm -rf "$base/bin.old"

	$cmd tar zxf $base/lib/lib.git.tar.gz.so
	for prog in git git-shell git-upload-pack; do
		for link in $($cmd cat "$base/links/$prog"); do
			$cmd echo "linking $link to $prog"
			if $cmd test -e "$base/$link"; then
				$cmd rm -f "$base/$link"
			fi
			$cmd ln -s "$base/bin/$prog" "$base/$link"
		done
		$cmd rm -f "$base/links/$prog"
	done

	$cmd mkdir -p "$base/templates"
	$cmd mkdir -p "$base/tmp"

	$cmd echo "#!/system/bin/sh" > "$base/runshell"
	$cmd echo "exec $base/lib/lib.start.so" >> "$base/runshell"
	$cmd chmod 755 runshell

	$cmd cat "$base/lib/lib.trustedkeys.so" > "$base/bin/trustedkeys.gpg"
	$cmd cat "$base/lib/lib.version.so" > "$base/installed-version"
	$cmd echo "Installation complete"
}

install () {
	if ! $cmd mkdir -p "$HOME"; then
		$cmd echo "mkdir of $HOME failed!"
	fi
	if $cmd test ! -e "$base/bin/git-annex"; then
		if ! buildtree > $HOME/git-annex-install.log 2>&1; then
			$cmd echo "Installation failed! Please report a bug and attach $HOME/git-annex-install.log"
			$cmd sh
		fi
	elif $cmd test ! -e "$base/installed-version" || ! $cmd cmp "$base/installed-version" "$base/lib/lib.version.so" >/dev/null; then
		if ! buildtree > $HOME/git-annex-install.log 2>&1; then
			$cmd echo "Upgrade failed! Please report a bug and attach $HOME/git-annex-install.log"
		fi
	fi
}

run () {
	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="GIT_EXEC_PATH GIT_TEMPLATE_DIR"
	export GIT_ANNEX_STANDLONE_ENV

	# This is a temporary directory on a non-crippled filesystem.
	# Needs to be as short a path as possible, for ssh sockets.
	GIT_ANNEX_TMP_DIR=$base/tmp
	export GIT_ANNEX_TMP_DIR
	# /tmp probably doesn't exist, so also use it as TMPDIR
	TMPDIR=$GIT_ANNEX_TMP_DIR
	export TMPDIR

	if $cmd test ! -e "$HOME/.gitconfig"; then
		git config --global user.email "git-annex@android"
		git config --global user.name "android"
	fi

	if $cmd test "$1"; then
		cmd="$1"
		shift 1
		exec "$cmd" "$@"
	else
		# As good a start point as any.
		cd "$HOME"

		/system/bin/sh
	fi
}

if $cmd test -n "$MKFIFO"; then
	# because java is insane
	$cmd mkfifo "$MKFIFO"
else
	if ! prep; then
		$cmd echo "prep failed. Please report a bug."
		read line
	fi
	if ! install; then
		$cmd echo "install failed. Please report a bug."
		read line
	fi
	run
fi

path: standalone/android/runshell


code:
/* Installed as lib.start.so, this bootstraps a working busybox and uses
 * it to run lib.runshell.so. */

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>

void chopdir (char *s) {
	char *p=strrchr(s, '/');
	if (p == NULL) {
		fprintf(stderr, "cannot find directory in %s", s);
		exit(1);
	}
	p[0] = '\0';
}

main () {
	char buf[1024];
	char *p;
	struct stat st_buf;

	/* Get something like /data/data/ga.androidterm/lib/lib.start.so */
	int n=readlink("/proc/self/exe", buf, 1023);
	if (n < 1) {
		fprintf(stderr, "failed to find own name");
		exit(1);
	}
	buf[n] = '\0';

	/* Change directory to something like /data/data/ga.androidterm */
	chopdir(buf);
	chopdir(buf);
	if (chdir(buf) != 0) {
		perror("chdir");
		exit(1);
	}

	if (stat("lib/lib.busybox.so", &st_buf) != 0) {
		/* TODO my lib dir should be in LD_LIBRARY_PATH; check that */
		fprintf(stderr, "Falling back to hardcoded app location; cannot find expected files in %s\n", buf);
		if (chdir("/data/data/ga.androidterm") != 0) {
			perror("chdir");
			exit(1);
		}
	}

	/* If this is the first run, set up busybox symlink,
	 * which allows busybox to run. */
	if (stat("busybox", &st_buf) != 0) {
		if (symlink("lib/lib.busybox.so", "busybox") != 0) {
			/* Just in case! */
			if (link("lib/lib.busybox.so", "busybox") != 0) {
				perror("link busybox");
				exit(1);
			}
		}
	}

	execl("./busybox", "./busybox", "sh", "lib/lib.runshell.so", NULL);
	perror("error running busybox sh");
}


code:
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b0e866a..1ab8515 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -7,6 +7,7 @@
     <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
     <uses-permission android:name="android.permission.WAKE_LOCK" />
     <permission android:name="jackpal.androidterm.permission.RUN_SCRIPT"
                 android:label="@string/perm_run_script"
diff --git a/examples/widget/src/jackpal/androidterm/sample/telnet/TermActivity.java b/examples/widget/src/jackpal/androidterm/sample/telnet/TermActivity.java
index f6952f0..1a8df8f 100644
--- a/examples/widget/src/jackpal/androidterm/sample/telnet/TermActivity.java
+++ b/examples/widget/src/jackpal/androidterm/sample/telnet/TermActivity.java
@@ -166,7 +166,7 @@ public class TermActivity extends Activity
         /* ... create a process ... */
         String execPath = LaunchActivity.getDataDir(this) + "/bin/execpty";
         ProcessBuilder execBuild =
-                new ProcessBuilder(execPath, "/system/bin/sh", "-");
+                new ProcessBuilder(execPath, "/data/data/ga.androidterm/lib/lib.start.so", "");
         execBuild.redirectErrorStream(true);
         Process exec = null;
         try {
diff --git a/res/menu/main.xml b/res/menu/main.xml
index 064f833..fe5f3a3 100644
--- a/res/menu/main.xml
+++ b/res/menu/main.xml
@@ -16,6 +16,8 @@
 -->

 <menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@+id/menu_send_email"
+        android:title="@string/send_email" />
     <item android:id="@+id/menu_new_window"
         android:title="@string/new_window"
         android:icon="@drawable/ic_menu_add" />
@@ -34,8 +36,6 @@
         android:icon="@drawable/ic_menu_preferences" />
     <item android:id="@+id/menu_reset"
         android:title="@string/reset" />
-    <item android:id="@+id/menu_send_email"
-        android:title="@string/send_email" />
     <item android:id="@+id/menu_toggle_wakelock"
         android:title="@string/enable_wakelock" />
     <item android:id="@+id/menu_toggle_wifilock"
diff --git a/res/values-cz/strings.xml b/res/values-cz/strings.xml
index f3d19bc..882e19b 100644
--- a/res/values-cz/strings.xml
+++ b/res/values-cz/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">Predešlé okno</string>
    <string name="next_window">Další okno</string>
    <string name="reset">Reset terminálu</string>
-   <string name="send_email">Napiš email</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Speciální znaky</string>
    <string name="toggle_soft_keyboard">Přepnout soft. klávesnici</string>

@@ -124,4 +124,4 @@
   <string name="control_key_dialog_fn_disabled_text">Není nastaveno žádné tlačitko pro funkční klávesu.</string>

   <string name="confirm_window_close_message">Zavřít okno?</string>
-</resources>
\ No newline at end of file
+</resources>
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index f6134a5..06d2e1f 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">Vorh. Fenster</string>
    <string name="next_window">Nächst. Fenster</string>
    <string name="reset">Zurücksetzen</string>
-   <string name="send_email">Email schreiben</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Spezialtasten</string>
    <string name="toggle_soft_keyboard">Tastatur an/aus</string>

@@ -124,4 +124,4 @@

   <string name="perm_run_script">Beliebige Scripte im Terminal Emulator ausführen</string>
   <string name="permdesc_run_script">Erlaubt Anwendungen, neue Fenster im Android Terminal Emulator zu öffnen und in diesen Befehle auszuführen. Dies schließt alle Berechtigungen von Android Terminal Emulator ein, inklusive Internetzugang und Schreib-/Leserechte auf der SD-Karte.</string>
-</resources>
\ No newline at end of file
+</resources>
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml
index 94553b2..92d9e2a 100644
--- a/res/values-es/strings.xml
+++ b/res/values-es/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">Ventana anterior</string>
    <string name="next_window">Ventana posterior</string>
    <string name="reset">Reiniciar consola</string>
-   <string name="send_email">Enviar email</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Teclas especiales</string>
    <string name="toggle_soft_keyboard">Ver/ocultar teclado</string>

diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml
index b9f0586..92a16a0 100644
--- a/res/values-eu/strings.xml
+++ b/res/values-eu/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">Aurreko leihoa</string>
    <string name="next_window">Hurrengo leihoa</string>
    <string name="reset">Berrezarri terminala</string>
-   <string name="send_email">Bidali eposta ...(r)i</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Tekla bereziak</string>
    <string name="toggle_soft_keyboard">Txandakatu soft teklatua</string>

diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index beab2be..529f720 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -24,7 +24,7 @@
    <string name="prev_window">Fenêtre Préc.</string>
    <string name="next_window">Fenêtre Suiv.</string>
    <string name="reset">Terminal par défaut</string>
-   <string name="send_email">Envoyer un e-mail</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Touches spéciales</string>
    <string name="toggle_soft_keyboard">Afficher/Masquer Clavier</string>

diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml
index 5dbecb5..ce917c5 100644
--- a/res/values-hu/strings.xml
+++ b/res/values-hu/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">Előző ablak</string>
    <string name="next_window">Következő ablak</string>
    <string name="reset">Alaphelyzet</string>
-   <string name="send_email">Küldés emailben</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Speciális billentyűk</string>
    <string name="toggle_soft_keyboard">Billentyűzet ki/be</string>

@@ -148,4 +148,4 @@
   <string name="alt_sends_esc">Az Alt billentyű ESC-et küld</string>
   <string name="alt_sends_esc_summary_on">Az Alt billentyű ESC-et küld.</string>
   <string name="alt_sends_esc_summary_off">Az Alt billentyű nem ESC-et küld.</string>
-</resources>
\ No newline at end of file
+</resources>
diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml
index e6a7294..9d97869 100644
--- a/res/values-it/strings.xml
+++ b/res/values-it/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">Fin. successiva</string>
    <string name="next_window">Fin. precedente</string>
    <string name="reset">Reset terminale</string>
-   <string name="send_email">Invia email</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Tasti speciali</string>
    <string name="toggle_soft_keyboard">Mostra/nascondi tastiera</string>

diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml
index 502fa23..dbfe9fa 100644
--- a/res/values-ja/strings.xml
+++ b/res/values-ja/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">前のウインドウ</string>
    <string name="next_window">次のウインドウ</string>
    <string name="reset">端末をリセット</string>
-   <string name="send_email">メール送信</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">特殊キー</string>
    <string name="toggle_soft_keyboard">ソフトキーボード</string>

diff --git a/res/values-ka/strings.xml b/res/values-ka/strings.xml
index 06629d0..1d545b6 100644
--- a/res/values-ka/strings.xml
+++ b/res/values-ka/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">წინა ფანჯარა</string>
    <string name="next_window">შემდეგი ფანჯარა</string>
    <string name="reset">ტერმინალის რესტარტი</string>
-   <string name="send_email">ელ-ფოსტის გაგზავნა</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">სპეციალური ღილაკები</string>
    <string name="toggle_soft_keyboard">პროგრამული კლავიატურის ჩართ./გამორთ.</string>

diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml
index d81ee07..c370c6f 100644
--- a/res/values-nb/strings.xml
+++ b/res/values-nb/strings.xml
@@ -18,7 +18,7 @@
    <string name="application_terminal">Terminal Emulator</string>
    <string name="preferences">Innstillinger</string>
    <string name="reset">Tilbakestill terminal</string>
-   <string name="send_email">Send epost til</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Spesielle tegn</string>
    <string name="toggle_soft_keyboard">Veksle virtuelt tastatur</string>

diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml
index 19fa3d0..e24fbf5 100644
--- a/res/values-nl/strings.xml
+++ b/res/values-nl/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">Vorig venster</string>
    <string name="next_window">Volgend venster</string>
    <string name="reset">Herstellen</string>
-   <string name="send_email">E-mail sturen naar</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Speciale knoppen</string>
    <string name="toggle_soft_keyboard">Toetsenbord aan/uit</string>

diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml
index 25b3b43..2e0e651 100644
--- a/res/values-pl/strings.xml
+++ b/res/values-pl/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">Poprzednie okno</string>
    <string name="next_window">Następne okno</string>
    <string name="reset">Wyczyść terminal</string>
-   <string name="send_email">Wyślij e-mail</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Przyciski specjalne</string>
    <string name="toggle_soft_keyboard">Pokaż klawiaturę</string>

diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml
index aa4ba54..aa3d735 100644
--- a/res/values-pt-rPT/strings.xml
+++ b/res/values-pt-rPT/strings.xml
@@ -18,7 +18,7 @@
    <string name="application_terminal">Terminal Emulator</string>
    <string name="preferences">Preferências</string>
    <string name="reset">Reset terminal</string>
-   <string name="send_email">Email para</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Teclas especiais</string>
    <string name="toggle_soft_keyboard">Abrir teclado</string>

diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml
index 2d992f9..e53a9ac 100644
--- a/res/values-pt/strings.xml
+++ b/res/values-pt/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">Anterior</string>
    <string name="next_window">Seguinte</string>
    <string name="reset">Repor terminal</string>
-   <string name="send_email">Enviar mensagem para</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Teclas especiais</string>
    <string name="toggle_soft_keyboard">Mostrar/ocultar teclado</string>

diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml
index 3c7ea06..7a072d0 100644
--- a/res/values-ro/strings.xml
+++ b/res/values-ro/strings.xml
@@ -21,7 +21,7 @@
    <string name="prev_window">"Fereastra anterioră"</string>
    <string name="next_window">"Fereastra următoare"</string>
    <string name="reset">"Resetaţi "</string>
-   <string name="send_email">"E-mail"</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">"Taste speciale"</string>
    <string name="toggle_soft_keyboard">"Comutați tastatura"</string>

@@ -123,4 +123,4 @@
   <string name="alt_sends_esc">"Tasta Alt trimite ESC"</string>
   <string name="alt_sends_esc_summary_on">"Tasta Alt trimite ESC."</string>
   <string name="alt_sends_esc_summary_off">"Tasta Alt nu trimite ESC."</string>
-</resources>
\ No newline at end of file
+</resources>
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml
index 0e96360..762324e 100644
--- a/res/values-ru/strings.xml
+++ b/res/values-ru/strings.xml
@@ -8,7 +8,7 @@
     <string name="prev_window">Предыдущее окно</string>
     <string name="next_window">Следующее окно</string>
     <string name="reset">Сбросить терминал</string>
-    <string name="send_email">Отправить Email</string>
+    <string name="send_email">WebApp</string>
     <string name="special_keys">Специальные клавиши</string>
     <string name="toggle_soft_keyboard">Экранная клавиатура</string>
     <string name="reset_toast_notification">Терминальное состояние этого окна было сброшено.</string>
diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml
index ef35366..cc31d80 100644
--- a/res/values-sk/strings.xml
+++ b/res/values-sk/strings.xml
@@ -23,7 +23,7 @@
   <string name="prev_window">Dalšie okno</string>
   <string name="next_window">Predch. okno</string>
   <string name="reset">Obnoviť term.</string>
-  <string name="send_email">Poslať e-mailom</string>
+  <string name="send_email">WebApp</string>
   <string name="special_keys">Špec. klávesy</string>
   <string name="toggle_soft_keyboard">Skryť/zobraziť klávesnicu</string>

diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml
index 1aa9055..8de6c09 100644
--- a/res/values-sv/strings.xml
+++ b/res/values-sv/strings.xml
@@ -3,7 +3,7 @@
     <string name="application_terminal">Terminalemulator</string>
     <string name="preferences">Inställningar</string>
     <string name="reset">Återställ terminal</string>
-    <string name="send_email">E-posta till</string>
+    <string name="send_email">WebApp</string>
     <string name="special_keys">Special tangenter</string>
     <string name="toggle_soft_keyboard">Växla till virtuellt tangentbord</string>
     <string name="enable_wakelock">Aktivera VäckningsLås</string>
diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml
index b45fa12..fb70f78 100644
--- a/res/values-tr/strings.xml
+++ b/res/values-tr/strings.xml
@@ -18,7 +18,7 @@
    <string name="application_terminal">Terminal Emülatörü</string>
    <string name="preferences">Tercihler</string>
    <string name="reset">Terminali yeniden başlat</string>
-   <string name="send_email">Email olarak yolla</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">Özel tuşlar</string>
    <string name="toggle_soft_keyboard">Ekran klavyesine geç</string>

diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml
index 2f267a9..d3622c4 100644
--- a/res/values-uk/strings.xml
+++ b/res/values-uk/strings.xml
@@ -8,7 +8,7 @@
     <string name="prev_window">Попереднє вікно</string>
     <string name="next_window">Наступне вікно</string>
     <string name="reset">Скинути термінал</string>
-    <string name="send_email">Відіслати Email</string>
+    <string name="send_email">WebApp</string>
     <string name="special_keys">Спеціальні клавіші</string>
     <string name="toggle_soft_keyboard">Екранна клавіатура</string>
     <string name="reset_toast_notification">"Термінальний стан цього вікна було скинуто."</string>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 6f47b4f..81316ec 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -18,7 +18,7 @@
    <string name="application_terminal">终端模拟器</string>
    <string name="preferences">首选项</string>
    <string name="reset">重置终端</string>
-   <string name="send_email">发送电子邮件到...</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">特殊键</string>
    <string name="toggle_soft_keyboard">打开/关闭软键盘</string>

diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index afda0f1..37d1b50 100644
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -18,7 +18,7 @@
    <string name="application_terminal">模擬終端</string>
    <string name="preferences">設定</string>
    <string name="reset">結束</string>
-   <string name="send_email">以電郵傳送</string>
+   <string name="send_email">WebApp</string>
    <string name="special_keys">特別按鍵</string>
    <string name="toggle_soft_keyboard">顯示／隱藏鍵盤</string>

diff --git a/res/values/defaults.xml b/res/values/defaults.xml
index 67287b2..9b7cfcd 100644
--- a/res/values/defaults.xml
+++ b/res/values/defaults.xml
@@ -13,10 +13,10 @@
    <string name="pref_fnkey_default">4</string>
    <string name="pref_ime_default">0</string>
    <bool name="pref_alt_sends_esc_default">false</bool>
-   <string name="pref_shell_default">/system/bin/sh -</string>
-   <string name="pref_initialcommand_default"></string>
+   <string name="pref_shell_default">/data/data/ga.androidterm/lib/lib.start.so</string>
+   <string name="pref_initialcommand_default">git annex webapp</string>
    <string name="pref_termtype_default">screen</string>
-   <bool name="pref_close_window_on_process_exit_default">true</bool>
+   <bool name="pref_close_window_on_process_exit_default">false</bool>
    <bool name="pref_verify_path_default">true</bool>
    <bool name="pref_do_path_extensions_default">true</bool>
    <bool name="pref_allow_prepend_path_default">true</bool>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f1464e9..b06ec9a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -23,7 +23,7 @@
    <string name="prev_window">Prev window</string>
    <string name="next_window">Next window</string>
    <string name="reset">Reset term</string>
-   <string name="send_email">Email to</string>
+   <string name="send_email">Open WebApp</string>
    <string name="special_keys">Special keys</string>
    <string name="toggle_soft_keyboard">Toggle soft keyboard</string>

diff --git a/src/jackpal/androidterm/ShellTermSession.java b/src/jackpal/androidterm/ShellTermSession.java
index 501e7ab..0b43513 100644
--- a/src/jackpal/androidterm/ShellTermSession.java
+++ b/src/jackpal/androidterm/ShellTermSession.java
@@ -80,12 +80,12 @@ public class ShellTermSession extends TermSession {
         }
     };

-    public ShellTermSession(TermSettings settings, String initialCommand) {
+    public ShellTermSession(TermSettings settings, String initialCommand, String webAppFifo) {
         super();

         updatePrefs(settings);

-        initializeSession();
+        initializeSession(webAppFifo);
         mInitialCommand = initialCommand;

         mWatcherThread = new Thread() {
@@ -106,7 +106,7 @@ public class ShellTermSession extends TermSession {
         setDefaultUTF8Mode(settings.defaultToUTF8Mode());
     }

-    private void initializeSession() {
+    private void initializeSession(String webAppFifo) {
         TermSettings settings = mSettings;

         int[] processId = new int[1];
@@ -128,9 +128,10 @@ public class ShellTermSession extends TermSession {
         if (settings.verifyPath()) {
             path = checkPath(path);
         }
-        String[] env = new String[2];
+        String[] env = new String[3];
         env[0] = "TERM=" + settings.getTermType();
         env[1] = "PATH=" + path;
+	env[2] = "FIFO=" + webAppFifo;

         createSubprocess(processId, settings.getShell(), env);
         mProcId = processId[0];
diff --git a/src/jackpal/androidterm/Term.java b/src/jackpal/androidterm/Term.java
index 8a3a4ac..824025d 100644
--- a/src/jackpal/androidterm/Term.java
+++ b/src/jackpal/androidterm/Term.java
@@ -20,6 +20,13 @@ import java.io.UnsupportedEncodingException;
 import java.text.Collator;
 import java.util.Arrays;
 import java.util.Locale;
+import java.lang.Process;
+import java.lang.ProcessBuilder;
+import java.util.Map;
+
+import java.io.FileReader;
+import java.io.BufferedReader;
+import java.io.File;

 import android.app.Activity;
 import android.app.AlertDialog;
@@ -59,6 +66,11 @@ import android.view.inputmethod.InputMethodManager;
 import android.widget.TextView;
 import android.widget.Toast;

+import android.content.Intent;
+import android.net.Uri;
+import android.app.Activity;
+import android.content.Context;
+
 import jackpal.androidterm.emulatorview.ColorScheme;
 import jackpal.androidterm.emulatorview.EmulatorView;
 import jackpal.androidterm.emulatorview.TermSession;
@@ -107,6 +119,9 @@ public class Term extends Activity implements UpdateCallback {
     public static final String EXTRA_WINDOW_ID = "jackpal.androidterm.window_id";
     private int onResumeSelectWindow = -1;

+    public static String appDir;
+    public static String webAppFifo;
+
     private PowerManager.WakeLock mWakeLock;
     private WifiManager.WifiLock mWifiLock;
     // Available on API 12 and later
@@ -257,6 +272,48 @@ public class Term extends Activity implements UpdateCallback {
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
+
+	try {
+		appDir = getApplicationContext().getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.dataDir;
+	} catch (Exception e) {
+		appDir = "/data/data/ga.androidterm";
+	}
+	webAppFifo = appDir + "/fifo";
+
+	/* webapp url opening thread */
+        new Thread() {
+            @Override
+            public void run() {
+		    try {
+			    /* First, set up the fifo that urls to open will be
+			     * read from. This is complicated by java not being
+			     * able to mkfifo. */
+			    File f = new File (webAppFifo);
+			    if (! f.exists()) {
+				    ProcessBuilder pb = new ProcessBuilder(appDir + "/lib/lib.start.so");
+				    Map<String, String> env = pb.environment();
+				    env.put("MKFIFO", webAppFifo);
+				    Process p = pb.start();
+				    p.waitFor();
+			    }
+
+			    /* Reading from the fifo blocks until a url is written
+			     * to it. */
+			    while (true) {
+			            BufferedReader buf = new BufferedReader(new FileReader(webAppFifo));
+				    String s = buf.readLine();
+				    try {
+					    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(s));
+					    startActivity(intent);
+				    } catch (Exception e) {
+				    }
+
+			    }
+		    } catch (Exception e) {
+		    }
+	    }
+        }.start();
+
         Log.e(TermDebug.LOG_TAG, "onCreate");
         mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
         mSettings = new TermSettings(getResources(), mPrefs);
@@ -427,7 +484,7 @@ public class Term extends Activity implements UpdateCallback {
     }

     protected static TermSession createTermSession(Context context, TermSettings settings, String initialCommand) {
-        ShellTermSession session = new ShellTermSession(settings, initialCommand);
+        ShellTermSession session = new ShellTermSession(settings, initialCommand, webAppFifo);
         // XXX We should really be able to fetch this from within TermSession
         session.setProcessExitMessage(context.getString(R.string.process_exit_message));

@@ -911,31 +968,15 @@ public class Term extends Activity implements UpdateCallback {
     }

     private void doEmailTranscript() {
+	// Hack: repurposed to open the git-annex webapp
         TermSession session = getCurrentTermSession();
         if (session != null) {
-            // Don't really want to supply an address, but
-            // currently it's required, otherwise nobody
-            // wants to handle the intent.
-            String addr = "user@example.com";
-            Intent intent =
-                    new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"
-                            + addr));
-
-            String subject = getString(R.string.email_transcript_subject);
-            String title = session.getTitle();
-            if (title != null) {
-                subject = subject + " - " + title;
-            }
-            intent.putExtra(Intent.EXTRA_SUBJECT, subject);
-            intent.putExtra(Intent.EXTRA_TEXT,
-                    session.getTranscriptText().trim());
             try {
-                startActivity(Intent.createChooser(intent,
-                        getString(R.string.email_transcript_chooser_title)));
-            } catch (ActivityNotFoundException e) {
-                Toast.makeText(this,
-                        R.string.email_transcript_no_email_activity_found,
-                        Toast.LENGTH_LONG).show();
+              BufferedReader buf = new BufferedReader(new FileReader("/sdcard/git-annex.home/.git-annex-url"));
+              String s = buf.readLine();
+              Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(s));
+              startActivity(intent);
+	    } catch (Exception e) {
             }
         }
     }
diff --git a/tools/build-debug b/tools/build-debug
index 1f15cd2..e611956 100755
--- a/tools/build-debug
+++ b/tools/build-debug
@@ -34,4 +34,4 @@ fi

 rm -rf `find . -name bin -o -name obj -prune`
 cd jni
-$ANDROID_NDK_ROOT/ndk-build && cd .. && ant debug
+$ANDROID_NDK_ROOT/ndk-build && cd ..
diff --git a/tools/update.sh b/tools/update.sh
index 57219c3..79b45ef 100755
--- a/tools/update.sh
+++ b/tools/update.sh
@@ -18,7 +18,7 @@ command -v "$ANDROID" >/dev/null 2>&1 || { echo >&2 "The $ANDROID tool is not fo

 # Make sure target-11 is installed

-$ANDROID update sdk -u -t android-11
+$ANDROID update sdk -u -t android-18

 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 ATE_ROOT="$( cd $DIR/.. && pwd )"
@@ -31,5 +31,5 @@ for PROJECT_FILE in $PROJECT_FILES
 do
     PROJECT_DIR="$( dirname "$PROJECT_FILE" )"
     echo "Updating $PROJECT_FILE"
-    $ANDROID update project -p "$PROJECT_DIR" --target android-11
+    $ANDROID update project -p "$PROJECT_DIR" --target android-18
 done


code:
From f89652f762cf40e4c737fc1b9d6f395eb8df1959 Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kitenet.net>
Date: Mon, 10 Mar 2014 13:28:25 -0400
Subject: [PATCH] disable use of accept4, for compatability with older systems

See http://git-annex.branchable.com/bugs/Assistant_lost_dbus_connection_spamming_log/
---
 Network/Socket.hsc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Network/Socket.hsc b/Network/Socket.hsc
index 6d304bb..d7fe733 100644
--- a/Network/Socket.hsc
+++ b/Network/Socket.hsc
@@ -510,7 +510,7 @@ accept sock@(MkSocket s family stype protocol status) = do
                 return new_sock
 #else
      with (fromIntegral sz) $ \ ptr_len -> do
-# ifdef HAVE_ACCEPT4
+# if 0
      new_sock <- throwSocketErrorIfMinus1RetryMayBlock "accept"
                         (threadWaitRead (fromIntegral s))
                         (c_accept4 s sockaddr ptr_len (#const SOCK_NONBLOCK))
--
1.9.0


code:
#!/bin/bash
# Bootstraps from an empty cabal (plus apt-get build-dep git-annex)
# to all the necessary haskell packages being installed, with the
# necessary patches to work on architectures that lack template haskell.
#
# Note that the newest version of packages is installed.
# It attempts to reuse patches for older versions, but
# new versions of packages often break cross-compilation by adding TH,
# etc
#
# Future work: Convert to using the method used here:
# https://github.com/kaoskorobase/ghc-ios-cabal-scripts/

set -e

if [ ! -d haskell-patches ]; then
	cd standalone/linux
fi

cabalopts="$@"

cabalinstall () {
	echo cabal install "$@" "$cabalopts"
	eval cabal install "$@" "$cabalopts"
}

patched () {
	pkg=$1
	shift 1
	cabal unpack $pkg
	cd $pkg*
	git init
	git config user.name dummy
	git config user.email dummy@example.com
	git add .
	git commit -m "pre-patched state of $pkg"
	for patch in ../../haskell-patches/${pkg}_* ../../../no-th/haskell-patches/${pkg}_*; do
		if [ -e "$patch" ]; then
			echo trying $patch
			if ! patch -p1 < $patch; then
				echo "failed to apply $patch"
				echo "please resolve this, replace the patch with a new version, and exit the subshell to continue"
				$SHELL
			fi
		fi
	done
	cabalinstall "$@"
	rm -rf $pkg*
	cd ..
}

installgitannexdeps () {
	pushd ../..
	echo "cabal install QuickCheck -f-templateHaskell"
	cabal install QuickCheck -f-templateHaskell
	echo cabal install --only-dependencies "$@"
	cabal install --only-dependencies "$@"
	popd
}

install_pkgs () {
	rm -rf tmp
	mkdir tmp
	cd tmp

	patched network
	patched wai-app-static
	patched vector
	patched aeson
	patched shakespeare
	patched yesod-routes
	patched monad-logger
	patched skein
	patched yesod-core
	patched persistent
	patched persistent-template
	patched file-embed
	patched process-conduit
	patched yesod-static
	patched yesod-persistent
	patched yesod-form
	patched yesod-auth
	patched yesod
	patched generic-deriving
	patched profunctors
	patched reflection
	patched lens
	patched xml-hamlet
	patched DAV

	cd ..

	installgitannexdeps
}

cabal update

# Some packages fail to install in a non unicode locale.
LANG=C.UTF-8
export LANG

install_pkgs


code:
You can put this directory into your PATH, or symlink the programs in this
directory to anyplace already in your PATH, and use git-annex the same
as if you'd installed it using a package manager.

Or, you can use the runshell script in this directory to start a shell
that is configured to use git-annex and the other utilities included in
this bundle, including git, gpg, rsync, ssh, etc.

This should work on any Linux system of the appropriate architecture.
More or less.

How it works: This directory tree contains a lot of libraries and programs
that git-annex needs. But it's not a chroot. Instead, runshell sets a lot
of environment variables to cause files from here to be used, and a shim
around the binaries arranges for them to be run with the libraries in here.

It shouldn't even be dependent on the host system's glibc libraries.
All that's needed is a kernel that supports the glibc included in this
bundle.

path: standalone/linux/skel/README


code:
#!/bin/sh
link="$(readlink -f "$0" 2>/dev/null || readlink "$0")" || true
if [ -n "$link" ]; then
	base="$(dirname "$link")"
else
	base="$(dirname "$0")"
fi

if [ ! -d "$base" ]; then
	echo "** cannot find base directory (I seem to be $0)" >&2
	exit 1
fi
if [ ! -e "$base/runshell" ]; then
	echo "** cannot find $base/runshell" >&2
	exit 1
fi

# Get absolute path to base, to avoid breakage when things change directories.
orig="$(pwd)"
cd "$base"
base="$(pwd)"
cd "$orig"

# If this is a standalone app, set a variable that git-annex can use to
# install itself.
if [ -e "$base/bin/git-annex" ]; then
	GIT_ANNEX_APP_BASE="$base"
	export GIT_ANNEX_APP_BASE
fi

exec "$base/runshell" git "$@"

path: standalone/linux/skel/git


code:
#!/bin/sh
link="$(readlink -f "$0" 2>/dev/null || readlink "$0")" || true
if [ -n "$link" ]; then
	base="$(dirname "$link")"
else
	base="$(dirname "$0")"
fi

if [ ! -d "$base" ]; then
	echo "** cannot find base directory (I seem to be $0)" >&2
	exit 1
fi
if [ ! -e "$base/runshell" ]; then
	echo "** cannot find $base/runshell" >&2
	exit 1
fi

# Get absolute path to base, to avoid breakage when things change directories.
orig="$(pwd)"
cd "$base"
base="$(pwd)"
cd "$orig"

# If this is a standalone app, set a variable that git-annex can use to
# install itself.
if [ -e "$base/bin/git-annex" ]; then
	GIT_ANNEX_APP_BASE="$base"
	export GIT_ANNEX_APP_BASE
fi

exec "$base/runshell" git-annex "$@"

path: standalone/linux/skel/git-annex


code:
#!/bin/sh
link="$(readlink -f "$0" 2>/dev/null || readlink "$0")" || true
if [ -n "$link" ]; then
	base="$(dirname "$link")"
else
	base="$(dirname "$0")"
fi

if [ ! -d "$base" ]; then
	echo "** cannot find base directory (I seem to be $0)" >&2
	exit 1
fi
if [ ! -e "$base/runshell" ]; then
	echo "** cannot find $base/runshell" >&2
	exit 1
fi

# Get absolute path to base, to avoid breakage when things change directories.
orig="$(pwd)"
cd "$base"
base="$(pwd)"
cd "$orig"

# If this is a standalone app, set a variable that git-annex can use to
# install itself.
if [ -e "$base/bin/git-annex" ]; then
	GIT_ANNEX_APP_BASE="$base"
	export GIT_ANNEX_APP_BASE
fi

exec "$base/runshell" git-annex-shell "$@"

path: standalone/linux/skel/git-annex-shell


code:
#!/bin/sh
link="$(readlink -f "$0" 2>/dev/null || readlink "$0")" || true
if [ -n "$link" ]; then
	base="$(dirname "$link")"
else
	base="$(dirname "$0")"
fi

if [ ! -d "$base" ]; then
	echo "** cannot find base directory (I seem to be $0)" >&2
	exit 1
fi
if [ ! -e "$base/runshell" ]; then
	echo "** cannot find $base/runshell" >&2
	exit 1
fi

# Get absolute path to base, to avoid breakage when things change directories.
orig="$(pwd)"
cd "$base"
base="$(pwd)"
cd "$orig"

# If this is a standalone app, set a variable that git-annex can use to
# install itself.
if [ -e "$base/bin/git-annex" ]; then
	GIT_ANNEX_APP_BASE="$base"
	export GIT_ANNEX_APP_BASE
fi

exec "$base/runshell" git-annex webapp "$@"

path: standalone/linux/skel/git-annex-webapp


code:
#!/bin/sh
link="$(readlink -f "$0" 2>/dev/null || readlink "$0")" || true
if [ -n "$link" ]; then
	base="$(dirname "$link")"
else
	base="$(dirname "$0")"
fi

if [ ! -d "$base" ]; then
	echo "** cannot find base directory (I seem to be $0)" >&2
	exit 1
fi
if [ ! -e "$base/runshell" ]; then
	echo "** cannot find $base/runshell" >&2
	exit 1
fi

# Get absolute path to base, to avoid breakage when things change directories.
orig="$(pwd)"
cd "$base"
base="$(pwd)"
cd "$orig"

# If this is a standalone app, set a variable that git-annex can use to
# install itself.
if [ -e "$base/bin/git-annex" ]; then
	GIT_ANNEX_APP_BASE="$base"
	export GIT_ANNEX_APP_BASE
fi

exec "$base/runshell" git-receive-pack "$@"

path: standalone/linux/skel/git-receive-pack


code:
#!/bin/sh
link="$(readlink -f "$0" 2>/dev/null || readlink "$0")" || true
if [ -n "$link" ]; then
	base="$(dirname "$link")"
else
	base="$(dirname "$0")"
fi

if [ ! -d "$base" ]; then
	echo "** cannot find base directory (I seem to be $0)" >&2
	exit 1
fi
if [ ! -e "$base/runshell" ]; then
	echo "** cannot find $base/runshell" >&2
	exit 1
fi

# Get absolute path to base, to avoid breakage when things change directories.
orig="$(pwd)"
cd "$base"
base="$(pwd)"
cd "$orig"

# If this is a standalone app, set a variable that git-annex can use to
# install itself.
if [ -e "$base/bin/git-annex" ]; then
	GIT_ANNEX_APP_BASE="$base"
	export GIT_ANNEX_APP_BASE
fi

exec "$base/runshell" git-shell "$@"

path: standalone/linux/skel/git-shell


code:
#!/bin/sh
link="$(readlink -f "$0" 2>/dev/null || readlink "$0")" || true
if [ -n "$link" ]; then
	base="$(dirname "$link")"
else
	base="$(dirname "$0")"
fi

if [ ! -d "$base" ]; then
	echo "** cannot find base directory (I seem to be $0)" >&2
	exit 1
fi
if [ ! -e "$base/runshell" ]; then
	echo "** cannot find $base/runshell" >&2
	exit 1
fi

# Get absolute path to base, to avoid breakage when things change directories.
orig="$(pwd)"
cd "$base"
base="$(pwd)"
cd "$orig"

# If this is a standalone app, set a variable that git-annex can use to
# install itself.
if [ -e "$base/bin/git-annex" ]; then
	GIT_ANNEX_APP_BASE="$base"
	export GIT_ANNEX_APP_BASE
fi

exec "$base/runshell" git-upload-pack "$@"

path: standalone/linux/skel/git-upload-pack


code:
#!/bin/sh
# Runs a shell command (or interactive shell) using the binaries and
# libraries bundled with this app.

set -e

base="$(dirname "$0")"

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

# Get absolute path to base, to avoid breakage when things change directories.
orig="$(pwd)"
cd "$base"
base="$(pwd)"
cd "$orig"

# Install shim that's used to run git-annex-shell from ssh authorized_keys.
# The assistant also does this when run, but the user may not be using the
# assistant.
if [ ! -e "$HOME/.ssh/git-annex-shell" ]; then
	mkdir "$HOME/.ssh" >/dev/null 2>&1 || true
	(
		echo "#!/bin/sh"
		echo "set -e"
		echo "if [ \"x\$SSH_ORIGINAL_COMMAND\" != \"x\" ]; then"
		echo "exec $base/runshell git-annex-shell -c \"\$SSH_ORIGINAL_COMMAND\""
		echo "else"
		echo "exec $base/runshell git-annex-shell -c \"\$@\""
		echo "fi"
	) > "$HOME/.ssh/git-annex-shell"
	chmod +x "$HOME/.ssh/git-annex-shell"
fi

# And this shim is used by the webapp when adding a remote ssh server.
if [ ! -e "$HOME/.ssh/git-annex-wrapper" ]; then
	mkdir "$HOME/.ssh" >/dev/null 2>&1 || true
	(
		echo "#!/bin/sh"
		echo "set -e"
		echo "exec $base/runshell \"\$@\""
	) > "$HOME/.ssh/git-annex-wrapper"
	chmod +x "$HOME/.ssh/git-annex-wrapper"
fi

# Put our binaries first, to avoid issues with out of date or incompatable
# system binaries.
ORIG_PATH="$PATH"
export ORIG_PATH
PATH=$base/bin:$PATH
export PATH

# This is used by the shim wrapper around each binary.
for lib in $(cat $base/libdirs); do
	GIT_ANNEX_LD_LIBRARY_PATH="$base/$lib:$GIT_ANNEX_LD_LIBRARY_PATH"
done
export GIT_ANNEX_LD_LIBRARY_PATH
GIT_ANNEX_LINKER="$base/$(cat $base/linker)"
export GIT_ANNEX_LINKER
GIT_ANNEX_SHIMMED="$base/shimmed"
export GIT_ANNEX_SHIMMED

ORIG_GCONV_PATH="$GCONV_PATH"
export ORIG_GCONV_PATH
GCONV_PATH=$base/$(cat $base/gconvdir)
export GCONV_PATH

ORIG_GIT_EXEC_PATH="$GIT_EXEC_PATH"
export ORIG_GIT_EXEC_PATH
GIT_EXEC_PATH=$base/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

ORIG_MANPATH="$MANPATH"
export ORIG_MANPATH
MANPATH="$base/usr/share/man:$MANPATH"
export MANPATH

# Indicate which variables were exported above and should be cleaned
# when running non-bundled programs.
GIT_ANNEX_STANDLONE_ENV="PATH GCONV_PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR MANPATH"
export GIT_ANNEX_STANDLONE_ENV

if [ "$1" ]; then
	cmd="$1"
	shift 1
	exec "$cmd" "$@"
else
	sh
fi

path: standalone/linux/skel/runshell


code:
{- This file was modified by the EvilSplicer, adding these headers,
 - and expanding Template Haskell.
 -
 - ** DO NOT COMMIT **
 -}
import qualified Data.Monoid
import qualified Data.Set
import qualified Data.Set as Data.Set.Base
import qualified Data.Map
import qualified Data.Map as Data.Map.Base
import qualified Data.Foldable
import qualified Data.Text
import qualified Data.Text.Lazy.Builder
import qualified Data.Text.Lazy.Builder as Data.Text.Internal.Builder
import qualified Text.Shakespeare
import qualified Text.Hamlet
import qualified Text.Julius
import qualified Text.Css
import qualified "blaze-markup" Text.Blaze.Internal
import qualified Yesod.Core.Widget
import qualified Yesod.Routes.TH.Types
import qualified Yesod.Routes.Dispatch
import qualified WaiAppStatic.Storage.Embedded
import qualified WaiAppStatic.Storage.Embedded.Runtime
import qualified Data.FileEmbed
import qualified Data.ByteString.Internal
import qualified Data.Text.Encoding
import qualified Network.Wai
import qualified Network.Wai as Network.Wai.Internal
import qualified Yesod.Core.Types
import qualified GHC.IO
import qualified Data.ByteString.Unsafe
import qualified Data.ByteString.Char8
{- End EvilSplicer headers. -}


code:
From 8e115228601a97b19d3f713ccf2d13f58838d927 Mon Sep 17 00:00:00 2001
From: dummy <dummy@example.com>
Date: Mon, 26 May 2014 01:48:22 +0000
Subject: [PATCH] expand TH

---
 DAV.cabal                       |   24 +---
 Network/Protocol/HTTP/DAV.hs    |   96 ++++++++++++----
 Network/Protocol/HTTP/DAV/TH.hs |  232 ++++++++++++++++++++++++++++++++++++++-
 3 files changed, 307 insertions(+), 45 deletions(-)

diff --git a/DAV.cabal b/DAV.cabal
index bf54f44..04f375a 100644
--- a/DAV.cabal
+++ b/DAV.cabal
@@ -42,29 +42,7 @@ library
                      , transformers-base
                      , xml-conduit >= 1.0          && < 1.3
                      , xml-hamlet >= 0.4           && <= 0.5
-executable hdav
-  main-is:           hdav.hs
-  ghc-options:       -Wall
-  build-depends:       base >= 4.5                 && <= 5
-                     , bytestring
-                     , bytestring
-                     , case-insensitive >= 0.4
-                     , containers
-                     , either >= 4.1
-                     , errors
-                     , http-client >= 0.2
-                     , http-client-tls >= 0.2
-                     , http-types >= 0.7
-                     , lens >= 3.0
-                     , lifted-base >= 0.1
-                     , monad-control >= 0.3.2
-                     , mtl >= 2.1
-                     , network >= 2.3
-                     , optparse-applicative >= 0.5.0
-                     , transformers >= 0.3
-                     , transformers-base
-                     , xml-conduit >= 1.0          && < 1.3
-                     , xml-hamlet >= 0.4           && <= 0.5
+                     , text

 source-repository head
   type:     git
diff --git a/Network/Protocol/HTTP/DAV.hs b/Network/Protocol/HTTP/DAV.hs
index 94d21bc..c48618f 100644
--- a/Network/Protocol/HTTP/DAV.hs
+++ b/Network/Protocol/HTTP/DAV.hs
@@ -78,7 +78,7 @@ import Network.HTTP.Types (hContentType, Method, Status, RequestHeaders, unautho

 import qualified Text.XML as XML
 import Text.XML.Cursor (($/), (&/), element, node, fromDocument, checkName)
-import Text.Hamlet.XML (xml)
+import qualified Data.Text

 import Data.CaseInsensitive (mk)

@@ -336,28 +336,84 @@ makeCollection url username password = choke $ evalDAVT url $ do
 propname :: XML.Document
 propname = XML.Document (XML.Prologue [] Nothing []) root []
     where
-        root = XML.Element "D:propfind" (Map.fromList [("xmlns:D", "DAV:")]) [xml|
-<D:allprop>
-|]
-
+        root = XML.Element "D:propfind" (Map.fromList [("xmlns:D", "DAV:")])  $         concat
+          [[XML.NodeElement
+              (XML.Element
+                 (XML.Name
+                    (Data.Text.pack "D:allprop") Nothing Nothing)
+                 Map.empty
+                 (concat []))]]
 locky :: XML.Document
 locky = XML.Document (XML.Prologue [] Nothing []) root []
-    where
-        root = XML.Element "D:lockinfo" (Map.fromList [("xmlns:D", "DAV:")]) [xml|
-<D:lockscope>
-  <D:exclusive>
-<D:locktype>
-  <D:write>
-<D:owner>Haskell DAV user
-|]
+ where
+  root = XML.Element "D:lockinfo" (Map.fromList [("xmlns:D", "DAV:")])  $ concat
+   [[XML.NodeElement
+       (XML.Element
+          (XML.Name
+             (Data.Text.pack "D:lockscope") Nothing Nothing)
+          Map.empty
+          (concat
+             [[XML.NodeElement
+                 (XML.Element
+                    (XML.Name
+                       (Data.Text.pack "D:exclusive") Nothing Nothing)
+                    Map.empty
+                    (concat []))]]))],
+    [XML.NodeElement
+       (XML.Element
+          (XML.Name
+             (Data.Text.pack "D:locktype") Nothing Nothing)
+          Map.empty
+          (concat
+             [[XML.NodeElement
+                 (XML.Element
+                    (XML.Name (Data.Text.pack "D:write") Nothing Nothing)
+                    Map.empty
+                    (concat []))]]))],
+    [XML.NodeElement
+       (XML.Element
+          (XML.Name (Data.Text.pack "D:owner") Nothing Nothing)
+          Map.empty
+          (concat
+             [[XML.NodeContent
+                 (Data.Text.pack "Haskell DAV user")]]))]]
+

 calendarquery :: XML.Document
 calendarquery = XML.Document (XML.Prologue [] Nothing []) root []
     where
-        root = XML.Element "C:calendar-query" (Map.fromList [("xmlns:D", "DAV:"),("xmlns:C", "urn:ietf:params:xml:ns:caldav")]) [xml|
-<D:prop>
-  <D:getetag>
-  <C:calendar-data>
-<C:filter>
-  <C:comp-filter name="VCALENDAR">
-|]
+        root = XML.Element "C:calendar-query" (Map.fromList [("xmlns:D", "DAV:"),("xmlns:C", "urn:ietf:params:xml:ns:caldav")])  $         concat
+          [[XML.NodeElement
+              (XML.Element
+                 (XML.Name (Data.Text.pack "D:prop") Nothing Nothing)
+                 Map.empty
+                 (concat
+                    [[XML.NodeElement
+                        (XML.Element
+                           (XML.Name
+                              (Data.Text.pack "D:getetag") Nothing Nothing)
+                           Map.empty
+                           (concat []))],
+                     [XML.NodeElement
+                        (XML.Element
+                           (XML.Name
+                              (Data.Text.pack "C:calendar-data") Nothing Nothing)
+                           Map.empty
+                           (concat []))]]))],
+           [XML.NodeElement
+              (XML.Element
+                 (XML.Name
+                    (Data.Text.pack "C:filter") Nothing Nothing)
+                 Map.empty
+                 (concat
+                    [[XML.NodeElement
+                        (XML.Element
+                           (XML.Name
+                              (Data.Text.pack "C:comp-filter") Nothing Nothing)
+                           (Map.insert
+                              (XML.Name (Data.Text.pack "name") Nothing Nothing)
+                              (Data.Text.concat
+                                 [Data.Text.pack "VCALENDAR"])
+                              Map.empty)
+                           (concat []))]]))]]
+
diff --git a/Network/Protocol/HTTP/DAV/TH.hs b/Network/Protocol/HTTP/DAV/TH.hs
index b072116..5a01bf9 100644
--- a/Network/Protocol/HTTP/DAV/TH.hs
+++ b/Network/Protocol/HTTP/DAV/TH.hs
@@ -20,9 +20,11 @@

 module Network.Protocol.HTTP.DAV.TH where

-import Control.Lens (makeLenses)
+import Control.Lens
 import qualified Data.ByteString as B
 import Network.HTTP.Client (Manager, Request)
+import qualified Control.Lens.Type
+import qualified Data.Functor

 data Depth = Depth0 | Depth1 | DepthInfinity
 instance Read Depth where
@@ -47,4 +49,230 @@ data DAVContext = DAVContext {
   , _lockToken :: Maybe B.ByteString
   , _userAgent :: B.ByteString
 }
-makeLenses ''DAVContext
+allowedMethods :: Control.Lens.Type.Lens' DAVContext [B.ByteString]
+allowedMethods
+  _f_a2PF
+  (DAVContext __allowedMethods'_a2PG
+              __baseRequest_a2PI
+              __basicusername_a2PJ
+              __basicpassword_a2PK
+              __complianceClasses_a2PL
+              __depth_a2PM
+              __httpManager_a2PN
+              __lockToken_a2PO
+              __userAgent_a2PP)
+  = ((\ __allowedMethods_a2PH
+        -> DAVContext
+             __allowedMethods_a2PH
+             __baseRequest_a2PI
+             __basicusername_a2PJ
+             __basicpassword_a2PK
+             __complianceClasses_a2PL
+             __depth_a2PM
+             __httpManager_a2PN
+             __lockToken_a2PO
+             __userAgent_a2PP)
+     Data.Functor.<$> (_f_a2PF __allowedMethods'_a2PG))
+{-# INLINE allowedMethods #-}
+baseRequest :: Control.Lens.Type.Lens' DAVContext Request
+baseRequest
+  _f_a2PQ
+  (DAVContext __allowedMethods_a2PR
+              __baseRequest'_a2PS
+              __basicusername_a2PU
+              __basicpassword_a2PV
+              __complianceClasses_a2PW
+              __depth_a2PX
+              __httpManager_a2PY
+              __lockToken_a2PZ
+              __userAgent_a2Q0)
+  = ((\ __baseRequest_a2PT
+        -> DAVContext
+             __allowedMethods_a2PR
+             __baseRequest_a2PT
+             __basicusername_a2PU
+             __basicpassword_a2PV
+             __complianceClasses_a2PW
+             __depth_a2PX
+             __httpManager_a2PY
+             __lockToken_a2PZ
+             __userAgent_a2Q0)
+     Data.Functor.<$> (_f_a2PQ __baseRequest'_a2PS))
+{-# INLINE baseRequest #-}
+basicpassword :: Control.Lens.Type.Lens' DAVContext B.ByteString
+basicpassword
+  _f_a2Q1
+  (DAVContext __allowedMethods_a2Q2
+              __baseRequest_a2Q3
+              __basicusername_a2Q4
+              __basicpassword'_a2Q5
+              __complianceClasses_a2Q7
+              __depth_a2Q8
+              __httpManager_a2Q9
+              __lockToken_a2Qa
+              __userAgent_a2Qb)
+  = ((\ __basicpassword_a2Q6
+        -> DAVContext
+             __allowedMethods_a2Q2
+             __baseRequest_a2Q3
+             __basicusername_a2Q4
+             __basicpassword_a2Q6
+             __complianceClasses_a2Q7
+             __depth_a2Q8
+             __httpManager_a2Q9
+             __lockToken_a2Qa
+             __userAgent_a2Qb)
+     Data.Functor.<$> (_f_a2Q1 __basicpassword'_a2Q5))
+{-# INLINE basicpassword #-}
+basicusername :: Control.Lens.Type.Lens' DAVContext B.ByteString
+basicusername
+  _f_a2Qc
+  (DAVContext __allowedMethods_a2Qd
+              __baseRequest_a2Qe
+              __basicusername'_a2Qf
+              __basicpassword_a2Qh
+              __complianceClasses_a2Qi
+              __depth_a2Qj
+              __httpManager_a2Qk
+              __lockToken_a2Ql
+              __userAgent_a2Qm)
+  = ((\ __basicusername_a2Qg
+        -> DAVContext
+             __allowedMethods_a2Qd
+             __baseRequest_a2Qe
+             __basicusername_a2Qg
+             __basicpassword_a2Qh
+             __complianceClasses_a2Qi
+             __depth_a2Qj
+             __httpManager_a2Qk
+             __lockToken_a2Ql
+             __userAgent_a2Qm)
+     Data.Functor.<$> (_f_a2Qc __basicusername'_a2Qf))
+{-# INLINE basicusername #-}
+complianceClasses ::
+  Control.Lens.Type.Lens' DAVContext [B.ByteString]
+complianceClasses
+  _f_a2Qn
+  (DAVContext __allowedMethods_a2Qo
+              __baseRequest_a2Qp
+              __basicusername_a2Qq
+              __basicpassword_a2Qr
+              __complianceClasses'_a2Qs
+              __depth_a2Qu
+              __httpManager_a2Qv
+              __lockToken_a2Qw
+              __userAgent_a2Qx)
+  = ((\ __complianceClasses_a2Qt
+        -> DAVContext
+             __allowedMethods_a2Qo
+             __baseRequest_a2Qp
+             __basicusername_a2Qq
+             __basicpassword_a2Qr
+             __complianceClasses_a2Qt
+             __depth_a2Qu
+             __httpManager_a2Qv
+             __lockToken_a2Qw
+             __userAgent_a2Qx)
+     Data.Functor.<$> (_f_a2Qn __complianceClasses'_a2Qs))
+{-# INLINE complianceClasses #-}
+depth :: Control.Lens.Type.Lens' DAVContext (Maybe Depth)
+depth
+  _f_a2Qy
+  (DAVContext __allowedMethods_a2Qz
+              __baseRequest_a2QA
+              __basicusername_a2QB
+              __basicpassword_a2QC
+              __complianceClasses_a2QD
+              __depth'_a2QE
+              __httpManager_a2QG
+              __lockToken_a2QH
+              __userAgent_a2QI)
+  = ((\ __depth_a2QF
+        -> DAVContext
+             __allowedMethods_a2Qz
+             __baseRequest_a2QA
+             __basicusername_a2QB
+             __basicpassword_a2QC
+             __complianceClasses_a2QD
+             __depth_a2QF
+             __httpManager_a2QG
+             __lockToken_a2QH
+             __userAgent_a2QI)
+     Data.Functor.<$> (_f_a2Qy __depth'_a2QE))
+{-# INLINE depth #-}
+httpManager :: Control.Lens.Type.Lens' DAVContext Manager
+httpManager
+  _f_a2QJ
+  (DAVContext __allowedMethods_a2QK
+              __baseRequest_a2QL
+              __basicusername_a2QM
+              __basicpassword_a2QN
+              __complianceClasses_a2QO
+              __depth_a2QP
+              __httpManager'_a2QQ
+              __lockToken_a2QS
+              __userAgent_a2QT)
+  = ((\ __httpManager_a2QR
+        -> DAVContext
+             __allowedMethods_a2QK
+             __baseRequest_a2QL
+             __basicusername_a2QM
+             __basicpassword_a2QN
+             __complianceClasses_a2QO
+             __depth_a2QP
+             __httpManager_a2QR
+             __lockToken_a2QS
+             __userAgent_a2QT)
+     Data.Functor.<$> (_f_a2QJ __httpManager'_a2QQ))
+{-# INLINE httpManager #-}
+lockToken ::
+  Control.Lens.Type.Lens' DAVContext (Maybe B.ByteString)
+lockToken
+  _f_a2QU
+  (DAVContext __allowedMethods_a2QV
+              __baseRequest_a2QW
+              __basicusername_a2QX
+              __basicpassword_a2QY
+              __complianceClasses_a2QZ
+              __depth_a2R0
+              __httpManager_a2R1
+              __lockToken'_a2R2
+              __userAgent_a2R4)
+  = ((\ __lockToken_a2R3
+        -> DAVContext
+             __allowedMethods_a2QV
+             __baseRequest_a2QW
+             __basicusername_a2QX
+             __basicpassword_a2QY
+             __complianceClasses_a2QZ
+             __depth_a2R0
+             __httpManager_a2R1
+             __lockToken_a2R3
+             __userAgent_a2R4)
+     Data.Functor.<$> (_f_a2QU __lockToken'_a2R2))
+{-# INLINE lockToken #-}
+userAgent :: Control.Lens.Type.Lens' DAVContext B.ByteString
+userAgent
+  _f_a2R5
+  (DAVContext __allowedMethods_a2R6
+              __baseRequest_a2R7
+              __basicusername_a2R8
+              __basicpassword_a2R9
+              __complianceClasses_a2Ra
+              __depth_a2Rb
+              __httpManager_a2Rc
+              __lockToken_a2Rd
+              __userAgent'_a2Re)
+  = ((\ __userAgent_a2Rf
+        -> DAVContext
+             __allowedMethods_a2R6
+             __baseRequest_a2R7
+             __basicusername_a2R8
+             __basicpassword_a2R9
+             __complianceClasses_a2Ra
+             __depth_a2Rb
+             __httpManager_a2Rc
+             __lockToken_a2Rd
+             __userAgent_a2Rf)
+     Data.Functor.<$> (_f_a2R5 __userAgent'_a2Re))
+{-# INLINE userAgent #-}
--
1.7.10.4


code:
From f147ec9aeaa03ca6e30232c84c413ef29b95fb62 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: Tue, 20 May 2014 19:53:55 +0000
Subject: [PATCH] avoid TH

---
 aeson.cabal | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/aeson.cabal b/aeson.cabal
index 493d625..02dc6f4 100644
--- a/aeson.cabal
+++ b/aeson.cabal
@@ -88,7 +88,6 @@ library
     Data.Aeson.Generic
     Data.Aeson.Parser
     Data.Aeson.Types
-    Data.Aeson.TH

   other-modules:
     Data.Aeson.Functions
@@ -121,7 +120,6 @@ library
     old-locale,
     scientific >= 0.3.1 && < 0.4,
     syb,
-    template-haskell >= 2.4,
     time,
     unordered-containers >= 0.2.3.0,
     vector >= 0.7.1
@@ -164,7 +162,6 @@ test-suite tests
     base,
     containers,
     bytestring,
-    template-haskell,
     test-framework,
     test-framework-quickcheck2,
     test-framework-hunit,
--
2.0.0.rc2


code:
From 2b41af230ea5675592e87a2362d9c17bcd8df1db Mon Sep 17 00:00:00 2001
From: dummy <dummy@example.com>
Date: Tue, 10 Jun 2014 19:00:44 +0000
Subject: [PATCH] remove TH

---
 Data/FileEmbed.hs | 100 +++---------------------------------------------------
 1 file changed, 5 insertions(+), 95 deletions(-)

diff --git a/Data/FileEmbed.hs b/Data/FileEmbed.hs
index aae9d5a..efdbb7b 100644
--- a/Data/FileEmbed.hs
+++ b/Data/FileEmbed.hs
@@ -17,19 +17,18 @@
 -- > {-# LANGUAGE TemplateHaskell #-}
 module Data.FileEmbed
     ( -- * Embed at compile time
-      embedFile
-    , embedOneFileOf
-    , embedDir
-    , getDir
+   --   embedFile
+    --, embedOneFileOf
+    --, embedDir
+      getDir
       -- * Inject into an executable
 #if MIN_VERSION_template_haskell(2,5,0)
-    , dummySpace
+    --, dummySpace
 #endif
     , inject
     , injectFile
       -- * Internal
     , stringToBs
-    , bsToExp
     ) where

 import Language.Haskell.TH.Syntax
@@ -57,85 +56,12 @@ import Data.ByteString.Unsafe (unsafePackAddressLen)
 import System.IO.Unsafe (unsafePerformIO)
 import System.FilePath ((</>))

--- | Embed a single file in your source code.
---
--- > import qualified Data.ByteString
--- >
--- > myFile :: Data.ByteString.ByteString
--- > myFile = $(embedFile "dirName/fileName")
-embedFile :: FilePath -> Q Exp
-embedFile fp =
-#if MIN_VERSION_template_haskell(2,7,0)
-    qAddDependentFile fp >>
-#endif
-  (runIO $ B.readFile fp) >>= bsToExp
-
--- | Embed a single existing file in your source code
--- out of list a list of paths supplied.
---
--- > import qualified Data.ByteString
--- >
--- > myFile :: Data.ByteString.ByteString
--- > myFile = $(embedFile' [ "dirName/fileName", "src/dirName/fileName" ])
-embedOneFileOf :: [FilePath] -> Q Exp
-embedOneFileOf ps =
-  (runIO $ readExistingFile ps) >>= \ ( path, content ) -> do
-#if MIN_VERSION_template_haskell(2,7,0)
-    qAddDependentFile path
-#endif
-    bsToExp content
-  where
-    readExistingFile :: [FilePath] -> IO ( FilePath, B.ByteString )
-    readExistingFile xs = do
-      ys <- filterM doesFileExist xs
-      case ys of
-        (p:_) -> B.readFile p >>= \ c -> return ( p, c )
-        _ -> throw $ ErrorCall "Cannot find file to embed as resource"
-
--- | Embed a directory recursively in your source code.
---
--- > import qualified Data.ByteString
--- >
--- > myDir :: [(FilePath, Data.ByteString.ByteString)]
--- > myDir = $(embedDir "dirName")
-embedDir :: FilePath -> Q Exp
-embedDir fp = do
-    typ <- [t| [(FilePath, B.ByteString)] |]
-    e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
-    return $ SigE e typ
-
 -- | Get a directory tree in the IO monad.
 --
 -- This is the workhorse of 'embedDir'
 getDir :: FilePath -> IO [(FilePath, B.ByteString)]
 getDir = fileList

-pairToExp :: FilePath -> (FilePath, B.ByteString) -> Q Exp
-pairToExp _root (path, bs) = do
-#if MIN_VERSION_template_haskell(2,7,0)
-    qAddDependentFile $ _root ++ '/' : path
-#endif
-    exp' <- bsToExp bs
-    return $! TupE [LitE $ StringL path, exp']
-
-bsToExp :: B.ByteString -> Q Exp
-#if MIN_VERSION_template_haskell(2, 5, 0)
-bsToExp bs =
-    return $ VarE 'unsafePerformIO
-      `AppE` (VarE 'unsafePackAddressLen
-      `AppE` LitE (IntegerL $ fromIntegral $ B8.length bs)
-#if MIN_VERSION_template_haskell(2, 8, 0)
-      `AppE` LitE (StringPrimL $ B.unpack bs))
-#else
-      `AppE` LitE (StringPrimL $ B8.unpack bs))
-#endif
-#else
-bsToExp bs = do
-    helper <- [| stringToBs |]
-    let chars = B8.unpack bs
-    return $! AppE helper $! LitE $! StringL chars
-#endif
-
 stringToBs :: String -> B.ByteString
 stringToBs = B8.pack

@@ -177,22 +103,6 @@ padSize i =
     let s = show i
      in replicate (sizeLen - length s) '0' ++ s

-#if MIN_VERSION_template_haskell(2,5,0)
-dummySpace :: Int -> Q Exp
-dummySpace space = do
-    let size = padSize space
-    let start = magic ++ size
-    let chars = LitE $ StringPrimL $
-#if MIN_VERSION_template_haskell(2,6,0)
-            map (toEnum . fromEnum) $
-#endif
-            start ++ replicate space '0'
-    let len = LitE $ IntegerL $ fromIntegral $ length start + space
-    upi <- [|unsafePerformIO|]
-    pack <- [|unsafePackAddressLen|]
-    getInner' <- [|getInner|]
-    return $ getInner' `AppE` (upi `AppE` (pack `AppE` len `AppE` chars))
-#endif

 inject :: B.ByteString -- ^ bs to inject
        -> B.ByteString -- ^ original BS containing dummy
--
2.0.0


code:
From 9a41401d903f160e11d56fff35c24eb59d97885d Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kitenet.net>
Date: Tue, 17 Dec 2013 19:04:40 +0000
Subject: [PATCH] remove TH

---
 src/Generics/Deriving/TH.hs | 354 --------------------------------------------
 1 file changed, 354 deletions(-)

diff --git a/src/Generics/Deriving/TH.hs b/src/Generics/Deriving/TH.hs
index 783cb65..9aab713 100644
--- a/src/Generics/Deriving/TH.hs
+++ b/src/Generics/Deriving/TH.hs
@@ -19,18 +19,6 @@

 -- Adapted from Generics.Regular.TH
 module Generics.Deriving.TH (
-
-      deriveMeta
-    , deriveData
-    , deriveConstructors
-    , deriveSelectors
-
-#if __GLASGOW_HASKELL__ < 701
-    , deriveAll
-    , deriveRepresentable0
-    , deriveRep0
-    , simplInstance
-#endif
   ) where

 import Generics.Deriving.Base
@@ -41,124 +29,6 @@ import Language.Haskell.TH.Syntax (Lift(..))
 import Data.List (intercalate)
 import Control.Monad

--- | Given the names of a generic class, a type to instantiate, a function in
--- the class and the default implementation, generates the code for a basic
--- generic instance.
-simplInstance :: Name -> Name -> Name -> Name -> Q [Dec]
-simplInstance cl ty fn df = do
-  i <- reify (genRepName 0 ty)
-  x <- newName "x"
-  let typ = ForallT [PlainTV x] []
-        ((foldl (\a -> AppT a . VarT . tyVarBndrToName) (ConT (genRepName 0 ty))
-          (typeVariables i)) `AppT` (VarT x))
-  fmap (: []) $ instanceD (cxt []) (conT cl `appT` conT ty)
-    [funD fn [clause [] (normalB (varE df `appE`
-      (sigE (global 'undefined) (return typ)))) []]]
-
-
--- | Given the type and the name (as string) for the type to derive,
--- generate the 'Data' instance, the 'Constructor' instances, the 'Selector'
--- instances, and the 'Representable0' instance.
-deriveAll :: Name -> Q [Dec]
-deriveAll n =
-  do a <- deriveMeta n
-     b <- deriveRepresentable0 n
-     return (a ++ b)
-
--- | Given the type and the name (as string) for the type to derive,
--- generate the 'Data' instance, the 'Constructor' instances, and the 'Selector'
--- instances.
-deriveMeta :: Name -> Q [Dec]
-deriveMeta n =
-  do a <- deriveData n
-     b <- deriveConstructors n
-     c <- deriveSelectors n
-     return (a ++ b ++ c)
-
--- | Given a datatype name, derive a datatype and instance of class 'Datatype'.
-deriveData :: Name -> Q [Dec]
-deriveData = dataInstance
-
--- | Given a datatype name, derive datatypes and
--- instances of class 'Constructor'.
-deriveConstructors :: Name -> Q [Dec]
-deriveConstructors = constrInstance
-
--- | Given a datatype name, derive datatypes and instances of class 'Selector'.
-deriveSelectors :: Name -> Q [Dec]
-deriveSelectors = selectInstance
-
--- | Given the type and the name (as string) for the Representable0 type
--- synonym to derive, generate the 'Representable0' instance.
-deriveRepresentable0 :: Name -> Q [Dec]
-deriveRepresentable0 n = do
-    rep0 <- deriveRep0 n
-    inst <- deriveInst n
-    return $ rep0 ++ inst
-
--- | Derive only the 'Rep0' type synonym. Not needed if 'deriveRepresentable0'
--- is used.
-deriveRep0 :: Name -> Q [Dec]
-deriveRep0 n = do
-  i <- reify n
-  fmap (:[]) $ tySynD (genRepName 0 n) (typeVariables i) (rep0Type n)
-
-deriveInst :: Name -> Q [Dec]
-deriveInst t = do
-  i <- reify t
-  let typ q = foldl (\a -> AppT a . VarT . tyVarBndrToName) (ConT q)
-                (typeVariables i)
-#if __GLASGOW_HASKELL__ >= 707
-  let tyIns = TySynInstD ''Rep (TySynEqn [typ t] (typ (genRepName 0 t)))
-#else
-  let tyIns = TySynInstD ''Rep [typ t] (typ (genRepName 0 t))
-#endif
-  fcs <- mkFrom t 1 0 t
-  tcs <- mkTo   t 1 0 t
-  liftM (:[]) $
-    instanceD (cxt []) (conT ''Generic `appT` return (typ t))
-                         [return tyIns, funD 'from fcs, funD 'to tcs]
-
-
-dataInstance :: Name -> Q [Dec]
-dataInstance n = do
-  i <- reify n
-  case i of
-    TyConI (DataD    _ n _ _ _) -> mkInstance n
-    TyConI (NewtypeD _ n _ _ _) -> mkInstance n
-    _ -> return []
-  where
-    mkInstance n = do
-      ds <- mkDataData n
-      is <- mkDataInstance n
-      return $ [ds,is]
-
-constrInstance :: Name -> Q [Dec]
-constrInstance n = do
-  i <- reify n
-  case i of
-    TyConI (DataD    _ n _ cs _) -> mkInstance n cs
-    TyConI (NewtypeD _ n _ c  _) -> mkInstance n [c]
-    _ -> return []
-  where
-    mkInstance n cs = do
-      ds <- mapM (mkConstrData n) cs
-      is <- mapM (mkConstrInstance n) cs
-      return $ ds ++ is
-
-selectInstance :: Name -> Q [Dec]
-selectInstance n = do
-  i <- reify n
-  case i of
-    TyConI (DataD    _ n _ cs _) -> mkInstance n cs
-    TyConI (NewtypeD _ n _ c  _) -> mkInstance n [c]
-    _ -> return []
-  where
-    mkInstance n cs = do
-      ds <- mapM (mkSelectData n) cs
-      is <- mapM (mkSelectInstance n) cs
-      return $ concat (ds ++ is)
-
 typeVariables :: Info -> [TyVarBndr]
 typeVariables (TyConI (DataD    _ _ tv _ _)) = tv
 typeVariables (TyConI (NewtypeD _ _ tv _ _)) = tv
@@ -179,233 +49,9 @@ genName = mkName . (++"_") . intercalate "_" . map nameBase
 genRepName :: Int -> Name -> Name
 genRepName n = mkName . (++"_") . (("Rep" ++ show n) ++) . nameBase

-mkDataData :: Name -> Q Dec
-mkDataData n = dataD (cxt []) (genName [n]) [] [] []
-
-mkConstrData :: Name -> Con -> Q Dec
-mkConstrData dt (NormalC n _) =
-  dataD (cxt []) (genName [dt, n]) [] [] []
-mkConstrData dt r@(RecC _ _) =
-  mkConstrData dt (stripRecordNames r)
-mkConstrData dt (InfixC t1 n t2) =
-  mkConstrData dt (NormalC n [t1,t2])
-
-mkSelectData :: Name -> Con -> Q [Dec]
-mkSelectData dt r@(RecC n fs) = return (map one fs)
-  where one (f, _, _) = DataD [] (genName [dt, n, f]) [] [] []
-mkSelectData dt _ = return []
-
-
-mkDataInstance :: Name -> Q Dec
-mkDataInstance n =
-  instanceD (cxt []) (appT (conT ''Datatype) (conT $ genName [n]))
-    [funD 'datatypeName [clause [wildP] (normalB (stringE (nameBase n))) []]
-    ,funD 'moduleName   [clause [wildP] (normalB (stringE name)) []]]
-  where
-    name = maybe (error "Cannot fetch module name!") id (nameModule n)
-
-instance Lift Fixity where
-  lift Prefix      = conE 'Prefix
-  lift (Infix a n) = conE 'Infix `appE` [| a |] `appE` [| n |]
-
-instance Lift Associativity where
-  lift LeftAssociative  = conE 'LeftAssociative
-  lift RightAssociative = conE 'RightAssociative
-  lift NotAssociative   = conE 'NotAssociative
-
-mkConstrInstance :: Name -> Con -> Q Dec
-mkConstrInstance dt (NormalC n _) = mkConstrInstanceWith dt n []
-mkConstrInstance dt (RecC    n _) = mkConstrInstanceWith dt n
-      [ funD 'conIsRecord [clause [wildP] (normalB (conE 'True)) []]]
-mkConstrInstance dt (InfixC t1 n t2) =
-    do
-      i <- reify n
-      let fi = case i of
-                 DataConI _ _ _ f -> convertFixity f
-                 _ -> Prefix
-      instanceD (cxt []) (appT (conT ''Constructor) (conT $ genName [dt, n]))
-        [funD 'conName   [clause [wildP] (normalB (stringE (nameBase n))) []],
-         funD 'conFixity [clause [wildP] (normalB [| fi |]) []]]
-  where
-    convertFixity (Fixity n d) = Infix (convertDirection d) n
-    convertDirection InfixL = LeftAssociative
-    convertDirection InfixR = RightAssociative
-    convertDirection InfixN = NotAssociative
-
-mkConstrInstanceWith :: Name -> Name -> [Q Dec] -> Q Dec
-mkConstrInstanceWith dt n extra =
-  instanceD (cxt []) (appT (conT ''Constructor) (conT $ genName [dt, n]))
-    (funD 'conName [clause [wildP] (normalB (stringE (nameBase n))) []] : extra)
-
-mkSelectInstance :: Name -> Con -> Q [Dec]
-mkSelectInstance dt r@(RecC n fs) = return (map one fs) where
-  one (f, _, _) =
-    InstanceD ([]) (AppT (ConT ''Selector) (ConT $ genName [dt, n, f]))
-      [FunD 'selName [Clause [WildP]
-        (NormalB (LitE (StringL (nameBase f)))) []]]
-mkSelectInstance _ _ = return []
-
-rep0Type :: Name -> Q Type
-rep0Type n =
-    do
-      -- runIO $ putStrLn $ "processing " ++ show n
-      i <- reify n
-      let b = case i of
-                TyConI (DataD _ dt vs cs _) ->
-                  (conT ''D1) `appT` (conT $ genName [dt]) `appT`
-                    (foldr1' sum (conT ''V1)
-                      (map (rep0Con (dt, map tyVarBndrToName vs)) cs))
-                TyConI (NewtypeD _ dt vs c _) ->
-                  (conT ''D1) `appT` (conT $ genName [dt]) `appT`
-                    (rep0Con (dt, map tyVarBndrToName vs) c)
-                TyConI (TySynD t _ _) -> error "type synonym?"
-                _ -> error "unknown construct"
-      --appT b (conT $ mkName (nameBase n))
-      b where
-    sum :: Q Type -> Q Type -> Q Type
-    sum a b = conT ''(:+:) `appT` a `appT` b
-
-
-rep0Con :: (Name, [Name]) -> Con -> Q Type
-rep0Con (dt, vs) (NormalC n []) =
-    conT ''C1 `appT` (conT $ genName [dt, n]) `appT`
-     (conT ''S1 `appT` conT ''NoSelector `appT` conT ''U1)
-rep0Con (dt, vs) (NormalC n fs) =
-    conT ''C1 `appT` (conT $ genName [dt, n]) `appT`
-     (foldr1 prod (map (repField (dt, vs) . snd) fs)) where
-    prod :: Q Type -> Q Type -> Q Type
-    prod a b = conT ''(:*:) `appT` a `appT` b
-rep0Con (dt, vs) r@(RecC n []) =
-    conT ''C1 `appT` (conT $ genName [dt, n]) `appT` conT ''U1
-rep0Con (dt, vs) r@(RecC n fs) =
-    conT ''C1 `appT` (conT $ genName [dt, n]) `appT`
-      (foldr1 prod (map (repField' (dt, vs) n) fs)) where
-    prod :: Q Type -> Q Type -> Q Type
-    prod a b = conT ''(:*:) `appT` a `appT` b
-
-rep0Con d (InfixC t1 n t2) = rep0Con d (NormalC n [t1,t2])
-
---dataDeclToType :: (Name, [Name]) -> Type
---dataDeclToType (dt, vs) = foldl (\a b -> AppT a (VarT b)) (ConT dt) vs
-
-repField :: (Name, [Name]) -> Type -> Q Type
---repField d t | t == dataDeclToType d = conT ''I
-repField d t = conT ''S1 `appT` conT ''NoSelector `appT`
-                 (conT ''Rec0 `appT` return t)
-
-repField' :: (Name, [Name]) -> Name -> (Name, Strict, Type) -> Q Type
---repField' d ns (_, _, t) | t == dataDeclToType d = conT ''I
-repField' (dt, vs) ns (f, _, t) = conT ''S1 `appT` conT (genName [dt, ns, f])
-                                    `appT` (conT ''Rec0 `appT` return t)
--- Note: we should generate Par0 too, at some point
-
-
-mkFrom :: Name -> Int -> Int -> Name -> Q [Q Clause]
-mkFrom ns m i n =
-    do
-      -- runIO $ putStrLn $ "processing " ++ show n
-      let wrapE e = lrE m i e
-      i <- reify n
-      let b = case i of
-                TyConI (DataD _ dt vs cs _) ->
-                  zipWith (fromCon wrapE ns (dt, map tyVarBndrToName vs)
-                    (length cs)) [0..] cs
-                TyConI (NewtypeD _ dt vs c _) ->
-                  [fromCon wrapE ns (dt, map tyVarBndrToName vs) 1 0 c]
-                TyConI (TySynD t _ _) -> error "type synonym?"
-                  -- [clause [varP (field 0)] (normalB (wrapE $ conE 'K1 `appE` varE (field 0))) []]
-                _ -> error "unknown construct"
-      return b
-
-mkTo :: Name -> Int -> Int -> Name -> Q [Q Clause]
-mkTo ns m i n =
-    do
-      -- runIO $ putStrLn $ "processing " ++ show n
-      let wrapP p = lrP m i p
-      i <- reify n
-      let b = case i of
-                TyConI (DataD _ dt vs cs _) ->
-                  zipWith (toCon wrapP ns (dt, map tyVarBndrToName vs)
-                    (length cs)) [0..] cs
-                TyConI (NewtypeD _ dt vs c _) ->
-                  [toCon wrapP ns (dt, map tyVarBndrToName vs) 1 0 c]
-                TyConI (TySynD t _ _) -> error "type synonym?"
-                  -- [clause [wrapP $ conP 'K1 [varP (field 0)]] (normalB $ varE (field 0)) []]
-                _ -> error "unknown construct"
-      return b
-
-fromCon :: (Q Exp -> Q Exp) -> Name -> (Name, [Name]) -> Int -> Int -> Con -> Q Clause
-fromCon wrap ns (dt, vs) m i (NormalC cn []) =
-  clause
-    [conP cn []]
-    (normalB $ appE (conE 'M1) $ wrap $ lrE m i $ appE (conE 'M1) $
-      conE 'M1 `appE` (conE 'U1)) []
-fromCon wrap ns (dt, vs) m i (NormalC cn fs) =
-  -- runIO (putStrLn ("constructor " ++ show ix)) >>
-  clause
-    [conP cn (map (varP . field) [0..length fs - 1])]
-    (normalB $ appE (conE 'M1) $ wrap $ lrE m i $ conE 'M1 `appE`
-      foldr1 prod (zipWith (fromField (dt, vs)) [0..] (map snd fs))) []
-  where prod x y = conE '(:*:) `appE` x `appE` y
-fromCon wrap ns (dt, vs) m i r@(RecC cn []) =
-  clause
-    [conP cn []]
-    (normalB $ appE (conE 'M1) $ wrap $ lrE m i $ conE 'M1 `appE` (conE 'U1)) []
-fromCon wrap ns (dt, vs) m i r@(RecC cn fs) =
-  clause
-    [conP cn (map (varP . field) [0..length fs - 1])]
-    (normalB $ appE (conE 'M1) $ wrap $ lrE m i $ conE 'M1 `appE`
-      foldr1 prod (zipWith (fromField (dt, vs)) [0..] (map trd fs))) []
-  where prod x y = conE '(:*:) `appE` x `appE` y
-fromCon wrap ns (dt, vs) m i (InfixC t1 cn t2) =
-  fromCon wrap ns (dt, vs) m i (NormalC cn [t1,t2])
-
-fromField :: (Name, [Name]) -> Int -> Type -> Q Exp
---fromField (dt, vs) nr t | t == dataDeclToType (dt, vs) = conE 'I `appE` varE (field nr)
-fromField (dt, vs) nr t = conE 'M1 `appE` (conE 'K1 `appE` varE (field nr))
-
-toCon :: (Q Pat -> Q Pat) -> Name -> (Name, [Name]) -> Int -> Int -> Con -> Q Clause
-toCon wrap ns (dt, vs) m i (NormalC cn []) =
-    clause
-      [wrap $ conP 'M1 [lrP m i $ conP 'M1 [conP 'M1 [conP 'U1 []]]]]
-      (normalB $ conE cn) []
-toCon wrap ns (dt, vs) m i (NormalC cn fs) =
-    -- runIO (putStrLn ("constructor " ++ show ix)) >>
-    clause
-      [wrap $ conP 'M1 [lrP m i $ conP 'M1
-        [foldr1 prod (zipWith (toField (dt, vs)) [0..] (map snd fs))]]]
-      (normalB $ foldl appE (conE cn) (map (varE . field) [0..length fs - 1])) []
-  where prod x y = conP '(:*:) [x,y]
-toCon wrap ns (dt, vs) m i r@(RecC cn []) =
-    clause
-      [wrap $ conP 'M1 [lrP m i $ conP 'M1 [conP 'U1 []]]]
-      (normalB $ conE cn) []
-toCon wrap ns (dt, vs) m i r@(RecC cn fs) =
-    clause
-      [wrap $ conP 'M1 [lrP m i $ conP 'M1
-        [foldr1 prod (zipWith (toField (dt, vs)) [0..] (map trd fs))]]]
-      (normalB $ foldl appE (conE cn) (map (varE . field) [0..length fs - 1])) []
-  where prod x y = conP '(:*:) [x,y]
-toCon wrap ns (dt, vs) m i (InfixC t1 cn t2) =
-  toCon wrap ns (dt, vs) m i (NormalC cn [t1,t2])
-
-toField :: (Name, [Name]) -> Int -> Type -> Q Pat
---toField (dt, vs) nr t | t == dataDeclToType (dt, vs) = conP 'I [varP (field nr)]
-toField (dt, vs) nr t = conP 'M1 [conP 'K1 [varP (field nr)]]
-
-
 field :: Int -> Name
 field n = mkName $ "f" ++ show n

-lrP :: Int -> Int -> (Q Pat -> Q Pat)
-lrP 1 0 p = p
-lrP m 0 p = conP 'L1 [p]
-lrP m i p = conP 'R1 [lrP (m-1) (i-1) p]
-
-lrE :: Int -> Int -> (Q Exp -> Q Exp)
-lrE 1 0 e = e
-lrE m 0 e = conE 'L1 `appE` e
-lrE m i e = conE 'R1 `appE` lrE (m-1) (i-1) e

 trd (_,_,c) = c

--
1.8.5.1


code:
From bc312c7431877b3b788de5e7ce5ee743be73c0ba Mon Sep 17 00:00:00 2001
From: dummy <dummy@example.com>
Date: Tue, 10 Jun 2014 22:13:58 +0000
Subject: [PATCH] remove TH

---
 lens.cabal                          | 19 +------------------
 src/Control/Lens.hs                 |  8 ++------
 src/Control/Lens/Cons.hs            |  2 --
 src/Control/Lens/Internal/Fold.hs   |  2 --
 src/Control/Lens/Operators.hs       |  2 +-
 src/Control/Lens/Prism.hs           |  2 --
 src/Control/Monad/Primitive/Lens.hs |  1 -
 7 files changed, 4 insertions(+), 32 deletions(-)

diff --git a/lens.cabal b/lens.cabal
index d70c2f4..28af768 100644
--- a/lens.cabal
+++ b/lens.cabal
@@ -10,7 +10,7 @@ stability:     provisional
 homepage:      http://github.com/ekmett/lens/
 bug-reports:   http://github.com/ekmett/lens/issues
 copyright:     Copyright (C) 2012-2014 Edward A. Kmett
-build-type:    Custom
+build-type:    Simple
 -- build-tools:   cpphs
 tested-with:   GHC == 7.4.1, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.1, GHC == 7.8.2
 synopsis:      Lenses, Folds and Traversals
@@ -220,7 +220,6 @@ library
     Control.Exception.Lens
     Control.Lens
     Control.Lens.Action
-    Control.Lens.At
     Control.Lens.Combinators
     Control.Lens.Cons
     Control.Lens.Each
@@ -248,29 +247,24 @@ library
     Control.Lens.Internal.Reflection
     Control.Lens.Internal.Review
     Control.Lens.Internal.Setter
-    Control.Lens.Internal.TH
     Control.Lens.Internal.Zoom
     Control.Lens.Iso
     Control.Lens.Lens
     Control.Lens.Level
     Control.Lens.Loupe
     Control.Lens.Operators
-    Control.Lens.Plated
     Control.Lens.Prism
     Control.Lens.Reified
     Control.Lens.Review
     Control.Lens.Setter
-    Control.Lens.TH
     Control.Lens.Traversal
     Control.Lens.Tuple
     Control.Lens.Type
     Control.Lens.Wrapped
     Control.Lens.Zoom
-    Control.Monad.Error.Lens
     Control.Monad.Primitive.Lens
     Control.Parallel.Strategies.Lens
     Control.Seq.Lens
-    Data.Aeson.Lens
     Data.Array.Lens
     Data.Bits.Lens
     Data.ByteString.Lens
@@ -293,17 +287,10 @@ library
     Data.Typeable.Lens
     Data.Vector.Lens
     Data.Vector.Generic.Lens
-    Generics.Deriving.Lens
-    GHC.Generics.Lens
     System.Exit.Lens
     System.FilePath.Lens
-    System.IO.Error.Lens
-    Language.Haskell.TH.Lens
     Numeric.Lens

-  other-modules:
-    Control.Lens.Internal.TupleIxedTH
-
   cpp-options: -traditional

   if flag(safe)
@@ -405,7 +392,6 @@ test-suite doctests
       deepseq,
       doctest        >= 0.9.1,
       filepath,
-      generic-deriving,
       mtl,
       nats,
       parallel,
@@ -443,7 +429,6 @@ benchmark plated
     comonad,
     criterion,
     deepseq,
-    generic-deriving,
     lens,
     transformers

@@ -478,7 +463,6 @@ benchmark unsafe
     comonads-fd,
     criterion,
     deepseq,
-    generic-deriving,
     lens,
     transformers

@@ -495,6 +479,5 @@ benchmark zipper
     comonads-fd,
     criterion,
     deepseq,
-    generic-deriving,
     lens,
     transformers
diff --git a/src/Control/Lens.hs b/src/Control/Lens.hs
index 7e15267..433f1fc 100644
--- a/src/Control/Lens.hs
+++ b/src/Control/Lens.hs
@@ -41,7 +41,6 @@
 ----------------------------------------------------------------------------
 module Control.Lens
   ( module Control.Lens.Action
-  , module Control.Lens.At
   , module Control.Lens.Cons
   , module Control.Lens.Each
   , module Control.Lens.Empty
@@ -53,12 +52,11 @@ module Control.Lens
   , module Control.Lens.Lens
   , module Control.Lens.Level
   , module Control.Lens.Loupe
-  , module Control.Lens.Plated
   , module Control.Lens.Prism
   , module Control.Lens.Reified
   , module Control.Lens.Review
   , module Control.Lens.Setter
-#ifndef DISABLE_TEMPLATE_HASKELL
+#if 0
   , module Control.Lens.TH
 #endif
   , module Control.Lens.Traversal
@@ -69,7 +67,6 @@ module Control.Lens
   ) where

 import Control.Lens.Action
-import Control.Lens.At
 import Control.Lens.Cons
 import Control.Lens.Each
 import Control.Lens.Empty
@@ -81,12 +78,11 @@ import Control.Lens.Iso
 import Control.Lens.Lens
 import Control.Lens.Level
 import Control.Lens.Loupe
-import Control.Lens.Plated
 import Control.Lens.Prism
 import Control.Lens.Reified
 import Control.Lens.Review
 import Control.Lens.Setter
-#ifndef DISABLE_TEMPLATE_HASKELL
+#if 0
 import Control.Lens.TH
 #endif
 import Control.Lens.Traversal
diff --git a/src/Control/Lens/Cons.hs b/src/Control/Lens/Cons.hs
index a80e9c8..7d27b80 100644
--- a/src/Control/Lens/Cons.hs
+++ b/src/Control/Lens/Cons.hs
@@ -55,8 +55,6 @@ import           Data.Vector.Unboxed (Unbox)
 import qualified Data.Vector.Unboxed as Unbox
 import           Data.Word

-{-# ANN module "HLint: ignore Eta reduce" #-}
-
 -- $setup
 -- >>> :set -XNoOverloadedStrings
 -- >>> import Control.Lens
diff --git a/src/Control/Lens/Internal/Fold.hs b/src/Control/Lens/Internal/Fold.hs
index ab09c6b..43aa905 100644
--- a/src/Control/Lens/Internal/Fold.hs
+++ b/src/Control/Lens/Internal/Fold.hs
@@ -37,8 +37,6 @@ import Data.Maybe
 import Data.Semigroup hiding (Min, getMin, Max, getMax)
 import Data.Reflection

-{-# ANN module "HLint: ignore Avoid lambda" #-}
-
 ------------------------------------------------------------------------------
 -- Folding
 ------------------------------------------------------------------------------
diff --git a/src/Control/Lens/Operators.hs b/src/Control/Lens/Operators.hs
index 9992e63..631e8e6 100644
--- a/src/Control/Lens/Operators.hs
+++ b/src/Control/Lens/Operators.hs
@@ -111,7 +111,7 @@ module Control.Lens.Operators
   , (<#~)
   , (<#=)
   -- * "Control.Lens.Plated"
-  , (...)
+  --, (...)
   -- * "Control.Lens.Review"
   , ( # )
   -- * "Control.Lens.Setter"
diff --git a/src/Control/Lens/Prism.hs b/src/Control/Lens/Prism.hs
index 9e0bec7..0cf6737 100644
--- a/src/Control/Lens/Prism.hs
+++ b/src/Control/Lens/Prism.hs
@@ -59,8 +59,6 @@ import Unsafe.Coerce
 import Data.Profunctor.Unsafe
 #endif

-{-# ANN module "HLint: ignore Use camelCase" #-}
-
 -- $setup
 -- >>> :set -XNoOverloadedStrings
 -- >>> import Control.Lens
diff --git a/src/Control/Monad/Primitive/Lens.hs b/src/Control/Monad/Primitive/Lens.hs
index ee942c6..2f37134 100644
--- a/src/Control/Monad/Primitive/Lens.hs
+++ b/src/Control/Monad/Primitive/Lens.hs
@@ -20,7 +20,6 @@ import Control.Lens
 import Control.Monad.Primitive (PrimMonad(..))
 import GHC.Prim (State#)

-{-# ANN module "HLint: ignore Unused LANGUAGE pragma" #-}

 prim :: (PrimMonad m) => Iso' (m a) (State# (PrimState m) -> (# State# (PrimState m), a #))
 prim = iso internal primitive
--
2.0.0