abuild: fix completions to vendor dir, warn on incorrect dir

Signed-off-by: Jakub Panek <me@panekj.dev>
This commit is contained in:
Jakub Panek 2023-06-22 04:04:50 +00:00 committed by alice
parent 38e84f9016
commit c26043748e
2 changed files with 57 additions and 2 deletions

View File

@ -939,6 +939,10 @@ prepare_subpackages() {
warning2 "Add \$pkgname-zsh-completion to subpackages"
fi
if [ -d "$pkgdir"/usr/share/fish/completions ]; then
warning "Found /usr/share/fish/completions"
warning2 "fish completions for programs should be located in /usr/share/fish/vendor_completions.d"
fi
if [ -d "$pkgdir"/usr/share/fish/vendor_completions.d ]; then
warning "Found /usr/share/fish/completions"
warning2 "Add \$pkgname-fish-completion to subpackages"
fi
@ -2179,7 +2183,15 @@ default_fishcomp() {
install_if="$pkgname=$pkgver-r$pkgrel fish"
cd "$pkgdir" || return 0
amove usr/share/fish/completions
if [ -d usr/share/fish/vendor_completions.d ]; then
amove usr/share/fish/vendor_completions.d
fi
if [ -d usr/share/fish/completions ]; then
warning "fish completions for programs should be in /usr/share/fish/vendor_completions.d"
amove usr/share/fish/completions
fi
}
fishcomp() {

View File

@ -44,7 +44,8 @@ init_tests \
abuild_setcap_binary_with_option \
abuild_command_provides \
abuild_gocache_dir \
abuild_cargo_home_dir
abuild_cargo_home_dir \
abuild_fish_comp_split
export ABUILD_SHAREDIR=$(atf_get_srcdir)/..
export ABUILD_CONF=/dev/null
@ -1018,3 +1019,45 @@ abuild_cargo_home_dir_body() {
-o match:"dir:.*/tmp/cargo" \
abuild prepare build
}
abuild_fish_comp_split_body() {
init_keys
mkdir fish-split-dir
cd fish-split-dir
cat >APKBUILD<<-EOF
# Maintainer: Joe User <juser@example.com>
pkgname="fish-split-dir"
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
prepare() {
mkdir -p "\$builddir"
}
package() {
mkdir -p "\$pkgdir"/usr/share/fish/completions/
mkdir -p "\$pkgdir"/usr/share/fish/vendor_completions.d/
echo "comp" > "\$pkgdir"/usr/share/fish/completions/comp.fish
echo "comp" > "\$pkgdir"/usr/share/fish/vendor_completions.d/comp.fish
}
EOF
# test that there is a warning for the legacy dir existing
atf_check -s exit:0 \
-e match:"fish completions for programs should be located in /usr/share/fish/vendor_completions.d" \
abuild prepare build rootpkg
# now add the correct subpackage
echo 'subpackages="$pkgname-fish-completion"' >> APKBUILD
abuild clean prepare build rootpkg
if ! [ -d pkg/fish-split-dir-fish-completion/usr/share/fish/completions ]; then
echo "missing old dir"
exit 1
fi
if ! [ -d pkg/fish-split-dir-fish-completion/usr/share/fish/vendor_completions.d ]; then
echo "missing new dir"
exit 1
fi
}