1 | # Copyright 1999-2006 Gentoo Foundation |
1 | # Copyright 1999-2006 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.279 2007/04/25 09:14:35 carlo Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.280 2007/05/05 07:52:26 vapier Exp $ |
4 | # |
4 | # |
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! |
… | |
… | |
366 | [[ -z ${T} ]] \ |
366 | [[ -z ${T} ]] \ |
367 | && topdir="/tmp" \ |
367 | && topdir="/tmp" \ |
368 | || topdir=${T} |
368 | || topdir=${T} |
369 | fi |
369 | fi |
370 | |
370 | |
371 | if [[ -z $(type -p mktemp) ]] ; then |
371 | if ! type -P mktemp > /dev/null ; then |
|
|
372 | # system lacks `mktemp` so we have to fake it |
372 | local tmp=/ |
373 | local tmp=/ |
373 | while [[ -e ${tmp} ]] ; do |
374 | while [[ -e ${tmp} ]] ; do |
374 | tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM} |
375 | tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM} |
375 | done |
376 | done |
376 | ${exe} "${tmp}" || ${exe} -p "${tmp}" |
377 | ${exe} "${tmp}" || ${exe} -p "${tmp}" |
377 | echo "${tmp}" |
378 | echo "${tmp}" |
378 | else |
379 | else |
|
|
380 | # the args here will give slightly wierd names on BSD, |
|
|
381 | # but should produce a usable file on all userlands |
379 | if [[ ${exe} == "touch" ]] ; then |
382 | if [[ ${exe} == "touch" ]] ; then |
380 | [[ ${USERLAND} == "GNU" ]] \ |
|
|
381 | && mktemp -p "${topdir}" \ |
|
|
382 | || TMPDIR="${topdir}" mktemp -t tmp |
383 | TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX |
383 | else |
384 | else |
384 | [[ ${USERLAND} == "GNU" ]] \ |
|
|
385 | && mktemp -d "${topdir}" \ |
|
|
386 | || TMPDIR="${topdir}" mktemp -dt tmp |
385 | TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX |
387 | fi |
386 | fi |
388 | fi |
387 | fi |
389 | } |
388 | } |
390 | |
389 | |
391 | # Small wrapper for getent (Linux), nidump (Mac OS X), |
390 | # Small wrapper for getent (Linux), nidump (Mac OS X), |