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

export CFLAGS="-mtune=generic -Os -pipe"
export CXXFLAGS="-mtune=generic -Os -pipe -fno-exceptions -fno-rtti"

P=playerctl
SRC=$P-$V
V=2.4.1
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc glib2-dev meson cmake   "
for Z in $LIST 
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
/usr/local/bin/wget -nc --no-check-certificate \
https://github.com/altdesktop/$P/archive/refs/tags/v$V.tar.gz
tar xvf v*gz
cd $SRC
meson setup --prefix=/usr/local -Dstrip=true -Ddebug=false -Dgtk-doc=false -Dintrospection=false -Dbash-completions=false -Dzsh-completions=false build  
# bash-completions: false
# debug           : false
# gtk-doc         : false
# introspection   : false
# prefix          : /usr/local
# strip           : true
# zsh-completions : false
ninja -C build # seconds
cd build
DESTDIR=/tmp/$P ninja install
cd /tmp

# no dev but doc still got built so use it
rm -rf $P/usr/local/include $P/usr/local/lib/pkgconfig

# doc
######
mkdir -p $P-doc/usr/local/share
mv $P/usr/local/share/man $P-doc/usr/local/share/

# main
######
mkdir -p $P/usr/local/share/doc/$P 
echo 'LGPL v 3' > $P/usr/local/share/doc/$P/COPYING


# TCZ them
#######
LIST="$P $P-doc "
for Z in $LIST
do
	mksquashfs $Z $Z.tcz
	md5sum $Z.tcz > $Z.tcz.md5.txt
	cd $Z
	find . -not -type d | cut -c 2- | sort > /tmp/$Z.tcz.list
	cd /tmp
done

ls -hal 

echo 'Title:          playerctl-doc.tcz
Description:    man page
Version:        2.4.1
Author:         https://github.com/altdesktop/playerctl/blob/master/CONTRIBUTORS
Original-site:  https://github.com/altdesktop/playerctl
Copying-policy: LGPL v 3
Size:           4.0K
Extension_by:   aus9 @linuxquestions.org
Tags:           media player 
Comments:       -
                
Change-log:     2025/12/04 v 2.4.1  on 16x
Current:        2025/12/04  '  > $P-doc.tcz.info
echo 'man-db.tcz' > $P-doc.tcz.dep

echo 'Title:          playerctl.tcz
Description:    command line media controller as below
Version:        2.4.1
Author:         https://github.com/altdesktop/playerctl/blob/master/CONTRIBUTORS
Original-site:  https://github.com/altdesktop/playerctl
Copying-policy: LGPL v 3
Size:           96K
Extension_by:   aus9 @linuxquestions.org
Tags:           media player 
Comments:       mpris media player command-line controller for 
                audacious-plugins,rhythmbox, vlc and xmms2. However, any player 
                that implements the MPRIS interface specification can be controlled 
                using playerctl

                NOTE you may need a playlist or a dir of files to play for some kb combos
                (tested with audacious-plugins)
                playerctl play-pause
                playerctl next
                playerctl previous 
                
Change-log:     2025/12/04 v 2.4.1  on 16x
Current:        2025/12/04  '  > $P.tcz.info

readelf -d $P/usr/local/bin/* | grep 'NEEDED'
#libplayerctl.so.2] this TCE
#libgobject-2.0.so.0]#libglib-2.0.so.0]#libgio-2.0.so.0] glib2

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

submitqc --libs
rm -rf *.zsync

# ineed wrapper scripts for t n p

DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus




