#!/bin/sh
# test we are root
if [ "$USER" != "root" ] ; then
   echo "Run as root please, exiting." 
   exit 1                                                      
fi

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

P=xfce4-settings
V=4.13.1
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc intltool exo-dev libnotify-dev \
libxklavier-dev libXcursor-dev upower-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://mirror.vinahost.vn/xfce/src/xfce/$P/4.13/$P-$V.tar.bz2 " $USER

mkdir $P
tar jxvf $P*bz2
cd $P-4*
./configure --enable-debug=no --enable-sound-settings \
--enable-xcursor --enable-xrandr --enable-libxklavier \
--enable-pluggable-dialogs
#######################################################
# Build Configuration:

# Installation prefix:       /usr/local
# Debug Support:             no
# Xrandr support:            yes
# UPower support:            yes
# Libnotify support:         yes
# Xcursor support:           yes
# Xorg libinput support:     no
# Embedded settings dialogs  yes
# Sounds settings support    yes
# Libxklavier support:       yes
# Mime settings (gio-unix):  yes
######################################################## 
make -j5
make install-strip DESTDIR=/tmp/$P
cd /tmp

# locale
#########
cd /tmp
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
cp $P-$V/AUTHORS $P/usr/local/share/doc/$P/
cp $P-$V/COPYING $P/usr/local/share/doc/$P/

# the desktops only appear in XFCE

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

cat > $P/usr/local/tce.installed/$P << 'EOF'
#!/bin/sh
/usr/local/etc/init.d/dbus start
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 'xfce4-settings.tcz' > $P-locale.tcz.dep

echo 'xfce4-settings.tcz
intltool.tcz
exo-dev.tcz 
libnotify-dev.tcz
libXcursor-dev.tcz
libxklavier-dev.tcz
upower-dev.tcz ' > $P-dev.tcz.dep

echo 'exo.tcz
libxklavier.tcz' > $P.tcz.dep

# upower can be a part of xfce4-power-manager as its optional dep

echo 'Title:          xfce4-settings.tcz  
Description:    xfce settings
Version:        4.13.1
Author:         see AUTHORS  
Original-site:  xfce.org
Copying-policy: GPL v2
Size:           		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       Mainly the XFCE settings manager.  dbus is started by 
                this App. adwaita icons are loaded by this app to provide 
                alternative icons but would have been loaded by
                Thunar in any case to run a XFCE session.

                Untested by me, if you need Assistive Technologies 
                click panel 1 Applications -> Settings 
                -> (Session and startup) -> (TAB) Application Autostart 
                and tick the box for AT-SPI please.....and
                Settings -> System -> Accessibility -> tick the box
                then check the other TABS please

                Optional dependencies --see their info files please.
                #####################
                gtk-xfce-engine.tcz --provides extra themes
                xfce4-xkb-plugin.tcz --kb configs and non-US layouts
                xfce4-power-manager 

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

echo 'Title:          xfce4-settings-locale.tcz
Description:    locales
Version:        4.13.1
Author:         see 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/03/11  First version 
Current:        2018/03/11 ' > $P-locale.tcz.info

submitqc  --libs
