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

export CFLAGS="-mtune=generic -Os -pipe"
export CXX="-mtune=generic -Os -pipe -fno-exceptions -fno-rtti" 

P=lxde-icon-theme
V=0.5.1
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc xz "
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://downloads.sourceforge.net/lxde/$SRC.tar.xz " $USER 

tar xvf $RC*xz
cd $SRC
./configure  --prefix=/usr/local  
make -j5 # nothing to be done
make install-strip DESTDIR=/tmp/$P
cd /tmp

# install script
################
mkdir -p $P/usr/local/tce.installed
cat >> $P/usr/local/tce.installed/$P <<'EOF'
#!/bin/sh
gtk-update-icon-cache /usr/local/share/icons/nuoveXT2/
EOF
chown -R root:staff $P/usr/local/tce.installed
chmod -R 775 $P/usr/local/tce.installed

mkdir -p $P/usr/local/share/doc/$P
echo 'GPL v3' > $P/usr/local/share/doc/$P/COPYING

# submit finds wrong perms on icons but tries to change to eg1
#Expected 755 permission:
#usr/local/share/icons/nuoveXT2/128x128/mimetypes/binary.png
# so submitqc run only on pass1
# icons should be 644
# dirs are already 755

find $P/usr/local/share/icons/nuoveXT2 -not -type d  -type f -exec chmod 644 {} \;
  
# create TCZ
###########
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
ls -hal

echo "Title:          lxde-icon-theme.tcz
Description:    icons for LXDE
Version:        0.5.1
Author:         Hong Jen Yee, Alexandre Moore
Original-site:  https://sourceforge.net/projects/lxde/
Copying-policy: GPL v3
Size:           4.6M           
Extension_by:   aus9 @linuxquestions.org  
Tags:           icons
Comments:       nuoveXT2 icons
                                
Change-log:     2015/08/20 v 0.5.1 on 6x  (gordon64)
Current:        2024/04/13 add install script on 15x (aus9)  " > $P.tcz.info

# icons no exe so to readelf
echo 'gtk-update-icon-cache.tcz ' > $P.tcz.dep

# pass 1
# submitqc --libs 

# submit thinks all pngs should be 755 WT? eg
#Expected 755 permission:
# usr/local/share/icons/nuoveXT2/128x128/mimetypes/binary.png

