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

Diff of /eclass/eutils.eclass

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

Revision 1.349 Revision 1.351
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.351 2010/10/17 21:35:44 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.
1964 1964
1965# find usr/share/doc -exec gzip {} + 1965# find usr/share/doc -exec gzip {} +
1966# ecompressdir --ignore /usr/share/doc/${PF}/html 1966# ecompressdir --ignore /usr/share/doc/${PF}/html
1967# ecompressdir --queue /usr/share/doc 1967# ecompressdir --queue /usr/share/doc
1968#} 1968#}
1969
1970# @FUNCTION: path_exists
1971# @USAGE: [-a|-o] <paths>
1972# @DESCRIPTION:
1973# Check if the specified paths exist. Works for all types of paths
1974# (files/dirs/etc...). The -a and -o flags control the requirements
1975# of the paths. They correspond to "and" and "or" logic. So the -a
1976# flag means all the paths must exist while the -o flag means at least
1977# one of the paths must exist. The default behavior is "and". If no
1978# paths are specified, then the return value is "false".
1979path_exists() {
1980 local opt=$1
1981 [[ ${opt} == -[ao] ]] && shift || opt="-a"
1982
1983 # no paths -> return false
1984 # same behavior as: [[ -e "" ]]
1985 [[ $# -eq 0 ]] && return 1
1986
1987 local p r=0
1988 for p in "$@" ; do
1989 [[ -e ${p} ]]
1990 : $(( r += $? ))
1991 done
1992
1993 case ${opt} in
1994 -a) return $(( r != 0 )) ;;
1995 -o) return $(( r == $# )) ;;
1996 esac
1997}

Legend:
Removed from v.1.349  
changed lines
  Added in v.1.351

  ViewVC Help
Powered by ViewVC 1.1.20