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

Diff of /eclass/eutils.eclass

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

Revision 1.373 Revision 1.378
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2012 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.373 2011/12/16 23:38:41 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.378 2012/01/31 06:36:19 ulm 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
135 # copy of "i" rather than the caller's copy. The __estack_xxx 135 # copy of "i" rather than the caller's copy. The __estack_xxx
136 # garbage is preferable to using $1/$2 everywhere as that is a 136 # garbage is preferable to using $1/$2 everywhere as that is a
137 # bit harder to read. 137 # bit harder to read.
138 local __estack_name="__ESTACK_$1__" ; shift 138 local __estack_name="__ESTACK_$1__" ; shift
139 local __estack_retvar=$1 ; shift 139 local __estack_retvar=$1 ; shift
140 eval local __estack_i=\${#${__estack_name}[@]} 140 eval local __estack_i=\${#${__estack_name}\[@\]}
141 # Don't warn -- let the caller interpret this as a failure 141 # Don't warn -- let the caller interpret this as a failure
142 # or as normal behavior (akin to `shift`) 142 # or as normal behavior (akin to `shift`)
143 [[ $(( --__estack_i )) -eq -1 ]] && return 1 143 [[ $(( --__estack_i )) -eq -1 ]] && return 1
144 144
145 if [[ -n ${__estack_retvar} ]] ; then 145 if [[ -n ${__estack_retvar} ]] ; then
146 eval ${__estack_retvar}=\"\${${__estack_name}[${__estack_i}]}\" 146 eval ${__estack_retvar}=\"\${${__estack_name}\[${__estack_i}\]}\"
147 fi 147 fi
148 eval unset ${__estack_name}[${__estack_i}] 148 eval unset ${__estack_name}\[${__estack_i}\]
149} 149}
150 150
151# @FUNCTION: eshopts_push 151# @FUNCTION: eshopts_push
152# @USAGE: [options to `set` or `shopt`] 152# @USAGE: [options to `set` or `shopt`]
153# @DESCRIPTION: 153# @DESCRIPTION:
160# rather than `set` as there are some options only available via that. 160# rather than `set` as there are some options only available via that.
161# 161#
162# A common example is to disable shell globbing so that special meaning/care 162# A common example is to disable shell globbing so that special meaning/care
163# may be used with variables/arguments to custom functions. That would be: 163# may be used with variables/arguments to custom functions. That would be:
164# @CODE 164# @CODE
165# eshopts_push -o noglob 165# eshopts_push -s noglob
166# for x in ${foo} ; do 166# for x in ${foo} ; do
167# if ...some check... ; then 167# if ...some check... ; then
168# eshopts_pop 168# eshopts_pop
169# return 0 169# return 0
170# fi 170# fi
171# done 171# done
172# eshopts_pop 172# eshopts_pop
173# @CODE 173# @CODE
174eshopts_push() { 174eshopts_push() {
175 # have to assume __ESHOPTS_SAVE__ isn't screwed with
176 # as a `declare -a` here will reset its value
177 if [[ $1 == -[su] ]] ; then 175 if [[ $1 == -[su] ]] ; then
178 estack_push eshopts "$(shopt -p)" 176 estack_push eshopts "$(shopt -p)"
179 [[ $# -eq 0 ]] && return 0 177 [[ $# -eq 0 ]] && return 0
180 shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*" 178 shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*"
181 else 179 else
544 local applied="${T}/epatch_user.applied" 542 local applied="${T}/epatch_user.applied"
545 [[ -e ${applied} ]] && return 2 543 [[ -e ${applied} ]] && return 2
546 544
547 # don't clobber any EPATCH vars that the parent might want 545 # don't clobber any EPATCH vars that the parent might want
548 local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches 546 local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches
549 for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}}; do 547 for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}; do
550 EPATCH_SOURCE=${base}/${CTARGET}/${check} 548 EPATCH_SOURCE=${base}/${CTARGET}/${check}
551 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check} 549 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check}
552 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check} 550 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check}
553 if [[ -d ${EPATCH_SOURCE} ]] ; then 551 if [[ -d ${EPATCH_SOURCE} ]] ; then
554 EPATCH_SOURCE=${EPATCH_SOURCE} \ 552 EPATCH_SOURCE=${EPATCH_SOURCE} \
609edos2unix() { 607edos2unix() {
610 [[ $# -eq 0 ]] && return 0 608 [[ $# -eq 0 ]] && return 0
611 sed -i 's/\r$//' -- "$@" || die 609 sed -i 's/\r$//' -- "$@" || die
612} 610}
613 611
614# Make a desktop file ! 612# @FUNCTION: make_desktop_entry
615# Great for making those icons in kde/gnome startmenu !
616# Amaze your friends ! Get the women ! Join today !
617#
618# make_desktop_entry(<command>, [name], [icon], [type], [fields]) 613# @USAGE: make_desktop_entry(<command>, [name], [icon], [type], [fields])
614# @DESCRIPTION:
615# Make a .desktop file.
619# 616#
617# @CODE
620# binary: what command does the app run with ? 618# binary: what command does the app run with ?
621# name: the name that will show up in the menu 619# name: the name that will show up in the menu
622# icon: give your little like a pretty little icon ... 620# icon: give your little like a pretty little icon ...
623# this can be relative (to /usr/share/pixmaps) or 621# this can be relative (to /usr/share/pixmaps) or
624# a full path to an icon 622# a full path to an icon
625# type: what kind of application is this ? for categories: 623# type: what kind of application is this?
624# for categories:
626# http://standards.freedesktop.org/menu-spec/latest/apa.html 625# http://standards.freedesktop.org/menu-spec/latest/apa.html
626# if unset, function tries to guess from package's category
627# fields: extra fields to append to the desktop file; a printf string 627# fields: extra fields to append to the desktop file; a printf string
628# @CODE
628make_desktop_entry() { 629make_desktop_entry() {
629 [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable" 630 [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable"
630 631
631 local exec=${1} 632 local exec=${1}
632 local name=${2:-${PN}} 633 local name=${2:-${PN}}

Legend:
Removed from v.1.373  
changed lines
  Added in v.1.378

  ViewVC Help
Powered by ViewVC 1.1.20