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

# prev build was libxfceui this is last in set

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=parole
V=4.18.0
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc libxfce4ui-dev taglib-dev dbus-glib-dev \
libnotify-dev gstreamer-dev  gst-plugins-base-dev"   
    for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

# list may have more than loaded
cd /usr/local/lib
rm -rf *.la
rm -rf gcc/aarch64-unknown-linux-gnu/12.2.0/plugin/*.la
rm -rf gcc/aarch64-unknown-linux-gnu/12.2.0/*.la
rm -rf gprofng/*.la 
rm -rf python3.8/site-packages/*.la
rm -rf pkcs11/*.la
rm -rf cairo/*.la
rm -rf gtk-2.0/modules/*.la
rm -rf gtk-2.0/2.10.0/printbackends/*.la
rm -rf gtk-2.0/2.10.0/immodules/*.la
rm -rf gtk-2.0/2.10.0/engines/*.la
rm -rf imlib2/loaders/*.la
rm -rf imlib2/filters/*.la
rm -rf gdk-pixbuf-2.0/2.10.0/loaders/*.la
rm -rf libnl/cli
cd /tmp
rm -rf /usr/lib/*.la

su -c "/usr/local/bin/wget -nc --no-check-certificate \
https://archive.xfce.org/src/apps/$P/4.18/$SRC.tar.bz2"  $USER
tar jxvf $SRC*bz2
cd $SRC
./configure --prefix=/usr/local	 --disable-debug --disable-mpris2-plugin --disable-notify-plugin
# prefix:                   /usr/local 
# Debug:                    no
# Building plugin api docs: no
# GStreamer API version:    1.0
# GTK+ version:             GTK+-3
# Clutter Backend:          blacklisted
# Taglib:                   yes
# Plugins-Notify:           no
# System Tray icon:         yes
# MPRIS2:                   no
make -j4 # 40 secs
make install-strip DESTDIR=/tmp/$P
cd /tmp

# no dev
#########
rm -rf $P/usr/local/include
rm -rf $P/usr/local/lib/$P-0/*la
rm -rf $P/usr/local/lib/pkgconfig

# locale
######
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/pixmaps
cp $P/usr/local/share/icons/hicolor/48x48/apps/org.xfce.parole.png $P/usr/local/share/pixmaps/$P.png
APP=$P/usr/local/share/applications
mv $APP/
# leave the other desktop intact for reduced error messages
echo 'FullPathIcon=/usr/local/share/pixmaps/parole.png' >> $APP/org.xfce.Parole.desktop\
mkdir -p $P/usr/local/share/doc/$P
echo 'GPL v2' > $P/usr/local/share/doc/$P/COPYING

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

echo '#!/bin/sh
USER=`cat /etc/sysconfig/tcuser`
[ -d /run/user/$USER ] || mkdir -p /run/user/$USER
export XDG_RUNTIME_DIR=/run/user/$USER ' > $P/usr/local/tce.installed/$P
chown -R root:staff $P/usr/local/tce.installed
chmod -R 775 $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

ls -hal

echo 'Title:          parole-locale.tcz  
Description:    language files
Version:        4.18.0
Author:         Ali Abdallah, Simon Steinbeiss & Sean Davis
Original-site:  https://docs.xfce.org/apps/parole/start
Copying-policy: GPL v2
Size:           552K		
Extension_by:   aus9
Tags:           gtk3 video audio player  
Comments:       untested by me 

Change-log:     2020/10/22 v 1.0.5 on 12.x 
Current:        2023/06/20 v 4.18.0 on 14.x '> $P-locale.tcz.info  
echo 'parole.tcz ' > $P-locale.tcz.dep  

echo 'Title:          parole.tcz  
Description:    gtk3 gstreamer media player 
Version:        4.18.0
Author:         Ali Abdallah, Simon Steinbeiss & Sean Davis
Original-site:  https://docs.xfce.org/apps/parole/start
Copying-policy: GPL v2
Size:           300K		
Extension_by:   aus9
Tags:           gtk3 video audio player  
Comments:       Online docs with extra links here
                https://docs.xfce.org/apps/parole/start
                home config is 
                ~/.config/xfce4/xfconf/xfce-perchannel-xml/parole.xml

                Video sub-titles not tested. You may need more fonts.
                If you load a screensaver, kill it.

                Audio: config already enabled and loads headphones (bcm2835)
                Which also allows my desktop speakers to sing to me.
                Read config.txt for hdmi issues please

                Plays most formats like mp3, mp4 etc but not .m4a (AAC) nor 
                .flac audio files. Some .mkv videos lose audio output 

                With parole open, tools -> plugins -> enable tray plugin and it works in jwm

                YMMV

Change-log:     2020/10/22 v 1.0.5 on 12.x 
Current:        2023/06/20 v 4.18.0 on 14.x '> $P.tcz.info

readelf -d $P/usr/local/bin/* | grep 'NEEDED' # delete TCBS duplicates below
#[libgsttag-1.0.so.0]gst-plugins-base
#[libgstpbutils-1.0.so.0] "
#[libgstaudio-1.0.so.0]   "
#[libgmodule-2.0.so.0]glib2 recursive dep libxfce4ui
#[libdbus-glib-1.so.2]dbus-glib
#[libdbus-1.so.3]dbus
#[libxfce4ui-2.so.0]libxfce4ui
#[libgtk-3.so.0]gtk3   "
#[libgdk-3.so.0]        "
#[libpangocairo-1.0.so.0]pango libxfce4ui 
#[libpango-1.0.so.0]               "
#[libharfbuzz.so.0]harfbuzz        "
#[libatk-1.0.so.0] atk             "
#[libcairo-gobject.so.2]cairo      "
#[libcairo.so.2]                   "
#[libgdk_pixbuf-2.0.so.0]gdk-pixbuf "
#[libxfce4util.so.7]libxfce4util recursive  "
#[libxfconf-0.so.3]xfconf recursive     "
#[libgio-2.0.so.0]glib2     "
#[libgstvideo-1.0.so.0]gst-plugins-base
#[libgstbase-1.0.so.0] "
#[libgstreamer-1.0.so.0]gstreamer
#[libgobject-2.0.so.0]glib2 rec dep libxfce4ui
#[libglib-2.0.so.0] "
#[libtag_c.so.0]taglib
#[libSM.so.6]libSM    dep libxfce4ui 
#[libICE.so.6]libICE    "
#[libX11.so.6]libX11    "

# misleading above...running from terminal parole I also see lots of messages like
# (gst-plugin-scanner:5700): GStreamer-WARNING **: 09:00:11.473: Failed to load plugin '/usr/local/lib/gstreamer-1.0/
###libgstmpeg2dec.so': libmpeg2.so.0: cannot open shared object file: No such file or directory
# tce-load -i liblcms2 reduces above and similar 


echo 'gst-plugins-base.tcz
libxfce4ui.tcz
dbus-glib.tcz
gstreamer.tcz
taglib.tcz
alsa.tcz
gst-plugins-good.tcz 
gst-plugins-bad.tcz
gst-plugins-ugly.tcz 
gst-libav.tcz 
liblcms2.tcz ' > $P.tcz.dep

submitqc --libs
rm -rf *.zsync



