| 1 | # Copyright 1999-2003 Gentoo Technologies, Inc. |
1 | # Copyright 1999-2003 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 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.23 2003/03/01 03:38:40 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.30 2003/05/31 13:24:45 mholzer 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. |
| … | |
… | |
| 94 | # List of patches not to apply. Not this is only file names, |
94 | # List of patches not to apply. Not this is only file names, |
| 95 | # and not the full path .. |
95 | # and not the full path .. |
| 96 | EPATCH_EXCLUDE="" |
96 | EPATCH_EXCLUDE="" |
| 97 | # Change the printed message for a single patch. |
97 | # Change the printed message for a single patch. |
| 98 | EPATCH_SINGLE_MSG="" |
98 | EPATCH_SINGLE_MSG="" |
|
|
99 | # Force applying bulk patches even if not following the style: |
|
|
100 | # |
|
|
101 | # ??_${ARCH}_foo.${EPATCH_SUFFIX} |
|
|
102 | # |
|
|
103 | EPATCH_FORCE="no" |
| 99 | |
104 | |
| 100 | # This function is for bulk patching, or in theory for just one |
105 | # This function is for bulk patching, or in theory for just one |
| 101 | # or two patches. |
106 | # or two patches. |
| 102 | # |
107 | # |
| 103 | # It should work with .bz2, .gz, .zip and plain text patches. |
108 | # It should work with .bz2, .gz, .zip and plain text patches. |
| … | |
… | |
| 151 | local EPATCH_SOURCE="$1" |
156 | local EPATCH_SOURCE="$1" |
| 152 | local EPATCH_SUFFIX="${1##*\.}" |
157 | local EPATCH_SUFFIX="${1##*\.}" |
| 153 | |
158 | |
| 154 | elif [ -n "$1" -a -d "$1" ] |
159 | elif [ -n "$1" -a -d "$1" ] |
| 155 | then |
160 | then |
|
|
161 | # Allow no extension if EPATCH_FORCE=yes ... used by vim for example ... |
|
|
162 | if [ "${EPATCH_FORCE}" = "yes" ] && [ -z "${EPATCH_SUFFIX}" ] |
|
|
163 | then |
|
|
164 | local EPATCH_SOURCE="$1/*" |
|
|
165 | else |
| 156 | local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}" |
166 | local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}" |
|
|
167 | fi |
| 157 | else |
168 | else |
| 158 | if [ ! -d ${EPATCH_SOURCE} ] |
169 | if [ ! -d ${EPATCH_SOURCE} ] |
| 159 | then |
170 | then |
| 160 | if [ -n "$1" -a "${EPATCH_SOURCE}" = "${WORKDIR}/patch" ] |
171 | if [ -n "$1" -a "${EPATCH_SOURCE}" = "${WORKDIR}/patch" ] |
| 161 | then |
172 | then |
| … | |
… | |
| 201 | # New ARCH dependant patch naming scheme... |
212 | # New ARCH dependant patch naming scheme... |
| 202 | # |
213 | # |
| 203 | # ???_arch_foo.patch |
214 | # ???_arch_foo.patch |
| 204 | # |
215 | # |
| 205 | if [ -f ${x} ] && \ |
216 | if [ -f ${x} ] && \ |
| 206 | [ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] |
217 | ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \ |
|
|
218 | [ "${EPATCH_FORCE}" = "yes" ]) |
| 207 | then |
219 | then |
| 208 | local count=0 |
220 | local count=0 |
| 209 | local popts="${EPATCH_OPTS}" |
221 | local popts="${EPATCH_OPTS}" |
| 210 | |
222 | |
| 211 | if [ -n "${EPATCH_EXCLUDE}" ] |
223 | if [ -n "${EPATCH_EXCLUDE}" ] |
| … | |
… | |
| 318 | then |
330 | then |
| 319 | einfo "Done with patching" |
331 | einfo "Done with patching" |
| 320 | fi |
332 | fi |
| 321 | } |
333 | } |
| 322 | |
334 | |
|
|
335 | # This function return true if we are using the NPTL pthreads |
|
|
336 | # implementation. |
|
|
337 | # |
|
|
338 | # <azarah@gentoo.org> (06 March 2003) |
|
|
339 | # |
|
|
340 | |
|
|
341 | have_NPTL() { |
|
|
342 | |
|
|
343 | cat > ${T}/test-nptl.c <<-"END" |
|
|
344 | #define _XOPEN_SOURCE |
|
|
345 | #include <unistd.h> |
|
|
346 | #include <stdio.h> |
|
|
347 | |
|
|
348 | int main() |
|
|
349 | { |
|
|
350 | char buf[255]; |
|
|
351 | char *str = buf; |
|
|
352 | |
|
|
353 | confstr(_CS_GNU_LIBPTHREAD_VERSION, str, 255); |
|
|
354 | if (NULL != str) { |
|
|
355 | printf("%s\n", str); |
|
|
356 | if (NULL != strstr(str, "NPTL")) |
|
|
357 | return 0; |
|
|
358 | } |
|
|
359 | |
|
|
360 | return 1; |
|
|
361 | } |
|
|
362 | END |
|
|
363 | |
|
|
364 | einfon "Checking for _CS_GNU_LIBPTHREAD_VERSION support in glibc ... " |
|
|
365 | if gcc -o ${T}/nptl ${T}/test-nptl.c &> /dev/null |
|
|
366 | then |
|
|
367 | echo "yes" |
|
|
368 | einfon "Checking what PTHREADS implementation we have ... " |
|
|
369 | if ${T}/nptl |
|
|
370 | then |
|
|
371 | return 0 |
|
|
372 | else |
|
|
373 | return 1 |
|
|
374 | fi |
|
|
375 | else |
|
|
376 | echo "no" |
|
|
377 | fi |
|
|
378 | |
|
|
379 | return 1 |
|
|
380 | } |
|
|
381 | |
| 323 | # This function check how many cpu's are present, and then set |
382 | # This function check how many cpu's are present, and then set |
| 324 | # -j in MAKEOPTS accordingly. |
383 | # -j in MAKEOPTS accordingly. |
| 325 | # |
384 | # |
| 326 | # Thanks to nall <nall@gentoo.org> for this. |
385 | # Thanks to nall <nall@gentoo.org> for this. |
| 327 | # |
386 | # |
| … | |
… | |
| 403 | # enewuser(username, uid, shell, homedir, groups, extra options) |
462 | # enewuser(username, uid, shell, homedir, groups, extra options) |
| 404 | # |
463 | # |
| 405 | # Default values if you do not specify any: |
464 | # Default values if you do not specify any: |
| 406 | # username: REQUIRED ! |
465 | # username: REQUIRED ! |
| 407 | # uid: next available (see useradd(8)) |
466 | # uid: next available (see useradd(8)) |
|
|
467 | # note: pass -1 to get default behavior |
| 408 | # shell: /bin/false |
468 | # shell: /bin/false |
| 409 | # homedir: /dev/null |
469 | # homedir: /dev/null |
| 410 | # groups: none |
470 | # groups: none |
| 411 | # extra: comment of 'added by portage for ${PN}' |
471 | # extra: comment of 'added by portage for ${PN}' |
| 412 | enewuser() { |
472 | enewuser() { |
| … | |
… | |
| 433 | # options to pass to useradd |
493 | # options to pass to useradd |
| 434 | local opts="" |
494 | local opts="" |
| 435 | |
495 | |
| 436 | # handle uid |
496 | # handle uid |
| 437 | local euid="$1"; shift |
497 | local euid="$1"; shift |
| 438 | if [ ! -z "${euid}" ] ; then |
498 | if [ ! -z "${euid}" ] && [ "${euid}" != "-1" ] ; then |
| 439 | if [ ${euid} -gt 0 ] ; then |
499 | if [ ${euid} -gt 0 ] ; then |
| 440 | opts="${opts} -u ${euid}" |
500 | opts="${opts} -u ${euid}" |
| 441 | else |
501 | else |
| 442 | eerror "Userid given but is not greater than 0 !" |
502 | eerror "Userid given but is not greater than 0 !" |
| 443 | die "${euid} is not a valid UID" |
503 | die "${euid} is not a valid UID" |
| … | |
… | |
| 566 | local oldsandbox="${oldsandbox}" |
626 | local oldsandbox="${oldsandbox}" |
| 567 | export SANDBOX_ON="0" |
627 | export SANDBOX_ON="0" |
| 568 | groupadd ${opts} ${egroup} || die "enewgroup failed" |
628 | groupadd ${opts} ${egroup} || die "enewgroup failed" |
| 569 | export SANDBOX_ON="${oldsandbox}" |
629 | export SANDBOX_ON="${oldsandbox}" |
| 570 | } |
630 | } |
|
|
631 | |
|
|
632 | # Simple script to replace 'dos2unix' binaries |
|
|
633 | # vapier@gentoo.org |
|
|
634 | # |
|
|
635 | # edos2unix(file, <more files>...) |
|
|
636 | edos2unix() { |
|
|
637 | for f in $@ ; do |
|
|
638 | cp ${f} ${T}/edos2unix |
|
|
639 | rm -f ${f} |
|
|
640 | sed 's/\r$//' ${T}/edos2unix > ${f} |
|
|
641 | rm -f ${T}/edos2unix |
|
|
642 | done |
|
|
643 | } |