1 |
# Copyright 1999-2011 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion.eclass,v 1.27 2011/08/22 04:46:31 vapier Exp $ |
4 |
|
5 |
# @DEPRECATED |
6 |
# This eclass has been superseded by bash-completion-r1 eclass. |
7 |
# Please modify your ebuilds to use that one instead. |
8 |
|
9 |
# @ECLASS: bash-completion.eclass |
10 |
# @MAINTAINER: |
11 |
# shell-tools@gentoo.org. |
12 |
# @AUTHOR: |
13 |
# Original author: Aaron Walker <ka0ttic@gentoo.org> |
14 |
# @BLURB: An Interface for installing contributed bash-completion scripts |
15 |
# @DESCRIPTION: |
16 |
# Simple eclass that provides an interface for installing |
17 |
# contributed (ie not included in bash-completion proper) |
18 |
# bash-completion scripts. |
19 |
# |
20 |
# Note: this eclass has been deprecated in favor of bash-completion-r1. Please |
21 |
# use that one instead. |
22 |
|
23 |
# @ECLASS-VARIABLE: BASHCOMPLETION_NAME |
24 |
# @DESCRIPTION: |
25 |
# Install the completion script with this name (see also dobashcompletion) |
26 |
|
27 |
# @ECLASS-VARIABLE: BASHCOMPFILES |
28 |
# @DESCRIPTION: |
29 |
# Space delimited list of files to install if dobashcompletion is called without |
30 |
# arguments. |
31 |
|
32 |
inherit eutils |
33 |
|
34 |
EXPORT_FUNCTIONS pkg_postinst |
35 |
|
36 |
IUSE="bash-completion" |
37 |
|
38 |
# Allow eclass to be inherited by eselect without a circular dependency |
39 |
if [[ ${CATEGORY}/${PN} != app-admin/eselect ]]; then |
40 |
RDEPEND="bash-completion? ( app-admin/eselect )" |
41 |
fi |
42 |
PDEPEND="bash-completion? ( app-shells/bash-completion )" |
43 |
|
44 |
# @FUNCTION: dobashcompletion |
45 |
# @USAGE: [file] [new_file] |
46 |
# @DESCRIPTION: |
47 |
# The first argument is the location of the bash-completion script to install, |
48 |
# and is required if BASHCOMPFILES is not set. The second argument is the name |
49 |
# the script will be installed as. If BASHCOMPLETION_NAME is set, it overrides |
50 |
# the second argument. If no second argument is given and BASHCOMPLETION_NAME |
51 |
# is not set, it will default to ${PN}. |
52 |
dobashcompletion() { |
53 |
local f |
54 |
|
55 |
eqawarn "bash-completion.eclass has been deprecated." |
56 |
eqawarn "Please update your ebuilds to use bash-completion-r1 instead." |
57 |
|
58 |
if [[ -z ${1} && -z ${BASHCOMPFILES} ]]; then |
59 |
die "Usage: dobashcompletion [file] [new file]" |
60 |
fi |
61 |
|
62 |
if use bash-completion; then |
63 |
insinto /usr/share/bash-completion |
64 |
if [[ -n ${1} ]]; then |
65 |
[[ -z ${BASHCOMPLETION_NAME} ]] && BASHCOMPLETION_NAME="${2:-${PN}}" |
66 |
newins "${1}" "${BASHCOMPLETION_NAME}" || die "Failed to install ${1}" |
67 |
else |
68 |
set -- ${BASHCOMPFILES} |
69 |
for f in "$@"; do |
70 |
if [[ -e ${f} ]]; then |
71 |
doins "${f}" || die "Failed to install ${f}" |
72 |
fi |
73 |
done |
74 |
fi |
75 |
fi |
76 |
} |
77 |
|
78 |
# @FUNCTION: bash-completion_pkg_postinst |
79 |
# @DESCRIPTION: |
80 |
# The bash-completion pkg_postinst function, which is exported |
81 |
bash-completion_pkg_postinst() { |
82 |
local f |
83 |
|
84 |
if use bash-completion ; then |
85 |
elog "The following bash-completion scripts have been installed:" |
86 |
if [[ -n ${BASHCOMPLETION_NAME} ]]; then |
87 |
elog " ${BASHCOMPLETION_NAME}" |
88 |
else |
89 |
set -- ${BASHCOMPFILES} |
90 |
for f in "$@"; do |
91 |
elog " $(basename ${f})" |
92 |
done |
93 |
fi |
94 |
elog |
95 |
elog "To enable command-line completion on a per-user basis run:" |
96 |
elog " eselect bashcomp enable <script>" |
97 |
elog |
98 |
elog "To enable command-line completion system-wide run:" |
99 |
elog " eselect bashcomp enable --global <script>" |
100 |
fi |
101 |
} |