# Contributor: Alexander Rigbo <alex@dnb.nu>
# Contributor: Daniel Markstedt <daniel@mindani.net>
# Maintainer: Daniel Markstedt <daniel@mindani.net>
pkgname=netatalk
pkgver=4.2.3
pkgrel=0
pkgdesc="Open Source AFP fileserver"
url="https://netatalk.io/"
arch="all"
license="GPL-2.0-or-later"
options="suid"  # needed for /usr/bin/afppasswd
makedepends="
	acl-dev
	attr-dev
	cmark
	db-dev
	file
	iniparser-dev
	libevent-dev
	libgcrypt-dev
	libtirpc-dev
	linux-headers
	mariadb-dev
	meson
	ninja
	"
subpackages="$pkgname-doc $pkgname-dev $pkgname-openrc"
source="https://github.com/Netatalk/netatalk/releases/download/netatalk-${pkgver//./-}/netatalk-$pkgver.tar.xz"

# secfixes:
#   3.1.19-r0:
#     - CVE-2024-38439
#     - CVE-2024-38440
#     - CVE-2024-38441
#   3.1.18-r0:
#     - CVE-2022-22995
#   3.1.17-r0:
#     - CVE-2023-42464
#   3.1.15-r0:
#     - CVE-2022-43634
#     - CVE-2022-45188
#   3.1.13-r0:
#     - CVE-2021-31439
#     - CVE-2022-23121
#     - CVE-2022-23123
#     - CVE-2022-23122
#     - CVE-2022-23125
#     - CVE-2022-23124
#     - CVE-2022-0194
#   3.1.12-r0:
#     - CVE-2018-1160

build() {
	meson setup build \
		--prefix=/usr \
		--sysconfdir=/etc \
		-Dbuildtype=release \
		-Ddefault_library=shared \
		-Dwith-acls=true \
		-Dwith-afpstats=false \
		-Dwith-appletalk=true \
		-Dwith-cracklib=false \
		-Dwith-docs=man \
		-Dwith-dtrace=false \
		-Dwith-init-style=openrc \
		-Dwith-kerberos=false \
		-Dwith-krbV-uam=false \
		-Dwith-init-hooks=false \
		-Dwith-install-hooks=false \
		-Dwith-ldap=false \
		-Dwith-ldsoconf=false \
		-Dwith-libiconv=false \
		-Dwith-lockfile-path=/run/lock \
		-Dwith-overwrite=true \
		-Dwith-pam=false \
		-Dwith-statedir-path=/var/lib \
		-Dwith-tcp-wrappers=false \
		-Dwith-tests=true \
		-Dwith-zeroconf=false
	meson compile -C build
}

check() {
	meson test -C build
}

package() {
	meson install -C build --destdir "$pkgdir"
}

sha512sums="
d23474cb1d0d3da52dd650b6d2287ab66d549910cc4db371e1c377caf7b9f43f21d7ff48d74d51b995be76970b79ade47bcc8313bfa4182a088beecbfe4b1905  netatalk-$pkgver.tar.xz
"
