#!/bin/sh
#  we are root

export CFLAGS="-mtune=generic -Os -pipe"
export CXX="g++ -flto -fuse-linker-plugin -mtune=generic -Os -pipe \
-fno-exceptions -fno-rtti" 

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

# gtk2 menu-cache  libexif are used for the indexing below
LIST="compiletc submitqc5 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  
make -j3

# 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
menu-cache.tcz
libexif.tcz
 ' > $P.tcz.dep

# gamin.tcz

# create info files let submitqc5 add size

echo "Title:          lxde-icon-theme.tcz
Description:    icons for LXDE
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:     2015/08/20 First version, 
Current:        2015/08/20 
" > $P.tcz.info

submitqc5