summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo <thinkabit.ukim@gmail.com>2019-05-02 16:14:46 -0300
committerNatanael Copa <ncopa@alpinelinux.org>2020-01-28 08:57:40 +0000
commitd5826968b713123a4f51d3dec1adb1225d0e194f (patch)
tree05c5f6fefd2d277ec3549ecd11b2d0f0e0c42623
parentd5f4982a9add40b1a20539b6421dbaf51da10306 (diff)
downloadabuild-d5826968b713123a4f51d3dec1adb1225d0e194f.tar.bz2
abuild-d5826968b713123a4f51d3dec1adb1225d0e194f.tar.xz
abuild.in: add default bashcomp, zshcomp and fishcomp functions
-rw-r--r--abuild.in67
1 files changed, 65 insertions, 2 deletions
diff --git a/abuild.in b/abuild.in
index c79596b..cb2309c 100644
--- a/abuild.in
+++ b/abuild.in
@@ -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"