From ab159e1f173b3441248eb925e82e338fa7c2aa0c Mon Sep 17 00:00:00 2001 From: Leonid Plyushch Date: Fri, 15 Sep 2017 15:00:09 +0300 Subject: [PATCH] python2: fix hardcoded paths --- packages/python2/build.sh | 1 + packages/python2/fix-paths.patch | 60 ++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 packages/python2/fix-paths.patch diff --git a/packages/python2/build.sh b/packages/python2/build.sh index afb2e2b14..142a8895b 100644 --- a/packages/python2/build.sh +++ b/packages/python2/build.sh @@ -9,6 +9,7 @@ TERMUX_PKG_HOSTBUILD=true _MAJOR_VERSION=2.7 TERMUX_PKG_VERSION=${_MAJOR_VERSION}.13 +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${TERMUX_PKG_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz TERMUX_PKG_SHA256=35d543986882f78261f97787fd3e06274bfa6df29fac9b4a94f73930ff98f731 diff --git a/packages/python2/fix-paths.patch b/packages/python2/fix-paths.patch new file mode 100644 index 000000000..0c813044c --- /dev/null +++ b/packages/python2/fix-paths.patch @@ -0,0 +1,60 @@ +diff -uNr Python-2.7.13/Lib/aifc.py Python-2.7.13.mod/Lib/aifc.py +--- Python-2.7.13/Lib/aifc.py 2016-12-17 22:05:05.000000000 +0200 ++++ Python-2.7.13.mod/Lib/aifc.py 2017-09-15 14:39:33.972798330 +0300 +@@ -960,7 +960,7 @@ + if __name__ == '__main__': + import sys + if not sys.argv[1:]: +- sys.argv.append('/usr/demos/data/audio/bach.aiff') ++ sys.argv.append('@TERMUX_PREFIX@/demos/data/audio/bach.aiff') + fn = sys.argv[1] + f = open(fn, 'r') + try: +diff -uNr Python-2.7.13/Lib/mailcap.py Python-2.7.13.mod/Lib/mailcap.py +--- Python-2.7.13/Lib/mailcap.py 2016-12-17 22:05:06.000000000 +0200 ++++ Python-2.7.13.mod/Lib/mailcap.py 2017-09-15 14:48:24.432797951 +0300 +@@ -44,7 +44,8 @@ + # Don't bother with getpwuid() + home = '.' # Last resort + mailcaps = [home + '/.mailcap', '/etc/mailcap', +- '/usr/etc/mailcap', '/usr/local/etc/mailcap'] ++ '/usr/etc/mailcap', '/usr/local/etc/mailcap', ++ '@TERMUX_PREFIX@/etc/mailcap'] + return mailcaps + + +diff -uNr Python-2.7.13/Lib/mimetypes.py Python-2.7.13.mod/Lib/mimetypes.py +--- Python-2.7.13/Lib/mimetypes.py 2016-12-17 22:05:06.000000000 +0200 ++++ Python-2.7.13.mod/Lib/mimetypes.py 2017-09-15 14:22:15.642799073 +0300 +@@ -47,6 +47,7 @@ + "/usr/local/lib/netscape/mime.types", + "/usr/local/etc/httpd/conf/mime.types", # Apache 1.2 + "/usr/local/etc/mime.types", # Apache 1.3 ++ "@TERMUX_PREFIX@/etc/mime.types", # Termux + ] + + inited = False +diff -uNr Python-2.7.13/Lib/posixpath.py Python-2.7.13.mod/Lib/posixpath.py +--- Python-2.7.13/Lib/posixpath.py 2016-12-17 22:05:06.000000000 +0200 ++++ Python-2.7.13.mod/Lib/posixpath.py 2017-09-15 14:47:13.762798002 +0300 +@@ -32,7 +32,7 @@ + extsep = '.' + sep = '/' + pathsep = ':' +-defpath = ':/bin:/usr/bin' ++defpath = ':@TERMUX_PREFIX@/bin:@TERMUX_PREFIX@/bin/applets' + altsep = None + devnull = '/dev/null' + +diff -uNr Python-2.7.13/Lib/uuid.py Python-2.7.13.mod/Lib/uuid.py +--- Python-2.7.13/Lib/uuid.py 2016-12-17 22:05:06.000000000 +0200 ++++ Python-2.7.13.mod/Lib/uuid.py 2017-09-15 14:46:19.442798040 +0300 +@@ -296,7 +296,7 @@ + def _popen(command, args): + import os + path = os.environ.get("PATH", os.defpath).split(os.pathsep) +- path.extend(('/sbin', '/usr/sbin')) ++ path.extend(('@TERMUX_PREFIX@/bin', '@TERMUX_PREFIX@/bin/applets')) + for dir in path: + executable = os.path.join(dir, command) + if (os.path.exists(executable) and