1 |
Now scripts are installed to ${PYTHON_SCRIPTDIR} initially, and then are |
2 |
moved to /usr/bin. |
3 |
--- |
4 |
gx86/eclass/distutils-r1.eclass | 47 +++++++++++++++++++++++++---------------- |
5 |
1 file changed, 29 insertions(+), 18 deletions(-) |
6 |
|
7 |
diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass |
8 |
index c2872b3..7102c58 100644 |
9 |
--- a/gx86/eclass/distutils-r1.eclass |
10 |
+++ b/gx86/eclass/distutils-r1.eclass |
11 |
@@ -409,39 +409,43 @@ distutils-r1_python_test() { |
12 |
: |
13 |
} |
14 |
|
15 |
-# @FUNCTION: _distutils-r1_rename_scripts |
16 |
+# @FUNCTION: _distutils-r1_wrap_scripts |
17 |
# @USAGE: <path> |
18 |
# @INTERNAL |
19 |
# @DESCRIPTION: |
20 |
-# Renames installed Python scripts to be implementation-suffixed. |
21 |
-# ${EPYTHON} needs to be set to the implementation name. |
22 |
-# |
23 |
-# All executable scripts having shebang referencing ${EPYTHON} |
24 |
-# in given path will be renamed. |
25 |
-_distutils-r1_rename_scripts() { |
26 |
+# Moves and wraps all Python scripts installed to PYTHON_SCRIPTDIR |
27 |
+# as necessary. |
28 |
+_distutils-r1_wrap_scripts() { |
29 |
debug-print-function ${FUNCNAME} "${@}" |
30 |
|
31 |
local path=${1} |
32 |
[[ ${path} ]] || die "${FUNCNAME}: no path given" |
33 |
|
34 |
+ mkdir -p "${path}/usr/bin" || die |
35 |
local f |
36 |
while IFS= read -r -d '' f; do |
37 |
- debug-print "${FUNCNAME}: found executable at ${f#${D}/}" |
38 |
+ local basename=${f##*/} |
39 |
+ debug-print "${FUNCNAME}: found executable at ${f#${path}/}" |
40 |
|
41 |
local shebang |
42 |
read -r shebang < "${f}" |
43 |
- if [[ ${shebang} == '#!'*${EPYTHON}* ]] |
44 |
- then |
45 |
+ if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then |
46 |
debug-print "${FUNCNAME}: matching shebang: ${shebang}" |
47 |
|
48 |
- local newf=${f}-${EPYTHON} |
49 |
- debug-print "${FUNCNAME}: renaming to ${newf#${D}/}" |
50 |
- mv "${f}" "${newf}" || die |
51 |
+ local newfn=${basename}-${EPYTHON} |
52 |
+ debug-print "${FUNCNAME}: renaming to /usr/bin/${newfn}" |
53 |
+ mv "${f}" "${ED%/}/usr/bin/${newfn}" || die |
54 |
+ |
55 |
+ debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}" |
56 |
+ _python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec \ |
57 |
+ "${path}${EPREFIX}/usr/bin/${basename}" || die |
58 |
+ else |
59 |
+ debug-print "${FUNCNAME}: non-matching shebang: ${shebang}" |
60 |
|
61 |
- debug-print "${FUNCNAME}: installing wrapper at ${f#${D}/}" |
62 |
- _python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec "${f}" || die |
63 |
+ debug-print "${FUNCNAME}: moving to /usr/bin/${basename}" |
64 |
+ mv "${f}" "${ED%/}/usr/bin/${basename}" || die |
65 |
fi |
66 |
- done < <(find "${path}" -type f -executable -print0) |
67 |
+ done < <(find "${path}/${PYTHON_SCRIPTDIR}" -type f -print0) |
68 |
} |
69 |
|
70 |
# @FUNCTION: distutils-r1_python_install |
71 |
@@ -474,15 +478,22 @@ distutils-r1_python_install() { |
72 |
|
73 |
local root=${D}/_${EPYTHON} |
74 |
[[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D} |
75 |
+ flags+=( --root="${root}" ) |
76 |
+ |
77 |
+ if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then |
78 |
+ local PYTHON_SCRIPTDIR |
79 |
+ python_export PYTHON_SCRIPTDIR |
80 |
+ flags+=( --install-scripts="${PYTHON_SCRIPTDIR}" ) |
81 |
+ fi |
82 |
|
83 |
- esetup.py install "${flags[@]}" --root="${root}" "${@}" |
84 |
+ esetup.py install "${flags[@]}" "${@}" |
85 |
|
86 |
if [[ -d ${root}$(python_get_sitedir)/tests ]]; then |
87 |
die "Package installs 'tests' package, file collisions likely." |
88 |
fi |
89 |
|
90 |
if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then |
91 |
- _distutils-r1_rename_scripts "${root}" |
92 |
+ _distutils-r1_wrap_scripts "${root}" |
93 |
multibuild_merge_root "${root}" "${D}" |
94 |
fi |
95 |
} |
96 |
-- |
97 |
1.8.3.2 |