From c6f89a7b49e40e0a6c40d1c924f15f447006c5ba Mon Sep 17 00:00:00 2001 From: Leonid Plyushch Date: Fri, 15 Sep 2017 15:13:01 +0300 Subject: [PATCH] python: fix hardcoded paths --- packages/python/build.sh | 2 +- packages/python/fix-paths.patch | 60 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 packages/python/fix-paths.patch diff --git a/packages/python/build.sh b/packages/python/build.sh index 318e5afe..9f7cbbc4 100644 --- a/packages/python/build.sh +++ b/packages/python/build.sh @@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Python 3 programming language intended to enable clear p TERMUX_PKG_DEPENDS="libandroid-support, ncurses, readline, libffi, openssl, libutil, libbz2, libsqlite, gdbm, ncurses-ui-libs, libcrypt, liblzma" _MAJOR_VERSION=3.6 TERMUX_PKG_VERSION=${_MAJOR_VERSION}.2 -TERMUX_PKG_REVISION=1 +TERMUX_PKG_REVISION=2 TERMUX_PKG_SHA256=9229773be41ed144370f47f0f626a1579931f5a390f1e8e3853174d52edd64a9 TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${TERMUX_PKG_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz diff --git a/packages/python/fix-paths.patch b/packages/python/fix-paths.patch new file mode 100644 index 00000000..20a0f67b --- /dev/null +++ b/packages/python/fix-paths.patch @@ -0,0 +1,60 @@ +diff -uNr Python-3.6.2/Lib/aifc.py Python-3.6.2.mod/Lib/aifc.py +--- Python-3.6.2/Lib/aifc.py 2017-07-08 06:33:27.000000000 +0300 ++++ Python-3.6.2.mod/Lib/aifc.py 2017-09-15 15:09:08.092797061 +0300 +@@ -920,7 +920,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] + with open(fn, 'r') as f: + print("Reading", fn) +diff -uNr Python-3.6.2/Lib/mailcap.py Python-3.6.2.mod/Lib/mailcap.py +--- Python-3.6.2/Lib/mailcap.py 2017-07-08 06:33:27.000000000 +0300 ++++ Python-3.6.2.mod/Lib/mailcap.py 2017-09-15 15:08:41.312797081 +0300 +@@ -55,7 +55,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-3.6.2/Lib/mimetypes.py Python-3.6.2.mod/Lib/mimetypes.py +--- Python-3.6.2/Lib/mimetypes.py 2017-07-08 06:33:27.000000000 +0300 ++++ Python-3.6.2.mod/Lib/mimetypes.py 2017-09-15 15:08:05.522797106 +0300 +@@ -49,6 +49,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-3.6.2/Lib/posixpath.py Python-3.6.2.mod/Lib/posixpath.py +--- Python-3.6.2/Lib/posixpath.py 2017-07-08 06:33:27.000000000 +0300 ++++ Python-3.6.2.mod/Lib/posixpath.py 2017-09-15 15:07:20.872797138 +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-3.6.2/Lib/uuid.py Python-3.6.2.mod/Lib/uuid.py +--- Python-3.6.2/Lib/uuid.py 2017-07-08 06:33:27.000000000 +0300 ++++ Python-3.6.2.mod/Lib/uuid.py 2017-09-15 15:06:36.372797170 +0300 +@@ -306,7 +306,7 @@ + import os, shutil, subprocess + executable = shutil.which(command) + if executable is None: +- path = os.pathsep.join(('/sbin', '/usr/sbin')) ++ path = os.pathsep.join(('@TERMUX_PREFIX@/bin', '@TERMUX_PREFIX@/bin/applets')) + executable = shutil.which(command, path=path) + if executable is None: + return None -- 2.11.0