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

Diff of /eclass/eutils.eclass

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

Revision 1.7 Revision 1.8
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.7 2002/11/25 04:20:07 vapier Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.8 2002/12/01 12:34:23 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 themselves. 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
127# <azarah@gentoo.org> (10 Nov 2002) 127# <azarah@gentoo.org> (10 Nov 2002)
128# 128#
129epatch() { 129epatch() {
130 local PIPE_CMD="" 130 local PIPE_CMD=""
131 local STDERR_TARGET="${T}/$$.out" 131 local STDERR_TARGET="${T}/$$.out"
132 local PATCH_TARGET="${T}/$$.patch"
133 local PATCH_SUFFIX=""
132 local SINGLE_PATCH="no" 134 local SINGLE_PATCH="no"
133 local x="" 135 local x=""
134 136
135 if [ "$#" -gt 1 ] 137 if [ "$#" -gt 1 ]
136 then 138 then
147 149
148 elif [ -n "$1" -a -d "$1" ] 150 elif [ -n "$1" -a -d "$1" ]
149 then 151 then
150 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}" 152 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}"
151 else 153 else
154 if [ ! -d ${EPATCH_SOURCE} ]
155 then
156 echo
157 eerror "Cannot find \$EPATCH_SOURCE!"
158 echo
159 die "Cannot find \$EPATCH_SOURCE!"
160 fi
161
152 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}" 162 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}"
153 fi 163 fi
154 164
155 case ${EPATCH_SUFFIX##*\.} in 165 case ${EPATCH_SUFFIX##*\.} in
156 bz2) 166 bz2)
157 PIPE_CMD="bzip2 -dc" 167 PIPE_CMD="bzip2 -dc"
168 PATCH_SUFFIX="bz2"
158 ;; 169 ;;
159 gz|Z|z) 170 gz|Z|z)
160 PIPE_CMD="gzip -dc" 171 PIPE_CMD="gzip -dc"
172 PATCH_SUFFIX="gz"
161 ;; 173 ;;
162 ZIP|zip) 174 ZIP|zip)
163 PIPE_CMD="unzip -p" 175 PIPE_CMD="unzip -p"
176 PATCH_SUFFIX="zip"
164 ;; 177 ;;
165 *) 178 *)
166 PIPE_CMD="cat" 179 PIPE_CMD="cat"
180 PATCH_SUFFIX="patch"
167 ;; 181 ;;
168 esac 182 esac
169 183
170 if [ "${SINGLE_PATCH}" = "no" ] 184 if [ "${SINGLE_PATCH}" = "no" ]
171 then 185 then
196 einfo "Applying ${x##*/}..." 210 einfo "Applying ${x##*/}..."
197 else 211 else
198 einfo " ${x##*/}..." 212 einfo " ${x##*/}..."
199 fi 213 fi
200 214
201 echo "***** ${x##*/} *****" > ${STDERR_TARGET} 215 echo "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
202 echo >> ${STDERR_TARGET} 216 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
203 217
204 # Allow for prefix to differ ... im lazy, so shoot me :/ 218 # Allow for prefix to differ ... im lazy, so shoot me :/
205 while [ "${count}" -lt 5 ] 219 while [ "${count}" -lt 5 ]
206 do 220 do
207 # Generate some useful debug info ... 221 # Generate some useful debug info ...
208 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET} 222 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
209 echo >> ${STDERR_TARGET} 223 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
224
225 if [ "${PATCH_SUFFIX}" != "patch" ]
226 then
227 echo -n "PIPE_COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
228 echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
229 else
230 PATCH_TARGET="${x}"
231 fi
210 232
211 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET} 233 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
212 echo "${PIPE_CMD} ${x} | patch ${popts} -p${count}" >> ${STDERR_TARGET} 234 echo "patch ${popts} -p${count} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
213 235
214 echo >> ${STDERR_TARGET} 236 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
215 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET} 237 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
238
239 if [ "${PATCH_SUFFIX}" != "patch" ]
240 then
241 if ! (${PIPE_CMD} ${x} > ${PATCH_TARGET}) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1
242 then
243 echo
244 eerror "Could not extract patch!"
245 #die "Could not extract patch!"
246 count=5
247 break
248 fi
249 fi
216 250
217 if eval ${PIPE_CMD} ${x} | patch ${popts} --dry-run -f -p${count} 2>&1 >> ${STDERR_TARGET} 251 if patch ${popts} --dry-run -f -p${count} < ${PATCH_TARGET} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1
218 then 252 then
219 eval ${PIPE_CMD} ${x} | patch ${popts} -p${count} 2>&1 >> ${STDERR_TARGET} 253 draw_line "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
254 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
255 echo "ACTUALLY APPLYING ${x##*/}..." >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
256 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
257 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
258
259 patch ${popts} -p${count} < ${PATCH_TARGET} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 2>&1
260
261 if [ "$?" -ne 0 ]
262 then
263 cat ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
264 echo
265 eerror "A dry-run of patch command succeeded, but actually"
266 eerror "applying the patch failed!"
267 #die "Real world sux compared to the dreamworld!"
268 count=5
269 fi
270
271 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
272
220 break 273 break
221 fi 274 fi
222 275
223 count=$((count + 1)) 276 count=$((count + 1))
224 done 277 done
225 278
279 if [ "${PATCH_SUFFIX}" != "patch" ]
280 then
281 rm -f ${PATCH_TARGET}
282 fi
283
226 if [ "${count}" -eq 5 ] 284 if [ "${count}" -eq 5 ]
227 then 285 then
286 echo
228 eerror "Failed Patch: ${x##*/}!" 287 eerror "Failed Patch: ${x##*/}!"
229 eerror 288 eerror
230 eerror "Include in your bugreport the contents of:" 289 eerror "Include in your bugreport the contents of:"
231 eerror 290 eerror
232 eerror " ${STDERR_TARGET}" 291 eerror " ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}"
233 eerror 292 echo
234 die "Failed Patch: ${x##*/}!" 293 die "Failed Patch: ${x##*/}!"
235 fi 294 fi
295
296 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
236 297
237 eend 0 298 eend 0
238 fi 299 fi
239 done 300 done
240 if [ "${SINGLE_PATCH}" = "no" ] 301 if [ "${SINGLE_PATCH}" = "no" ]

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.20