#!/bin/sh
# we are root

# one package relies on the other, evidence is do autogen then 
# libcdio---cat configure | grep libcddb*
# eg WARNING: new enough libcddb not found. CDDB access disabled....on first pass.
# vcdimager --configure -> Required libcdio library not found
#./autogen (for libcdio) says checking if gcc supports -fno-rtti -fno-exceptions... no
# some original packages still build la static so not disabled 

export CFLAGS="-O2 -pipe -march=i486 -mtune=i686"
export CXXFLAGS="-O2 -pipe -march=i486 -mtune=i686"

DB=libcddb
IO=libcdio
VI=vcdimager
USER=`cat /etc/sysconfig/tcuser`

# loads old libcdio stuff but get overwritten later
LIST="compiletc submitqc6 git ncurses-dev automake \
libtool-dev texinfo help2man libcdio-dev vcdimager-dev"
for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

# get packages
##############
cd /tmp
su -c "wget http://git.savannah.gnu.org/gitweb/\
?p=libcdio.git;a=snapshot;\
h=ed55ba4f77733313a179a8bdb2e3f675ba0906bd;sf=tgz\
" $USER

su -c "/usr/local/bin/wget -nc  \
http://internode.dl.sourceforge.net/project/libcddb/libcddb/1.3.2/libcddb-1.3.2.tar.bz2 \                                
" $USER

su -c "wget http://ftp.hosteurope.de/mirror/ftp.gnu.org/gnu/vcdimager/\
vcdimager-0.7.24.tar.gz  " $USER  

# Pass ONE libcdio
##################
# we are root for rest of commands
mv libcdio-* git
# google suggests fixes as
cd git/src
touch cd-drive.1 cd-info.1 cd-read.1 iso-info.1 iso-read.1
cd ..
touch doc/version.texi

./autogen.sh
# configure: WARNING: new enough libcddb not found----first pass
# Using CD-ROM drivers : cdrdao, BIN/CUE, NRG, GNU/Linux
# Building cd-info     : yes
# Building cd-read     : yes
# Building cdda-player : yes
# Building iso-info    : yes
# Building iso-read    : yes
# Building C++ programs: yes

./configure --prefix=/usr/local --localstatedir=/var 
make -j5                    
make install 
cd /tmp

# Pass TWO libcddb
###################
tar jxvf $DB-1.3.2.tar.bz2
cd $DB-*
./configure --prefix=/usr/local --localstatedir=/var  
make -j5                    
make install
cd /tmp 

# pass THREE vcdimager
######################
tar xvf $VI-0.7.24.tar.gz
cd $VI-*
# checking if gcc supports -fno-rtti -fno-exceptions... no
./configure --prefix=/usr/local --localstatedir=/var 
make -j5                    
make install
cd /tmp

# Pass FOUR real libcdio
########################
cd git
./configure --prefix=/usr/local \
--localstatedir=/var --enable-vcd-info
make -j5
mkdir -p /tmp/$IO
make install DESTDIR=/tmp/$IO

