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

### dummy template: cut down Samba to size.
TARBALL=samba4-cutdown-$PKGVER-$PKGARCH-$PKGBUILD.txz
MD5SUM=
SRC_URL=samba4-$PKGVER-$PKGARCH-$PKGBUILD.txz
BUNDLE=

SLACKREQ='samba4-cutdown'
SLACKDESC="samba4-winbind: samba4-winbind $PKGVER (Samba4 NetBIOS name resolution)
samba4-winbind: 
samba4-winbind: This contains the winbindd daemon as well as the NSS libraries to 
samba4-winbind: enable NetBIOS name resolution via DNS system. This is extracted out
samba4-winbind: of the full samba4 package and requires samba4-cutdown is installed.
samba4-winbind:
samba4-winbind: If you have installed the full samba4 package you don't need this
samba4-winbind: package.
samba4-winbind: 
samba4-winbind: Install this package and start the winbindd service.
samba4-winbind: 
"
SLACKINSTALL='grep -q wins ./etc/nsswitch.conf || sed -i -e "/^hosts/ s/$/ wins/" ./etc/nsswitch.conf'
SLACKUNINSTALL='grep -q wins ./etc/nsswitch.conf && sed -i -e "/^hosts/ s/ wins//" ./etc/nsswitch.conf'


PKG_NOMAKEPKG=yes
PKG_NOBUILD=yes

### nothing to download
unset -f pkg_download

pkg_prepare() {
	: do nothing
}

pkg_package() {
	if  [ -e $OUTPUT_DIR/$SRC_URL ] ; then
		# extract the source package
		echo extracting $SRC_URL &&
		mkdir -p tmp/samba4      &&
		tar -xf $OUTPUT_DIR/$SRC_URL -C tmp/samba4  &&

		# get what we need
		mkdir -p tmp/winbind/usr/sbin tmp/winbind/usr/$LIBDIR/samba   &&
		cp -a tmp/samba4/usr/sbin/winbindd tmp/winbind/usr/sbin       &&
		cp -a tmp/samba4/usr/$LIBDIR/libnss_* tmp/winbind/usr/$LIBDIR &&
		for p in                   \
			libdcerpc-samba4.so    \
			libidmap-samba4.so     \
			libMESSAGING-samba4.so \
			libnss-info-samba4.so
		do
			cp -a tmp/samba4/usr/$LIBDIR/samba/$p tmp/winbind/usr/$LIBDIR/samba || return 1
		done		
		rm -r tmp/samba4     &&

	    # install init script
	    mkdir -p tmp/winbind/etc/init.d  &&
	    install -m755 tmp/pkg/61-winbindd tmp/winbind/etc/init.d &&
	    
		# build the package
		echo making package  &&
		cd tmp/winbind       &&
		pkg_package_dir .
	else
		return 1
	fi
}

pkg_build() { 
	: do nothing
}
 
