1 |
dirtyepic 11/03/31 04:13:51 |
2 |
|
3 |
Modified: bash-completion.eclass |
4 |
Log: |
5 |
Add support for installing multiple bash-completion files. (bug #356585) |
6 |
|
7 |
Revision Changes Path |
8 |
1.25 eclass/bash-completion.eclass |
9 |
|
10 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/bash-completion.eclass?rev=1.25&view=markup |
11 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/bash-completion.eclass?rev=1.25&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/bash-completion.eclass?r1=1.24&r2=1.25 |
13 |
|
14 |
Index: bash-completion.eclass |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-x86/eclass/bash-completion.eclass,v |
17 |
retrieving revision 1.24 |
18 |
retrieving revision 1.25 |
19 |
diff -u -r1.24 -r1.25 |
20 |
--- bash-completion.eclass 7 Apr 2010 04:20:46 -0000 1.24 |
21 |
+++ bash-completion.eclass 31 Mar 2011 04:13:51 -0000 1.25 |
22 |
@@ -1,6 +1,6 @@ |
23 |
# Copyright 1999-2010 Gentoo Foundation |
24 |
# Distributed under the terms of the GNU General Public License v2 |
25 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion.eclass,v 1.24 2010/04/07 04:20:46 darkside Exp $ |
26 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion.eclass,v 1.25 2011/03/31 04:13:51 dirtyepic Exp $ |
27 |
|
28 |
# @ECLASS: bash-completion.eclass |
29 |
# @MAINTAINER: |
30 |
@@ -17,6 +17,11 @@ |
31 |
# @DESCRIPTION: |
32 |
# Install the completion script with this name (see also dobashcompletion) |
33 |
|
34 |
+# @ECLASS-VARIABLE: BASHCOMPFILES |
35 |
+# @DESCRIPTION: |
36 |
+# Space delimited list of files to install if dobashcompletion is called without |
37 |
+# arguments. |
38 |
+ |
39 |
EXPORT_FUNCTIONS pkg_postinst |
40 |
|
41 |
IUSE="bash-completion" |
42 |
@@ -28,22 +33,33 @@ |
43 |
PDEPEND="bash-completion? ( app-shells/bash-completion )" |
44 |
|
45 |
# @FUNCTION: dobashcompletion |
46 |
-# @USAGE: < file > [ new_file ] |
47 |
+# @USAGE: [file] [new_file] |
48 |
# @DESCRIPTION: |
49 |
-# First arg, <file>, is required and is the location of the bash-completion |
50 |
-# script to install. If the variable BASHCOMPLETION_NAME is set in the |
51 |
-# ebuild, dobashcompletion will install <file> as |
52 |
-# /usr/share/bash-completion/$BASHCOMPLETION_NAME. If it is not set, |
53 |
-# dobashcompletion will check if a second arg [new_file] was passed, installing as |
54 |
-# the specified name. Failing both these checks, dobashcompletion will |
55 |
-# install the file as /usr/share/bash-completion/${PN}. |
56 |
+# The first argument is the location of the bash-completion script to install, |
57 |
+# and is required if BASHCOMPFILES is not set. The second argument is the name |
58 |
+# the script will be installed as. If BASHCOMPLETION_NAME is set, it overrides |
59 |
+# the second argument. If no second argument is given and BASHCOMPLETION_NAME |
60 |
+# is not set, it will default to ${PN}. |
61 |
dobashcompletion() { |
62 |
- [[ -z "$1" ]] && die "usage: dobashcompletion <file> <new file>" |
63 |
- [[ -z "${BASHCOMPLETION_NAME}" ]] && BASHCOMPLETION_NAME="${2:-${PN}}" |
64 |
+ local f |
65 |
|
66 |
- if use bash-completion ; then |
67 |
+ if [[ -z ${1} && -z ${BASHCOMPFILES} ]]; then |
68 |
+ die "Usage: dobashcompletion [file] [new file]" |
69 |
+ fi |
70 |
+ |
71 |
+ if use bash-completion; then |
72 |
insinto /usr/share/bash-completion |
73 |
- newins "$1" "${BASHCOMPLETION_NAME}" || die "Failed to install $1" |
74 |
+ if [[ -n ${1} ]]; then |
75 |
+ [[ -z ${BASHCOMPLETION_NAME} ]] && BASHCOMPLETION_NAME="${2:-${PN}}" |
76 |
+ newins "${1}" "${BASHCOMPLETION_NAME}" || die "Failed to install ${1}" |
77 |
+ else |
78 |
+ set -- ${BASHCOMPFILES} |
79 |
+ for f in "$@"; do |
80 |
+ if [[ -e ${f} ]]; then |
81 |
+ doins "${f}" || die "Failed to install ${f}" |
82 |
+ fi |
83 |
+ done |
84 |
+ fi |
85 |
fi |
86 |
} |
87 |
|
88 |
@@ -51,16 +67,24 @@ |
89 |
# @DESCRIPTION: |
90 |
# The bash-completion pkg_postinst function, which is exported |
91 |
bash-completion_pkg_postinst() { |
92 |
+ local f |
93 |
+ |
94 |
if use bash-completion ; then |
95 |
- elog "In the case that you haven't yet enabled command-line completion" |
96 |
- elog "for ${PN}, you can run:" |
97 |
- elog |
98 |
- elog " eselect bashcomp enable ${BASHCOMPLETION_NAME:-${PN}}" |
99 |
+ elog "The following bash-completion scripts have been installed:" |
100 |
elog |
101 |
- elog "to install locally, or" |
102 |
+ if [[ -n ${BASHCOMPLETION_NAME} ]]; then |
103 |
+ elog " ${BASHCOMPLETION_NAME}" |
104 |
+ else |
105 |
+ set -- ${BASHCOMPFILES} |
106 |
+ for f in "$@"; do |
107 |
+ elog " $(basename ${f})" |
108 |
+ done |
109 |
+ fi |
110 |
elog |
111 |
- elog " eselect bashcomp enable --global ${BASHCOMPLETION_NAME:-${PN}}" |
112 |
+ elog "To enable command-line completion on a per-user basis run:" |
113 |
+ elog " eselect bashcomp enable <script>" |
114 |
elog |
115 |
- elog "to install system-wide." |
116 |
+ elog "To enable command-line completion system-wide run:" |
117 |
+ elog " eselect bashcomp enable --global <script>" |
118 |
fi |
119 |
} |