/[gentoo-x86]/eclass/bash-completion-r1.eclass
Gentoo

Diff of /eclass/bash-completion-r1.eclass

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

Revision 1.3 Revision 1.8
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2013 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/bash-completion-r1.eclass,v 1.3 2012/09/27 16:35:41 axs Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion-r1.eclass,v 1.8 2013/07/22 20:06:31 grobian Exp $
4 4
5# @ECLASS: bash-completion-r1.eclass 5# @ECLASS: bash-completion-r1.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# mgorny@gentoo.org 7# mgorny@gentoo.org
8# @BLURB: A few quick functions to install bash-completion files 8# @BLURB: A few quick functions to install bash-completion files
9# @EXAMPLE: 9# @EXAMPLE:
10# 10#
11# @CODE 11# @CODE
12# EAPI=4 12# EAPI=5
13#
14# src_configure() {
15# econf \
16# --with-bash-completion-dir="$(get_bashcompdir)"
17# }
13# 18#
14# src_install() { 19# src_install() {
15# default 20# default
16# 21#
17# newbashcomp contrib/${PN}.bash-completion ${PN} 22# newbashcomp contrib/${PN}.bash-completion ${PN}
18# } 23# }
19# @CODE 24# @CODE
20 25
26inherit toolchain-funcs
27
21case ${EAPI:-0} in 28case ${EAPI:-0} in
22 0|1|2|3|4|5) ;; 29 0|1|2|3|4|5) ;;
23 *) die "EAPI ${EAPI} unsupported (yet)." 30 *) die "EAPI ${EAPI} unsupported (yet)."
24esac 31esac
32
33# @FUNCTION: _bash-completion-r1_get_bashdir
34# @INTERNAL
35# @DESCRIPTION:
36# First argument is name of the string in bash-completion.pc
37# Second argument is the fallback directory if the string is not found
38# @EXAMPLE:
39# _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion/completions
40_bash-completion-r1_get_bashdir() {
41 debug-print-function ${FUNCNAME} "${@}"
42
43 if $(tc-getPKG_CONFIG) --exists bash-completion; then
44 local pcbc="$($(tc-getPKG_CONFIG) --variable=$1 bash-completion)"
45 # we need to return unprefixed, so strip from what pkg-config returns
46 # to us, bug #477692
47 echo "${pcdb#${EPREFIX}}"
48 else
49 echo $2
50 fi
51}
52
53# @FUNCTION: _bash-completion-r1_get_bashcompdir
54# @INTERNAL
55# @DESCRIPTION:
56# Get unprefixed bash-completion completions directory.
57_bash-completion-r1_get_bashcompdir() {
58 debug-print-function ${FUNCNAME} "${@}"
59
60 if has_version '<app-shells/bash-completion-2.1-r1'; then
61 _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion
62 else
63 _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion/completions
64 fi
65}
66
67# @FUNCTION: _bash-completion-r1_get_helpersdir
68# @INTERNAL
69# @DESCRIPTION:
70# Get unprefixed bash-completion helpers directory.
71_bash-completion-r1_get_bashhelpersdir() {
72 debug-print-function ${FUNCNAME} "${@}"
73
74 _bash-completion-r1_get_bashdir helpersdir /usr/share/bash-completion/helpers
75}
76
77# @FUNCTION: get_bashcompdir
78# @DESCRIPTION:
79# Get the bash-completion completions directory.
80get_bashcompdir() {
81 debug-print-function ${FUNCNAME} "${@}"
82
83 echo "${EPREFIX}$(_bash-completion-r1_get_bashcompdir)"
84}
85
86# @FUNCTION: get_bashhelpersdir
87# @INTERNAL
88# @DESCRIPTION:
89# Get the bash-completion helpers directory.
90get_bashhelpersdir() {
91 debug-print-function ${FUNCNAME} "${@}"
92
93 echo "${EPREFIX}$(_bash-completion-r1_get_bashhelpersdir)"
94}
25 95
26# @FUNCTION: dobashcomp 96# @FUNCTION: dobashcomp
27# @USAGE: file [...] 97# @USAGE: file [...]
28# @DESCRIPTION: 98# @DESCRIPTION:
29# Install bash-completion files passed as args. Has EAPI-dependant failure 99# Install bash-completion files passed as args. Has EAPI-dependant failure
30# behavior (like doins). 100# behavior (like doins).
31dobashcomp() { 101dobashcomp() {
32 debug-print-function ${FUNCNAME} "${@}" 102 debug-print-function ${FUNCNAME} "${@}"
33 103
34 ( 104 (
35 insinto /usr/share/bash-completion 105 insinto "$(_bash-completion-r1_get_bashcompdir)"
36 doins "${@}" 106 doins "${@}"
37 ) 107 )
38} 108}
39 109
40# @FUNCTION: newbashcomp 110# @FUNCTION: newbashcomp
44# behavior (like newins). 114# behavior (like newins).
45newbashcomp() { 115newbashcomp() {
46 debug-print-function ${FUNCNAME} "${@}" 116 debug-print-function ${FUNCNAME} "${@}"
47 117
48 ( 118 (
49 insinto /usr/share/bash-completion 119 insinto "$(_bash-completion-r1_get_bashcompdir)"
50 newins "${@}" 120 newins "${@}"
51 ) 121 )
52} 122}

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.20