| 1 | # Copyright 1999-2010 Gentoo Foundation |
1 | # Copyright 1999-2011 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.92 2011/06/10 10:14:21 flameeyes Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.94 2011/10/03 04:04:46 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: libtool.eclass |
5 | # @ECLASS: libtool.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # base-system@gentoo.org |
7 | # base-system@gentoo.org |
| 8 | # @BLURB: quickly update bundled libtool code |
8 | # @BLURB: quickly update bundled libtool code |
| … | |
… | |
| 14 | # generated libtool files. We do not run the libtoolize program because that |
14 | # generated libtool files. We do not run the libtoolize program because that |
| 15 | # requires a regeneration of the main autotool files in order to work properly. |
15 | # requires a regeneration of the main autotool files in order to work properly. |
| 16 | |
16 | |
| 17 | DESCRIPTION="Based on the ${ECLASS} eclass" |
17 | DESCRIPTION="Based on the ${ECLASS} eclass" |
| 18 | |
18 | |
| 19 | inherit toolchain-funcs |
19 | inherit multilib toolchain-funcs |
| 20 | |
20 | |
| 21 | ELT_PATCH_DIR="${ECLASSDIR}/ELT-patches" |
21 | ELT_PATCH_DIR="${ECLASSDIR}/ELT-patches" |
| 22 | |
22 | |
| 23 | # |
23 | # |
| 24 | # See if we can apply $2 on $1, and if so, do it |
24 | # See if we can apply $2 on $1, and if so, do it |
| 25 | # |
25 | # |
| 26 | ELT_try_and_apply_patch() { |
26 | ELT_try_and_apply_patch() { |
| 27 | local ret=0 |
27 | local ret=0 |
| 28 | local file=$1 |
28 | local file=$1 |
| 29 | local patch=$2 |
29 | local patch=$2 |
|
|
30 | local src=$3 |
|
|
31 | local disp="${src} patch" |
|
|
32 | local log="${T}/elibtool.log" |
| 30 | |
33 | |
| 31 | echo -e "\nTrying $(basename "$(dirname "${patch}")")-${patch##*/}.patch on ${file}" \ |
34 | if [[ -z ${__ELT_NOTED_TMP} ]] ; then |
| 32 | &>> "${T}/elibtool.log" |
35 | __ELT_NOTED_TMP=true |
|
|
36 | printf 'temp patch: %s\n' "${patch}" > "${log}" |
|
|
37 | fi |
|
|
38 | printf '\nTrying %s\n' "${disp}" >> "${log}" |
| 33 | |
39 | |
| 34 | # We only support patchlevel of 0 - why worry if its static patches? |
40 | # We only support patchlevel of 0 - why worry if its static patches? |
| 35 | if patch -p0 --dry-run "${file}" "${patch}" &>> "${T}/elibtool.log" ; then |
41 | if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then |
| 36 | einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..." |
42 | einfo " Applying ${disp} ..." |
| 37 | patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" \ |
43 | patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1 |
| 38 | &>> "${T}/elibtool.log" |
|
|
| 39 | ret=$? |
44 | ret=$? |
| 40 | export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}" |
45 | export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}" |
| 41 | else |
46 | else |
| 42 | ret=1 |
47 | ret=1 |
| 43 | fi |
48 | fi |
| 44 | |
49 | |
| 45 | return "${ret}" |
50 | return "${ret}" |
| … | |
… | |
| 59 | # |
64 | # |
| 60 | # Run through the patches in $2 and see if any |
65 | # Run through the patches in $2 and see if any |
| 61 | # apply to $1 ... |
66 | # apply to $1 ... |
| 62 | # |
67 | # |
| 63 | ELT_walk_patches() { |
68 | ELT_walk_patches() { |
| 64 | local patch |
69 | local patch tmp |
| 65 | local ret=1 |
70 | local ret=1 |
| 66 | local file=$1 |
71 | local file=$1 |
| 67 | local patch_set=$2 |
72 | local patch_set=$2 |
| 68 | local patch_dir="${ELT_PATCH_DIR}/${patch_set}" |
73 | local patch_dir="${ELT_PATCH_DIR}/${patch_set}" |
| 69 | local rem_int_dep=$3 |
74 | local rem_int_dep=$3 |
| 70 | |
75 | |
| 71 | [[ -z ${patch_set} ]] && return 1 |
76 | [[ -z ${patch_set} ]] && return 1 |
| 72 | [[ ! -d ${patch_dir} ]] && return 1 |
77 | [[ ! -d ${patch_dir} ]] && return 1 |
| 73 | |
78 | |
|
|
79 | # Allow patches to use @GENTOO_LIBDIR@ replacements |
|
|
80 | local sed_args=( -e "s:@GENTOO_LIBDIR@:$(get_libdir):g" ) |
|
|
81 | if [[ -n ${rem_int_dep} ]] ; then |
|
|
82 | # replace @REM_INT_DEP@ with what was passed |
|
|
83 | # to --remove-internal-dep |
|
|
84 | sed_args+=( -e "s|@REM_INT_DEP@|${rem_int_dep}|g" ) |
|
|
85 | fi |
|
|
86 | |
| 74 | pushd "${ELT_PATCH_DIR}" >/dev/null |
87 | pushd "${ELT_PATCH_DIR}" >/dev/null || die |
| 75 | |
88 | |
| 76 | # Go through the patches in reverse order (newer version to older) |
89 | # Go through the patches in reverse order (newer version to older) |
| 77 | for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do |
90 | for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do |
| 78 | # For --remove-internal-dep ... |
91 | tmp="${T}/libtool-elt.patch" |
| 79 | if [[ -n ${rem_int_dep} ]] ; then |
92 | sed "${sed_args[@]}" "${patch}" > "${tmp}" || die |
| 80 | # For replace @REM_INT_DEP@ with what was passed |
|
|
| 81 | # to --remove-internal-dep |
|
|
| 82 | local tmp="${T}/$$.rem_int_deps.patch" |
|
|
| 83 | sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" "${patch}" > "${tmp}" |
|
|
| 84 | patch=${tmp} |
|
|
| 85 | fi |
|
|
| 86 | |
|
|
| 87 | if ELT_try_and_apply_patch "${file}" "${patch}" ; then |
93 | if ELT_try_and_apply_patch "${file}" "${tmp}" "${patch}" ; then |
| 88 | # Break to unwind w/popd rather than return directly |
94 | # Break to unwind w/popd rather than return directly |
| 89 | ret=0 |
95 | ret=0 |
| 90 | break |
96 | break |
| 91 | fi |
97 | fi |
| 92 | done |
98 | done |