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

P=freedoom
V=0.13.0
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="submitqc  "
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/$P/$P/releases/download/v$V/$SRC.zip
unzip $SRC.zip

# doc
######
mkdir -p      $P-doc/usr/local/share/doc/$P
cp $SRC/*.pdf $P-doc/usr/local/share/doc/$P

# main
######
mkdir -p $P/usr/local/share/doc/$P $P/usr/local/share/$P/files $P/usr/local/share/games/uzdoom
cp $SRC/COPYING.txt $P/usr/local/share/doc/$P/
cp $SRC/*wad $P/usr/local/share/games/uzdoom

# 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:          freedoom-doc.tcz
Description:    3x PDF manuals
Version:        0.13.0
Author:         Contributors to the Freedoom project
Original-site:  https://freedoom.github.io/download.html
Copying-policy: https://github.com/freedoom/freedoom/blob/master/COPYING.adoc
Size:           2.8M
Extension_by:   aus9 
Tags:           game 
Comments:       English, French & Spanish
              
Change-log:     2026/01/02 v 0.13.0  on 16x
Current:        2026/01/02 '  > $P-doc.tcz.info

echo 'Title:          freedoom.tcz
Description:    2x Free Doom game wads
                WARNING has pixelated violence
Version:        0.13.0
Author:         Contributors to the Freedoom project
Original-site:  https://freedoom.github.io/download.html
Copying-policy: https://github.com/freedoom/freedoom/blob/master/COPYING.adoc
Size:           24M
Extension_by:   aus9 
Tags:           game 
Comments:       Freedoom is a complete, free content first person shooter 
                games, based on the Doom engine. Needs a doom engine
                see TCE=uzdoom, not suitable for children

                *1.wad= Four episodes, nine levels each. Aims for compatibility with 
                        The Ultimate Doom mods, AKA Doom 1. 

                *2.wad= 32 levels in one episode, featuring extra monsters and 
                        double-barrelled shotgun. Aims for compatibility with 
                        Doom II mods.
              
Change-log:     2026/01/02 v 0.13.0  on 16x
Current:        2026/01/02     '  > $P.tcz.info
# no deps

submitqc --libs
rm -rf *.zsync

