#!/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=fastfetch
V=2.37.0
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc cmake python3.9-dev libvulkan-dev dbus-dev pulseaudio-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/$P-cli/$P/archive/refs/tags/$V.tar.gz  " $USER 
tar xvf $V*gz
cd $SRC
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../
make -j5  # 30s
make install DESTDIR=/tmp/$P
cd /tmp

# 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
mv $P/usr/local/share/licenses/$P/LICENSE $P/usr/local/share/doc/$P/
rm -rf $P/usr/local/share/licenses

# we have no fish shell...but we have zsh but removed as its old
rm -rf $P/usr/local/share/fish
rm -rf $P/usr/local/share/zsh

strip --strip-unneeded $P/usr/local/bin/*

# TCZ them
###########
LIST2="$P $P-doc "
for Z in $LIST2
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:          fastfetch-doc.tcz
Description:    man page
Version:        2.37.0
Author:         Linus Dierheimer & Carter Li  
Original-site:  https://github.com/fastfetch-cli/fastfetch
Copying-policy: accompanied
Size:           8.0K           
Extension_by:   aus9 @linuxquestions.org
Tags:           terminal system information cli
Comments:       -
                
Change-log:     2025/02/16 v 2.37.0 on 16x
Current:        2025/02/16     ' > $P-doc.tcz.info  
echo 'man-db.tcz                                   ' > $P-doc.tcz.dep 

echo 'Title:          fastfetch.tcz
Description:    CLI system infomation tool
Version:        2.37.0
Author:         Linus Dierheimer & Carter Li    
Original-site:  https://github.com/fastfetch-cli/fastfetch
Copying-policy: accompanied
Size:           1.4M          
Extension_by:   aus9 @linuxquestions.org
Tags:           terminal system information cli
Comments:       neofetch no longer active,
                fastfetch supports wayland

                quick info is $ fastfetch
                For other options see TCE-doc please
                or /usr/local/share/fastfetch/presets/
                or I recommend https://blog.desdelinux.net/en/fastfetch-tutorial/

                one liners that might interest you?
                $ fastfetch -s sound # displays only sound
                $ fastfetch --logo none # normal output sans logo

Change-log:     2025/02/16 v 2.37.0 on 16x
Current:        2025/02/16     ' > $P.tcz.info  
readelf -d $P/usr/local/bin/* | grep 'NEEDED'  # TCBs only 

submitqc --libs
rm -rf *.zsync


