#!/bin/sh
#  we are root

export CFLAGS="-O2 -pipe -march=i486 -mtune=i686"
export CXXFLAGS="-O2 -pipe -fno-exceptions -fno-rtti -march=i486 -mtune=i686"
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig

P=lxde-icon-theme
USER=`cat /etc/sysconfig/tcuser`

# gtk2 menu-cache and libexif are used for the indexing below
LIST="compiletc submitqc6 xz gtk2 menu-cache libexif "
for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
su -c "wget http://internode.dl.sourceforge.net/project/lxde/LXDE%20Icon%20Theme/\
lxde-icon-theme-0.5.1/lxde-icon-theme-0.5.1.tar.xz \                                  
" $USER 

xz -d $P-0.5.1.tar.xz
tar xvf $P-0.5.1.tar
cd $P-0.5.1
./configure  --prefix=/usr/local  

# install build into ram drive with running deps
# next generate the cache
# complete final tcz
make install 
gtk-update-icon-cache /usr/local/share/icons/nuoveXT2/
mkdir -p /tmp/$P
make install DESTDIR=/tmp/$P 
cp -R /usr/local/share/icons/nuoveXT2/icon-theme.cache /tmp/$P/usr/local/share/icons/nuoveXT2/
cd /tmp

# create TCZ
###########
LIST2="$P "
for Z in $LIST2
do
	mksquashfs $Z $Z.tcz
	md5sum $Z.tcz > $Z.tcz.md5.txt
	cd $Z
	find usr -not -type d > /tmp/$Z.tcz.list
        cd /tmp
done

echo "usr/local/share/icons/nuoveXT2/icon-theme.cache" >> $Z.tcz.list

# create depend files
################
echo 'gtk2.tcz
 ' > $P.tcz.dep

# create info files let submitqc5 add size

echo "Title:          lxde-icon-theme.tcz
Description:    Default icon theme nuoveXT2 for LXDE/PCManFM
Version:        0.5.1
Author:         Hong Jen Yee, Alexandre Moore
Original-site:  http://pcmanfm.sourceforge.net
Copying-policy: GPL v2
Size:           
Extension_by:   gordon64
Tags:           icons
Comments:       icons
                ----
                Compiled for Pure64
Change-log:     2012/11/27 First version, 0.5.0 
                2013/07/26 Added icon cache bmarkus 0.5.0
Current:        2015/09/01 v0.5.1 gordon64 
" > $P.tcz.info

submitqc6