Gentoo Archives: gentoo-dev

From: Mike Frysinger <vapier@g.o>
To: Gentoo Development <gentoo-dev@l.g.o>
Subject: [gentoo-dev] libtool.eclass update to allow @...@ replacements in patches
Date: Thu, 29 Sep 2011 17:30:29
Message-Id: 201109291328.09124.vapier@gentoo.org
1 cleaned up ELT_try_and_apply_patch a bit, and added support for
2 @GENTOO_LIBDIR@ in patches
3 -mike
4
5 --- libtool.eclass
6 +++ libtool.eclass
7 @@ -16,7 +16,7 @@
8
9 DESCRIPTION="Based on the ${ECLASS} eclass"
10
11 -inherit toolchain-funcs
12 +inherit multilib toolchain-funcs
13
14 ELT_PATCH_DIR="${ECLASSDIR}/ELT-patches"
15
16 @@ -27,17 +27,18 @@ ELT_try_and_apply_patch() {
17 local ret=0
18 local file=$1
19 local patch=$2
20 + local src=$3
21 + local disp="${src} patch"
22 + local log="${T}/elibtool.log"
23
24 - echo -e "\nTrying $(basename "$(dirname "${patch}")")-${patch##*/}.patch on ${file}" \
25 - >> "${T}/elibtool.log" 2>&1
26 + printf '\nTrying %s\nTMP: %s\n' "${disp}" "${patch}" >> "${log}"
27
28 # We only support patchlevel of 0 - why worry if its static patches?
29 - if patch -p0 --dry-run "${file}" "${patch}" >> "${T}/elibtool.log" 2>&1 ; then
30 - einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ..."
31 - patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" \
32 - >> "${T}/elibtool.log" 2>&1
33 + if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then
34 + einfo " Applying ${disp} ..."
35 + patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1
36 ret=$?
37 - export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}"
38 + export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}"
39 else
40 ret=1
41 fi
42 @@ -61,7 +62,7 @@ ELT_libtool_version() {
43 # apply to $1 ...
44 #
45 ELT_walk_patches() {
46 - local patch
47 + local patch tmp
48 local ret=1
49 local file=$1
50 local patch_set=$2
51 @@ -71,20 +72,21 @@ ELT_walk_patches() {
52 [[ -z ${patch_set} ]] && return 1
53 [[ ! -d ${patch_dir} ]] && return 1
54
55 - pushd "${ELT_PATCH_DIR}" >/dev/null
56 + # Allow patches to use @GENTOO_LIBDIR@ replacements
57 + local sed_args=( -e "s:@GENTOO_LIBDIR@:$(get_libdir):g" )
58 + if [[ -n ${rem_int_dep} ]] ; then
59 + # replace @REM_INT_DEP@ with what was passed
60 + # to --remove-internal-dep
61 + sed_args+=( -e "s|@REM_INT_DEP@|${rem_int_dep}|g" )
62 + fi
63 +
64 + pushd "${ELT_PATCH_DIR}" >/dev/null || die
65
66 # Go through the patches in reverse order (newer version to older)
67 for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r) ; do
68 - # For --remove-internal-dep ...
69 - if [[ -n ${rem_int_dep} ]] ; then
70 - # For replace @REM_INT_DEP@ with what was passed
71 - # to --remove-internal-dep
72 - local tmp="${T}/$$.rem_int_deps.patch"
73 - sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" "${patch}" > "${tmp}"
74 - patch=${tmp}
75 - fi
76 -
77 - if ELT_try_and_apply_patch "${file}" "${patch}" ; then
78 + tmp="${T}/libtool-elt.patch"
79 + sed "${sed_args[@]}" "${patch}" > "${tmp}" || die
80 + if ELT_try_and_apply_patch "${file}" "${tmp}" "${patch}" ; then
81 # Break to unwind w/popd rather than return directly
82 ret=0
83 break

Replies