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

CFLAGS="-mtune=generic -Os -pipe"
CXX="g++ -flto -fuse-linker-plugin -mtune=generic -Os -pipe "

P=ristretto
V=0.8.3
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`

LIST="compiletc submitqc libexif-dev libxfce4util-dev libxfce4ui-dev gtk2-dev"
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 \
http://archive.xfce.org/src/apps/$P/0.8/$SRC.tar.bz2  " $USER  
mkdir $P
tar jxvf $SRC*bz2
cd $SRC
./configure --disable-debug
make -j5
make install-strip DESTDIR=/tmp/$P
cd /tmp

# locale
#########
mkdir -p $P-locale/usr/local/share
mv $P/usr/local/share/locale $P-locale/usr/local/share

# main
#####
mkdir -p $P/usr/local/share/doc/$P
echo 'GPL v2' > $P/usr/local/share/doc/$P/COPYING 

# desktop
#############
mkdir $P/usr/local/share/pixmaps
cp -f $P/usr/local/share/icons/hicolor/48x48/apps/$P.png $P/usr/local/share/pixmaps/

DESK=$P/usr/local/share/applications/$P.desktop
sed 's|Name=Ristretto Image Viewer|Name=ristretto|' -i $DESK
echo 'X-FullPathIcon=/usr/local/share/pixmaps/ristretto.png' >> $DESK

tce.install
#############
mkdir -p $P/usr/local/tce.installed

cat << EOF >> $P/usr/local/tce.installed/$P
#!/bin/sh
gtk-update-icon-cache -q -f -t /usr/local/share/icons/hicolor
EOF

chown -R root:staff $P/usr/local/tce.installed
chmod -R 755 $P/usr/local/tce.installed

# TCZ them
#######
LIST="$P $P-locale"
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 'libexif.tcz
libxfce4util.tcz 
libxfce4ui.tcz
gtk2.tcz
librsvg.tcz
file.tcz' > $P.tcz.dep

echo 'ristretto.tcz' > $P-locale.tcz.dep

ls -alh

echo 'Title:          ristretto.tcz  
Description:    Image viewer 
Version:        0.8.3
Author:         Stephan Arts - icon by Simon Steinbeiss  
Original-site:  http://archive.xfce.org/src/apps/ristretto/
Copying-policy: GPL v2
Size:           156K		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       Image viewer can run as a stand alone
                outside of XFCE 

                Can slideshow                   
 
                Compiled for 64 9.x
Change-log:     2018/08/23  First version 
Current:        2018/08/23 ' > $P.tcz.info

echo 'Title:          ristretto-locale.tcz
Description:    locales
Version:        0.8.3
Author:         Stephan Arts - icon by Simon Steinbeiss 
Original-site:  http://archive.xfce.org/src/apps/ristretto/
Copying-policy: GPL v2
Size:           324K		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       for non-english users untested

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

submitqc --libs

