#!/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 "

P=xbubble
V=0.5.11.2
SRC=$P-$V.orig
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc git libpng-dev libX11-dev libXt-dev gettext-dev imagemagick "
for Z in $LIST 
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
URL=https://sources.debian.org/data/main/x/xbubble/0.5.11.2-3.5/debian/patches
su -c "/usr/local/bin/wget -nc --no-check-certificate \
http://deb.debian.org/debian/pool/main/x/xbubble/xbubble_0.5.11.2.orig.tar.gz \
$URL/no-werror.patch \
$URL/10-game.c.patch \
$URL/Fixes-FTBFS-with-loadpng.c-ignoring-return-value-of-fread \
$URL/Check-returns-from-the-realpath-function-in-data_file-function \
$URL/libpng15.patch " $USER
tar xvf $P*gz
cd $SRC
patch -Np1 < ../no-werror.patch
patch -Np1 < ../10-game.c.patch
patch -Np1 < ../Fixes-FTBFS-with-loadpng.c-ignoring-return-value-of-fread
patch -Np1 < ../Check-returns-from-the-realpath-function-in-data_file-function
patch -Np1 < ../libpng15.patch
./configure --prefix=/usr/local --with-x
make -j4  # seconds
make install-strip DESTDIR=/tmp/$P
cd /tmp

# doc
##### built to wrong pathway
mkdir -p $P-doc/usr/local/share/
mv $P/usr/local/man $P-doc/usr/local/share/

# 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/doc/$P
echo 'GPL v 2' > $P/usr/local/share/doc/$P/COPYING

# desktop stuff
################
mkdir -p $P/usr/local/share/pixmaps
cp $P/usr/local/share/xbubble/themes/plain/Bubble_green_DEFAULT_01.png $P/usr/local/share/pixmaps/xbubble.png
convert $P/usr/local/share/pixmaps/xbubble.png -resize 48x48 $P/usr/local/share/pixmaps/xbubble.png
# no desktop create non-locale one
DESK=$P/usr/local/share/applications/$P.desktop
mkdir -p $P/usr/local/share/applications
echo '[Desktop Entry]
Name=xbubble
Comment=shoot the bubbles
Exec=xbubble
Icon=xbubble
Terminal=false
Type=Application
Categories=Game;
X-FullPathIcon=/usr/local/share/pixmaps/xbubble.png' > $DESK

# TCZ them
#######
LIST="$P $P-doc $P-locale "
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:          xbubble-doc.tcz
Description:    man page
Version:        0.5.11.2
Author:         Ivan Djelic & Martin Quinson
Original-site:  http://deb.debian.org/debian/pool/main/x/xbubble
                https://sources.debian.org/data/main/x/xbubble/0.5.11.2-3.5/debian/patches
Copying-policy: GPL v 2
Size:           4.0K
Extension_by:   aus9 @linuxquestions.org
Tags:           game 
Comments:       -
                
Change-log:     2014/12/07 v 0.5.11.2 on 15x
Current:        2024/12/07 '  > $P-doc.tcz.info
echo 'man-db.tcz' > $P-doc.tcz.dep

echo 'Title:          xbubble-locale.tcz
Description:    only French language files
Version:        0.5.11.2
Author:         Ivan Djelic & Martin Quinson
Original-site:  http://deb.debian.org/debian/pool/main/x/xbubble
                https://sources.debian.org/data/main/x/xbubble/0.5.11.2-3.5/debian/patches
Copying-policy: GPL v 2
Size:           4.0K
Extension_by:   aus9 @linuxquestions.org
Tags:           game 
Comments:       untested by me
                
Change-log:     2014/12/07 v 0.5.11.2 on 15x
Current:        2024/12/07 '  > $P-locale.tcz.info
echo 'xbubble.tcz' > $P-locale.tcz.dep

echo 'Title:          xbubble.tcz
Description:    bubble shooting game
Version:        0.5.11.2
Author:         Ivan Djelic & Martin Quinson
Original-site:  http://deb.debian.org/debian/pool/main/x/xbubble
                https://sources.debian.org/data/main/x/xbubble/0.5.11.2-3.5/debian/patches
Copying-policy: GPL v 2
Size:           5.2M
Extension_by:   aus9 @linuxquestions.org
Tags:           game 
Comments:       shoot 3 bubbles of same colour to clear them.
                Any bubbles dependent on cleared bubbles will clear too.
                Game is over if bubbles reach a marked line.
                1 or 2 player + player vs computer modes
                5 difficulty levels but no sound.
                3 themes default is fancy
                
                To try another theme run
                $ xbubble -t frozen (or plain )
$ xbubble [-d display] [-s scale] [-f framerate] [-r resourcepath] [-t theme]
                but on Debian and here, most settings do not work
                IMHO frozen theme looks like frozen-bubble

                -s 100 gave me full screen
                
Change-log:     2014/12/07 v 0.5.11.2 on 15x
Current:        2024/12/07 '  > $P.tcz.info
readelf -d $P/usr/local/bin/* | grep 'NEEDED'
#libX11.so.6]libX11
#libpng16.so.16]libpng
#libmvec.so.1]glibc_add_lib.tcz

# ignore gtk icon caching 
echo 'libX11.tcz
libpng.tcz
glibc_add_lib.tcz ' > $P.tcz.dep

submitqc --libs
rm -rf *.zsync

