/[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.6 - (hide annotations) (download)
Mon Jul 22 11:28:42 2013 UTC (13 months, 4 weeks ago) by ssuominen
Branch: MAIN
Changes since 1.5: +7 -7 lines
Remove use of EPREFIX wrt #477692 to avoid collision with Portage helpers

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.6 # $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion-r1.eclass,v 1.5 2013/07/15 23:54:03 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     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 mgorny 1.4 # @FUNCTION: _bash-completion-r1_get_bashcompdir
51     # @INTERNAL
52     # @DESCRIPTION:
53 ssuominen 1.5 # Get unprefixed bash-completion completions directory.
54 mgorny 1.4 _bash-completion-r1_get_bashcompdir() {
55     debug-print-function ${FUNCNAME} "${@}"
56    
57 ssuominen 1.5 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 ssuominen 1.6 debug-print-function ${FUNCNAME} "${@}"
70 ssuominen 1.5
71 ssuominen 1.6 _bash-completion-r1_get_bashdir helpersdir /usr/share/bash-completion/helpers
72 mgorny 1.4 }
73    
74     # @FUNCTION: get_bashcompdir
75     # @DESCRIPTION:
76 ssuominen 1.5 # Get the bash-completion completions directory.
77 mgorny 1.4 get_bashcompdir() {
78     debug-print-function ${FUNCNAME} "${@}"
79    
80 ssuominen 1.6 echo "$(_bash-completion-r1_get_bashcompdir)"
81 mgorny 1.4 }
82    
83 ssuominen 1.5 # @FUNCTION: get_bashhelpersdir
84     # @INTERNAL
85     # @DESCRIPTION:
86     # Get the bash-completion helpers directory.
87     get_bashhelpersdir() {
88     debug-print-function ${FUNCNAME} "${@}"
89    
90 ssuominen 1.6 echo "$(_bash-completion-r1_get_bashhelpersdir)"
91 ssuominen 1.5 }
92    
93 mgorny 1.1 # @FUNCTION: dobashcomp
94     # @USAGE: file [...]
95     # @DESCRIPTION:
96     # Install bash-completion files passed as args. Has EAPI-dependant failure
97     # behavior (like doins).
98     dobashcomp() {
99     debug-print-function ${FUNCNAME} "${@}"
100    
101     (
102 mgorny 1.4 insinto "$(_bash-completion-r1_get_bashcompdir)"
103 mgorny 1.1 doins "${@}"
104     )
105     }
106    
107     # @FUNCTION: newbashcomp
108     # @USAGE: file newname
109     # @DESCRIPTION:
110     # Install bash-completion file under a new name. Has EAPI-dependant failure
111     # behavior (like newins).
112     newbashcomp() {
113     debug-print-function ${FUNCNAME} "${@}"
114    
115     (
116 mgorny 1.4 insinto "$(_bash-completion-r1_get_bashcompdir)"
117 mgorny 1.1 newins "${@}"
118     )
119     }

  ViewVC Help
Powered by ViewVC 1.1.20