commit: 0674131adf745882b40cb02ba39747382541c4ab Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> AuthorDate: Mon Jun 20 19:37:02 2016 +0000 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> CommitDate: Mon Jun 20 19:37:02 2016 +0000 URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=0674131a
sys-apps/portage: backport C module fix Package-Manager: portage-2.2.28 sys-apps/portage/Manifest | 6 +- ...-util-locale.py-fix-decoding-for-python2-.patch | 40 ++++++ ...d-stub-for-building-custom-modules-in-C-C.patch | 59 ++++++++ ...-util-locale.py-add-a-C-module-to-help-ch.patch | 151 +++++++++++++++++++++ ....2.26-r99.ebuild => portage-2.2.28-r999.ebuild} | 8 +- 5 files changed, 259 insertions(+), 5 deletions(-) diff --git a/sys-apps/portage/Manifest b/sys-apps/portage/Manifest index aa4ce2d..51130a3 100644 --- a/sys-apps/portage/Manifest +++ b/sys-apps/portage/Manifest @@ -1,7 +1,9 @@ +AUX 0001-pym-portage-util-locale.py-fix-decoding-for-python2-.patch 1374 SHA256 1c40030d4ef7c2a56ea81f00281a56432bb7918d294abcda7b9eab7eb05fd1c9 SHA512 f434323783fa4db0bc096f35da93a33311f00fd8b315f95cc5f3d78365ea0d70376609c27f1d64319bd49f83db6d0cc7d88d035c758f1f0de62f1ef9243c0a30 WHIRLPOOL cdecf4a184fea71c0ee93aa5598cc513e676203d8a226da8c90524471d79f2c22b474c2a2edba0ae3495257792dfc7bd3e78c9a9aed3e9e85bb4906161451891 +AUX 0002-setup.py-add-stub-for-building-custom-modules-in-C-C.patch 1867 SHA256 285fd48357a1996a92860a03059656729d5faa05e4d150865abaaf79f93d5acd SHA512 e073c849650822ea01c804605a4c5743957f9c8c45076dcd9a983951f6607716c1891c0a564268af3c1c0680361d0c4605ed30e50c4f0a23909a1f155925622a WHIRLPOOL f0e6bdaa992d2d374a65e96c9a148b6460a42bb1d939f1b60bbb11368553c750318befae3157e236302580f8b682887ebdc08ec40e62e8f1d81cda925cd48e97 +AUX 0003-pym-portage-util-locale.py-add-a-C-module-to-help-ch.patch 4075 SHA256 42e7c7c9eff8ee423f9e23a7f3d9aa2d629b2755cd053c21d53796bfb9f3655f SHA512 090b8905db5af236644e57b3050e80dab0d58ef63abd2c94746a63204de155379ab63ca9536e53e30be6d6e7bf529047675e17ce266c0256f5f1f828222e4a32 WHIRLPOOL 0b9baa422b64072eb95454b8e833fa040a4ea47d609f42ac7da744f58d3ef20d96e06ce4c488b26593c311a0d9451cc684849d04093328abf34d174c90023a7d AUX README.RESCUE 137 SHA256 69bea0c755eab59b6b4d90838b8551744f0b0c8eeac170b1cd13a71ee83f9ac4 SHA512 dba0f0d6d4cd140e636cc70dfb7bdb298e2f2fb040bc07b0874cac994bdbabd26bfd9361d85a0f8b9a92a185281e4901606b9e4f563afdc8867341bbe6af1cb0 WHIRLPOOL 713fcc790442999d56e13efaf536fec9954dadeda680b3642d0358311332096ddedf8b55697bd1ca620d84f0dc7d025ff7931e086c74c1f5032be72dca2ff8f5 AUX portage-2.2.26-fix-check_locale.patch 810 SHA256 d055958fe52fbfb4d628b11c3a52226f0ce07895d951efbf285d55b0bac455a1 SHA512 33b4d497788de9146abe9a99e4c788c94e8e5e4e615ae7bf18ed415407d4bf0398fb972d938a78f3fff1edfee425f2d672e9868e58efb15cfcccab65cfb5152b WHIRLPOOL 3477eb51320b13de03038e5cf1987f00cce03d65467148ffc23728540de09fde94128cc25986fc40688206059d2ca84734ba4a7379583f68511a2c5f0f0aff23 -DIST portage-2.2.26.tar.bz2 977277 SHA256 7f57aa704c58ea47f031f177203dc7b335e01e7ec1e809437ea9e46e3f9263e5 SHA512 fd1a5e5d028d52ba82bbeb7f87bf331d0c1d8c7f5a3bd450c668dd742e99185b6d2b21944f5d7788fe941c99736744b08157ca30145f0964ea60a7c2c435d601 WHIRLPOOL 0469f4c5609146c57eae4baeb8488b95c04f336a5511460ee44d15746339fd43a7c2d61b58528845d77a6a0b21e46c2afad19a9f05e94ac8dc6180032d71f298 DIST portage-2.2.28.tar.bz2 969138 SHA256 da8148a1a9275c87f535679e41b1bb3a1380ba0f903b80510017517e4c5229d0 SHA512 d21bf7e7dcc0a779a13df6a959e5d4291492fce2a5525b67e9a4705888021f9c08b8d78cd32b2eb930ac5428c40383e4e46da5a7b1ed5c9c9c42314c0f1c6a0b WHIRLPOOL 1b9584b0243b46c70d0778aad57df2d3ea99e19f243280e542c29e6fed0634b72de6b203a3c296c2977d1a6e5e5250b910574176c692d2c7c27c0938528bb43d -EBUILD portage-2.2.26-r99.ebuild 11703 SHA256 32a5b9852ff9620a1b1191baa2b54e0fb6b6abc8bad8944f0a9d6757e249a058 SHA512 b83b69af04617c925c4be8cd9d0a18c7d62c3b9d5b127d4451245bc8f6bcf24c6e3d16228c5e198f3969fc7049178d0f9a9c0cf669c09a4e2c61d4d2d5fc2e14 WHIRLPOOL f598ce0601676f3f0e7b84045e909b1158a33b3da58f3b4e7d3d19febb79f0794aab1ed6804b956b695d48d62462b65c9c18b8602ecd1380d522dfb234d357e7 EBUILD portage-2.2.28-r99.ebuild 11704 SHA256 b814d8beda3bd2364b13153ef5663d40497684ace1cdc2209bd03a61a5fe8fb7 SHA512 78442e2d479acb0b59cade22060c5bef2740cf3c5ae451b25ca629f547824f4bb04a768e5400623d1508f72318bbc0abcf31b8286886241de6cbe640f0f95eb1 WHIRLPOOL 7f220a0e33e825b123f364dff0d43d57f1823bb01e454f66fea71825ec206d4fb8ce42478e033e98fb6c6ae1f598af57008b64effe6274a53e5655e39834095f +EBUILD portage-2.2.28-r999.ebuild 11908 SHA256 65003a03410bcfcc49b56746293dcdf8bbcabb6c85e6f4229fe2caf97a27dbe9 SHA512 4e33ae8ee35ecf9bf609e8b603de050903e4b4a1c79fc6eb65cff524b731dd044314ce72a663296cd511451e333351de1ac6374569d85852fd5ab6800bddaa7c WHIRLPOOL 842c97b6cfd98ca4f3b0de666b5bc3ce465cab48cd94cf66b7fe593be4344b8737da780cb8da7c2434880ee0e5df8594061c34914451fd6425cb84cf153cf0c4 MISC metadata.xml 814 SHA256 e33780a3f1af692a5539738aa243581beb5d6398daf23ac28a252b8481742db1 SHA512 d68c833a70bae0e497f5c0217f6f64161c7cbe3fd01253e8f5657512e5eb62438dec5cc587ca9667c0cd4f791f25cdcb3f7017743f6f66cfdc41fec835b4f3a7 WHIRLPOOL b2c926e03f312e1cdcaedf1f6c5f9b0c25887e93f44fb8aef56212f72369e1916efa863e34cd568d0f50cddcaf8fb9bf33d745d7fc785c62476162465f3298b7 diff --git a/sys-apps/portage/files/0001-pym-portage-util-locale.py-fix-decoding-for-python2-.patch b/sys-apps/portage/files/0001-pym-portage-util-locale.py-fix-decoding-for-python2-.patch new file mode 100644 index 0000000..258c221 --- /dev/null +++ b/sys-apps/portage/files/0001-pym-portage-util-locale.py-fix-decoding-for-python2-.patch @@ -0,0 +1,40 @@ +From f13322877e2778f145308160ccee5d2e27b34235 Mon Sep 17 00:00:00 2001 +From: "Anthony G. Basile" <[email protected]> +Date: Wed, 25 May 2016 08:48:32 -0400 +Subject: [PATCH 1/3] pym/portage/util/locale.py: fix decoding for python2 plus + some locales + +When using python2 with some locales, like turkish, chr() is passed values not in +range(128) which cannot be decoded as ASCII, thus throwing a UnicodeDecodeError +exception. We use _unicode_decode() from portage.util to address this. + +Signed-off-by: Anthony G. Basile <[email protected]> +--- + pym/portage/util/locale.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/pym/portage/util/locale.py b/pym/portage/util/locale.py +index 2a15ea1..093eb86 100644 +--- a/pym/portage/util/locale.py ++++ b/pym/portage/util/locale.py +@@ -15,7 +15,7 @@ import textwrap + import traceback + + import portage +-from portage.util import writemsg_level ++from portage.util import _unicode_decode, writemsg_level + from portage.util._ctypes import find_library, LoadLibrary + + +@@ -62,7 +62,7 @@ def _check_locale(silent): + "as LC_CTYPE in make.conf.") + msg = [l for l in textwrap.wrap(msg, 70)] + msg.append("") +- chars = lambda l: ''.join(chr(x) for x in l) ++ chars = lambda l: ''.join(_unicode_decode(chr(x)) for x in l) + if uc != ruc: + msg.extend([ + " %s -> %s" % (chars(lc), chars(ruc)), +-- +2.7.3 + diff --git a/sys-apps/portage/files/0002-setup.py-add-stub-for-building-custom-modules-in-C-C.patch b/sys-apps/portage/files/0002-setup.py-add-stub-for-building-custom-modules-in-C-C.patch new file mode 100644 index 0000000..d880e44 --- /dev/null +++ b/sys-apps/portage/files/0002-setup.py-add-stub-for-building-custom-modules-in-C-C.patch @@ -0,0 +1,59 @@ +From 0ce1fa04fc6ce32c54efa0e48cd61f577aa585b2 Mon Sep 17 00:00:00 2001 +From: "Anthony G. Basile" <[email protected]> +Date: Thu, 19 May 2016 06:52:43 -0400 +Subject: [PATCH 2/3] setup.py: add stub for building custom modules in C/C++ + +Currently portage doesn't include any custom modules written in C/C++. +This commit introduces stub code for building such modules in setup.py. + +Signed-off-by: Anthony G. Basile <[email protected]> +--- + setup.py | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/setup.py b/setup.py +index 75c4bcb..25429bc 100755 +--- a/setup.py ++++ b/setup.py +@@ -4,7 +4,7 @@ + + from __future__ import print_function + +-from distutils.core import setup, Command ++from distutils.core import setup, Command, Extension + from distutils.command.build import build + from distutils.command.build_scripts import build_scripts + from distutils.command.clean import clean +@@ -30,6 +30,9 @@ import sys + # TODO: + # - smarter rebuilds of docs w/ 'install_docbook' and 'install_epydoc'. + ++# Dictionary of scripts. The structure is ++# key = location in filesystem to install the scripts ++# value = list of scripts, path relative to top source directory + x_scripts = { + 'bin': [ + 'bin/ebuild', 'bin/egencache', 'bin/emerge', 'bin/emerge-webrsync', +@@ -41,6 +44,10 @@ x_scripts = { + ], + } + ++# Dictionary custom modules written in C/C++ here. The structure is ++# key = module name ++# value = list of C/C++ source code, path relative to top source directory ++x_c_helpers = {} + + class x_build(build): + """ Build command with extra build_man call. """ +@@ -636,6 +643,8 @@ setup( + ['$sysconfdir/portage/repo.postsync.d', ['cnf/repo.postsync.d/example']], + ], + ++ ext_modules = [Extension(name=n, sources=m) for n, m in x_c_helpers.items()], ++ + cmdclass = { + 'build': x_build, + 'build_man': build_man, +-- +2.7.3 + diff --git a/sys-apps/portage/files/0003-pym-portage-util-locale.py-add-a-C-module-to-help-ch.patch b/sys-apps/portage/files/0003-pym-portage-util-locale.py-add-a-C-module-to-help-ch.patch new file mode 100644 index 0000000..8b89030 --- /dev/null +++ b/sys-apps/portage/files/0003-pym-portage-util-locale.py-add-a-C-module-to-help-ch.patch @@ -0,0 +1,151 @@ +From aeb46be70eefc2bdcd851b1a7eba2fcc7b4fa575 Mon Sep 17 00:00:00 2001 +From: "Anthony G. Basile" <[email protected]> +Date: Fri, 27 May 2016 09:47:34 -0400 +Subject: [PATCH 3/3] pym/portage/util/locale.py: add a C module to help check + locale + +The current method to check for a sane system locale is to use python's +ctypes.util.find_library() to construct a full library path to the +system libc.so and pass that path to ctypes.CDLL() so we can call +toupper() and tolower() directly. However, this gets bogged down in +implementation details and fails with musl. + +We work around this design flaw in ctypes with a small python module +written in C which provides thin wrappers to toupper() and tolower(), +and only fall back on the current ctypes-based check when this module +is not available. + +This has been tested on glibc, uClibc and musl systems. + +X-Gentoo-bug: 571444 +X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=571444 + +Signed-off-by: Anthony G. Basile <[email protected]> +--- + pym/portage/util/locale.py | 16 ++++++----- + setup.py | 6 +++- + src/portage_util_libc.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 82 insertions(+), 8 deletions(-) + create mode 100644 src/portage_util_libc.c + +diff --git a/pym/portage/util/locale.py b/pym/portage/util/locale.py +index 093eb86..5b09945 100644 +--- a/pym/portage/util/locale.py ++++ b/pym/portage/util/locale.py +@@ -34,13 +34,15 @@ def _check_locale(silent): + """ + The inner locale check function. + """ +- +- libc_fn = find_library("c") +- if libc_fn is None: +- return None +- libc = LoadLibrary(libc_fn) +- if libc is None: +- return None ++ try: ++ from portage.util import libc ++ except ImportError: ++ libc_fn = find_library("c") ++ if libc_fn is None: ++ return None ++ libc = LoadLibrary(libc_fn) ++ if libc is None: ++ return None + + lc = list(range(ord('a'), ord('z')+1)) + uc = list(range(ord('A'), ord('Z')+1)) +diff --git a/setup.py b/setup.py +index 25429bc..5ca8156 100755 +--- a/setup.py ++++ b/setup.py +@@ -47,7 +47,11 @@ x_scripts = { + # Dictionary custom modules written in C/C++ here. The structure is + # key = module name + # value = list of C/C++ source code, path relative to top source directory +-x_c_helpers = {} ++x_c_helpers = { ++ 'portage.util.libc' : [ ++ 'src/portage_util_libc.c', ++ ], ++} + + class x_build(build): + """ Build command with extra build_man call. """ +diff --git a/src/portage_util_libc.c b/src/portage_util_libc.c +new file mode 100644 +index 0000000..977b954 +--- /dev/null ++++ b/src/portage_util_libc.c +@@ -0,0 +1,68 @@ ++/* Copyright 2005-2016 Gentoo Foundation ++ * Distributed under the terms of the GNU General Public License v2 ++ */ ++ ++#include <Python.h> ++#include <stdlib.h> ++#include <ctype.h> ++ ++static PyObject * _libc_tolower(PyObject *, PyObject *); ++static PyObject * _libc_toupper(PyObject *, PyObject *); ++ ++static PyMethodDef LibcMethods[] = { ++ {"tolower", _libc_tolower, METH_VARARGS, "Convert to lower case using system locale."}, ++ {"toupper", _libc_toupper, METH_VARARGS, "Convert to upper case using system locale."}, ++ {NULL, NULL, 0, NULL} ++}; ++ ++#if PY_MAJOR_VERSION >= 3 ++static struct PyModuleDef moduledef = { ++ PyModuleDef_HEAD_INIT, ++ "libc", /* m_name */ ++ "Module for converting case using the system locale", /* m_doc */ ++ -1, /* m_size */ ++ LibcMethods, /* m_methods */ ++ NULL, /* m_reload */ ++ NULL, /* m_traverse */ ++ NULL, /* m_clear */ ++ NULL, /* m_free */ ++}; ++ ++PyMODINIT_FUNC ++PyInit_libc(void) ++{ ++ PyObject *m; ++ m = PyModule_Create(&moduledef); ++ return m; ++} ++#else ++PyMODINIT_FUNC ++initlibc(void) ++{ ++ Py_InitModule("libc", LibcMethods); ++} ++#endif ++ ++ ++static PyObject * ++_libc_tolower(PyObject *self, PyObject *args) ++{ ++ int c; ++ ++ if (!PyArg_ParseTuple(args, "i", &c)) ++ return NULL; ++ ++ return Py_BuildValue("i", tolower(c)); ++} ++ ++ ++static PyObject * ++_libc_toupper(PyObject *self, PyObject *args) ++{ ++ int c; ++ ++ if (!PyArg_ParseTuple(args, "i", &c)) ++ return NULL; ++ ++ return Py_BuildValue("i", toupper(c)); ++} +-- +2.7.3 + diff --git a/sys-apps/portage/portage-2.2.26-r99.ebuild b/sys-apps/portage/portage-2.2.28-r999.ebuild similarity index 97% rename from sys-apps/portage/portage-2.2.26-r99.ebuild rename to sys-apps/portage/portage-2.2.28-r999.ebuild index 3aa681a..c03d330 100644 --- a/sys-apps/portage/portage-2.2.26-r99.ebuild +++ b/sys-apps/portage/portage-2.2.28-r999.ebuild @@ -11,13 +11,13 @@ PYTHON_COMPAT=( ) PYTHON_REQ_USE='bzip2(+)' -inherit distutils-r1 eutils multilib +inherit distutils-r1 multilib DESCRIPTION="Portage is the package management and distribution system for Gentoo" HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Portage" LICENSE="GPL-2" -KEYWORDS="amd64 arm ~mips ppc x86" +KEYWORDS="~amd64 ~arm ~mips ~ppc ~x86" SLOT="0" IUSE="build doc epydoc +ipc linguas_ru selinux xattr" @@ -85,7 +85,9 @@ pkg_setup() { python_prepare_all() { distutils-r1_python_prepare_all - epatch "${FILESDIR}"/${P}-fix-check_locale.patch + epatch "${FILESDIR}"/0001-pym-portage-util-locale.py-fix-decoding-for-python2-.patch + epatch "${FILESDIR}"/0002-setup.py-add-stub-for-building-custom-modules-in-C-C.patch + epatch "${FILESDIR}"/0003-pym-portage-util-locale.py-add-a-C-module-to-help-ch.patch if ! use ipc ; then einfo "Disabling ipc..."
