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