From b8c21e9c4641f6e5ef27d6a78913b7d9eb548a03 Mon Sep 17 00:00:00 2001
From: Hugo Osvaldo Barrera <hugo@whynothugo.nl>
Date: Thu, 2 Jan 2025 14:04:49 +0100
Subject: [PATCH] community/py3-keyring: install shell completions

---
 community/py3-keyring/APKBUILD | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/community/py3-keyring/APKBUILD b/community/py3-keyring/APKBUILD
index 34599398a2c0..3e831374a6ed 100644
--- a/community/py3-keyring/APKBUILD
+++ b/community/py3-keyring/APKBUILD
@@ -1,7 +1,7 @@
 # Maintainer: opal hart <opal@wowana.me>
 pkgname=py3-keyring
 pkgver=24.3.1
-pkgrel=1
+pkgrel=2
 pkgdesc="Access the system keyring service from Python"
 url="https://github.com/jaraco/keyring"
 arch="noarch"
@@ -13,9 +13,13 @@ depends="
 	py3-secretstorage
 	python3
 	"
-makedepends="py3-setuptools py3-gpep517 py3-installer py3-wheel py3-setuptools_scm"
+makedepends="py3-setuptools py3-gpep517 py3-installer py3-wheel py3-setuptools_scm py3-shtab"
 checkdepends="py3-pytest"
-subpackages="$pkgname-pyc"
+subpackages="
+	$pkgname-pyc
+	$pkgname-bash-completion
+	$pkgname-zsh-completion
+"
 source="https://files.pythonhosted.org/packages/source/k/keyring/keyring-$pkgver.tar.gz"
 builddir="$srcdir/keyring-$pkgver"
 
@@ -25,6 +29,11 @@ build() {
 	gpep517 build-wheel \
 		--wheel-dir .dist \
 		--output-fd 3 3>&1 >&2
+
+	python3 -m venv --clear --without-pip --system-site-packages .tempenv
+	.tempenv/bin/python3 -m installer .dist/keyring-$pkgver-py3-none-any.whl
+	.tempenv/bin/keyring --print-completion zsh > keyring.bash
+	.tempenv/bin/keyring --print-completion zsh > keyring.zsh
 }
 
 check() {
@@ -34,6 +43,9 @@ check() {
 package() {
 	python3 -m installer -d "$pkgdir" \
 		.dist/keyring-$pkgver-py3-none-any.whl
+
+	install -Dm 644 keyring.bash "$pkgdir/usr/share/bash-completion/completions/keyring"
+	install -Dm 644 keyring.zsh "$pkgdir/usr/share/zsh/site-functions/_keyring"
 }
 
 sha512sums="
-- 
GitLab