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

export CFLAGS="-march=armv8-a+crc -mtune=cortex-a72 -Os -pipe" 
export CXXFLAGS="-march=armv8-a+crc -mtune=cortex-a72 -Os -pipe \
-fno-exceptions -fno-rtti"

P=gpicview
V=0.2.5
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc squashfs-tools zsync wget xz 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 \
https://downloads.sourceforge.net/lxde/$SRC.tar.xz"  $USER
xz -d $SRC*xz && tar xvf $SRC*tar
mkdir $P
cd $SRC
./configure --prefix=/usr/local --disable-nls --enable-static=no
make -j5 # takes seconds
make install-strip DESTDIR=/tmp/$P
cd /tmp

# main
######
mkdir -p $P/usr/local/share/pixmaps
cp $P/usr/local/share/icons/hicolor/48x48/apps/$P.png $P/usr/local/share/pixmaps
APP=$P/usr/local/share/applications/$P.desktop
echo 'X-FullPathIcon=/usr/local/share/pixmaps/gpicview.png' >> $APP

# TCZ them
###########
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
        sed 's|usr|/usr|g' -i /tmp/$Z.tcz.list
	cd /tmp
        zsyncmake $Z.tcz
done

ls -hal

echo 'Title:          gpicview.tcz
Description:    gtk2 image/slideshow tool
Version:        0.2.5
Author:         https://github.com/skawouter/gpicview/blob/master/AUTHORS 
Original-site:  http://lxde.sourceforge.net/gpicview/
Copying-policy: GPL v2
Size:           56K
Extension-by:   aus9
Tags:           image viewer slideshow
Comments:       GUI should preview images after click
                open file -> selecting a dir that contains
                supported images: jpeg, png, svg
                animated gif shows only first image

                Hover to see button functions please

Change-log:     2020/11/15 Original 0.2.5 on 12x
Current:        2020/11/15  ' > $P.tcz.info 

echo 'gtk2.tcz' > $P.tcz.dep