# strip for cdio
################
cd /tmp/$IO/usr/local
strip --strip-all bin/*
strip --strip-unneeded lib/*.so*
strip --strip-debug lib/*.a
cd /tmp

# create cdio dev
#################
mkdir -p $IO-dev/usr/local/lib
mv $IO/usr/local/include $IO-dev/usr/local/
mv $IO/usr/local/lib/*.la $IO-dev/usr/local/lib/
chmod 644 $IO-dev/usr/local/lib/*.la
mv $IO/usr/local/lib/*.a $IO-dev/usr/local/lib/
mv $IO/usr/local/lib/pkgconfig $IO-dev/usr/local/lib/

# create cdio doc
#################
mkdir -p $IO-doc/usr/local
mv $IO/usr/local/share $IO-doc/usr/local/

# create cdio depend files
##########################
echo 'ncurses.tcz
vcdimager.tcz' > $IO.tcz.dep

echo 'ncurses-dev.tcz
automake.tcz 
libtool-dev.tcz
texinfo.tcz
help2man.tcz
' > $IO-dev.tcz.dep

# Pass Five make real cddb
#############################
cd $DB-*
./configure --prefix=/usr/local --localstatedir=/var --with-cdio
make -j5
mkdir -p /tmp/$DB
make install DESTDIR=/tmp/$DB

# Strip for cddb
###################
cd /tmp/$DB/usr/local
strip --strip-all bin/*
strip --strip-unneeded lib/*.so*
strip --strip-debug lib/*.a
cd /tmp

# create dev for cddb
########################
mkdir -p $DB-dev/usr/local/lib
mv $DB/usr/local/include $DB-dev/usr/local/
mv $DB/usr/local/lib/pkgconfig $DB-dev/usr/local/lib/
mv $DB/usr/local/lib/*.la $DB-dev/usr/local/lib/
chmod 644 $DB-dev/usr/local/lib/*.la
mv $DB/usr/local/lib/*.a $DB-dev/usr/local/lib/

# create cddb depend files
##########################
echo 'libcdio.tcz ' > $DB.tcz.dep

echo "libcddb.tcz
libcdio-dev.tcz" > $DB-dev.tcz.dep

# Pass SIX read vcdimager
####################
cd $VI-*
./configure --prefix=/usr/local --localstatedir=/var
make -j5 
mkdir -p /tmp/$VI
make install DESTDIR=/tmp/$VI

# strip for vcdimager
######################
cd /tmp/$VI/usr/local
strip --strip-all bin/*
strip --strip-unneeded lib/*.so*
strip --strip-debug lib/*.a
cd /tmp

# create vcdimager dev
#################
mkdir -p $VI-dev/usr/local/lib
mv $VI/usr/local/include $VI-dev/usr/local/
mv $VI/usr/local/lib/*.la $VI-dev/usr/local/lib/
chmod 644 $VI-dev/usr/local/lib/*.la
mv $VI/usr/local/lib/*.a $VI-dev/usr/local/lib/
mv $VI/usr/local/lib/pkgconfig $VI-dev/usr/local/lib/

# create vcdimager doc
#################
mkdir -p $VI-doc/usr/local
mv $VI/usr/local/share $VI-doc/usr/local/

# create vcd deps
##################
echo 'vcdimager.tcz' > $VI-dev.tcz.dep

echo 'libxml2.tcz
popt.tcz ' > $VI.tcz.dep



# TCZ them
##########
LIST2="$IO $IO-dev $IO-doc $DB $DB-dev $VI $VI-dev $VI-doc "
for Z in $LIST2
do
	mksquashfs $Z $Z.tcz
	md5sum $Z.tcz > $Z.tcz.md5.txt
	cd $Z
	find usr -not -type d > /tmp/$Z.tcz.list
	cd /tmp
done



# create info files let submitqc5 add size
####################

echo 'Title:          libcdio.tcz
Description:    GNU Compact Disc Input and Control Library
Version:        0.94git 2015/09/04 
Author:         Rocky Bernstein, Herbert Valiero Riedel
Original-site:  http://www.gnu.org/software/libcdio/
Copying-policy: GPLv3
Size: 
Extension_by:   gordon64
Tags:           libcdio
Comments:       The GNU Compact Disc Input and Control library 
                (libcdio) contains a library for CD-ROM and CD 
                image access
                A library for working with ISO-9660 filesystems 
                (libiso9660) is included


                Compiled for x86 6.x
Change-log:     2008/08/16 First version 0.80 Jason W
                2008/12/09 Rebuilt for i486 and size Jason W
                2009/07/10 Updated to 0.81 Jason W
Current:        2015/09/01 updated version 0.94git gordon64
' > $IO.tcz.info

echo 'Title:          libcdio-dev.tcz
Description:    libcdio devs
Version:        0.94git 2015/09/04 
Author:         Rocky Bernstein, Herbert Valiero Riedel
Original-site:  http://www.gnu.org/software/libcdio/
Copying-policy: GPLv3
Size: 
Extension_by:   gordon64
Tags:           libcdio
Comments:       Development files

                Compiled for x86 6.x
Change-log:     2008/08/16 First version 0.80 Jason W
                2008/12/09 Rebuilt for i486 and size Jason W
                2009/07/10 Updated to 0.81 Jason W
Current:        2015/09/01 updated version 0.94git gordon64
' > $IO-dev.tcz.info

echo 'Title:          libcdio-doc.tcz
Description:    libcdio docs
Version:        0.94git 2015/09/04 
Author:         Rocky Bernstein, Herbert Valiero Riedel
Original-site:  http://www.gnu.org/software/libcdio/
Copying-policy: GPLv3
Size: 
Extension_by:   gordon64
Tags:           libcdio
Comments:       Documents

                Compiled for x86 6.x
Change-log:     First version 
Current:        2015/09/01 0.94git gordon64
' > $IO-doc.tcz.info

########################################################
echo 'Title:          libcddb.tcz
Description:    cddb data access
Version:        1.3.2
Author:         see list of sites below
Original-site:  http://sourceforge.net/projects/libcddb/
Copying-policy: see list of sites below
Size: 
Extension_by:   gordon64
Tags:	           cd cddb data audio av
Comments:       Libcddb is a library that implements the different protocols 
                (CDDBP, HTTP) to access data on a CDDB server
                http://freedb.org
                64 bit maintainer Juanito

                Compiled for x86                
Change-log:     first version 
Current:        2015/09/01 
' > $DB.tcz.info

echo 'Title:          libcddb-dev.tcz
Description:    libcddb devs
Version:        1.3.2
Author:         see list of sites below
Original-site:  http://sourceforge.net/projects/libcddb/
Copying-policy: see list of sites below
Size: 
Extension_by:   gordon64
Tags:	           cd cddb data audio av
Comments:       development files only
                64 bit maintainer Juanito

                Compiled for x86                
Change-log:     first version 
Current:        2015/09/01 
' > $DB-dev.tcz.info

###################################################

echo 'Title:          vcdimager.tcz
Description:    Mastering suite for VCDs and SVCDs.
Version:        0.7.23
Author:         Herbert Valerio Riedel, Rocky Bernstein
Original-site:  http://www.gnu.org/software/vcdimager/
Copying-policy: GPLv2
Size: 		
Extension_by:   gordon64   
Tags:           VCD SVCD
Comments:       full-featured mastering suite for authoring, 
                disassembling and analyzing Video CDs and 
                Super Video CDs. 

                compiled for x86 6.x
Change-log:     2010/01/23 first version 0.7.23 Arslan S.
Current:        2015/09/05 v0.7.24 gordon64
' > $P.tcz.info

echo 'Title:          vcdimager-dev.tcz
Description:    vcdimager devs
Version:        0.7.23
Author:         Herbert Valerio Riedel, Rocky Bernstein
Original-site:  http://www.gnu.org/software/vcdimager/
Copying-policy: GPLv2
Size: 		
Extension_by:   gordon64   
Tags:           VCD SVCD
Comments:       Development files

                compiled for x86 6.x
Change-log:     2010/01/23 first version 0.7.23 Arslan S.
Current:   	2015/09/05 v0.7.24 gordon64
' > $P-dev.tcz.info

echo 'Title:          vcdimager-doc.tcz
Description:    vcdimager docs
Version:        0.7.23
Author:         Herbert Valerio Riedel, Rocky Bernstein
Original-site:  http://www.gnu.org/software/vcdimager/
Copying-policy: GPLv2
Size: 		
Extension_by:   gordon64   
Tags:           VCD SVCD
Comments:       Documents

                compiled for x86 6.x
Change-log:     -- first version 
Current:   	2015/09/05 
' > $P-doc.tcz.info

submitqc6