1 |
commit: 8533e77f07ef9f2c768f31eae6259b2eab599b30 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Apr 22 07:20:31 2017 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Aug 11 13:35:08 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8533e77f |
7 |
|
8 |
libtool.eclass: Use external eltpatch tool |
9 |
|
10 |
Closes: https://github.com/gentoo/gentoo/pull/4467 |
11 |
|
12 |
eclass/libtool.eclass | 477 +------------------------------------------------- |
13 |
1 file changed, 6 insertions(+), 471 deletions(-) |
14 |
|
15 |
diff --git a/eclass/libtool.eclass b/eclass/libtool.eclass |
16 |
index 576abd3a5f8..2e0f608d342 100644 |
17 |
--- a/eclass/libtool.eclass |
18 |
+++ b/eclass/libtool.eclass |
19 |
@@ -16,104 +16,9 @@ |
20 |
if [[ -z ${_LIBTOOL_ECLASS} ]]; then |
21 |
_LIBTOOL_ECLASS=1 |
22 |
|
23 |
-DEPEND=">=app-portage/elt-patches-20170317" |
24 |
+DEPEND=">=app-portage/elt-patches-20170422" |
25 |
|
26 |
-libtool_elt_patch_dir() { |
27 |
- echo "${EPREFIX}/usr/share/elt-patches" |
28 |
-} |
29 |
- |
30 |
-inherit multilib toolchain-funcs |
31 |
- |
32 |
-# |
33 |
-# See if we can apply $2 on $1, and if so, do it |
34 |
-# |
35 |
-ELT_try_and_apply_patch() { |
36 |
- local ret=0 |
37 |
- local file=$1 |
38 |
- local patch=$2 |
39 |
- local src=$3 |
40 |
- local disp="${src} patch" |
41 |
- local log="${T}/elibtool.log" |
42 |
- |
43 |
- if [[ -z ${_ELT_NOTED_TMP} ]] ; then |
44 |
- _ELT_NOTED_TMP=true |
45 |
- printf 'temp patch: %s\n' "${patch}" > "${log}" |
46 |
- fi |
47 |
- printf '\nTrying %s\n' "${disp}" >> "${log}" |
48 |
- |
49 |
- if [[ ! -e ${file} ]] ; then |
50 |
- echo "File not found: ${file}" >> "${log}" |
51 |
- return 1 |
52 |
- fi |
53 |
- |
54 |
- # Save file for permission restoration. `patch` sometimes resets things. |
55 |
- # Ideally we'd want 'stat -c %a', but stat is highly non portable and we are |
56 |
- # guaranted to have GNU find, so use that instead. |
57 |
- local perms="$(find ${file} -maxdepth 0 -printf '%m')" |
58 |
- # We only support patchlevel of 0 - why worry if its static patches? |
59 |
- if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then |
60 |
- einfo " Applying ${disp} ..." |
61 |
- patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1 |
62 |
- ret=$? |
63 |
- export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}" |
64 |
- else |
65 |
- ret=1 |
66 |
- fi |
67 |
- chmod "${perms}" "${file}" |
68 |
- |
69 |
- return "${ret}" |
70 |
-} |
71 |
- |
72 |
-# |
73 |
-# Get string version of ltmain.sh or ltconfig (passed as $1) |
74 |
-# |
75 |
-ELT_libtool_version() { |
76 |
- ( |
77 |
- unset VERSION |
78 |
- eval $(grep -e '^[[:space:]]*VERSION=' "$1") |
79 |
- echo "${VERSION:-0}" |
80 |
- ) |
81 |
-} |
82 |
- |
83 |
-# |
84 |
-# Run through the patches in $2 and see if any |
85 |
-# apply to $1 ... |
86 |
-# |
87 |
-ELT_walk_patches() { |
88 |
- local patch tmp |
89 |
- local ret=1 |
90 |
- local file=$1 |
91 |
- local patch_set=$2 |
92 |
- local patch_dir="$(libtool_elt_patch_dir)/${patch_set}" |
93 |
- local rem_int_dep=$3 |
94 |
- |
95 |
- [[ -z ${patch_set} ]] && return 1 |
96 |
- [[ ! -d ${patch_dir} ]] && return 1 |
97 |
- |
98 |
- # Allow patches to use @GENTOO_LIBDIR@ replacements |
99 |
- local sed_args=( -e "s:@GENTOO_LIBDIR@:$(get_libdir):g" ) |
100 |
- if [[ -n ${rem_int_dep} ]] ; then |
101 |
- # replace @REM_INT_DEP@ with what was passed |
102 |
- # to --remove-internal-dep |
103 |
- sed_args+=( -e "s|@REM_INT_DEP@|${rem_int_dep}|g" ) |
104 |
- fi |
105 |
- |
106 |
- pushd "$(libtool_elt_patch_dir)" >/dev/null || die |
107 |
- |
108 |
- # Go through the patches in reverse order (newer version to older) |
109 |
- for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do |
110 |
- tmp="${T}/libtool-elt.patch" |
111 |
- sed "${sed_args[@]}" "${patch}" > "${tmp}" || die |
112 |
- if ELT_try_and_apply_patch "${file}" "${tmp}" "${patch}" ; then |
113 |
- # Break to unwind w/popd rather than return directly |
114 |
- ret=0 |
115 |
- break |
116 |
- fi |
117 |
- done |
118 |
- |
119 |
- popd >/dev/null |
120 |
- return ${ret} |
121 |
-} |
122 |
+inherit toolchain-funcs |
123 |
|
124 |
# @FUNCTION: elibtoolize |
125 |
# @USAGE: [dirs] [--portage] [--reverse-deps] [--patch-only] [--remove-internal-dep=xxx] [--shallow] [--no-uclibc] |
126 |
@@ -126,384 +31,14 @@ ELT_walk_patches() { |
127 |
# |
128 |
# The other options should be avoided in general unless you know what's going on. |
129 |
elibtoolize() { |
130 |
- local x |
131 |
- local dirs=() |
132 |
- local do_portage="no" |
133 |
- local do_reversedeps="yes" |
134 |
- local do_only_patches="no" |
135 |
- local do_uclibc="yes" |
136 |
- local deptoremove= |
137 |
- local do_shallow="no" |
138 |
- local force="false" |
139 |
- local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed target-nm ppc64le" |
140 |
- |
141 |
- for x in "$@" ; do |
142 |
- case ${x} in |
143 |
- --portage) |
144 |
- # Only apply portage patch, and don't |
145 |
- # 'libtoolize --copy --force' if all patches fail. |
146 |
- do_portage="yes" |
147 |
- ;; |
148 |
- --reverse-deps) |
149 |
- # Apply the reverse-deps patch |
150 |
- # http://bugzilla.gnome.org/show_bug.cgi?id=75635 |
151 |
- do_reversedeps="yes" |
152 |
- elt_patches+=" fix-relink" |
153 |
- ;; |
154 |
- --patch-only) |
155 |
- # Do not run libtoolize if none of the patches apply .. |
156 |
- do_only_patches="yes" |
157 |
- ;; |
158 |
- --remove-internal-dep=*) |
159 |
- # We will replace @REM_INT_DEP@ with what is needed |
160 |
- # in ELT_walk_patches() ... |
161 |
- deptoremove=${x#--remove-internal-dep=} |
162 |
- |
163 |
- # Add the patch for this ... |
164 |
- [[ -n ${deptoremove} ]] && elt_patches+=" rem-int-dep" |
165 |
- ;; |
166 |
- --shallow) |
167 |
- # Only patch the ltmain.sh in ${S} |
168 |
- do_shallow="yes" |
169 |
- ;; |
170 |
- --no-uclibc) |
171 |
- do_uclibc="no" |
172 |
- ;; |
173 |
- --force) |
174 |
- force="true" |
175 |
- ;; |
176 |
- -*) |
177 |
- eerror "Invalid elibtoolize option: ${x}" |
178 |
- die "elibtoolize called with ${x} ??" |
179 |
- ;; |
180 |
- *) dirs+=( "${x}" ) |
181 |
- esac |
182 |
- done |
183 |
- |
184 |
- [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf" |
185 |
- |
186 |
- case ${CHOST} in |
187 |
- *-aix*) elt_patches+=" hardcode aixrtl" ;; #213277 |
188 |
- *-darwin*) elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf" ;; |
189 |
- *-solaris*) elt_patches+=" sol2-conf sol2-ltmain" ;; |
190 |
- *-freebsd*) elt_patches+=" fbsd-conf fbsd-ltconf" ;; |
191 |
- *-hpux*) elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc" ;; |
192 |
- *-irix*) elt_patches+=" irix-ltmain" ;; |
193 |
- *-mint*) elt_patches+=" mint-conf" ;; |
194 |
- esac |
195 |
- |
196 |
- if $(tc-getLD) --version 2>&1 | grep -qs 'GNU gold'; then |
197 |
- elt_patches+=" gold-conf" |
198 |
- fi |
199 |
- |
200 |
- # Find out what dirs to scan. |
201 |
- if [[ ${do_shallow} == "yes" ]] ; then |
202 |
- [[ ${#dirs[@]} -ne 0 ]] && die "Using --shallow with explicit dirs doesn't make sense" |
203 |
- [[ -f ${S}/ltmain.sh || -f ${S}/configure ]] && dirs+=( "${S}" ) |
204 |
- else |
205 |
- [[ ${#dirs[@]} -eq 0 ]] && dirs+=( "${S}" ) |
206 |
- dirs=( $(find "${dirs[@]}" '(' -name ltmain.sh -o -name configure ')' -printf '%h\n' | sort -u) ) |
207 |
- fi |
208 |
- |
209 |
- local d p ret |
210 |
- for d in "${dirs[@]}" ; do |
211 |
- export ELT_APPLIED_PATCHES= |
212 |
- |
213 |
- if [[ -f ${d}/.elibtoolized ]] ; then |
214 |
- ${force} || continue |
215 |
- fi |
216 |
+ type -P eltpatch &>/dev/null || die "eltpatch not found; is app-portage/elt-patches installed?" |
217 |
|
218 |
- local outfunc="einfo" |
219 |
- [[ -f ${d}/.elibtoolized ]] && outfunc="ewarn" |
220 |
- ${outfunc} "Running elibtoolize in: ${d#${WORKDIR}/}/" |
221 |
- if [[ ${outfunc} == "ewarn" ]] ; then |
222 |
- ewarn " We've already been run in this tree; you should" |
223 |
- ewarn " avoid this if possible (perhaps by filing a bug)" |
224 |
- fi |
225 |
- |
226 |
- # patching ltmain.sh |
227 |
- [[ -f ${d}/ltmain.sh ]] && |
228 |
- for p in ${elt_patches} ; do |
229 |
- ret=0 |
230 |
- |
231 |
- case ${p} in |
232 |
- portage) |
233 |
- # Stupid test to see if its already applied ... |
234 |
- if ! grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then |
235 |
- ELT_walk_patches "${d}/ltmain.sh" "${p}" |
236 |
- ret=$? |
237 |
- fi |
238 |
- ;; |
239 |
- rem-int-dep) |
240 |
- ELT_walk_patches "${d}/ltmain.sh" "${p}" "${deptoremove}" |
241 |
- ret=$? |
242 |
- ;; |
243 |
- fix-relink) |
244 |
- # Do not apply if we do not have the relink patch applied ... |
245 |
- if grep -qs 'inst_prefix_dir' "${d}/ltmain.sh" ; then |
246 |
- ELT_walk_patches "${d}/ltmain.sh" "${p}" |
247 |
- ret=$? |
248 |
- fi |
249 |
- ;; |
250 |
- max_cmd_len) |
251 |
- # Do not apply if $max_cmd_len is not used ... |
252 |
- if grep -qs 'max_cmd_len' "${d}/ltmain.sh" ; then |
253 |
- ELT_walk_patches "${d}/ltmain.sh" "${p}" |
254 |
- ret=$? |
255 |
- fi |
256 |
- ;; |
257 |
- as-needed) |
258 |
- ELT_walk_patches "${d}/ltmain.sh" "${p}" |
259 |
- ret=$? |
260 |
- ;; |
261 |
- uclibc-ltconf) |
262 |
- # Newer libtoolize clears ltconfig, as not used anymore |
263 |
- if [[ -s ${d}/ltconfig ]] ; then |
264 |
- ELT_walk_patches "${d}/ltconfig" "${p}" |
265 |
- ret=$? |
266 |
- fi |
267 |
- ;; |
268 |
- fbsd-ltconf) |
269 |
- if [[ -s ${d}/ltconfig ]] ; then |
270 |
- ELT_walk_patches "${d}/ltconfig" "${p}" |
271 |
- ret=$? |
272 |
- fi |
273 |
- ;; |
274 |
- darwin-ltconf) |
275 |
- # Newer libtoolize clears ltconfig, as not used anymore |
276 |
- if [[ -s ${d}/ltconfig ]] ; then |
277 |
- ELT_walk_patches "${d}/ltconfig" "${p}" |
278 |
- ret=$? |
279 |
- fi |
280 |
- ;; |
281 |
- darwin-ltmain) |
282 |
- # special case to avoid false positives (failing to apply |
283 |
- # ltmain.sh path message), newer libtools have this patch |
284 |
- # built in, so not much to patch around then |
285 |
- if [[ -e ${d}/ltmain.sh ]] && \ |
286 |
- ! grep -qs 'verstring="-compatibility_version' "${d}/ltmain.sh" ; then |
287 |
- ELT_walk_patches "${d}/ltmain.sh" "${p}" |
288 |
- ret=$? |
289 |
- fi |
290 |
- ;; |
291 |
- install-sh) |
292 |
- ELT_walk_patches "${d}/install-sh" "${p}" |
293 |
- ret=$? |
294 |
- ;; |
295 |
- cross) |
296 |
- if tc-is-cross-compiler ; then |
297 |
- ELT_walk_patches "${d}/ltmain.sh" "${p}" |
298 |
- ret=$? |
299 |
- fi |
300 |
- ;; |
301 |
- *) |
302 |
- ELT_walk_patches "${d}/ltmain.sh" "${p}" |
303 |
- ret=$? |
304 |
- ;; |
305 |
- esac |
306 |
- |
307 |
- if [[ ${ret} -ne 0 ]] ; then |
308 |
- case ${p} in |
309 |
- relink) |
310 |
- local version=$(ELT_libtool_version "${d}/ltmain.sh") |
311 |
- # Critical patch, but could be applied ... |
312 |
- # FIXME: Still need a patch for ltmain.sh > 1.4.0 |
313 |
- if ! grep -qs 'inst_prefix_dir' "${d}/ltmain.sh" && \ |
314 |
- [[ $(VER_to_int "${version}") -ge $(VER_to_int "1.4.0") ]] ; then |
315 |
- ewarn " Could not apply relink.patch!" |
316 |
- fi |
317 |
- ;; |
318 |
- portage) |
319 |
- # Critical patch - for this one we abort, as it can really |
320 |
- # cause breakage without it applied! |
321 |
- if [[ ${do_portage} == "yes" ]] ; then |
322 |
- # Stupid test to see if its already applied ... |
323 |
- if ! grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then |
324 |
- echo |
325 |
- eerror "Portage patch requested, but failed to apply!" |
326 |
- eerror "Please file a bug report to add a proper patch." |
327 |
- die "Portage patch requested, but failed to apply!" |
328 |
- fi |
329 |
- else |
330 |
- if grep -qs 'We do not want portage' "${d}/ltmain.sh" ; then |
331 |
- # ewarn " Portage patch seems to be already applied." |
332 |
- # ewarn " Please verify that it is not needed." |
333 |
- : |
334 |
- else |
335 |
- local version=$(ELT_libtool_version "${d}"/ltmain.sh) |
336 |
- echo |
337 |
- eerror "Portage patch failed to apply (ltmain.sh version ${version})!" |
338 |
- eerror "Please file a bug report to add a proper patch." |
339 |
- die "Portage patch failed to apply!" |
340 |
- fi |
341 |
- # We do not want to run libtoolize ... |
342 |
- ELT_APPLIED_PATCHES="portage" |
343 |
- fi |
344 |
- ;; |
345 |
- darwin-*) |
346 |
- [[ ${CHOST} == *"-darwin"* ]] && ewarn " Darwin patch set '${p}' failed to apply!" |
347 |
- ;; |
348 |
- esac |
349 |
- fi |
350 |
- done |
351 |
- |
352 |
- # makes sense for ltmain.sh patches only |
353 |
- [[ -f ${d}/ltmain.sh ]] && |
354 |
- if [[ -z ${ELT_APPLIED_PATCHES} ]] ; then |
355 |
- if [[ ${do_portage} == "no" && \ |
356 |
- ${do_reversedeps} == "no" && \ |
357 |
- ${do_only_patches} == "no" && \ |
358 |
- ${deptoremove} == "" ]] |
359 |
- then |
360 |
- ewarn "Cannot apply any patches, please file a bug about this" |
361 |
- die |
362 |
- fi |
363 |
- fi |
364 |
- |
365 |
- # patching configure |
366 |
- [[ -f ${d}/configure ]] && |
367 |
- for p in ${elt_patches} ; do |
368 |
- ret=0 |
369 |
- |
370 |
- case ${p} in |
371 |
- uclibc-conf) |
372 |
- if grep -qs 'Transform linux' "${d}/configure" ; then |
373 |
- ELT_walk_patches "${d}/configure" "${p}" |
374 |
- ret=$? |
375 |
- fi |
376 |
- ;; |
377 |
- fbsd-conf) |
378 |
- if grep -qs 'version_type=freebsd-' "${d}/configure" ; then |
379 |
- ELT_walk_patches "${d}/configure" "${p}" |
380 |
- ret=$? |
381 |
- fi |
382 |
- ;; |
383 |
- darwin-conf) |
384 |
- if grep -qs '&& echo \.so ||' "${d}/configure" ; then |
385 |
- ELT_walk_patches "${d}/configure" "${p}" |
386 |
- ret=$? |
387 |
- fi |
388 |
- ;; |
389 |
- aixrtl|hpux-conf) |
390 |
- ret=1 |
391 |
- local subret=0 |
392 |
- # apply multiple patches as often as they match |
393 |
- while [[ $subret -eq 0 ]]; do |
394 |
- subret=1 |
395 |
- if [[ -e ${d}/configure ]]; then |
396 |
- ELT_walk_patches "${d}/configure" "${p}" |
397 |
- subret=$? |
398 |
- fi |
399 |
- if [[ $subret -eq 0 ]]; then |
400 |
- # have at least one patch succeeded. |
401 |
- ret=0 |
402 |
- fi |
403 |
- done |
404 |
- ;; |
405 |
- mint-conf|gold-conf|sol2-conf) |
406 |
- ELT_walk_patches "${d}/configure" "${p}" |
407 |
- ret=$? |
408 |
- ;; |
409 |
- target-nm) |
410 |
- ELT_walk_patches "${d}/configure" "${p}" |
411 |
- ret=$? |
412 |
- ;; |
413 |
- ppc64le) |
414 |
- ELT_walk_patches "${d}/configure" "${p}" |
415 |
- ret=$? |
416 |
- ;; |
417 |
- *) |
418 |
- # ltmain.sh patches are applied above |
419 |
- ;; |
420 |
- esac |
421 |
- |
422 |
- if [[ ${ret} -ne 0 ]] ; then |
423 |
- case ${p} in |
424 |
- uclibc-*) |
425 |
- [[ ${CHOST} == *-uclibc ]] && ewarn " uClibc patch set '${p}' failed to apply!" |
426 |
- ;; |
427 |
- fbsd-*) |
428 |
- if [[ ${CHOST} == *-freebsd* ]] ; then |
429 |
- if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' \ |
430 |
- "${d}/configure" 2>/dev/null) ]]; then |
431 |
- eerror " FreeBSD patch set '${p}' failed to apply!" |
432 |
- die "FreeBSD patch set '${p}' failed to apply!" |
433 |
- fi |
434 |
- fi |
435 |
- ;; |
436 |
- darwin-*) |
437 |
- [[ ${CHOST} == *"-darwin"* ]] && ewarn " Darwin patch set '${p}' failed to apply!" |
438 |
- ;; |
439 |
- esac |
440 |
- fi |
441 |
- done |
442 |
- |
443 |
- rm -f "${d}/libtool" |
444 |
- |
445 |
- > "${d}/.elibtoolized" |
446 |
- done |
447 |
+ ELT_LOGDIR=${T} \ |
448 |
+ LD=$(tc-getLD) \ |
449 |
+ eltpatch "${@}" || die "eltpatch failed" |
450 |
} |
451 |
|
452 |
uclibctoolize() { die "Use elibtoolize"; } |
453 |
darwintoolize() { die "Use elibtoolize"; } |
454 |
|
455 |
-# char *VER_major(string) |
456 |
-# |
457 |
-# Return the Major (X of X.Y.Z) version |
458 |
-# |
459 |
-VER_major() { |
460 |
- [[ -z $1 ]] && return 1 |
461 |
- |
462 |
- local VER=$@ |
463 |
- echo "${VER%%[^[:digit:]]*}" |
464 |
-} |
465 |
- |
466 |
-# char *VER_minor(string) |
467 |
-# |
468 |
-# Return the Minor (Y of X.Y.Z) version |
469 |
-# |
470 |
-VER_minor() { |
471 |
- [[ -z $1 ]] && return 1 |
472 |
- |
473 |
- local VER=$@ |
474 |
- VER=${VER#*.} |
475 |
- echo "${VER%%[^[:digit:]]*}" |
476 |
-} |
477 |
- |
478 |
-# char *VER_micro(string) |
479 |
-# |
480 |
-# Return the Micro (Z of X.Y.Z) version. |
481 |
-# |
482 |
-VER_micro() { |
483 |
- [[ -z $1 ]] && return 1 |
484 |
- |
485 |
- local VER=$@ |
486 |
- VER=${VER#*.*.} |
487 |
- echo "${VER%%[^[:digit:]]*}" |
488 |
-} |
489 |
- |
490 |
-# int VER_to_int(string) |
491 |
-# |
492 |
-# Convert a string type version (2.4.0) to an int (132096) |
493 |
-# for easy compairing or versions ... |
494 |
-# |
495 |
-VER_to_int() { |
496 |
- [[ -z $1 ]] && return 1 |
497 |
- |
498 |
- local VER_MAJOR=$(VER_major "$1") |
499 |
- local VER_MINOR=$(VER_minor "$1") |
500 |
- local VER_MICRO=$(VER_micro "$1") |
501 |
- local VER_int=$(( VER_MAJOR * 65536 + VER_MINOR * 256 + VER_MICRO )) |
502 |
- |
503 |
- # We make version 1.0.0 the minimum version we will handle as |
504 |
- # a sanity check ... if its less, we fail ... |
505 |
- if [[ ${VER_int} -ge 65536 ]] ; then |
506 |
- echo "${VER_int}" |
507 |
- return 0 |
508 |
- fi |
509 |
- |
510 |
- echo 1 |
511 |
- return 1 |
512 |
-} |
513 |
- |
514 |
fi |