/[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.8 - (hide annotations) (download)
Mon Jul 22 20:06:31 2013 UTC (8 months, 3 weeks ago) by grobian
Branch: MAIN
Changes since 1.7: +7 -4 lines
Another attempt at fixing bash-completion for Prefix, bug #477692#c9

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 grobian 1.8 # $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion-r1.eclass,v 1.7 2013/07/22 11:38:59 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     # _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion/completions
40     _bash-completion-r1_get_bashdir() {
41     debug-print-function ${FUNCNAME} "${@}"
42    
43 ssuominen 1.7 if $(tc-getPKG_CONFIG) --exists bash-completion; then
44 grobian 1.8 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 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.5 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 ssuominen 1.6 debug-print-function ${FUNCNAME} "${@}"
73 ssuominen 1.5
74 ssuominen 1.6 _bash-completion-r1_get_bashdir helpersdir /usr/share/bash-completion/helpers
75 mgorny 1.4 }
76    
77     # @FUNCTION: get_bashcompdir
78     # @DESCRIPTION:
79 ssuominen 1.5 # Get the bash-completion completions directory.
80 mgorny 1.4 get_bashcompdir() {
81     debug-print-function ${FUNCNAME} "${@}"
82    
83 grobian 1.8 echo "${EPREFIX}$(_bash-completion-r1_get_bashcompdir)"
84 mgorny 1.4 }
85    
86 ssuominen 1.5 # @FUNCTION: get_bashhelpersdir
87     # @INTERNAL
88     # @DESCRIPTION:
89     # Get the bash-completion helpers directory.
90     get_bashhelpersdir() {
91     debug-print-function ${FUNCNAME} "${@}"
92    
93 grobian 1.8 echo "${EPREFIX}$(_bash-completion-r1_get_bashhelpersdir)"
94 ssuominen 1.5 }
95    
96 mgorny 1.1 # @FUNCTION: dobashcomp
97     # @USAGE: file [...]
98     # @DESCRIPTION:
99     # Install bash-completion files passed as args. Has EAPI-dependant failure
100     # behavior (like doins).
101     dobashcomp() {
102     debug-print-function ${FUNCNAME} "${@}"
103    
104     (
105 mgorny 1.4 insinto "$(_bash-completion-r1_get_bashcompdir)"
106 mgorny 1.1 doins "${@}"
107     )
108     }
109    
110     # @FUNCTION: newbashcomp
111     # @USAGE: file newname
112     # @DESCRIPTION:
113     # Install bash-completion file under a new name. Has EAPI-dependant failure
114     # behavior (like newins).
115     newbashcomp() {
116     debug-print-function ${FUNCNAME} "${@}"
117    
118     (
119 mgorny 1.4 insinto "$(_bash-completion-r1_get_bashcompdir)"
120 mgorny 1.1 newins "${@}"
121     )
122     }

  ViewVC Help
Powered by ViewVC 1.1.20