| 1 |
# Copyright 1999-2002 Gentoo Technologies, Inc. |
| 2 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
# Author: Martin Schlemmer <azarah@gentoo.org> |
| 4 |
# $Header: /home/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.1 2002/10/26 09:16:03 azarah Exp $ |
| 5 |
# This eclass is for general purpose functions that most ebuilds |
| 6 |
# have to implement themselfs. |
| 7 |
# |
| 8 |
# NB: If you add anything, please comment it! |
| 9 |
|
| 10 |
ECLASS=eutils |
| 11 |
INHERITED="$INHERITED $ECLASS" |
| 12 |
|
| 13 |
newdepend sys-devel/patch |
| 14 |
|
| 15 |
DESCRIPTION="Based on the ${ECLASS} eclass" |
| 16 |
|
| 17 |
# This function generate linker scripts in /usr/lib for dynamic |
| 18 |
# libs in /lib. This is to fix linking problems when you have |
| 19 |
# the .so in /lib, and the .a in /usr/lib. What happens is that |
| 20 |
# in some cases when linking dynamic, the .a in /usr/lib is used |
| 21 |
# instead of the .so in /lib due to gcc/libtool tweaking ld's |
| 22 |
# library search path. This cause many builds to fail. |
| 23 |
# See bug #4411 for more info. |
| 24 |
# |
| 25 |
# To use, simply call: |
| 26 |
# |
| 27 |
# gen_usr_ldscript libfoo.so |
| 28 |
# |
| 29 |
# Note that you should in general use the unversioned name of |
| 30 |
# the library, as ldconfig should usually update it correctly |
| 31 |
# to point to the latest version of the library present. |
| 32 |
# |
| 33 |
# <azarah@gentoo.org> (26 Oct 2002) |
| 34 |
# |
| 35 |
gen_usr_ldscript() { |
| 36 |
|
| 37 |
# Just make sure it exists |
| 38 |
dodir /usr/lib |
| 39 |
|
| 40 |
cat > ${D}/usr/lib/$1 <<"END_LDSCRIPT" |
| 41 |
/* GNU ld script |
| 42 |
Because Gentoo have critical dynamic libraries |
| 43 |
in /lib, and the static versions in /usr/lib, we |
| 44 |
need to have a "fake" dynamic lib in /usr/lib, |
| 45 |
otherwise we run into linking problems. |
| 46 |
See bug #4411 on http://bugs.gentoo.org/ for |
| 47 |
more info. */ |
| 48 |
GROUP ( /lib/libxxx ) |
| 49 |
END_LDSCRIPT |
| 50 |
|
| 51 |
dosed "s:libxxx:$1:" /usr/lib/$1 |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
# Default directory where patches are located |
| 56 |
EPATCH_SOURCE="${WORKDIR}/patch" |
| 57 |
# Default directory in which patches should be applied |
| 58 |
EPATCH_WORKDIR="${S}" |
| 59 |
# Default extension for patches |
| 60 |
EPATCH_SUFFIX="patch.bz2" |
| 61 |
# Default options for patch |
| 62 |
EPATCH_OPTS="" |
| 63 |
|
| 64 |
# This function is for bulk patching, or in theory for just one |
| 65 |
# or two patches. |
| 66 |
# |
| 67 |
# It should work with .bz2, .gz, .zip and plain text patches. |
| 68 |
# Currently all patches should be the same format. |
| 69 |
# |
| 70 |
# You do not have to specify '-p' option to patch, as it will |
| 71 |
# try with -p0 to -p5 until it succeed, or fail at -p5. |
| 72 |
# |
| 73 |
# Above EPATCH_* variables can be used to control various defaults, |
| 74 |
# bug they should be left as is to ensure an ebuild can rely on |
| 75 |
# them for. |
| 76 |
# |
| 77 |
# Patch/Patches should preferibly have the form of: |
| 78 |
# |
| 79 |
# ??_${ARCH}_foo.${EPATCH_SUFFIX} |
| 80 |
# |
| 81 |
# For example: |
| 82 |
# |
| 83 |
# 01_all_misc-fix.patch.bz2 |
| 84 |
# 02_sparc_another-fix.patch.bz2 |
| 85 |
# |
| 86 |
# This ensures that there are a set order, and you can have ARCH |
| 87 |
# specific patches. |
| 88 |
# |
| 89 |
# <azarah@gentoo.org> (10 Nov 2002) |
| 90 |
# |
| 91 |
epatch() { |
| 92 |
local PIPE_CMD="" |
| 93 |
local STDERR_TARGET="${T}/$$.out" |
| 94 |
|
| 95 |
case ${EPATCH_SUFFIX##*\.} in |
| 96 |
bz2) |
| 97 |
PIPE_CMD="bzip2 -dc" |
| 98 |
;; |
| 99 |
gz) |
| 100 |
PIPE_CMD="gzip -dc" |
| 101 |
;; |
| 102 |
zip) |
| 103 |
PIPE_CMD="unzip -p" |
| 104 |
;; |
| 105 |
*) |
| 106 |
PIPE_CMD="cat" |
| 107 |
;; |
| 108 |
esac |
| 109 |
|
| 110 |
cd ${EPATCH_WORKDIR} |
| 111 |
einfo "Applying various patches (bugfixes/updates)..." |
| 112 |
for x in ${EPATCH_SOURCE}/*.${EPATCH_SUFFIX} |
| 113 |
do |
| 114 |
# New ARCH dependant patch naming scheme... |
| 115 |
# |
| 116 |
# ???_arch_foo.patch |
| 117 |
# |
| 118 |
if [ -f ${x} ] && \ |
| 119 |
[ "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] |
| 120 |
then |
| 121 |
local count=0 |
| 122 |
local popts="${EPATCH_OPTS}" |
| 123 |
|
| 124 |
einfo " ${x##*/}..." |
| 125 |
|
| 126 |
> ${STDERR_TARGET} |
| 127 |
|
| 128 |
# Allow for prefix to differ ... im lazy, so shoot me :/ |
| 129 |
while [ "${count}" -lt 5 ] |
| 130 |
do |
| 131 |
if eval ${PIPE_CMD} ${x} | patch ${popts} --dry-run -f -p${count} 2>&1 >> ${STDERR_TARGET} |
| 132 |
then |
| 133 |
eval ${PIPE_CMD} ${x} | patch ${popts} -p${count} 2>&1 >> ${STDERR_TARGET} |
| 134 |
break |
| 135 |
fi |
| 136 |
|
| 137 |
count=$((count + 1)) |
| 138 |
done |
| 139 |
|
| 140 |
if [ "${count}" -eq 5 ] |
| 141 |
then |
| 142 |
eerror "Failed Patch: ${x##*/}!" |
| 143 |
eerror |
| 144 |
eerror "Include in your bugreport the contents of:" |
| 145 |
eerror |
| 146 |
eerror " ${STDERR_TARGET}" |
| 147 |
eerror |
| 148 |
die "Failed Patch: ${x##*/}!" |
| 149 |
fi |
| 150 |
fi |
| 151 |
done |
| 152 |
eend 0 "Done with patching" |
| 153 |
} |