1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 BASHCOMP_P=bashcomp-2.0.3
7 PYTHON_COMPAT=( python3_{6,7} )
8 inherit bash-completion-r1 python-any-r1
10 DESCRIPTION="Programmable Completion for bash"
11 HOMEPAGE="https://github.com/scop/bash-completion"
13 https://github.com/scop/bash-completion/releases/download/${PV}/${P}.tar.xz
14 eselect? ( https://github.com/mgorny/bashcomp2/releases/download/v${BASHCOMP_P#*-}/${BASHCOMP_P}.tar.gz )"
18 KEYWORDS="~alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris"
22 # completion collision with net-fs/mc
23 RDEPEND=">=app-shells/bash-4.3_p30-r1:0
32 $(python_gen_any_dep '
33 dev-python/pexpect[${PYTHON_USEDEP}]
34 dev-python/pytest[${PYTHON_USEDEP}]
37 PDEPEND=">=app-shells/gentoo-bashcomp-20140911"
40 # Remove unwanted completions.
41 local strip_completions=(
42 # Slackware package stuff, quite generic names cause collisions
43 # (e.g. with sys-apps/pacman)
44 explodepkg installpkg makepkg pkgtool removepkg upgradepkg
46 # Debian/Red Hat network stuff
47 ifdown ifup ifquery ifstatus
49 # Installed in app-editors/vim-core
52 # Now-dead symlinks to deprecated completions
55 if [[ ${ARCH} != *-fbsd && ${ARCH} != *-freebsd ]]; then
57 freebsd-update kldload kldunload portinstall portsnap
58 pkg_deinstall pkg_delete pkg_info
63 for file in "${strip_completions[@]}"; do
64 rm "${ED}"/usr/share/bash-completion/completions/${file} ||
65 die "stripping ${file} failed"
68 # remove deprecated completions (moved to other packages)
69 rm "${ED}"/usr/share/bash-completion/completions/_* || die
73 has_version "dev-python/pexpect[${PYTHON_USEDEP}]" &&
74 has_version "dev-python/pytest[${PYTHON_USEDEP}]"
78 use test && python-any-r1_pkg_setup
83 eapply "${WORKDIR}/${BASHCOMP_P}/bash-completion-blacklist-support.patch"
84 # Bug 543100, update bug 601194
85 eapply "${FILESDIR}/${PN}-2.1-escape-characters-r1.patch"
90 # Tests need an interactive shell, #477066
92 # http://pkgs.fedoraproject.org/cgit/rpms/bash-completion.git/tree/bash-completion.spec
94 # real-time output of the log ;-)
95 touch "${T}/dtach-test.log" || die
96 tail -f "${T}/dtach-test.log" &
99 # override the default expect timeout and buffer size to avoid tests
100 # failing randomly due to cold cache, busy system or just more output
101 # than upstream anticipated (they run tests on pristine docker
102 # installs of binary distros)
103 nonfatal dtach -N "${T}/dtach.sock" \
104 bash -c 'emake check RUNTESTFLAGS="OPT_TIMEOUT=300 OPT_BUFFER_SIZE=1000000" PYTESTFLAGS="-vv" \
105 &> "${T}"/dtach-test.log; echo ${?} > "${T}"/dtach-test.out'
108 [[ -f ${T}/dtach-test.out ]] || die "Unable to run tests"
109 [[ $(<"${T}"/dtach-test.out) == 0 ]] || die "Tests failed"
113 # work-around race conditions, bug #526996
114 mkdir -p "${ED}"/usr/share/bash-completion/{completions,helpers} || die
116 emake DESTDIR="${D}" profiledir="${EPREFIX}"/etc/bash/bashrc.d install
120 dodoc AUTHORS CHANGES CONTRIBUTING.md README.md
122 # install the eselect module
124 insinto /usr/share/eselect/modules
125 doins "${WORKDIR}/${BASHCOMP_P}/bashcomp.eselect"
126 doman "${WORKDIR}/${BASHCOMP_P}/bashcomp.eselect.5"
132 for v in ${REPLACING_VERSIONS}; do
133 if ver_test "${v}" -lt 2.1-r90; then
134 ewarn "For bash-completion autoloader to work, all completions need to"
135 ewarn "be installed in /usr/share/bash-completion/completions. You may"
136 ewarn "need to rebuild packages that installed completions in the old"
137 ewarn "location. You can do this using:"
139 ewarn "$ find ${EPREFIX}/usr/share/bash-completion -maxdepth 1 -type f '!' -name 'bash_completion' -exec emerge -1v {} +"
141 ewarn "After the rebuild, you should remove the old setup symlinks:"
143 ewarn "$ find ${EPREFIX}/etc/bash_completion.d -type l -delete"
147 if has_version 'app-shells/zsh'; then
149 elog "If you are interested in using the provided bash completion functions with"
150 elog "zsh, valuable tips on the effective use of bashcompinit are available:"
151 elog " http://www.zsh.org/mla/workers/2003/msg00046.html"