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

Diff of /eclass/eutils.eclass

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

Revision 1.143 Revision 1.153
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 Gentoo Foundation
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# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.143 2005/01/26 16:19:12 ka0ttic Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.153 2005/02/18 21:55:35 azarah Exp $
4# 4#
5# Author: Martin Schlemmer <azarah@gentoo.org> 5# Author: Martin Schlemmer <azarah@gentoo.org>
6# 6#
7# This eclass is for general purpose functions that most ebuilds 7# This eclass is for general purpose functions that most ebuilds
8# have to implement themselves. 8# have to implement themselves.
14INHERITED="$INHERITED $ECLASS" 14INHERITED="$INHERITED $ECLASS"
15 15
16DEPEND="!bootstrap? ( sys-devel/patch )" 16DEPEND="!bootstrap? ( sys-devel/patch )"
17 17
18DESCRIPTION="Based on the ${ECLASS} eclass" 18DESCRIPTION="Based on the ${ECLASS} eclass"
19
20# ecpu_check
21# Usage:
22#
23# ecpu_check array_of_cpu_flags
24#
25# array_of_cpu_flags - An array of cpu flags to check against USE flags
26#
27# Checks user USE related cpu flags against /proc/cpuinfo. If user enables a
28# cpu flag that is not supported in their processor flags, it will warn the
29# user if CROSSCOMPILE is not set to 1 ( because cross compile users are
30# obviously using different cpu flags than their own cpu ). Examples:
31#
32# CPU_FLAGS=(mmx mmx2 sse sse2)
33# ecpu_check CPU_FLAGS
34# Chris White <chriswhite@gentoo.org> (03 Feb 2005)
35
36ecpu_check() {
37 # Think about changing below to: if [ "${CROSSCOMPILE}" -ne 1 -a -e "/proc/cpuinfo" ]
38 # and dropping the else if you do not plan on adding anything to that
39 # empty block ....
40 # PS: also try to add some quoting, and consider rather using ${foo} than $foo ...
41 if [ "${CROSSCOMPILE}" != "1" -a -e "/proc/cpuinfo" ]
42 then
43 CPU_FLAGS=${1}
44 USER_CPU=`grep "flags" /proc/cpuinfo`
45
46 for flags in `seq 1 ${#CPU_FLAGS[@]}`
47 do
48 if has ${CPU_FLAGS[${flags} - 1]} ${USER_CPU} && ! has ${CPU_FLAGS[${flags} - 1]} ${USE}
49 then
50 ewarn "Your system is ${CPU_FLAGS[${flags} - 1]} capable but you don't have it enabled!"
51 ewarn "You might be cross compiling (in this case set CROSSCOMPILE to 1 to disable this warning."
52 fi
53
54 if ! has ${CPU_FLAGS[${flags} - 1]} ${USER_CPU} && has ${CPU_FLAGS[${flags} -1]} ${USE}
55 then
56 ewarn "You have ${CPU_FLAGS[${flags} - 1]} support enabled but your processor doesn't"
57 ewarn "Seem to support it! You might be cross compiling or do not have /proc filesystem"
58 ewarn "enabled. If either is the case, set CROSSCOMPILE to 1 to disable this warning."
59 fi
60 done
61 fi
62}
19 63
20# Wait for the supplied number of seconds. If no argument is supplied, defaults 64# Wait for the supplied number of seconds. If no argument is supplied, defaults
21# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not 65# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not
22# outputting to a terminal, don't wait. For compatability purposes, the argument 66# outputting to a terminal, don't wait. For compatability purposes, the argument
23# must be an integer greater than zero. 67# must be an integer greater than zero.
248 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \ 292 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \
249 [ "${EPATCH_FORCE}" = "yes" ]) 293 [ "${EPATCH_FORCE}" = "yes" ])
250 then 294 then
251 local count=0 295 local count=0
252 local popts="${EPATCH_OPTS}" 296 local popts="${EPATCH_OPTS}"
297 local patchname=${x##*/}
253 298
254 if [ -n "${EPATCH_EXCLUDE}" ] 299 if [ -n "${EPATCH_EXCLUDE}" ]
255 then 300 then
256 if [ "`eval echo \$\{EPATCH_EXCLUDE/${x##*/}\}`" != "${EPATCH_EXCLUDE}" ] 301 if [ "${EPATCH_EXCLUDE/${patchname}}" != "${EPATCH_EXCLUDE}" ]
257 then 302 then
258 continue 303 continue
259 fi 304 fi
260 fi 305 fi
261 306
263 then 308 then
264 if [ -n "${EPATCH_SINGLE_MSG}" ] 309 if [ -n "${EPATCH_SINGLE_MSG}" ]
265 then 310 then
266 einfo "${EPATCH_SINGLE_MSG}" 311 einfo "${EPATCH_SINGLE_MSG}"
267 else 312 else
268 einfo "Applying ${x##*/} ..." 313 einfo "Applying ${patchname} ..."
269 fi 314 fi
270 else 315 else
271 einfo " ${x##*/} ..." 316 einfo " ${patchname} ..."
272 fi 317 fi
273 318
274 echo "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 319 echo "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
275 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 320 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
276 321
277 # Allow for prefix to differ ... im lazy, so shoot me :/ 322 # Allow for prefix to differ ... im lazy, so shoot me :/
278 while [ "${count}" -lt 5 ] 323 while [ "${count}" -lt 5 ]
279 do 324 do
280 # Generate some useful debug info ... 325 # Generate some useful debug info ...
281 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 326 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
282 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 327 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
283 328
284 if [ "${PATCH_SUFFIX}" != "patch" ] 329 if [ "${PATCH_SUFFIX}" != "patch" ]
285 then 330 then
286 echo -n "PIPE_COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 331 echo -n "PIPE_COMMAND: " >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
287 echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 332 echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
288 else 333 else
289 PATCH_TARGET="${x}" 334 PATCH_TARGET="${x}"
290 fi 335 fi
291 336
292 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 337 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
293 echo "patch -p${count} ${popts} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 338 echo "patch -p${count} ${popts} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
294 339
295 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 340 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
296 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 341 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
297 342
298 if [ "${PATCH_SUFFIX}" != "patch" ] 343 if [ "${PATCH_SUFFIX}" != "patch" ]
299 then 344 then
300 if ! (${PIPE_CMD} ${x} > ${PATCH_TARGET}) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 345 if ! (${PIPE_CMD} ${x} > ${PATCH_TARGET}) >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} 2>&1
301 then 346 then
302 echo 347 echo
303 eerror "Could not extract patch!" 348 eerror "Could not extract patch!"
304 #die "Could not extract patch!" 349 #die "Could not extract patch!"
305 count=5 350 count=5
306 break 351 break
307 fi 352 fi
308 fi 353 fi
309 354
310 if (cat ${PATCH_TARGET} | patch -p${count} ${popts} --dry-run -f) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 355 if (cat ${PATCH_TARGET} | patch -p${count} ${popts} --dry-run -f) >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} 2>&1
311 then 356 then
312 draw_line "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 357 draw_line "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
313 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 358 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
314 echo "ACTUALLY APPLYING ${x##*/} ..." >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 359 echo "ACTUALLY APPLYING ${patchname} ..." >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
315 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 360 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
316 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 361 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
317 362
318 cat ${PATCH_TARGET} | patch -p${count} ${popts} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 2>&1 363 cat ${PATCH_TARGET} | patch -p${count} ${popts} >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real 2>&1
319 364
320 if [ "$?" -ne 0 ] 365 if [ "$?" -ne 0 ]
321 then 366 then
322 cat ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 367 cat ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
323 echo 368 echo
324 eerror "A dry-run of patch command succeeded, but actually" 369 eerror "A dry-run of patch command succeeded, but actually"
325 eerror "applying the patch failed!" 370 eerror "applying the patch failed!"
326 #die "Real world sux compared to the dreamworld!" 371 #die "Real world sux compared to the dreamworld!"
327 count=5 372 count=5
328 fi 373 fi
329 374
330 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 375 rm -f ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
331 376
332 break 377 break
333 fi 378 fi
334 379
335 count=$((count + 1)) 380 count=$((count + 1))
341 fi 386 fi
342 387
343 if [ "${count}" -eq 5 ] 388 if [ "${count}" -eq 5 ]
344 then 389 then
345 echo 390 echo
346 eerror "Failed Patch: ${x##*/}!" 391 eerror "Failed Patch: ${patchname}!"
347 eerror 392 eerror
348 eerror "Include in your bugreport the contents of:" 393 eerror "Include in your bugreport the contents of:"
349 eerror 394 eerror
350 eerror " ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}" 395 eerror " ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}"
351 echo 396 echo
352 die "Failed Patch: ${x##*/}!" 397 die "Failed Patch: ${patchname}!"
353 fi 398 fi
354 399
355 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 400 rm -f ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
356 401
357 eend 0 402 eend 0
358 fi 403 fi
359 done 404 done
360 if [ "${SINGLE_PATCH}" = "no" ] 405 if [ "${SINGLE_PATCH}" = "no" ]
1602 patch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null 1647 patch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null
1603 done 1648 done
1604 eend 0 1649 eend 0
1605} 1650}
1606 1651
1607# dopamd [ file ] [ new file ] 1652# dopamd <file> [more files]
1608# 1653#
1609# Install pam auth config file in /etc/pam.d 1654# Install pam auth config file in /etc/pam.d
1610#
1611# The first argument, 'file' is required. Install as 'new file', if
1612# specified.
1613
1614dopamd() { 1655dopamd() {
1615 local pamd="$1" newpamd="${2:-$1}"
1616 [[ -z "$1" ]] && die "dopamd requires at least one argument." 1656 [[ -z $1 ]] && die "dopamd requires at least one argument"
1617 1657
1618 use pam || return 0 1658 use pam || return 0
1619 1659
1620 insinto /etc/pam.d 1660 insinto /etc/pam.d
1621 # these are the default doins options, but be explicit just in case 1661 # these are the default doins options, but be explicit just in case
1622 insopts -m 0644 -o root -g root 1662 insopts -m 0644 -o root -g root
1623 newins ${pamd} ${newpamd} || die "failed to install ${newpamd}" 1663 doins "$@" || die "failed to install $@"
1624} 1664}
1665# newpamd <old name> <new name>
1666#
1667# Install pam file <old name> as <new name> in /etc/pam.d
1668newpamd() {
1669 [[ $# -ne 2 ]] && die "newpamd requires two arguements"
1670
1671 use pam || return 0
1672
1673 insinto /etc/pam.d
1674 # these are the default doins options, but be explicit just in case
1675 insopts -m 0644 -o root -g root
1676 newins "$1" "$2" || die "failed to install $1 as $2"
1677}

Legend:
Removed from v.1.143  
changed lines
  Added in v.1.153

  ViewVC Help
Powered by ViewVC 1.1.20