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

P=notosans
PN=$P-fonts-ttf
USER=`cat /etc/sysconfig/tcuser`
su -c "tce-load -i wget squashfs-tools wget " $USER
cd /tmp
su -c "/usr/local/bin/wget -nc --no-check-certificate \
https://www.fontsquirrel.com/fonts/download/noto-sans "  $USER
unzip noto-sans
mkdir -p $PN/usr/local/share/doc/$PN
mv SIL*.txt $PN/usr/local/share/doc/$PN
mkdir -p $PN/usr/local/share/fonts/$P
mv *ttf $PN/usr/local/share/fonts/$P
# ignore attempt to move dir to itself 
# mv: can't rename 'notosans-fonts-ttf': Invalid argument

# tce.installed
############
mkdir -p $PN/usr/local/tce.installed
cat >> $PN/usr/local/tce.installed/$PN <<'EOF'
#!/bin/sh
fc-cache /usr/local/share/fonts/notosans
EOF
chown -R root:staff $PN/usr/local/tce.installed
chmod -R 775 $PN/usr/local/tce.installed

# TCZ them
###########
LIST="$PN "
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
done

ls -hal

echo 'Title:          notosans-fonts-ttf.tcz
Description:    sans serif fonts 
Version:        unknown
Author:         Google Inc
Original-site:  https://www.fontsquirrel.com/fonts
Copying-policy: SIL Open Font License v 1.1
Size:           13M
Extension_by:   aus9
Tags:           ttf font sans
Comments:       Noto Sans for Latin, Cyrillic and 
                Greek scripts
                Large range of weights and types
  
Change-log:     2023/07/18 any arch 
Current:        2023/07/18      ' > $PN.tcz.info

echo 'fontconfig.tcz' > $PN.tcz.dep
