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

# source: james
TARBALL=avahi-${PKGVER}.tar.gz
MD5SUM=d76c59d0882ac6c256d70a2a585362a6
SRC_URL=https://github.com/lathiat/avahi/releases/download/v${PKGVER}/$TARBALL
BUNDLE=

SLACKREQ='dbus glib gtk2 expat gdbm libcap2'  # build-time only: libdaemon
SLACKDESC="avahi: avahi $PKGVER (mDNS/Bonjour/Zeroconf daemon)
avahi: 
avahi: Avahi is a system which facilitates service discovery on a local 
avahi: network via the mDNS/DNS-SD protocol suite. This enables you to plug 
avahi: your laptop or computer into a network and instantly be able to view 
avahi: other people who you can chat with, find printers to print to or find 
avahi: files being shared. Compatible technology is found in Apple MacOS X 
avahi: (branded \"Bonjour\" and sometimes \"Zeroconf\").
avahi: 
avahi: http://www.avahi.org/
avahi:
"

# note - this must be the same as the ones in fatdog-scripts
SLACKINSTALL='
sed -i -e "/^avahi:/d;/^avahi-autoipd:/d;" ./etc/passwd ./etc/shadow ./etc/group;
echo "avahi:x:50:119:avahi,,,:/tmp:/bin/false" >> ./etc/passwd;
echo "avahi-autoipd:x:51:119:avahi-autoipd,,,:/tmp:/bin/false" >> ./etc/passwd;
echo "avahi:!:0:0:99999:7:::" >> ./etc/shadow;
echo "avahi-autoipd:!:0:0:99999:7:::" >> ./etc/shadow;
echo "avahi:x:50:avahi" >> ./etc/group;
echo "avahi-autoipd:x:51:avahi-autoipd" >> ./etc/group;
'
SLACKUNINSTALL='sed -i -e "/^avahi:/d;/^avahi-autoipd:/d;" ./etc/passwd ./etc/shadow ./etc/group'

### default pkg_download
### default pkg_prepare
### default pkg_package

### build
pkg_build() {
	cd /tmp/avahi* && 
	
	CONFFLAGS="$CONFFLAGS --with-distro=slackware --disable-static \
		--disable-qt3 --disable-qt4 --disable-gtk3 \
		--disable-python --disable-mono \
		--enable-compat-libdns_sd --enable-compat-howl"
	pkg_build_autoconf &&
	
	# we support full libdns_sd and howl - do adjustment as per COMPAT-LAYERS
	ln -sfT avahi-compat-howl.pc /usr/$LIBDIR/pkgconfig/howl.pc &&
	ln -sfT avahi-compat-libdns_sd/dns_sd.h /usr/include/dns_sd.h &&
	
	# In Fatdog /usr/{,s}bin overrides /{,s}/bin
	sed -i -e 's|^PATH=.*|PATH=/usr/sbin:/usr/bin:/sbin:/bin|' \
		/etc/rc.d/rc.avahidaemon /etc/rc.d/rc.avahidnsconfd &&
	
	# move startup files
	mkdir -p /etc/rc.d /etc/init.d &&
	mv /etc/rc.d/rc.avahidaemon   /etc/init.d/56-avahi-daemon &&
	mv /etc/rc.d/rc.avahidnsconfd /etc/init.d/57-avahi-dnsconfd &&
	
	# enable default startup for avahi-daemon and nothing else
	chmod +x /etc/init.d/56-avahi-daemon &&
	chmod -x /etc/init.d/57-avahi-dnsconfd &&

	# icons, icons
	install -m644 /tmp/pkg/network-workgroup.png /usr/share/icons &&

	pkg_build_slackdesc &&
	
	# multilib
	mv -v /usr/share/gir-1.0/* /usr/share/gir-1.0-64 &&
	rm -r /usr/share/gir-1.0/
}
