# not a script as I am not showing that I used web browser to get pem for https://github.com/Smithay/smithay.git
# AND updated ca-certs....I do show some fixes tho below
# cargo fix https://github.com/rust-lang/cargo/issues/13457#issuecomment-2063947062

export CFLAGS="-mtune=generic -Os -pipe"
export CXXFLAGS="-mtune=generic -Os -pipe "
P=xwayland-satellite
V=0.8.2
SRC=$P-$V
SRC2=$SRC/target/release
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc clang git rust libxcb-dev xwayland   "    
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/Supreeeme/$P/archive/refs/tags/v$V.tar.gz
tar xvf v*gz
cd $SRC

# fix cargo ssl error for https://index.crates.io/config.json 
##############################################################  Note I build by root so change pathway if you use non-root
[ -d /root/.cargo ] || mkdir -p /root/.cargo
echo 'cargo-net.git-fetch-with-cli = true
registries.crates-io.protocol = "git" ' > /root/.cargo/config.toml

# fix cargo ssl error for https://github.com/Smithay/smithay.git
#################################################################
# A add the crt to /usr/local/share/ca-certificates and follow instructions
# B /etc/ssl pathway as per home bin
[ -d /etc/ssl/certs ] || mkdir -p /etc/ssl/certs
[ -f /etc/ca-certificates.conf ] || cp -p /usr/local/share/ca-certificates/files/ca-certificates.conf /etc
update-ca-certificates
ln -s /usr/local/etc/ssl/certs/ca-certificates.crt /etc/ssl/cacert.pem
ln -s /usr/local/etc/ssl/certs/ca-certificates.crt /etc/ssl/ca-bundle.crt

cargo build --release # takes 1m 14s
cd /tmp
########################################################
# main
######
mkdir -p $P/usr/local/share/doc/$P
cp $SRC/LICENSE $P/usr/local/share/doc/$P/

mkdir -p $P/usr/local/bin 
cp $SRC2/$P $P/usr/local/bin
strip --strip-unneeded $P/usr/local/bin/$P


# TCZ them
#######
LIST="$P "
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:          xwayland-satellite.tcz 
Description:    xwayland outside your wayland
Version:        0.8.2
Author:         Supreeeme 
Original-site:  https://github.com/Supreeeme/xwayland-satellite
Copying-policy: Mozilla Public License 2.0
Size:           2.5M		
Extension_by:   aus9 
Tags:           wayland  
Comments:       xwayland-satellite grants rootless Xwayland integration to 
                any Wayland compositor implementing xdg_wm_base and viewporter. 

                The host compositor needs:
                Core interfaces (wl_output, wl_surface, wl_compositor, etc)
                xdg_shell (xdg_wm_base, xdg_surface, xdg_popup, xdg_toplevel)
                wp_viewporter - used for scaling

                Can optionally use: Linux dmabuf, XDG activation,
                XDG decoration, XDG foreign, Pointer constraints,
                Primary selection, Tablet input & Fractional scale

                This TCE is an optional TCE for niri as it can not use xwayland direct
 
Change-log:     2026/09/21 v 0.8.2 on 17x
Current:        2026/09/21  '  > $P.tcz.info

readelf -d $P/usr/local/bin/$P | grep 'NEEDED'
#[libxcb-cursor.so.0][libxcb.so.1] libxcb

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

submitqc --libs
rm -rf *.zsync

