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

P=liberation-fonts-ttf
V=2.00.1
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://releases.pagure.org/liberation-fonts/$SRC.tar.gz " $USER 
tar xvf $SRC*gz

# main
#####
mkdir -p $P/usr/local/share/fonts/liberation
cp $SRC/*ttf $P/usr/local/share/fonts/liberation
mkdir -p $P/usr/local/share/doc/$P
cp $SRC/AUTHORS $P/usr/local/share/doc/$P
cp $SRC/LICENSE $P/usr/local/share/doc/$P 

# tce.installed
##############
mkdir -p $P/usr/local/tce.installed
cat > $P/usr/local/tce.installed/$P << 'EOF'
#!/bin/sh
fc-cache
EOF
chown -R root:staff $P/usr/local/tce.installed
chmod -R 755 $P/usr/local/tce.installed


# 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
done


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

echo 'Title:          liberation-fonts-ttf.tcz  
Description:    see below
Version:        2.00.1
Author:         see doc for authors  
Original-site:  https://pagure.io/liberation-fonts
Copying-policy: SIL OPEN FONT LICENSE Version 1.1
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           fonts  
Comments:       The Liberation(tm) Fonts is a font family 
                which aims at metric compatibility with 
                Arial, Times New Roman, and Courier New. 
                It is sponsored by Red Hat 

                This package does not include
                Liberation Sans Narrow font due 
                to licensing problems.         
                
                If your App is open when you load this 
                package, please close your editor and 
                on your App restart, the fonts should 
                be available.        

                Compiled for 64 9.x
Change-log:     2018/05/06  First version 
Current:        2018/05/06 ' > $P.tcz.info

submitqc --libs
