#!/bin/bash
# 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 CXXFLAGS="-mtune=generic -Os -pipe -fno-exceptions -fno-rtti"

# Apps cairo-dev some not loading do it manually
P=slurp
V=1.5.0
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
 libxkbcommon-dev
LIST="compiletc submitqc meson wayland-dev cairo-dev libxkbcommon-dev libXext-dev libXrender-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://github.com/emersion/$P/releases/download/v$V/$SRC.tar.gz   " $USER
tar xvf $SRC*gz
cd $SRC
meson setup --prefix=/usr/local -Dstrip=true -Ddebug=false -Dman-pages=disabled build
# debug    : false
# prefix   : /usr/local
# strip    : true
# man-pages: disabled
ninja -C build # seconds
cd build
DESTDIR=/tmp/$P ninja install
cd /tmp

# main
######
mkdir -p $P/usr/local/share/doc/$P
cp $SRC/LICENSE  $P/usr/local/share/doc/$P/

# TCZ them
#######
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:          slurp.tcz 
Description:    Select a region in wayland for screenshots 
Version:        1.5.0
Author:         emersion
Original-site:  https://github.com/emersion/slurp
Copying-policy: Accompanied 
Size:           20K		
Extension_by:   aus9 @linuxquestions.org 
Tags:           wayland screen capture
Comments:       slurp is a command-line app to select a region 
                inside wayland desktop eg sway and 
                used with grim to take a screenshot.
                grim can not escape its current window, but slurp can.

                $ slurp | grim 1.png
                (for a RH mouse user, Left click top left corner of 
                your desired selection, hold mouse button down
                move mouse to bottom RH corner of selection.
                Release button.....screenshot taken)

                grim has been made a dep of slurp

Change-log:     2019/06/16 v 1.2.0 on 10x 
                2020/07/02 v git 20200702 on 11x 
                2023/04/22 v 1.4.0 on 14x  
Current:        2024/03/31 v 1.5.0 on 15x ' > $P.tcz.info

readelf -d $P/usr/local/bin/$P | grep 'NEEDED'

#[libcairo.so.2]cairo
#[libwayland-client.so.0][libwayland-cursor.so.0] wayland
#[libxkbcommon.so.0]     libxkbcommon

echo 'grim.tcz
cairo.tcz
wayland.tcz
libxkbcommon.tcz' > $P.tcz.dep

submitqc --libs
rm -rf *.zsync

