Gentoo Archives: gentoo-python

From: "Michał Górny" <mgorny@g.o>
To: gentoo-python@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-python] [PATCH] distutils-r1: parse & handle custom --install-scripts.
Date: Sat, 19 Oct 2013 22:18:07
Message-Id: 1382220958-26756-1-git-send-email-mgorny@gentoo.org
1 Some ebuilds don't like the sane defaults and like to override
2 --install-scripts. Parse that argument in order to obtain the requested
3 install dir, and place the wrapper there.
4
5 Fixes: https://bugs.gentoo.org/show_bug.cgi?id=487788
6 ---
7 eclass/distutils-r1.eclass | 40 ++++++++++++++++++++++++++++++----------
8 1 file changed, 30 insertions(+), 10 deletions(-)
9
10 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
11 index acc791b..9ede335 100644
12 --- a/eclass/distutils-r1.eclass
13 +++ b/eclass/distutils-r1.eclass
14 @@ -407,21 +407,21 @@ distutils-r1_python_test() {
15 }
16
17 # @FUNCTION: _distutils-r1_wrap_scripts
18 -# @USAGE: <path>
19 +# @USAGE: <path> <bindir>
20 # @INTERNAL
21 # @DESCRIPTION:
22 # Moves and wraps all installed scripts/executables as necessary.
23 _distutils-r1_wrap_scripts() {
24 debug-print-function ${FUNCNAME} "${@}"
25
26 + [[ ${#} -eq 2 ]] || die "usage: ${FUNCNAME} <path> <bindir>"
27 local path=${1}
28 - [[ ${path} ]] || die "${FUNCNAME}: no path given"
29 + local bindir=${2}
30
31 if ! _python_want_python_exec2; then
32 - local PYTHON_SCRIPTDIR=${EPREFIX}/usr/bin
33 + local PYTHON_SCRIPTDIR=${bindir}
34 fi
35
36 - mkdir -p "${path}${EPREFIX}/usr/bin" || die
37 local f
38 while IFS= read -r -d '' f; do
39 local basename=${f##*/}
40 @@ -429,6 +429,7 @@ _distutils-r1_wrap_scripts() {
41
42 [[ -d ${f} ]] && die "Unexpected directory: ${f}"
43
44 + mkdir -p "${path}${bindir}" || die
45 local shebang
46 read -r shebang < "${f}"
47 if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then
48 @@ -440,14 +441,14 @@ _distutils-r1_wrap_scripts() {
49 mv "${f}" "${newf}" || die
50 fi
51
52 - debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}"
53 + debug-print "${FUNCNAME}: installing wrapper at ${bindir}/${basename}"
54 _python_ln_rel "${path}${EPREFIX}"$(_python_get_wrapper_path) \
55 - "${path}${EPREFIX}/usr/bin/${basename}" || die
56 + "${path}${bindir}/${basename}" || die
57 elif _python_want_python_exec2; then
58 debug-print "${FUNCNAME}: non-matching shebang: ${shebang}"
59
60 - debug-print "${FUNCNAME}: moving to /usr/bin/${basename}"
61 - mv "${f}" "${path}${EPREFIX}/usr/bin/${basename}" || die
62 + debug-print "${FUNCNAME}: moving to ${bindir}/${basename}"
63 + mv "${f}" "${path}${bindir}/${basename}" || die
64 fi
65 done < <(find "${path}${PYTHON_SCRIPTDIR}" -mindepth 1 -print0)
66 }
67 @@ -491,14 +492,33 @@ distutils-r1_python_install() {
68 flags+=( --install-scripts="${PYTHON_SCRIPTDIR}" )
69 fi
70
71 - esetup.py install "${flags[@]}" "${@}"
72 + esetup.py install "${@}" "${flags[@]}"
73
74 if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
75 die "Package installs 'tests' package, file collisions likely."
76 fi
77
78 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
79 - _distutils-r1_wrap_scripts "${root}"
80 + # user may override --install-scripts
81 + # note: this is poor but distutils argv parsing is dumb
82 + local scriptdir=${EPREFIX}/usr/bin
83 + set -- "${mydistutilsargs[@]}" "${@}"
84 + while [[ ${@} ]]; do
85 + local a=${1}
86 + shift
87 +
88 + case "${a}" in
89 + --install-scripts=*)
90 + scriptdir=${a#--install-scripts=}
91 + ;;
92 + --install-scripts)
93 + scriptdir=${1}
94 + shift
95 + ;;
96 + esac
97 + done
98 +
99 + _distutils-r1_wrap_scripts "${root}" "${scriptdir}"
100 multibuild_merge_root "${root}" "${D}"
101 fi
102 }
103 --
104 1.8.4

Replies