app-shells/bash-completion: arm64 stable (bug #709762)
[gentoo.git] / app-shells / bash-completion / bash-completion-2.10.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 BASHCOMP_P=bashcomp-2.0.3
7 PYTHON_COMPAT=( python3_{6,7} )
8 inherit bash-completion-r1 python-any-r1
9
10 DESCRIPTION="Programmable Completion for bash"
11 HOMEPAGE="https://github.com/scop/bash-completion"
12 SRC_URI="
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 )"
15
16 LICENSE="GPL-2+"
17 SLOT="0"
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"
19 IUSE="+eselect test"
20 RESTRICT="test"
21
22 # completion collision with net-fs/mc
23 RDEPEND=">=app-shells/bash-4.3_p30-r1:0
24         sys-apps/miscfiles
25         !!net-fs/mc"
26 DEPEND="
27         test? (
28                 ${RDEPEND}
29                 app-misc/dtach
30                 dev-util/dejagnu
31                 dev-tcltk/tcllib
32                 $(python_gen_any_dep '
33                         dev-python/pexpect[${PYTHON_USEDEP}]
34                         dev-python/pytest[${PYTHON_USEDEP}]
35                 ')
36         )"
37 PDEPEND=">=app-shells/gentoo-bashcomp-20140911"
38
39 strip_completions() {
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
45
46                 # Debian/Red Hat network stuff
47                 ifdown ifup ifquery ifstatus
48
49                 # Installed in app-editors/vim-core
50                 xxd
51
52                 # Now-dead symlinks to deprecated completions
53                 hd ncal
54         )
55         if [[ ${ARCH} != *-fbsd && ${ARCH} != *-freebsd ]]; then
56                 strip_completions+=(
57                         freebsd-update kldload kldunload portinstall portsnap
58                         pkg_deinstall pkg_delete pkg_info
59                 )
60         fi
61
62         local file
63         for file in "${strip_completions[@]}"; do
64                 rm "${ED}"/usr/share/bash-completion/completions/${file} ||
65                         die "stripping ${file} failed"
66         done
67
68         # remove deprecated completions (moved to other packages)
69         rm "${ED}"/usr/share/bash-completion/completions/_* || die
70 }
71
72 python_check_deps() {
73         has_version "dev-python/pexpect[${PYTHON_USEDEP}]" &&
74         has_version "dev-python/pytest[${PYTHON_USEDEP}]"
75 }
76
77 pkg_setup() {
78         use test && python-any-r1_pkg_setup
79 }
80
81 src_prepare() {
82         use eselect &&
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"
86         eapply_user
87 }
88
89 src_test() {
90         # Tests need an interactive shell, #477066
91         # idea stolen from:
92         # http://pkgs.fedoraproject.org/cgit/rpms/bash-completion.git/tree/bash-completion.spec
93
94         # real-time output of the log ;-)
95         touch "${T}/dtach-test.log" || die
96         tail -f "${T}/dtach-test.log" &
97         local tail_pid=${!}
98
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'
106
107         kill "${tail_pid}"
108         [[ -f ${T}/dtach-test.out ]] || die "Unable to run tests"
109         [[ $(<"${T}"/dtach-test.out) == 0 ]] || die "Tests failed"
110 }
111
112 src_install() {
113         # work-around race conditions, bug #526996
114         mkdir -p "${ED}"/usr/share/bash-completion/{completions,helpers} || die
115
116         emake DESTDIR="${D}" profiledir="${EPREFIX}"/etc/bash/bashrc.d install
117
118         strip_completions
119
120         dodoc AUTHORS CHANGES CONTRIBUTING.md README.md
121
122         # install the eselect module
123         if use eselect; then
124                 insinto /usr/share/eselect/modules
125                 doins "${WORKDIR}/${BASHCOMP_P}/bashcomp.eselect"
126                 doman "${WORKDIR}/${BASHCOMP_P}/bashcomp.eselect.5"
127         fi
128 }
129
130 pkg_postinst() {
131         local v
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:"
138                         ewarn
139                         ewarn "$ find ${EPREFIX}/usr/share/bash-completion -maxdepth 1 -type f '!' -name 'bash_completion' -exec emerge -1v {} +"
140                         ewarn
141                         ewarn "After the rebuild, you should remove the old setup symlinks:"
142                         ewarn
143                         ewarn "$ find ${EPREFIX}/etc/bash_completion.d -type l -delete"
144                 fi
145         done
146
147         if has_version 'app-shells/zsh'; then
148                 elog
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"
152                 elog
153         fi
154 }