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