apkbuilds @ 3.21

 1pkgname=invidious
 2pkgver=v2.20241110.0
 3pkgrel=0
 4pkgdesc="Alternative front-end to YouTube"
 5url="https://github.com/iv-org/invidious"
 6arch="x86_64"
 7license="AGPL-3.0-or-later"
 8depends="
 9	rsvg-convert
10"
11options="!check" # testing breaks for now fixing later
12makedepends="
13	crystal
14	git
15	libxml2-dev
16	openssl-dev
17	shards
18	sqlite-dev
19	yaml-dev
20	zlib-dev
21"
22install="$pkgname.pre-install"
23pkgusers="$pkgname"
24pkggroups="$pkgname"
25subpackages="$pkgname-openrc"
26source="
27	$pkgname-$pkgver.tar.gz::https://github.com/iv-org/invidious/archive/refs/tags/$pkgver.tar.gz
28	$pkgname.initd
29"
30builddir="$srcdir/$pkgname-${pkgver:1}"
31
32prepare() {
33	default_prepare
34
35	sed \
36		-e 's/^CURRENT_BRANCH =.*/CURRENT_BRANCH = "release"/' \
37		-e 's/^CURRENT_COMMIT  =.*/CURRENT_COMMIT  = "'$pkgver'"/' \
38		-e 's/^CURRENT_VERSION =.*/CURRENT_VERSION = "'$pkgver'"/' \
39		-e 's/^ASSET_COMMIT =.*/ASSET_COMMIT = "'$pkgver'"/' \
40		-i src/invidious.cr
41
42	datadir=/usr/share/webapps/invidious
43	# fix paths
44	sed -i src/invidious.cr \
45		-e "s|\(public_folder\) \"assets\"|\1 \"$datadir/assets\"|"
46	sed -i src/invidious/helpers/i18n.cr \
47		-e "s|File.read(\"locales/|File.read(\"$datadir/locales/|"
48	sed -i src/invidious/database/base.cr \
49		-e "s|config/sql|/etc/$pkgname/\0|g"
50
51}
52
53build() {
54	shards install
55	crystal build \
56		--release \
57		-Ddisable_quic \
58		src/invidious.cr
59}
60
61package() {
62	install -Dm755 "$pkgname" "$pkgdir"/usr/bin/invidious
63	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
64	mkdir -p "$pkgdir"/usr/share/webapps/invidious
65	cp -r "$builddir"/assets "$builddir"/locales \
66		"$pkgdir"/usr/share/webapps/invidious
67	install -Dm644 "$builddir"/config/config.example.yml \
68		"$pkgdir"/etc/"$pkgname"/config.yml
69}
70sha512sums="
713ed9d47c520736d9df95541f6a85cc456c4b9ce03bd8f38905f7a11542ba0875d9d1736be82bee8d56039937b0321188ce0228d760ad616e6cc2d0aa7cbd8535  invidious-v2.20241110.0.tar.gz
72ed0a2e498751927c1ad82619395a07c169f7353a9c1453381ad288ad501b915010df5b799e4f102e034f0483b9101b9a8ae40d150b3d7db80605f87b9ca6f596  invidious.initd
73"