#!/bin/sh
# test we are root
if [ "$(id -u)" != "0" ]; then
   echo "run as root now exitting"
   exit 1
fi

export CFLAGS="-march=armv8-a+crc -mtune=cortex-a72 -Os -pipe" 
export CXXFLAGS="-march=armv8-a+crc -mtune=cortex-a72 -Os -pipe \
-fno-exceptions -fno-rtti"

P=nss-mdns
V=0.14.1
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc wget squashfs-tools zsync avahi-dev "
for Z in $LIST    
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
su -c "/usr/local/bin/wget -nc --no-check-certificate \
https://github.com/lathiat/$P/releases/download/v$V/$SRC.tar.gz " $USER
tar xvf $SRC*gz
cd $SRC
AVAHI_SOCKET='/run/avahi-daemon/socket' ./configure --prefix=/usr/local 
make -j5 # takes seconds 
make install-strip DESTDIR=/tmp/$P  # takes seconds
cd /tmp

# TCZ them
#######  
LIST="$P "
for Z in $LIST
do
	mksquashfs $Z $Z.tcz
	md5sum $Z.tcz > $Z.tcz.md5.txt
	cd $Z
	find usr -not -type d > /tmp/$Z.tcz.list
        sed 's|usr|/usr|g' -i /tmp/$Z.tcz.list
        cd /tmp
        zsyncmake $Z.tcz
done

ls -hal

echo 'Title:          nss-mdns.tcz
Description:    name resolution by mDNS  
Version:        0.14.1
Author:         Lennart Poettering
Original-site:  https://github.com/lathiat/nss-mdns
Copying-policy: LGPL v 2.1
Size:           12K
Extension_by:   aus9
Tags:           daemon
Comments:       nss-mdns is a plugin providing host name resolution via Multicast DNS 
                (aka Zeroconf, aka Apple Rendezvous, aka Apple Bonjour) nss-mdns provides 
                client functionality only, which means that you have to run avahi if you 
                want to register the local host name via mDNS.

                compiled to know avahi socket is non-standard under /run not /var/run
                
                nss-mdns tries to contact a running avahi-daemon for resolving host names and 
                addresses and making use of its superior record cacheing. Instructions 
                https://github.com/lathiat/nss-mdns
                Especially: If you run a firewall, do not forget to allow UDP traffic to the 
                mDNS multicast address 224.0.0.251 on port 5353. 

Change-log:     2020/09/18 Original v 0.14.1 on 12x 
Current:        2020/09/18    ' > $P.tcz.info

# test.....strings * | grep socket -> 6 positive hits for socket  and /run/avahi-daemon/socket


