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

P=mononoki
PN=$P-ttf-fonts
V=1.2
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
su -c "tce-load -i wget squashfs-tools zsync " $USER
cd /tmp
su -c "/usr/local/bin/wget -nc --no-check-certificate \
https://github.com/madmalik/$P/releases/download/$V/$P.zip \
https://raw.githubusercontent.com/madmalik/$P/master/LICENSE"  $USER
unzip $P*
mkdir -p $PN/usr/local/share/doc/$PN
mv LICENSE $PN/usr/local/share/doc/$PN
mkdir -p $PN/usr/local/share/fonts/$PN
mv *ttf $PN/usr/local/share/fonts/$PN

# tce.installed
############
mkdir -p $PN/usr/local/tce.installed
echo '#!/bin/sh
fc-cache /usr/local/share/fonts/mononoki-ttf-fonts
' > $PN/usr/local/tce.installed/$PN
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:          mononoki-ttf-fonts.tcz
Description:    monospace true type fonts 
Version:        1.2
Author:         Matthias Tellen
Original-site:  https://madmalik.github.io/mononoki/
Copying-policy: SIL Open Font License, Version 1.1
Size:           212K
Extension_by:   aus9
Tags:           ttf font
Comments:       Contains Bold, Bold italic, italic 
                and regular true type fonts

Change-log:     2020/09/03 Original 1.2 on 12x anyarch
Current:        2020/09/03
' > $PN.tcz.info

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


