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

P=oxygen
PN=oxygen-fonts
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://dl.1001fonts.com/$P.zip " $USER 
unzip $P*zip

# main
#####
mkdir -p $PN/usr/local/share/fonts/$P
mv *ttf $PN/usr/local/share/fonts/$P
mkdir -p $PN/usr/local/share/doc/$PN
mv OFL.txt $PN/usr/local/share/doc/$PN/COPYING

# 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/oxygen
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:          oxygen-fonts.tcz  
Description:    web browser unicode truetype fonts
Version:        20150516
Author:         Vernon Adams 
Original-site:  https://www.1001fonts.com/oxygen-font.html
Copying-policy: SIL Open Font v 1.1
Size:           92K		
Extension_by:   aus9 
Tags:           fonts unicode ttf
Comments:       Oxygen is a Unicode typeface family that supports 
                languages that use the Latin script family.              
                Designed for web browsers using FreeType font system.
                Works with other Apps too.

                In firefox Preferences click Advanced to choose
                oxygen for serif, sans or mono. Refresh page and decide 
                if font is any good for you.
                
Change-log:     2018/05/06 Original 
Current:        2020/06/01 add script on 11x for 32/64 bits ' > $PN.tcz.info

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

submitqc --libs

