/[gentoo-x86]/eclass/eutils.eclass
Gentoo

Contents of /eclass/eutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Mon Nov 11 21:36:45 2002 UTC (11 years, 8 months ago) by azarah
Branch: MAIN
Changes since 1.3: +6 -5 lines
do only local changes to EPATCH_SUFFIX and EPATCH_SOURCE in epatch()

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.3 2002/11/11 19:51:20 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 extension for patches
58 EPATCH_SUFFIX="patch.bz2"
59 # Default options for patch
60 EPATCH_OPTS=""
61
62 # This function is for bulk patching, or in theory for just one
63 # or two patches.
64 #
65 # It should work with .bz2, .gz, .zip and plain text patches.
66 # Currently all patches should be the same format.
67 #
68 # You do not have to specify '-p' option to patch, as it will
69 # try with -p0 to -p5 until it succeed, or fail at -p5.
70 #
71 # Above EPATCH_* variables can be used to control various defaults,
72 # bug they should be left as is to ensure an ebuild can rely on
73 # them for.
74 #
75 # Patches are applied in current directory.
76 #
77 # Bulk 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 # If you however give an argument to epatch(), it will treat it as a
90 # single patch that need to be applied if its a file. If on the other
91 # hand its a directory, it will set EPATCH_SOURCE to this.
92 #
93 # <azarah@gentoo.org> (10 Nov 2002)
94 #
95 epatch() {
96 local PIPE_CMD=""
97 local STDERR_TARGET="${T}/$$.out"
98 local SINGLE_PATCH="no"
99 local x=""
100
101 if [ "$#" -gt 1 ]
102 then
103 eerror "Invalid arguments to epatch()"
104 die "Invalid arguments to epatch()"
105 fi
106
107 if [ -n "$1" -a -f "$1" ]
108 then
109 SINGLE_PATCH="yes"
110
111 local EPATCH_SOURCE="$1"
112 local EPATCH_SUFFIX="${1##*\.}"
113
114 elif [ -n "$1" -a -d "$1" ]
115 then
116 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}"
117 else
118 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}"
119 fi
120
121 case ${EPATCH_SUFFIX##*\.} in
122 bz2)
123 PIPE_CMD="bzip2 -dc"
124 ;;
125 gz)
126 PIPE_CMD="gzip -dc"
127 ;;
128 zip)
129 PIPE_CMD="unzip -p"
130 ;;
131 *)
132 PIPE_CMD="cat"
133 ;;
134 esac
135
136 if [ "${SINGLE_PATCH}" = "no" ]
137 then
138 einfo "Applying various patches (bugfixes/updates)..."
139 fi
140 for x in ${EPATCH_SOURCE}
141 do
142 # New ARCH dependant patch naming scheme...
143 #
144 # ???_arch_foo.patch
145 #
146 if [ -f ${x} ] && \
147 [ -n "$1" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ]
148 then
149 local count=0
150 local popts="${EPATCH_OPTS}"
151
152 if [ "${SINGLE_PATCH}" = "yes" ]
153 then
154 einfo "Applying ${x##*/}..."
155 else
156 einfo " ${x##*/}..."
157 fi
158
159 echo "*** Patch ${x##*/} ***" > ${STDERR_TARGET}
160
161 # Allow for prefix to differ ... im lazy, so shoot me :/
162 while [ "${count}" -lt 5 ]
163 do
164 if eval ${PIPE_CMD} ${x} | patch ${popts} --dry-run -f -p${count} 2>&1 >> ${STDERR_TARGET}
165 then
166 eval ${PIPE_CMD} ${x} | patch ${popts} -p${count} 2>&1 >> ${STDERR_TARGET}
167 break
168 fi
169
170 count=$((count + 1))
171 done
172
173 if [ "${count}" -eq 5 ]
174 then
175 eerror "Failed Patch: ${x##*/}!"
176 eerror
177 eerror "Include in your bugreport the contents of:"
178 eerror
179 eerror " ${STDERR_TARGET}"
180 eerror
181 die "Failed Patch: ${x##*/}!"
182 fi
183
184 eend 0
185 fi
186 done
187 if [ "${SINGLE_PATCH}" = "no" ]
188 then
189 einfo "Done with patching"
190 fi
191 }

  ViewVC Help
Powered by ViewVC 1.1.20