summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8d032b69dd810b5627da2ba831665e01319cbf57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Maintainer: Hauke Rehfeld <aur.archlinux.org@haukerehfeld.de>
pkgname=python-keyring-minimal-git
pkgver=r12.5c266c5
pkgrel=2
pkgdesc="A minimal libsecret keyring in python that works with keepassxc."
arch=(any)
url="https://github.com/hrehfeld/python-keyring-minimal"
depends=('python' 'libsecret')
license=(AGPL-3.0)
makedepends=("python" "python-pip" "git" 'python-build')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
replaces=()
backup=()
options=()
install=
source=("git+${url}.git")
noextract=()
md5sums=('SKIP')

pkgver() {
	cd "$srcdir/${pkgname%-git}"

	# Git, no tags available
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
	cd "$srcdir/${pkgname%-git}"
	git checkout master
	sed -r -i "s/^version=([.0-9]*)$/version=\1+$pkgver/" setup.cfg
  _actual_version=$(grep -Po '(?<=^version=)(.*)$' setup.cfg)
}

build() {
	cd "$srcdir/${pkgname%-git}"
	python -m build
  pip install --no-deps --target="keyring-minimal" "dist/keyring-minimal-${_actual_version}.tar.gz"
}

package() {
  sitepackages=$(python -c "import site; print(site.getsitepackages()[0])")
  _pyver="3.$(python -c 'import sys; print(sys.version_info.minor);')"
  mkdir -p $pkgdir/"$sitepackages"
  cp -r $srcdir/${pkgname%-git}/keyring-minimal/* $pkgdir/"$sitepackages"
	sh -c "rm $pkgdir/usr/lib/python${_pyver}/site-packages/keyring_minimal-*.dist-info/direct_url.json"

	for f in "keyring-minimal-askpass"
	do
		install -Dm755 "$srcdir/${pkgname%-git}/$f" "$pkgdir/usr/bin/$f"
	done
	ln -sf /usr/lib/python${_pyver}/site-packages/bin/keyring-minimal "$pkgdir/usr/bin/"
}