aports/community/racksdb/APKBUILD

118 lines
3.1 KiB
Text

# Contributor: omni <omni+alpine@hack.org>
# Maintainer: omni <omni+alpine@hack.org>
pkgname=racksdb
pkgver=0.4.0
pkgrel=2
pkgdesc="YAML-based database of datacenter infrastructures"
url="https://rackslab.io/en/solutions/racksdb/"
arch="noarch"
license="GPL-3.0-or-later"
depends="py3-$pkgname=$pkgver-r$pkgrel"
_pydepends="python3
py3-clustershell
pango
py3-cairo
py3-gobject3
py3-pyaml
"
makedepends="asciidoctor npm py3-gpep517 py3-setuptools py3-wheel"
checkdepends="py3-pytest $_pydepends"
subpackages="$pkgname-doc
$pkgname-web:_web
py3-$pkgname-web-pyc:_py3_web_pyc
py3-$pkgname-web:_py3_web
py3-$pkgname-pyc
py3-$pkgname:_py3
"
source="$pkgname-$pkgver.tar.gz::https://github.com/rackslab/RacksDB/archive/refs/tags/v$pkgver.tar.gz
frontend-npm-audit.patch
"
builddir="$srcdir/RacksDB-$pkgver"
options="net" # npm
prepare() {
default_prepare
cd frontend
npm ci --foreground-scripts
}
build() {
gpep517 build-wheel --wheel-dir .dist --output-fd 3 3>&1 >&2
for adocman in docs/man/*.adoc; do
asciidoctor --backend manpage --attribute mansource='RacksDB 0.4.0' "$adocman"
done
cd frontend
npm run build
}
check() {
python3 -m venv --clear --without-pip --system-site-packages .testenv
.testenv/bin/python3 -m installer .dist/*.whl
.testenv/bin/python3 -m pytest
cd frontend
# check for vulnerabilities, some fixes may have breaking changes and need
# to be handled with care, only fail on Severity: high, TODO: change this
npm audit --audit-level=high
}
package() {
python3 -m installer -d "$pkgdir" .dist/*.whl
install -dm0755 "$pkgdir"/usr/share/"$pkgname"/frontend
cp -r frontend/dist/* \
"$pkgdir"/usr/share/"$pkgname"/frontend/
cp -r schemas "$pkgdir"/usr/share/"$pkgname"/
install -dm0755 "$pkgdir"/etc/"$pkgname"
install -Dm0644 docs/man/*.1 -t "$pkgdir"/usr/share/man/man1/
install -Dm0644 CHANGELOG.md -t "$pkgdir"/usr/share/doc/"$pkgname"/
cp -r examples "$pkgdir"/usr/share/doc/"$pkgname"/
install -Dm0644 docs/modules/db/examples/*yml \
-t "$pkgdir"/usr/share/doc/"$pkgname"/examples/db/
install -Dm0644 docs/modules/usage/examples/custom.* \
-t "$pkgdir"/usr/share/doc/"$pkgname"/examples/
}
_web() {
depends="py3-$pkgname-web=$pkgver-r$pkgrel"
pkgdesc="$pkgname Web UI"
amove usr/bin/racksdb-web
amove usr/share/racksdb/frontend
}
_py3_web_pyc() {
pkgdesc="Precompiled Python bytecode for ${subpkgname%-pyc}"
install_if="${subpkgname%-pyc}=$pkgver-r$pkgrel pyc"
amove usr/lib/python3*/site-packages/racksdb/web/__pycache__
}
_py3_web() {
depends="python3
py3-flask
py3-requests-toolbelt
py3-$pkgname=$pkgver-r$pkgrel
"
pkgdesc="$pkgname Web UI python3 bindings"
amove usr/lib/python3*/site-packages/racksdb/web
}
_py3() {
depends="$_pydepends"
pkgdesc="$pkgname python3 bindings"
amove usr/lib/python3*
}
sha512sums="
365980fb69415ee5fab6eaf37ba296fad7481605bba3ac0ac28108ccf13f129b7ed7415cf8680b9b0c1a2e2bdb26448525fe5e338522f59a0cc7d4468590375e racksdb-0.4.0.tar.gz
1f1211673369f87075a97ee52d36335843963d645629d23bb0dc8730684f6917a99507953f1cc21ea16f1bf27a7c0648717b6b2ce2200ba152f001b7e54d7d0e frontend-npm-audit.patch
"