clean up patch applying a bit, and add support for @GENTOO_LIBDIR@ replacements in...
authorMike Frysinger <vapier@gentoo.org>
Mon, 3 Oct 2011 04:04:46 +0000 (04:04 +0000)
committerMike Frysinger <vapier@gentoo.org>
Mon, 3 Oct 2011 04:04:46 +0000 (04:04 +0000)
eclass/libtool.eclass

index 5a7a2fa966d34733a3a7189a783a60864caf031b..c6a06b99e6b475d7c4e18469bc89fcbb23c8c77f 100644 (file)
@@ -1,6 +1,6 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.93 2011/06/10 16:17:57 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.94 2011/10/03 04:04:46 vapier Exp $
 
 # @ECLASS: libtool.eclass
 # @MAINTAINER:
@@ -16,7 +16,7 @@
 
 DESCRIPTION="Based on the ${ECLASS} eclass"
 
-inherit toolchain-funcs
+inherit multilib toolchain-funcs
 
 ELT_PATCH_DIR="${ECLASSDIR}/ELT-patches"
 
@@ -27,17 +27,22 @@ ELT_try_and_apply_patch() {
        local ret=0
        local file=$1
        local patch=$2
+       local src=$3
+       local disp="${src} patch"
+       local log="${T}/elibtool.log"
 
-       echo -e "\nTrying $(basename "$(dirname "${patch}")")-${patch##*/}.patch on ${file}" \
-               >> "${T}/elibtool.log" 2>&1
+       if [[ -z ${__ELT_NOTED_TMP} ]] ; then
+               __ELT_NOTED_TMP=true
+               printf 'temp patch: %s\n' "${patch}" > "${log}"
+       fi
+       printf '\nTrying %s\n' "${disp}" >> "${log}"
 
        # We only support patchlevel of 0 - why worry if its static patches?
-       if patch -p0 --dry-run "${file}" "${patch}" >> "${T}/elibtool.log" 2>&1 ; then
-               einfo "  Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..."
-               patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" \
-                       >> "${T}/elibtool.log" 2>&1
+       if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then
+               einfo "  Applying ${disp} ..."
+               patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1
                ret=$?
-               export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}"
+               export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}"
        else
                ret=1
        fi
@@ -61,7 +66,7 @@ ELT_libtool_version() {
 # apply to $1 ...
 #
 ELT_walk_patches() {
-       local patch
+       local patch tmp
        local ret=1
        local file=$1
        local patch_set=$2
@@ -71,20 +76,21 @@ ELT_walk_patches() {
        [[ -z ${patch_set} ]] && return 1
        [[ ! -d ${patch_dir} ]] && return 1
 
-       pushd "${ELT_PATCH_DIR}" >/dev/null
+       # Allow patches to use @GENTOO_LIBDIR@ replacements
+       local sed_args=( -e "s:@GENTOO_LIBDIR@:$(get_libdir):g" )
+       if [[ -n ${rem_int_dep} ]] ; then
+               # replace @REM_INT_DEP@ with what was passed
+               # to --remove-internal-dep
+               sed_args+=( -e "s|@REM_INT_DEP@|${rem_int_dep}|g" )
+       fi
+
+       pushd "${ELT_PATCH_DIR}" >/dev/null || die
 
        # Go through the patches in reverse order (newer version to older)
        for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do
-               # For --remove-internal-dep ...
-               if [[ -n ${rem_int_dep} ]] ; then
-                       # For replace @REM_INT_DEP@ with what was passed
-                       # to --remove-internal-dep
-                       local tmp="${T}/$$.rem_int_deps.patch"
-                       sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" "${patch}" > "${tmp}"
-                       patch=${tmp}
-               fi
-
-               if ELT_try_and_apply_patch "${file}" "${patch}" ; then
+               tmp="${T}/libtool-elt.patch"
+               sed "${sed_args[@]}" "${patch}" > "${tmp}" || die
+               if ELT_try_and_apply_patch "${file}" "${tmp}" "${patch}" ; then
                        # Break to unwind w/popd rather than return directly
                        ret=0
                        break