abuild.in: add default bashcomp, zshcomp and fishcomp functions

This commit is contained in:
Leo 2019-05-02 16:14:46 -03:00 committed by Natanael Copa
parent d5f4982a9a
commit d5826968b7
1 changed files with 65 additions and 2 deletions

View File

@ -552,12 +552,23 @@ subpkg_set() {
[ "$_splitarch" = "$1" ] && _splitarch=""
subpkgsplit=${_splitarch%%:*}
[ -z "$subpkgsplit" ] && subpkgsplit="${subpkgname##*-}"
if [ -z "$subpkgsplit" ]; then
if is_bashcomp_pkg "$subpkgname"; then
subpkgsplit=bashcomp
elif is_zshcomp_pkg "$subpkgname"; then
subpkgsplit=zshcomp
elif is_fishcomp_pkg "$subpkgname"; then
subpkgsplit=fishcomp
else
subpkgsplit="${subpkgname##*-}"
fi
fi
subpkgarch=${_splitarch#*:}
if [ "$subpkgarch" = "$_splitarch" -o -z "$subpkgarch" ]; then
case "$subpkgname" in
*-doc | *-openrc | *-lang | *-lang-*) subpkgarch="noarch" ;;
*-doc | *-openrc | *-lang | *-lang-* | *sh-completion) subpkgarch="noarch" ;;
*) subpkgarch="$pkgarch" ;;
esac
fi
@ -1181,6 +1192,21 @@ is_openrc_pkg() {
test "${1%-openrc}" != "$1"
}
# returns true if this is the -bash-completion package
is_bashcomp_pkg() {
test "${1%-bash-completion}" != "$1"
}
# returns true if this is the -zsh-completion package
is_zshcomp_pkg() {
test "${1%-zsh-completion}" != "$1"
}
# returns true if this is the -fish-completion package
is_fishcomp_pkg() {
test "${1%-fish-completion}" != "$1"
}
# check that noarch is set if needed
archcheck() {
options_has "!archcheck" && return 0
@ -1880,6 +1906,43 @@ openrc() {
default_openrc
}
default_bashcomp() {
depends=""
pkgdesc="Bash completions for $pkgname"
install_if="$pkgname=$pkgver-r$pkgrel bash-completion"
cd "$pkgdir" || return 0
amove /usr/share/bash-completion/completions
}
bashcomp() {
default_bashcomp
}
default_zshcomp() {
depends=""
pkgdesc="Zsh completions for $pkgname"
install_if="$pkgname=$pkgver-r$pkgrel zsh"
amove usr/share/zsh/site-functions
}
zshcomp() {
default_zshcomp
}
default_fishcomp() {
depends=""
pkgdesc="Fish completions for $pkgname"
install_if="$pkgname=$pkgver-r$pkgrel fish"
cd "$pkgdir" || return 0
amove usr/share/fish/completions
}
fishcomp() {
default_fishcomp
}
is_function() {
type "$1" 2>&1 | head -n 1 | egrep -q "is a (shell )?function"