Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ cat python:2.7/musl-find_library.patch
- diff -ru Python-2.7.12.orig/Lib/ctypes/util.py Python-2.7.12/Lib/ctypes/util.py
- --- Python-2.7.12.orig/Lib/ctypes/util.py 2016-06-26 00:49:30.000000000 +0300
- +++ Python-2.7.12/Lib/ctypes/util.py 2016-11-03 16:05:46.954665040 +0200
- @@ -204,6 +204,41 @@
- def find_library(name, is64 = False):
- return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name))
- + elif True:
- +
- + # Patched for Alpine Linux / musl - search manually system paths
- + def _is_elf(filepath):
- + try:
- + with open(filepath, 'rb') as fh:
- + return fh.read(4) == b'\x7fELF'
- + except:
- + return False
- +
- + def find_library(name):
- + from glob import glob
- + # absolute name?
- + if os.path.isabs(name):
- + return name
- + # special case for libm, libcrypt and libpthread and musl
- + if name in ['m', 'crypt', 'pthread']:
- + name = 'c'
- + elif name in ['libm.so', 'libcrypt.so', 'libpthread.so']:
- + name = 'libc.so'
- + # search in standard locations (musl order)
- + paths = ['/lib', '/usr/local/lib', '/usr/lib']
- + if 'LD_LIBRARY_PATH' in os.environ:
- + paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths
- + for d in paths:
- + f = os.path.join(d, name)
- + if _is_elf(f):
- + return os.path.basename(f)
- +
- + prefix = os.path.join(d, 'lib'+name)
- + for suffix in ['.so', '.so.*']:
- + for f in glob('{0}{1}'.format(prefix, suffix)):
- + if _is_elf(f):
- + return os.path.basename(f)
- +
- else:
- def _findSoname_ldconfig(name):
- $ cat python:2.7/unchecked-ioctl.patch
- --- ./Modules/fcntlmodule.c.orig
- +++ ./Modules/fcntlmodule.c
- @@ -118,7 +118,7 @@
- int mutate_arg = 1;
- char buf[IOCTL_BUFSZ+1]; /* argument plus NUL byte */
- - if (PyArg_ParseTuple(args, "O&Iw#|i:ioctl",
- + if (PyArg_ParseTuple(args, "O&Iw#|n:ioctl",
- conv_descriptor, &fd, &code,
- &str, &len, &mutate_arg)) {
- char *arg;
- $ cat python:3.4/fix-xattrs-glibc.patch
- diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
- index 8f8ba25..72b92da 100644
- --- a/Modules/posixmodule.c
- +++ b/Modules/posixmodule.c
- @@ -103,8 +103,9 @@ corresponding Unix manual entries for more information on calls.");
- #undef HAVE_SCHED_SETAFFINITY
- #endif
- -#if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
- +#if defined(HAVE_SYS_XATTR_H) && defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
- #define USE_XATTRS
- +#include <linux/limits.h>
- #endif
- #ifdef USE_XATTRS
- $ cat python:3.4/musl-find_library.patch
- diff -ru Python-2.7.12.orig/Lib/ctypes/util.py Python-2.7.12/Lib/ctypes/util.py
- --- Python-2.7.12.orig/Lib/ctypes/util.py 2016-06-26 00:49:30.000000000 +0300
- +++ Python-2.7.12/Lib/ctypes/util.py 2016-11-03 16:05:46.954665040 +0200
- @@ -204,6 +204,41 @@
- def find_library(name, is64 = False):
- return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name))
- + elif True:
- +
- + # Patched for Alpine Linux / musl - search manually system paths
- + def _is_elf(filepath):
- + try:
- + with open(filepath, 'rb') as fh:
- + return fh.read(4) == b'\x7fELF'
- + except:
- + return False
- +
- + def find_library(name):
- + from glob import glob
- + # absolute name?
- + if os.path.isabs(name):
- + return name
- + # special case for libm, libcrypt and libpthread and musl
- + if name in ['m', 'crypt', 'pthread']:
- + name = 'c'
- + elif name in ['libm.so', 'libcrypt.so', 'libpthread.so']:
- + name = 'libc.so'
- + # search in standard locations (musl order)
- + paths = ['/lib', '/usr/local/lib', '/usr/lib']
- + if 'LD_LIBRARY_PATH' in os.environ:
- + paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths
- + for d in paths:
- + f = os.path.join(d, name)
- + if _is_elf(f):
- + return os.path.basename(f)
- +
- + prefix = os.path.join(d, 'lib'+name)
- + for suffix in ['.so', '.so.*']:
- + for f in glob('{0}{1}'.format(prefix, suffix)):
- + if _is_elf(f):
- + return os.path.basename(f)
- +
- else:
- def _findSoname_ldconfig(name):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement