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

# error: cannot use ‘typeid’ with ‘-fno-rtti’ kept from aspell build
export CFLAGS="-mtune=generic -Os -pipe"  
export CXXFLAGS="-mtune=generic -Os -pipe -fno-exceptions "

PEN=aspell-en
SRCEN=aspell6-en-2020.12.07-0
PDE=aspell-de
SRCDE=aspell6-de-20161207-7-0
PES=aspell-es
SRCES=aspell6-es-1.11-2
PFR=aspell-fr
SRCFR=aspell-fr-0.50-3
PIT=aspell-it
SRCIT=aspell6-it-2.2_20050523-0
PPTBR=aspell-pt_BR
SRCPTBR=aspell6-pt_BR-20131030-12-0

USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc aspell  "
for Z in $LIST 
    do 
    su -c "tce-load -i $Z" $USER
done

URL=https://ftp.gnu.org/gnu/$P/dict
cd /tmp
su -c "/usr/local/bin/wget -nc --no-check-certificate \
$URL/$SRCEN.tar.bz2  \
$URL/de/$SRCDE.tar.bz2 \
$URL/es/$SRCES.tar.bz2 \
$URL/fr/$SRCFR.tar.bz2 \
$URL/it/$SRCIT.tar.bz2 \
$URL/pt_BR/$SRCPTBR.tar.bz2 " $USER

# dictionaries
###############
LIST="aspell6-de-20161207-7-0 aspell6-en-2020.12.07-0 aspell6-es-1.11-2 aspell6-it-2.2_20050523-0 \
aspell6-pt_BR-20131030-12-0 aspell-fr-0.50-3   "
for Z in $LIST
do
	tar jxvf $Z.tar.bz2
done

LISTA="aspell-en aspell-de aspell-es aspell-fr aspell-it aspell-pt_BR"
   for Z in $LISTA
do   
   mkdir -p $Z/usr/local/lib/aspell-0.60 
   mkdir -p $Z/usr/local/share/doc/$Z
done

# we will use timestamps to grab the files for building
# I could have made another list below but thought it too risky as I need to check the lists*

# en
#####
cd $SRCEN
./configure
make -j4
touch /tmp/marken
sleep 60 # force a delay so we do not move anything recent not connected to make install
make install
find /usr/local -newer /tmp/marken -not -type d > /tmp/listen # make sure all went to one dir
cd /usr/local/lib/aspell-0.60/
mv *.alias /tmp/$PEN/usr/local/lib/aspell-0.60/
mv *.dat   /tmp/$PEN/usr/local/lib/aspell-0.60/
mv *.multi /tmp/$PEN/usr/local/lib/aspell-0.60/
mv *.rws   /tmp/$PEN/usr/local/lib/aspell-0.60/

# de
#####
cd /tmp/$SRCDE
./configure
make -j4
touch /tmp/markde
sleep 60 # force a delay
make install
find /usr/local -newer /tmp/markde -not -type d > /tmp/listde
cd /usr/local/lib/aspell-0.60/
mv *.alias /tmp/$PDE/usr/local/lib/aspell-0.60/
mv *.dat   /tmp/$PDE/usr/local/lib/aspell-0.60/
mv *.multi /tmp/$PDE/usr/local/lib/aspell-0.60/
mv *.rws   /tmp/$PDE/usr/local/lib/aspell-0.60/

# es
#####
cd /tmp/$SRCES
./configure
make -j4
touch /tmp/markes
sleep 60
make install
find /usr/local -newer /tmp/markes -not -type d > /tmp/listes
cd /usr/local/lib/aspell-0.60/
mv *.alias /tmp/$PES/usr/local/lib/aspell-0.60/
mv *.dat   /tmp/$PES/usr/local/lib/aspell-0.60/
mv *.multi /tmp/$PES/usr/local/lib/aspell-0.60/
mv *.rws   /tmp/$PES/usr/local/lib/aspell-0.60/

# fr
#####
cd /tmp/$SRCFR
./configure
make -j4
touch /tmp/markfr
sleep 60
make install
find /usr/local -newer /tmp/markfr -not -type d > /tmp/listfr
cd /usr/local/lib/aspell-0.60/
mv *.alias /tmp/$PFR/usr/local/lib/aspell-0.60/
mv *.dat   /tmp/$PFR/usr/local/lib/aspell-0.60/
mv *.multi /tmp/$PFR/usr/local/lib/aspell-0.60/
mv *.rws   /tmp/$PFR/usr/local/lib/aspell-0.60/

# it
#####
cd /tmp/$SRCIT
./configure
make -j4
touch /tmp/markit
sleep 60
make install
find /usr/local -newer /tmp/markit -not -type d > /tmp/listit
cd /usr/local/lib/aspell-0.60/
mv *.alias /tmp/$PIT/usr/local/lib/aspell-0.60/
mv *.dat   /tmp/$PIT/usr/local/lib/aspell-0.60/
mv *.multi /tmp/$PIT/usr/local/lib/aspell-0.60/
mv *.rws   /tmp/$PIT/usr/local/lib/aspell-0.60/

