1 |
--- |
2 |
gx86/eclass/python-r1.eclass | 66 ++++++++++++++++++++++++++++++++++++++++++++ |
3 |
1 file changed, 66 insertions(+) |
4 |
|
5 |
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass |
6 |
index 6d4eb33..44103a8 100644 |
7 |
--- a/gx86/eclass/python-r1.eclass |
8 |
+++ b/gx86/eclass/python-r1.eclass |
9 |
@@ -611,3 +611,69 @@ python_replicate_script() { |
10 |
_python_ln_rel "${ED}"/usr/bin/python-exec "${f}" || die |
11 |
done |
12 |
} |
13 |
+ |
14 |
+# @ECLASS-VARIABLE: python_scriptroot |
15 |
+# @DEFAULT_UNSET |
16 |
+# @DESCRIPTION: |
17 |
+# The current script destination for python_doscript(). The path |
18 |
+# is relative to the installation root (${ED}). |
19 |
+# |
20 |
+# When unset, ${DESTTREE}/bin (/usr/bin by default) will be used. |
21 |
+# |
22 |
+# Can be set indirectly through the python_scriptinto() function. |
23 |
+# |
24 |
+# Example: |
25 |
+# @CODE |
26 |
+# src_install() { |
27 |
+# local python_scriptroot=${GAMES_BINDIR} |
28 |
+# python_foreach_impl python_doscript foo |
29 |
+# } |
30 |
+# @CODE |
31 |
+ |
32 |
+# @FUNCTION: python_scriptinto |
33 |
+# @USAGE: <new-path> |
34 |
+# @DESCRIPTION: |
35 |
+# Set the current scriptroot. The new value will be stored |
36 |
+# in the 'python_scriptroot' environment variable. The new value need |
37 |
+# be relative to the installation root (${ED}). |
38 |
+# |
39 |
+# Alternatively, you can set the variable directly. |
40 |
+python_scriptinto() { |
41 |
+ debug-print-function ${FUNCNAME} "${@}" |
42 |
+ |
43 |
+ python_scriptroot=${1} |
44 |
+} |
45 |
+ |
46 |
+# @FUNCTION: python_doscript |
47 |
+# @USAGE: <files>... |
48 |
+# @DESCRIPTION: |
49 |
+# Install the given scripts into current python_scriptroot, |
50 |
+# for the current Python implementation (${EPYTHON}). |
51 |
+# |
52 |
+# All specified files must start with a 'python' shebang. The shebang |
53 |
+# will be converted, the file will be renamed to be EPYTHON-suffixed |
54 |
+# and a wrapper will be installed in place of the original name. |
55 |
+python_doscript() { |
56 |
+ debug-print-function ${FUNCNAME} "${@}" |
57 |
+ |
58 |
+ [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' |
59 |
+ |
60 |
+ local d=${python_scriptroot:-${DESTTREE}/bin} |
61 |
+ local INSDESTTREE INSOPTIONS |
62 |
+ |
63 |
+ insinto "${d}" |
64 |
+ insopts -m755 |
65 |
+ |
66 |
+ local f |
67 |
+ for f; do |
68 |
+ local oldfn=${f##*/} |
69 |
+ local newfn=${oldfn}-${EPYTHON} |
70 |
+ |
71 |
+ debug-print "${FUNCNAME}: ${oldfn} -> ${newfn}" |
72 |
+ newins "${f}" "${newfn}" |
73 |
+ _python_rewrite_shebang "${D}/${d}/${newfn}" |
74 |
+ |
75 |
+ # install the wrapper |
76 |
+ _python_ln_rel "${ED}"/usr/bin/python-exec "${D}/${d}/${oldfn}" || die |
77 |
+ done |
78 |
+} |
79 |
-- |
80 |
1.8.0 |