| 1 | # Copyright 1999-2009 Gentoo Foundation |
1 | # Copyright 1999-2009 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.349 2010/08/19 21:32:26 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.353 2011/01/09 02:16:53 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: eutils.eclass |
5 | # @ECLASS: eutils.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # base-system@gentoo.org |
7 | # base-system@gentoo.org |
| 8 | # @BLURB: many extra (but common) functions that are used in ebuilds |
8 | # @BLURB: many extra (but common) functions that are used in ebuilds |
| … | |
… | |
| 200 | # If you do not specify any options, then epatch will default to the directory |
200 | # If you do not specify any options, then epatch will default to the directory |
| 201 | # specified by EPATCH_SOURCE. |
201 | # specified by EPATCH_SOURCE. |
| 202 | # |
202 | # |
| 203 | # When processing directories, epatch will apply all patches that match: |
203 | # When processing directories, epatch will apply all patches that match: |
| 204 | # @CODE |
204 | # @CODE |
| 205 | # ${EPATCH_FORCE} == "yes" |
205 | # if ${EPATCH_FORCE} != "yes" |
| 206 | # ??_${ARCH}_foo.${EPATCH_SUFFIX} |
206 | # ??_${ARCH}_foo.${EPATCH_SUFFIX} |
| 207 | # else |
207 | # else |
| 208 | # *.${EPATCH_SUFFIX} |
208 | # *.${EPATCH_SUFFIX} |
| 209 | # @CODE |
209 | # @CODE |
| 210 | # The leading ?? are typically numbers used to force consistent patch ordering. |
210 | # The leading ?? are typically numbers used to force consistent patch ordering. |
| … | |
… | |
| 357 | # such patches. |
357 | # such patches. |
| 358 | local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }') |
358 | local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }') |
| 359 | if [[ -n ${abs_paths} ]] ; then |
359 | if [[ -n ${abs_paths} ]] ; then |
| 360 | count=1 |
360 | count=1 |
| 361 | printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}" |
361 | printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}" |
|
|
362 | fi |
|
|
363 | # Similar reason, but with relative paths. |
|
|
364 | local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}") |
|
|
365 | if [[ -n ${rel_paths} ]] ; then |
|
|
366 | eqawarn "QA Notice: Your patch uses relative paths '../'." |
|
|
367 | eqawarn " In the future this will cause a failure." |
|
|
368 | eqawarn "${rel_paths}" |
| 362 | fi |
369 | fi |
| 363 | |
370 | |
| 364 | # Dynamically detect the correct -p# ... i'm lazy, so shoot me :/ |
371 | # Dynamically detect the correct -p# ... i'm lazy, so shoot me :/ |
| 365 | while [[ ${count} -lt 5 ]] ; do |
372 | while [[ ${count} -lt 5 ]] ; do |
| 366 | # Generate some useful debug info ... |
373 | # Generate some useful debug info ... |
| … | |
… | |
| 1785 | ewarn "the libraries are not being removed. You need to run revdep-rebuild" |
1792 | ewarn "the libraries are not being removed. You need to run revdep-rebuild" |
| 1786 | ewarn "in order to remove these old dependencies. If you do not have this" |
1793 | ewarn "in order to remove these old dependencies. If you do not have this" |
| 1787 | ewarn "helper program, simply emerge the 'gentoolkit' package." |
1794 | ewarn "helper program, simply emerge the 'gentoolkit' package." |
| 1788 | ewarn |
1795 | ewarn |
| 1789 | fi |
1796 | fi |
| 1790 | ewarn " # revdep-rebuild --library ${lib##*/}" |
1797 | ewarn " # revdep-rebuild --library '${lib}'" |
| 1791 | done |
1798 | done |
| 1792 | if [[ ${notice} -eq 1 ]] ; then |
1799 | if [[ ${notice} -eq 1 ]] ; then |
| 1793 | ewarn |
1800 | ewarn |
| 1794 | ewarn "Once you've finished running revdep-rebuild, it should be safe to" |
1801 | ewarn "Once you've finished running revdep-rebuild, it should be safe to" |
| 1795 | ewarn "delete the old libraries. Here is a copy & paste for the lazy:" |
1802 | ewarn "delete the old libraries. Here is a copy & paste for the lazy:" |
| … | |
… | |
| 1964 | |
1971 | |
| 1965 | # find usr/share/doc -exec gzip {} + |
1972 | # find usr/share/doc -exec gzip {} + |
| 1966 | # ecompressdir --ignore /usr/share/doc/${PF}/html |
1973 | # ecompressdir --ignore /usr/share/doc/${PF}/html |
| 1967 | # ecompressdir --queue /usr/share/doc |
1974 | # ecompressdir --queue /usr/share/doc |
| 1968 | #} |
1975 | #} |
|
|
1976 | |
|
|
1977 | # @FUNCTION: path_exists |
|
|
1978 | # @USAGE: [-a|-o] <paths> |
|
|
1979 | # @DESCRIPTION: |
|
|
1980 | # Check if the specified paths exist. Works for all types of paths |
|
|
1981 | # (files/dirs/etc...). The -a and -o flags control the requirements |
|
|
1982 | # of the paths. They correspond to "and" and "or" logic. So the -a |
|
|
1983 | # flag means all the paths must exist while the -o flag means at least |
|
|
1984 | # one of the paths must exist. The default behavior is "and". If no |
|
|
1985 | # paths are specified, then the return value is "false". |
|
|
1986 | path_exists() { |
|
|
1987 | local opt=$1 |
|
|
1988 | [[ ${opt} == -[ao] ]] && shift || opt="-a" |
|
|
1989 | |
|
|
1990 | # no paths -> return false |
|
|
1991 | # same behavior as: [[ -e "" ]] |
|
|
1992 | [[ $# -eq 0 ]] && return 1 |
|
|
1993 | |
|
|
1994 | local p r=0 |
|
|
1995 | for p in "$@" ; do |
|
|
1996 | [[ -e ${p} ]] |
|
|
1997 | : $(( r += $? )) |
|
|
1998 | done |
|
|
1999 | |
|
|
2000 | case ${opt} in |
|
|
2001 | -a) return $(( r != 0 )) ;; |
|
|
2002 | -o) return $(( r == $# )) ;; |
|
|
2003 | esac |
|
|
2004 | } |