--- /dev/null
+diff -u -r ../upstream.git/apt-pkg/contrib/fileutl.cc ./apt-pkg/contrib/fileutl.cc
+--- ../upstream.git/apt-pkg/contrib/fileutl.cc 2014-05-05 14:01:59.000000000 +0200
++++ ./apt-pkg/contrib/fileutl.cc 2014-06-06 00:09:17.233239376 +0200
+@@ -46,7 +46,9 @@
+ #include <dirent.h>
+ #include <signal.h>
+ #include <errno.h>
++#ifndef __ANDROID__
+ #include <glob.h>
++#endif
+
+ #include <set>
+ #include <algorithm>
+@@ -93,7 +95,7 @@
+ _exit(100);
+ }
+
+- if (chdir("/tmp/") != 0)
++ if (chdir("@TERMUX_PREFIX@/tmp/") != 0)
+ _exit(100);
+
+ unsigned int Count = 1;
+@@ -1883,7 +1885,11 @@
+ FileFdErrno("read","Unable to read original size of gzipped file");
+ return 0;
+ }
++#ifdef __ANDROID__
++ size = letoh32(size);
++#else
+ size = le32toh(size);
++#endif
+
+ if (lseek(iFd, oldPos, SEEK_SET) < 0)
+ {
+@@ -1998,6 +2004,7 @@
+ std::vector<std::string> Glob(std::string const &pattern, int flags)
+ {
+ std::vector<std::string> result;
++#ifndef __ANDROID__
+ glob_t globbuf;
+ int glob_res;
+ unsigned int i;
+@@ -2017,6 +2024,7 @@
+ result.push_back(string(globbuf.gl_pathv[i]));
+
+ globfree(&globbuf);
++#endif
+ return result;
+ }
+ /*}}}*/
+@@ -2025,15 +2033,10 @@
+ {
+ const char *tmpdir = getenv("TMPDIR");
+
+-#ifdef P_tmpdir
+- if (!tmpdir)
+- tmpdir = P_tmpdir;
+-#endif
+-
+ // check that tmpdir is set and exists
+ struct stat st;
+ if (!tmpdir || strlen(tmpdir) == 0 || stat(tmpdir, &st) != 0)
+- tmpdir = "/tmp";
++ tmpdir = "@TERMUX_PREFIX@/tmp";
+
+ return string(tmpdir);
+ }