/[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.1 Revision 1.6
1# Copyright 1999-2011 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.1 2011/09/08 16:25:54 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion-r1.eclass,v 1.6 2013/07/22 11:28:42 ssuominen 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
25
26inherit toolchain-funcs
27
28case ${EAPI:-0} in
29 0|1|2|3|4|5) ;;
30 *) die "EAPI ${EAPI} unsupported (yet)."
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 echo "$($(tc-getPKG_CONFIG) --variable=$1 bash-completion)"
45 else
46 echo $2
47 fi
48}
49
50# @FUNCTION: _bash-completion-r1_get_bashcompdir
51# @INTERNAL
52# @DESCRIPTION:
53# Get unprefixed bash-completion completions directory.
54_bash-completion-r1_get_bashcompdir() {
55 debug-print-function ${FUNCNAME} "${@}"
56
57 if has_version '<app-shells/bash-completion-2.1-r1'; then
58 _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion
59 else
60 _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion/completions
61 fi
62}
63
64# @FUNCTION: _bash-completion-r1_get_helpersdir
65# @INTERNAL
66# @DESCRIPTION:
67# Get unprefixed bash-completion helpers directory.
68_bash-completion-r1_get_bashhelpersdir() {
69 debug-print-function ${FUNCNAME} "${@}"
70
71 _bash-completion-r1_get_bashdir helpersdir /usr/share/bash-completion/helpers
72}
73
74# @FUNCTION: get_bashcompdir
75# @DESCRIPTION:
76# Get the bash-completion completions directory.
77get_bashcompdir() {
78 debug-print-function ${FUNCNAME} "${@}"
79
80 echo "$(_bash-completion-r1_get_bashcompdir)"
81}
82
83# @FUNCTION: get_bashhelpersdir
84# @INTERNAL
85# @DESCRIPTION:
86# Get the bash-completion helpers directory.
87get_bashhelpersdir() {
88 debug-print-function ${FUNCNAME} "${@}"
89
90 echo "$(_bash-completion-r1_get_bashhelpersdir)"
91}
20 92
21# @FUNCTION: dobashcomp 93# @FUNCTION: dobashcomp
22# @USAGE: file [...] 94# @USAGE: file [...]
23# @DESCRIPTION: 95# @DESCRIPTION:
24# Install bash-completion files passed as args. Has EAPI-dependant failure 96# Install bash-completion files passed as args. Has EAPI-dependant failure
25# behavior (like doins). 97# behavior (like doins).
26dobashcomp() { 98dobashcomp() {
27 debug-print-function ${FUNCNAME} "${@}" 99 debug-print-function ${FUNCNAME} "${@}"
28 100
29 ( 101 (
30 insinto /usr/share/bash-completion 102 insinto "$(_bash-completion-r1_get_bashcompdir)"
31 doins "${@}" 103 doins "${@}"
32 ) 104 )
33} 105}
34 106
35# @FUNCTION: newbashcomp 107# @FUNCTION: newbashcomp
39# behavior (like newins). 111# behavior (like newins).
40newbashcomp() { 112newbashcomp() {
41 debug-print-function ${FUNCNAME} "${@}" 113 debug-print-function ${FUNCNAME} "${@}"
42 114
43 ( 115 (
44 insinto /usr/share/bash-completion 116 insinto "$(_bash-completion-r1_get_bashcompdir)"
45 newins "${@}" 117 newins "${@}"
46 ) 118 )
47} 119}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.20