# pt_BR
#####
cd /tmp/$SRCPTBR
./configure
make -j4
touch /tmp/markpt
sleep 60
make install
find /usr/local -newer /tmp/markpt -not -type d > /tmp/listpt
cd /usr/local/lib/aspell-0.60/
mv *.alias /tmp/$PPTBR/usr/local/lib/aspell-0.60/
mv *.dat   /tmp/$PPTBR/usr/local/lib/aspell-0.60/
mv *.multi /tmp/$PPTBR/usr/local/lib/aspell-0.60/
mv *.rws   /tmp/$PPTBR/usr/local/lib/aspell-0.60/

# add licences and copyright where applicable  gpl es fr it
cd /tmp
echo 'GPL v 2' > COPYING
cp COPYING $PES/usr/local/share/doc/$PES
cp COPYING $PFR/usr/local/share/doc/$PFR
mv COPYING $PIT/usr/local/share/doc/$PIT
cp $SRCEN/Copyright $PEN/usr/local/share/doc/$PEN # needs the scowl too as per contents of copyright
cp $SRCEN/doc/SCOWL-README $PEN/usr/local/share/doc/$PEN
cp $SRCDE/Copyright $PDE/usr/local/share/doc/$PDE

# TCZ them
#######
LISTA="aspell-en aspell-de aspell-es aspell-fr aspell-it aspell-pt_BR"
for Z in $LISTA
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:          aspell-de.tcz
Description:    aspell German dictionary
Version:        20161207-7-0
Author:         Björn Jacke
Original-site:  https://ftp.gnu.org/gnu/aspell/dict/0index.html
Copying-policy: accompanied
Size:           1000K 
Extension_by:   aus9 @linuxquestions.org
Tags:           spell check dictionary english
Comments:       -
                
Change-log:     2024/10/27 v 20161207-7-0 on 15x
Current:        2024/10/27  ' > $P-de.tcz.info
echo 'aspell-locale.tcz' > $P-de.tcz.dep

echo 'Title:          aspell-en.tcz
Description:    aspell English dictionary
Version:        2020.12.07-0
Author:         Kevin Atkinson
Original-site:  https://ftp.gnu.org/gnu/aspell/dict/0index.html
Copying-policy: accompanied
Size:           2.1M 
Extension_by:   aus9 @linuxquestions.org
Tags:           spell check dictionary english
Comments:       Upgrade WARNING if you have added any file to
                persistence please move out of backup, reboot and
                check for differences please. YMMV

                With the change in dependency, this become the TCE to
                add to your boot list if you use it frequently
                
Change-log:     2013/12/16 v 7.1 (Juanito)
                2018/01/24 v 2017.08.24
Current:        2024/10/27 v 2020.12.07-0 on 15x (aus9) ' > $P-en.tcz.info
echo 'aspell.tcz' > $P-en.tcz.dep

echo 'Title:          aspell-es.tcz
Description:    aspell Spanish dictionary
Version:        1.11-2
Author:         Agustin Martin Domingo
Original-site:  https://ftp.gnu.org/gnu/aspell/dict/0index.html
Copying-policy: GPL v 2
Size:           596K 
Extension_by:   aus9 @linuxquestions.org
Tags:           spell check dictionary english
Comments:       -
                
Change-log:     2024/10/27 v 1.11-2 on 15x
Current:        2024/10/27  ' > $P-es.tcz.info
echo 'aspell-locale.tcz' > $P-es.tcz.dep

echo 'Title:          aspell-fr.tcz
Description:    aspell French dictionary
Version:        0.50-3
Author:         Gutenberg Association
Original-site:  https://ftp.gnu.org/gnu/aspell/dict/0index.html
Copying-policy: GPL v 2
Size:           7.0M 
Extension_by:   aus9 @linuxquestions.org
Tags:           spell check dictionary english
Comments:       -
                
Change-log:     2024/10/27 v 0.50-3 on 15x
Current:        2024/10/27  ' > $P-fr.tcz.info
echo 'aspell-locale.tcz' > $P-fr.tcz.dep

echo 'Title:          aspell-it.tcz
Description:    aspell Italian dictionary
Version:        2.2_20050523-0
Author:         Davide Prina
Original-site:  https://ftp.gnu.org/gnu/aspell/dict/0index.html
Copying-policy: GPL v 2
Size:           840K 
Extension_by:   aus9 @linuxquestions.org
Tags:           spell check dictionary english
Comments:       -
                
Change-log:     2024/10/27 v 2.2_20050523-0 on 15x
Current:        2024/10/27  ' > $P-it.tcz.info
echo 'aspell-locale.tcz' > $P-it.tcz.dep

echo 'Title:          aspell-pt_BR.tcz
Description:    aspell Brazilian Portuguese dictionary
Version:        20131030-12-0
Author:         Raimundo Santos Moura
Original-site:  https://ftp.gnu.org/gnu/aspell/dict/0index.html
Copying-policy: unknown believed to be GPL v2
Size:           3.4M 
Extension_by:   aus9 @linuxquestions.org
Tags:           spell check dictionary english
Comments:       -
                
Change-log:     2024/10/27 v 20161207-7-0 on 15x
Current:        2024/10/27  ' > $P-pt_BR.tcz.info
echo 'aspell-locale.tcz' > $P-pt_BR.tcz.dep

submitqc --libs 
rm -rf *.zsync

# we can not have a locale user forced to load en dictionary to get access to their lang dictionary

