Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.64 KB | None | 0 0
  1. $ cat python:2.7/musl-find_library.patch
  2. diff -ru Python-2.7.12.orig/Lib/ctypes/util.py Python-2.7.12/Lib/ctypes/util.py
  3. --- Python-2.7.12.orig/Lib/ctypes/util.py 2016-06-26 00:49:30.000000000 +0300
  4. +++ Python-2.7.12/Lib/ctypes/util.py 2016-11-03 16:05:46.954665040 +0200
  5. @@ -204,6 +204,41 @@
  6. def find_library(name, is64 = False):
  7. return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name))
  8.  
  9. + elif True:
  10. +
  11. + # Patched for Alpine Linux / musl - search manually system paths
  12. + def _is_elf(filepath):
  13. + try:
  14. + with open(filepath, 'rb') as fh:
  15. + return fh.read(4) == b'\x7fELF'
  16. + except:
  17. + return False
  18. +
  19. + def find_library(name):
  20. + from glob import glob
  21. + # absolute name?
  22. + if os.path.isabs(name):
  23. + return name
  24. + # special case for libm, libcrypt and libpthread and musl
  25. + if name in ['m', 'crypt', 'pthread']:
  26. + name = 'c'
  27. + elif name in ['libm.so', 'libcrypt.so', 'libpthread.so']:
  28. + name = 'libc.so'
  29. + # search in standard locations (musl order)
  30. + paths = ['/lib', '/usr/local/lib', '/usr/lib']
  31. + if 'LD_LIBRARY_PATH' in os.environ:
  32. + paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths
  33. + for d in paths:
  34. + f = os.path.join(d, name)
  35. + if _is_elf(f):
  36. + return os.path.basename(f)
  37. +
  38. + prefix = os.path.join(d, 'lib'+name)
  39. + for suffix in ['.so', '.so.*']:
  40. + for f in glob('{0}{1}'.format(prefix, suffix)):
  41. + if _is_elf(f):
  42. + return os.path.basename(f)
  43. +
  44. else:
  45.  
  46. def _findSoname_ldconfig(name):
  47.  
  48. $ cat python:2.7/unchecked-ioctl.patch
  49. --- ./Modules/fcntlmodule.c.orig
  50. +++ ./Modules/fcntlmodule.c
  51. @@ -118,7 +118,7 @@
  52. int mutate_arg = 1;
  53. char buf[IOCTL_BUFSZ+1]; /* argument plus NUL byte */
  54.  
  55. - if (PyArg_ParseTuple(args, "O&Iw#|i:ioctl",
  56. + if (PyArg_ParseTuple(args, "O&Iw#|n:ioctl",
  57. conv_descriptor, &fd, &code,
  58. &str, &len, &mutate_arg)) {
  59. char *arg;
  60.  
  61. $ cat python:3.4/fix-xattrs-glibc.patch
  62. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
  63. index 8f8ba25..72b92da 100644
  64. --- a/Modules/posixmodule.c
  65. +++ b/Modules/posixmodule.c
  66. @@ -103,8 +103,9 @@ corresponding Unix manual entries for more information on calls.");
  67. #undef HAVE_SCHED_SETAFFINITY
  68. #endif
  69.  
  70. -#if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
  71. +#if defined(HAVE_SYS_XATTR_H) && defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
  72. #define USE_XATTRS
  73. +#include <linux/limits.h>
  74. #endif
  75.  
  76. #ifdef USE_XATTRS
  77.  
  78. $ cat python:3.4/musl-find_library.patch
  79. diff -ru Python-2.7.12.orig/Lib/ctypes/util.py Python-2.7.12/Lib/ctypes/util.py
  80. --- Python-2.7.12.orig/Lib/ctypes/util.py 2016-06-26 00:49:30.000000000 +0300
  81. +++ Python-2.7.12/Lib/ctypes/util.py 2016-11-03 16:05:46.954665040 +0200
  82. @@ -204,6 +204,41 @@
  83. def find_library(name, is64 = False):
  84. return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name))
  85.  
  86. + elif True:
  87. +
  88. + # Patched for Alpine Linux / musl - search manually system paths
  89. + def _is_elf(filepath):
  90. + try:
  91. + with open(filepath, 'rb') as fh:
  92. + return fh.read(4) == b'\x7fELF'
  93. + except:
  94. + return False
  95. +
  96. + def find_library(name):
  97. + from glob import glob
  98. + # absolute name?
  99. + if os.path.isabs(name):
  100. + return name
  101. + # special case for libm, libcrypt and libpthread and musl
  102. + if name in ['m', 'crypt', 'pthread']:
  103. + name = 'c'
  104. + elif name in ['libm.so', 'libcrypt.so', 'libpthread.so']:
  105. + name = 'libc.so'
  106. + # search in standard locations (musl order)
  107. + paths = ['/lib', '/usr/local/lib', '/usr/lib']
  108. + if 'LD_LIBRARY_PATH' in os.environ:
  109. + paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths
  110. + for d in paths:
  111. + f = os.path.join(d, name)
  112. + if _is_elf(f):
  113. + return os.path.basename(f)
  114. +
  115. + prefix = os.path.join(d, 'lib'+name)
  116. + for suffix in ['.so', '.so.*']:
  117. + for f in glob('{0}{1}'.format(prefix, suffix)):
  118. + if _is_elf(f):
  119. + return os.path.basename(f)
  120. +
  121. else:
  122.  
  123. def _findSoname_ldconfig(name):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement