Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 2/2] p-d-ng: use distutils-made scripts instead of 'redoing' them.
Date: Mon, 24 Sep 2012 21:51:24
Message-Id: 1348523379-16610-2-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/2] p-d-ng: split out default impl selection logic. by "Michał Górny"
1 Instead of 'redoing' the installed script, just rename the ones
2 installed by distutils in each phase.
3
4 This also changes suffixes from -pythonX_Y to -pythonX.Y for no good
5 reason.
6 ---
7 gx86/eclass/python-distutils-ng.eclass | 39 +++++++++++++++++++++++++++-------
8 1 file changed, 31 insertions(+), 8 deletions(-)
9
10 diff --git a/gx86/eclass/python-distutils-ng.eclass b/gx86/eclass/python-distutils-ng.eclass
11 index ab13ffc..b478277 100644
12 --- a/gx86/eclass/python-distutils-ng.eclass
13 +++ b/gx86/eclass/python-distutils-ng.eclass
14 @@ -292,25 +292,48 @@ python-distutils-ng_src_test() {
15 fi
16 }
17
18 -# Phase function: src_install
19 -python-distutils-ng_src_install() {
20 +# A wrapper necessary to 'redo' scripts.
21 +_python-distutils-ng_install_wrapper() {
22 if type python_install &> /dev/null; then
23 - _python-distutils-ng_run_for_each_impl python_install
24 + python_install "${@}"
25 else
26 - _python-distutils-ng_run_for_each_impl \
27 - _python-distutils-ng_default_distutils_install
28 + _python-distutils-ng_default_distutils_install "${@}"
29 fi
30
31 + if [[ -z "${PYTHON_DISABLE_SCRIPT_REDOS}" ]]; then
32 + local f
33 + # XXX: change this if we ever allow directories in bin/sbin
34 + for f in "${D}"/{,usr/}{,s}bin/*; do
35 + if [[ -x ${f} ]]; then
36 + if [[ "$(head -n 1 "${f}")" == '#!'*${PYTHON}* ]]
37 + then
38 + mv "${f}" "${f}"-${EPYTHON} || die
39 + fi
40 + fi
41 + done
42 + fi
43 +}
44 +
45 +# Phase function: src_install
46 +python-distutils-ng_src_install() {
47 + _python-distutils-ng_run_for_each_impl \
48 + _python-distutils-ng_install_wrapper
49 +
50 if type python_install_all &> /dev/null; then
51 einfo "Running python_install_all in ${S} for all"
52 pushd "${S}" &> /dev/null
53 python_install_all
54 popd &> /dev/null
55 fi
56 -
57 if [[ -z "${PYTHON_DISABLE_SCRIPT_REDOS}" ]]; then
58 - for script_file in $(find "${D}"{,usr/}{,s}bin/ -type f -executable 2> /dev/null); do
59 - python-distutils-ng_redoscript "/${script_file#${D}}"
60 + local best_impl=$(_python-distutils-ng_get_best_impl)
61 + local f
62 +
63 + # XXX: change this if we ever allow directories in bin/sbin
64 + for f in "${D}"/{,usr/}{,s}bin/*-${best_impl/_/.}; do
65 + if [[ -x ${f} ]]; then
66 + ln -s "${f##*/}" "${f%-*}" || die
67 + fi
68 done
69 fi
70 }
71 --
72 1.7.12