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

USER=`cat /etc/sysconfig/tcuser`
P=liberation
PN=$P-fonts-ttf
V=2.1.0
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc"
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/liberationfonts/$P-fonts/files/4178407/$PN-$V.tar.gz \
https://raw.githubusercontent.com/liberationfonts/liberation-fonts/devel/AUTHORS \
https://raw.githubusercontent.com/liberationfonts/liberation-fonts/devel/LICENSE" $USER 
tar xvf $P*gz

# main
#####
mkdir -p $PN/usr/local/share/fonts/liberation
mkdir -p $PN/usr/local/share/doc/$PN
mv $P*$V/* $PN/usr/local/share/fonts/liberation
mv AUTHORS $PN/usr/local/share/doc/$PN
mv LICENSE $PN/usr/local/share/doc/$PN

# 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/liberation
EOF
chown -R root:staff $PN/usr/local/tce.installed
chmod -R 755 $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:          liberation-fonts-ttf.tcz  
Description:    fonts see below
Version:        2.1.0
Author:         see doc for authors  
Original-site:  https://github.com/liberationfonts
Copying-policy: SIL OPEN FONT LICENSE Version 1.1
Size:           2.5M		
Extension_by:   aus9 
Tags:           fonts  
Comments:       The Liberation Fonts is a font collection 
                which aims to provide compatibility 
                to Times New Roman, Arial, Courier New

Change-log:     2008/08/13 Original for 32 bit (curaga)
                2011/09/16 Update to 1.07, add Slackware config file (32-curaga)
                2018/05/06 Original 2.00.1 (64-aus9) 
Current:        2020/06/07 updated (32/64) to 2.1.0   
' > $PN.tcz.info

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

submitqc --libs
