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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (hide annotations) (download)
Wed Jan 22 19:41:21 2014 UTC (6 months ago) by ssuominen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.11: +2 -2 lines
supress the pkg-config command output

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

  ViewVC Help
Powered by ViewVC 1.1.20