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

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

P=xfce4-appfinder
V=4.13.0
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc intltool glib2-dev gtk3-dev \
libxfce4ui-dev garcon-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/xfce/$P/4.13/$SRC.tar.bz2  " $USER 
tar jxvf $P*bz2
mkdir $P
cd $SRC
./configure --disable-debug
#######################################################
# Toolkit:           GTK+-3
# Debugging Support: no
#################################################
make check
make install-strip DESTDIR=/tmp/$P
cd /tmp

# no dev TCZ
##############

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

# doc
#####
mkdir -p $P-doc/usr/local/share/doc/$P
cp $SRC/AUTHORS $P-doc/usr/local/share/doc/$P
cp $SRC/COPYING $P-doc/usr/local/share/doc/$P

# main
#####
mkdir -p $P/usr/local/share/doc/$P
echo 'see doc tcz for license' > $P/usr/local/share/doc/$P/COPYING

# TCZ them
#######
LIST="$P $P-doc $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 'xfce4-appfinder.tcz' > $P-locale.tcz.dep

echo 'xfce4-appfinder.tcz
intltool.tcz
glib2-dev.tcz
gtk3-dev.tcz 
libxfce4ui-dev.tcz 
garcon-dev.tcz ' > $P-dev.tcz.dep

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

echo 'Title:          xfce4-appfinder.tcz  
Description:    xfce find and launch app
Version:        4.13.0
Author:         see doc for authors  
Original-site:  xfce.org
Copying-policy: GPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       Find and launch "loaded" software that
                has desktop entries

                panel 1 -> Applications -> Accessories
                -> Application Finder OR
                kb shortcut ALT key + F2 key

                When it first opens it looks like a 
                normal search bar.

                If you click the down arrow to the
                right of input area, a mini menu appears.

                Once open, the arrow changes to an up 
                arrow to act like a minimise menu button.

                If you launch from this app, the selected
                app will open and the appfinder app will
                close.

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

echo 'Title:          xfce4-appfinder-doc.tcz
Description:    docs
Version:        4.13.0
Author:         see doc for authors 
Original-site:  xfce.org
Copying-policy: GPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       some docs
                
                Compiled for 64 9.x
Change-log:     2018/04/26  First version 
Current:        2018/04/26  ' > $P-doc.tcz.info

echo 'Title:          xfce4-appfinder-locale.tcz
Description:    locales
Version:        4.13.0
Author:         see doc for authors 
Original-site:  xfce.org
Copying-policy: GPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       for non-english users untested

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

submitqc --libs
