Commit d5826968 authored by Leo's avatar Leo Committed by Natanael Copa

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

parent d5f4982a
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment