From 49a8c267b0234f20abbf8e7cde00747bd559506d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Pola=C5=84ski?= <michal@polanski.me>
Date: Sat, 23 Jul 2022 02:01:21 +0200
Subject: [PATCH] testing/mdbook: generate shell completions in the build
 function

---
 testing/mdbook/APKBUILD | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/testing/mdbook/APKBUILD b/testing/mdbook/APKBUILD
index 235b22aa2580..5357e55afba1 100644
--- a/testing/mdbook/APKBUILD
+++ b/testing/mdbook/APKBUILD
@@ -23,6 +23,10 @@ prepare() {
 
 build() {
 	cargo build --frozen --release
+
+	./target/release/mdbook completions bash > $pkgname.bash
+	./target/release/mdbook completions fish > $pkgname.fish
+	./target/release/mdbook completions zsh > $pkgname.zsh
 }
 
 check() {
@@ -32,16 +36,9 @@ check() {
 package() {
 	install -Dm755 target/release/mdbook "$pkgdir"/usr/bin/mdbook
 
-	target/release/mdbook completions bash > mdbook.bash
-	target/release/mdbook completions fish > mdbook.fish
-	target/release/mdbook completions zsh > _mdbook
-
-	install -Dm644 mdbook.bash \
-		"$pkgdir/usr/share/bash-completion/completions/mdbook"
-	install -Dm644 mdbook.fish \
-		"$pkgdir/usr/share/fish/completions/mdbook.fish"
-	install -Dm644 _mdbook \
-		"$pkgdir/usr/share/zsh/site-functions/_mdbook"
+	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
+	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/completions/$pkgname.fish
+	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
 }
 
 sha512sums="
-- 
GitLab