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

Diff of /eclass/eutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.6 Revision 1.9
1# Copyright 1999-2002 Gentoo Technologies, Inc. 1# Copyright 1999-2002 Gentoo Technologies, Inc.
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# Author: Martin Schlemmer <azarah@gentoo.org> 3# Author: Martin Schlemmer <azarah@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.6 2002/11/12 18:25:37 azarah Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.9 2002/12/01 15:48:27 azarah Exp $
5# This eclass is for general purpose functions that most ebuilds 5# This eclass is for general purpose functions that most ebuilds
6# have to implement themselfs. 6# have to implement themselves.
7# 7#
8# NB: If you add anything, please comment it! 8# NB: If you add anything, please comment it!
9 9
10ECLASS=eutils 10ECLASS=eutils
11INHERITED="$INHERITED $ECLASS" 11INHERITED="$INHERITED $ECLASS"
90# Default options for patch 90# Default options for patch
91EPATCH_OPTS="" 91EPATCH_OPTS=""
92# List of patches not to apply. Not this is only file names, 92# List of patches not to apply. Not this is only file names,
93# and not the full path .. 93# and not the full path ..
94EPATCH_EXCLUDE="" 94EPATCH_EXCLUDE=""
95# Change the printed message for a single patch.
96EPATCH_SINGLE_MSG=""
95 97
96# This function is for bulk patching, or in theory for just one 98# This function is for bulk patching, or in theory for just one
97# or two patches. 99# or two patches.
98# 100#
99# It should work with .bz2, .gz, .zip and plain text patches. 101# It should work with .bz2, .gz, .zip and plain text patches.
127# <azarah@gentoo.org> (10 Nov 2002) 129# <azarah@gentoo.org> (10 Nov 2002)
128# 130#
129epatch() { 131epatch() {
130 local PIPE_CMD="" 132 local PIPE_CMD=""
131 local STDERR_TARGET="${T}/$$.out" 133 local STDERR_TARGET="${T}/$$.out"
134 local PATCH_TARGET="${T}/$$.patch"
135 local PATCH_SUFFIX=""
132 local SINGLE_PATCH="no" 136 local SINGLE_PATCH="no"
133 local x="" 137 local x=""
134 138
135 if [ "$#" -gt 1 ] 139 if [ "$#" -gt 1 ]
136 then 140 then
147 151
148 elif [ -n "$1" -a -d "$1" ] 152 elif [ -n "$1" -a -d "$1" ]
149 then 153 then
150 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}" 154 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}"
151 else 155 else
156 if [ ! -d ${EPATCH_SOURCE} ]
157 then
158 echo
159 eerror "Cannot find \$EPATCH_SOURCE!"
160 echo
161 die "Cannot find \$EPATCH_SOURCE!"
162 fi
163
152 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}" 164 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}"
153 fi 165 fi
154 166
155 case ${EPATCH_SUFFIX##*\.} in 167 case ${EPATCH_SUFFIX##*\.} in
156 bz2) 168 bz2)
157 PIPE_CMD="bzip2 -dc" 169 PIPE_CMD="bzip2 -dc"
170 PATCH_SUFFIX="bz2"
158 ;; 171 ;;
159 gz|Z|z) 172 gz|Z|z)
160 PIPE_CMD="gzip -dc" 173 PIPE_CMD="gzip -dc"
174 PATCH_SUFFIX="gz"
161 ;; 175 ;;
162 ZIP|zip) 176 ZIP|zip)
163 PIPE_CMD="unzip -p" 177 PIPE_CMD="unzip -p"
178 PATCH_SUFFIX="zip"
164 ;; 179 ;;
165 *) 180 *)
166 PIPE_CMD="cat" 181 PIPE_CMD="cat"
182 PATCH_SUFFIX="patch"
167 ;; 183 ;;
168 esac 184 esac
169 185
170 if [ "${SINGLE_PATCH}" = "no" ] 186 if [ "${SINGLE_PATCH}" = "no" ]
171 then 187 then
176 # New ARCH dependant patch naming scheme... 192 # New ARCH dependant patch naming scheme...
177 # 193 #
178 # ???_arch_foo.patch 194 # ???_arch_foo.patch
179 # 195 #
180 if [ -f ${x} ] && \ 196 if [ -f ${x} ] && \
181 [ -n "$1" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] 197 [ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ]
182 then 198 then
183 local count=0 199 local count=0
184 local popts="${EPATCH_OPTS}" 200 local popts="${EPATCH_OPTS}"
185 201
186 if [ -n "${EPATCH_EXCLUDE}" ] 202 if [ -n "${EPATCH_EXCLUDE}" ]
187 then 203 then
188 if [ "${EPATCH_EXCLUDE/${x##*/}}" != "${EPATCH_EXCLUDE}" ] 204 if [ "`eval echo \$\{EPATCH_EXCLUDE/${x##*/}\}`" != "${EPATCH_EXCLUDE}" ]
189 then 205 then
190 continue 206 continue
191 fi 207 fi
192 fi 208 fi
193 209
194 if [ "${SINGLE_PATCH}" = "yes" ] 210 if [ "${SINGLE_PATCH}" = "yes" ]
195 then 211 then
212 if [ -n "${EPATCH_SINGLE_MSG}" ]
213 then
214 einfo "${EPATCH_SINGLE_MSG}"
215 else
196 einfo "Applying ${x##*/}..." 216 einfo "Applying ${x##*/}..."
217 fi
197 else 218 else
198 einfo " ${x##*/}..." 219 einfo " ${x##*/}..."
199 fi 220 fi
200 221
201 echo "***** ${x##*/} *****" > ${STDERR_TARGET} 222 echo "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
202 echo >> ${STDERR_TARGET} 223 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
203 224
204 # Allow for prefix to differ ... im lazy, so shoot me :/ 225 # Allow for prefix to differ ... im lazy, so shoot me :/
205 while [ "${count}" -lt 5 ] 226 while [ "${count}" -lt 5 ]
206 do 227 do
207 # Generate some useful debug info ... 228 # Generate some useful debug info ...
208 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET} 229 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
209 echo >> ${STDERR_TARGET} 230 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
231
232 if [ "${PATCH_SUFFIX}" != "patch" ]
233 then
234 echo -n "PIPE_COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
235 echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
236 else
237 PATCH_TARGET="${x}"
238 fi
210 239
211 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET} 240 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
212 echo "${PIPE_CMD} ${x} | patch ${popts} -p${count}" >> ${STDERR_TARGET} 241 echo "patch ${popts} -p${count} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
213 242
214 echo >> ${STDERR_TARGET} 243 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
215 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET} 244 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
245
246 if [ "${PATCH_SUFFIX}" != "patch" ]
247 then
248 if ! (${PIPE_CMD} ${x} > ${PATCH_TARGET}) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1
249 then
250 echo
251 eerror "Could not extract patch!"
252 #die "Could not extract patch!"
253 count=5
254 break
255 fi
256 fi
216 257
217 if eval ${PIPE_CMD} ${x} | patch ${popts} --dry-run -f -p${count} 2>&1 >> ${STDERR_TARGET} 258 if patch ${popts} --dry-run -f -p${count} < ${PATCH_TARGET} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1
259 then
260 draw_line "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
261 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
262 echo "ACTUALLY APPLYING ${x##*/}..." >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
263 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
264 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
265
266 patch ${popts} -p${count} < ${PATCH_TARGET} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 2>&1
267
268 if [ "$?" -ne 0 ]
218 then 269 then
219 eval ${PIPE_CMD} ${x} | patch ${popts} -p${count} 2>&1 >> ${STDERR_TARGET} 270 cat ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
271 echo
272 eerror "A dry-run of patch command succeeded, but actually"
273 eerror "applying the patch failed!"
274 #die "Real world sux compared to the dreamworld!"
275 count=5
276 fi
277
278 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
279
220 break 280 break
221 fi 281 fi
222 282
223 count=$((count + 1)) 283 count=$((count + 1))
224 done 284 done
225 285
286 if [ "${PATCH_SUFFIX}" != "patch" ]
287 then
288 rm -f ${PATCH_TARGET}
289 fi
290
226 if [ "${count}" -eq 5 ] 291 if [ "${count}" -eq 5 ]
227 then 292 then
293 echo
228 eerror "Failed Patch: ${x##*/}!" 294 eerror "Failed Patch: ${x##*/}!"
229 eerror 295 eerror
230 eerror "Include in your bugreport the contents of:" 296 eerror "Include in your bugreport the contents of:"
231 eerror 297 eerror
232 eerror " ${STDERR_TARGET}" 298 eerror " ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}"
233 eerror 299 echo
234 die "Failed Patch: ${x##*/}!" 300 die "Failed Patch: ${x##*/}!"
235 fi 301 fi
302
303 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
236 304
237 eend 0 305 eend 0
238 fi 306 fi
239 done 307 done
240 if [ "${SINGLE_PATCH}" = "no" ] 308 if [ "${SINGLE_PATCH}" = "no" ]

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.20