# Description: SMB server and client for unix
# URL: https://www.samba.org
# Maintainer: Juergen Daubert, jue at crux dot nu
# Depends on: dbus gnutls ldb linux-pam jansson p5-json p5-parse-yapp rpcsvc-proto
# Optional: brotli cups libidn2

name=samba
version=4.20.0
release=1
source=(https://www.samba.org/samba/ftp/stable/$name-$version.tar.gz \
	samba.rc samba.pam)

build () {
	cd $name-$version

	./configure \
		--enable-fhs \
		--prefix=/usr \
		--libexecdir=/usr/lib \
		--localstatedir=/var \
		--sysconfdir=/etc \
		--with-piddir=/run/samba \
		--with-sockets-dir=/run/samba \
		--with-privatedir=/etc/samba/private \
		--with-pammodulesdir=/lib/security \
		--bundled-libraries=!tdb,!talloc,!tevent,!popt,!ldb,!cmocka \
		--without-{ad-dc,ads,ldap}

	make
	make DESTDIR=$PKG install

	# man pages
	local p
	for p in docs/manpages/*; do
		install -D -m 644 $p $PKG/usr/share/man/man${p##*.}/${p##*/}
	done

	# cleanup
	chmod 1777 $PKG/var/lock
	rm -r $PKG/run

	# config-file and start-script
	install -d $PKG/etc/{samba,rc.d,pam.d}
	install -m 0600 examples/smb.conf.default $PKG/etc/samba
	install -m 0755 $SRC/samba.rc $PKG/etc/rc.d/samba
	install -m 0644 $SRC/samba.pam $PKG/etc/pam.d/samba

	# revdep
	install -d $PKG/etc/revdep.d
	echo '/usr/lib/samba' > $PKG/etc/revdep.d/samba
}
