1 |
Signed-off-by: Ulrich Müller <ulm@g.o> |
2 |
--- |
3 |
eclass/eutils.eclass | 51 ++---------------------------------- |
4 |
eclass/wrapper.eclass | 61 +++++++++++++++++++++++++++++++++++++++++++ |
5 |
2 files changed, 63 insertions(+), 49 deletions(-) |
6 |
create mode 100644 eclass/wrapper.eclass |
7 |
|
8 |
diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass |
9 |
index 3b3e328ba30d..0072f4ccf3e7 100644 |
10 |
--- a/eclass/eutils.eclass |
11 |
+++ b/eclass/eutils.eclass |
12 |
@@ -22,9 +22,9 @@ _EUTILS_ECLASS=1 |
13 |
case ${EAPI:-0} in |
14 |
0|1|2|3|4|5|6) |
15 |
inherit desktop edos2unix epatch estack ltprune multilib \ |
16 |
- preserve-libs toolchain-funcs vcs-clean |
17 |
+ preserve-libs toolchain-funcs vcs-clean wrapper |
18 |
;; |
19 |
- 7) inherit edos2unix ;; |
20 |
+ 7) inherit edos2unix wrapper ;; |
21 |
*) die "${ECLASS} is banned in EAPI ${EAPI}" ;; |
22 |
esac |
23 |
|
24 |
@@ -112,53 +112,6 @@ strip-linguas() { |
25 |
export LINGUAS=${newls:1} |
26 |
} |
27 |
|
28 |
-# @FUNCTION: make_wrapper |
29 |
-# @USAGE: <wrapper> <target> [chdir] [libpaths] [installpath] |
30 |
-# @DESCRIPTION: |
31 |
-# Create a shell wrapper script named wrapper in installpath |
32 |
-# (defaults to the bindir) to execute target (default of wrapper) by |
33 |
-# first optionally setting LD_LIBRARY_PATH to the colon-delimited |
34 |
-# libpaths followed by optionally changing directory to chdir. |
35 |
-make_wrapper() { |
36 |
- local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5 |
37 |
- local tmpwrapper=$(emktemp) |
38 |
- has "${EAPI:-0}" 0 1 2 && local EPREFIX="" |
39 |
- |
40 |
- ( |
41 |
- echo '#!/bin/sh' |
42 |
- if [[ -n ${libdir} ]] ; then |
43 |
- local var |
44 |
- if [[ ${CHOST} == *-darwin* ]] ; then |
45 |
- var=DYLD_LIBRARY_PATH |
46 |
- else |
47 |
- var=LD_LIBRARY_PATH |
48 |
- fi |
49 |
- cat <<-EOF |
50 |
- if [ "\${${var}+set}" = "set" ] ; then |
51 |
- export ${var}="\${${var}}:${EPREFIX}${libdir}" |
52 |
- else |
53 |
- export ${var}="${EPREFIX}${libdir}" |
54 |
- fi |
55 |
- EOF |
56 |
- fi |
57 |
- [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}" |
58 |
- # We don't want to quote ${bin} so that people can pass complex |
59 |
- # things as ${bin} ... "./someprog --args" |
60 |
- printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" |
61 |
- ) > "${tmpwrapper}" |
62 |
- chmod go+rx "${tmpwrapper}" |
63 |
- |
64 |
- if [[ -n ${path} ]] ; then |
65 |
- ( |
66 |
- exeopts -m 0755 |
67 |
- exeinto "${path}" |
68 |
- newexe "${tmpwrapper}" "${wrapper}" |
69 |
- ) || die |
70 |
- else |
71 |
- newbin "${tmpwrapper}" "${wrapper}" || die |
72 |
- fi |
73 |
-} |
74 |
- |
75 |
path_exists() { |
76 |
eerror "path_exists has been removed. Please see the following post" |
77 |
eerror "for a replacement snippet:" |
78 |
diff --git a/eclass/wrapper.eclass b/eclass/wrapper.eclass |
79 |
new file mode 100644 |
80 |
index 000000000000..8cde94979d1a |
81 |
--- /dev/null |
82 |
+++ b/eclass/wrapper.eclass |
83 |
@@ -0,0 +1,61 @@ |
84 |
+# Copyright 1999-2020 Gentoo Authors |
85 |
+# Distributed under the terms of the GNU General Public License v2 |
86 |
+ |
87 |
+# @ECLASS: wrapper.eclass |
88 |
+# @MAINTAINER: |
89 |
+# base-system@g.o |
90 |
+# @BLURB: create a shell wrapper script |
91 |
+ |
92 |
+if [[ -z ${_WRAPPER_ECLASS} ]]; then |
93 |
+_WRAPPER_ECLASS=1 |
94 |
+ |
95 |
+inherit eutils # for emktemp |
96 |
+ |
97 |
+# @FUNCTION: make_wrapper |
98 |
+# @USAGE: <wrapper> <target> [chdir] [libpaths] [installpath] |
99 |
+# @DESCRIPTION: |
100 |
+# Create a shell wrapper script named wrapper in installpath |
101 |
+# (defaults to the bindir) to execute target (default of wrapper) |
102 |
+# by first optionally setting LD_LIBRARY_PATH to the colon-delimited |
103 |
+# libpaths followed by optionally changing directory to chdir. |
104 |
+make_wrapper() { |
105 |
+ local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5 |
106 |
+ local tmpwrapper=$(emktemp) |
107 |
+ has "${EAPI:-0}" 0 1 2 && local EPREFIX="" |
108 |
+ |
109 |
+ ( |
110 |
+ echo '#!/bin/sh' |
111 |
+ if [[ -n ${libdir} ]] ; then |
112 |
+ local var |
113 |
+ if [[ ${CHOST} == *-darwin* ]] ; then |
114 |
+ var=DYLD_LIBRARY_PATH |
115 |
+ else |
116 |
+ var=LD_LIBRARY_PATH |
117 |
+ fi |
118 |
+ cat <<-EOF |
119 |
+ if [ "\${${var}+set}" = "set" ] ; then |
120 |
+ export ${var}="\${${var}}:${EPREFIX}${libdir}" |
121 |
+ else |
122 |
+ export ${var}="${EPREFIX}${libdir}" |
123 |
+ fi |
124 |
+ EOF |
125 |
+ fi |
126 |
+ [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}" |
127 |
+ # We don't want to quote ${bin} so that people can pass complex |
128 |
+ # things as ${bin} ... "./someprog --args" |
129 |
+ printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" |
130 |
+ ) > "${tmpwrapper}" |
131 |
+ chmod go+rx "${tmpwrapper}" |
132 |
+ |
133 |
+ if [[ -n ${path} ]] ; then |
134 |
+ ( |
135 |
+ exeopts -m 0755 |
136 |
+ exeinto "${path}" |
137 |
+ newexe "${tmpwrapper}" "${wrapper}" |
138 |
+ ) || die |
139 |
+ else |
140 |
+ newbin "${tmpwrapper}" "${wrapper}" || die |
141 |
+ fi |
142 |
+} |
143 |
+ |
144 |
+fi |
145 |
-- |
146 |
2.28.0 |