#### this file is sourced not run
PKGVER=4.17.5
PKGBUILD=1
PKGARCH=x86_64

# source: BLFS 11.3
TARBALL=samba-$PKGVER.tar.gz
MD5SUM=8e1d89cad4de151a6de83ff1eac359a1
SRC_URL=http://samba.org/samba/ftp/stable/$TARBALL
BUNDLE=

SLACKREQ='libgnutls libjansson libtirpc avahi libaio libarchive
libcap2 libfuse3' # requires python to build
SLACKDESC="samba4: samba4 $PKGVER (CIFS/SMB Server and Client)  
samba4:  
samba4: The Samba package provides file and print services to SMB/CIFS clients 
samba4: and Windows networking to Linux clients. Samba can also be configured 
samba4: as a Windows Domain Controller replacement, a file/print server acting 
samba4: as a member of a Windows Active Directory domain and a NetBIOS 
samba4: (rfc1001/1002) nameserver (which among other things provides LAN 
samba4: browsing support).  
samba4: 
samba4: 
samba4:  
"
SLACKSUG='python'

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	cd /tmp/samba*
	CONFFLAGS="$CONFFLAGS \
    --with-piddir=/run/samba \
    --without-pam         \
    --enable-fhs          \
    --without-systemd     \
    --without-ldap        \
    --without-ads         \
    --without-quotas      \
    --disable-iprint      \
    --without-iconv       \
    --disable-glusterfs   \
    --without-ad-dc"
    #--without-winbind

	./configure $CONFFLAGS &&
	make $MAKEFLAGS &&

	# BLFS 11.3 fix python interpreter
	sed '1s@^.*$@#!/usr/bin/python3@' \
		-i ./bin/default/source4/scripting/bin/samba-gpupdate.inst &&

	# BLFS 11.3 remove possibly old python modules
	rm -rf /usr/lib/python3.11/site-packages/samba &&
	
	make $MAKEINSTALLFLAGS install &&

	# install
	#mv -v /usr/lib64/libnss_win{s,bind}.so*   /lib64                       &&
	#ln -v -sf ../../lib64/libnss_winbind.so.2 /usr/lib64/libnss_winbind.so &&
	#ln -v -sf ../../lib64/libnss_wins.so.2    /usr/lib64/libnss_wins.so    &&

	install -v -m644    examples/smb.conf.default /etc/samba &&
	mkdir -pv /etc/openldap/schema                           &&

	install -v -m644    examples/LDAP/README                 \
						/etc/openldap/schema/README.LDAP     &&

	install -v -m644    examples/LDAP/samba*                 \
						/etc/openldap/schema                 &&

	install -v -m755    examples/LDAP/{get*,ol*}             \
						/etc/openldap/schema                 &&
	
	# cups
	mkdir -p /usr/$LIBDIR/cups/backend                         &&
	ln -v -sf /usr/bin/smbspool /usr/$LIBDIR/cups/backend/smb  &&
	
	pkg_build_slackdesc
}
