#!/bin/sh
#copyleft jls_legalize (unsenepopiu at tin dot it)
#create alsa-oss tcel and tczl extensions from sources
#and pack them into a single .bfe file
#togheter with info, md5 and dep files.
#Info files shall be in the dir where this script is,
#togheter with the source tar.bz2 file
#requires make, gcc-binutils and base devs for compiling and advcomp for packaging
#tested on tinycore 2.0RC2.1
THE_APP=alsa-oss
VERSION=1.0.17
LIBRARY="l"
MODULE=""
echo "unpack the sources"
tar xjf ${THE_APP}-${VERSION}.tar.bz2
cd ${THE_APP}-1.0.17
[ ! -d extension ] && mkdir -p extension/build
echo "compile"
export CFLAGS="-march=i486 -mtune=i686 -Os -pipe"
export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti"
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
#make clean
./configure --prefix=/usr/local
make DESTDIR=$PWD/extension/build install
chmod +x extension/build/usr/local/bin/aoss
echo "tce"
cd extension/build
find usr -not -type d > ../${THE_APP}.tce${LIBRARY}${MODULE}.list
tar czvf ../${THE_APP}.tce${LIBRARY}${MODULE} --numeric-owner -T ../${THE_APP}.tce${LIBRARY}${MODULE}.list
cd ..
advdef -z4 ${THE_APP}.tce${LIBRARY}${MODULE}
md5sum ${THE_APP}.tce${LIBRARY}${MODULE}   >  ${THE_APP}.tce${LIBRARY}${MODULE}.md5.txt
echo "alsa-modules-2.6.29.1-tinycore.tcem" >  ${THE_APP}.tce${LIBRARY}${MODULE}.dep
echo "input-2.6.29.1-tinycore.tcem"        >> ${THE_APP}.tce${LIBRARY}${MODULE}.dep
echo "bash.tce"                            >> ${THE_APP}.tce${LIBRARY}${MODULE}.dep
echo "alsa.tcel"                           >> ${THE_APP}.tce${LIBRARY}${MODULE}.dep
echo "tcz"
cp ${THE_APP}.tce${LIBRARY}${MODULE}.list ${THE_APP}.tcz${LIBRARY}${MODULE}.list
mkfs.cramfs build ${THE_APP}.tcz${LIBRARY}${MODULE}
md5sum ${THE_APP}.tcz${LIBRARY}${MODULE}   >  ${THE_APP}.tcz${LIBRARY}${MODULE}.md5.txt
echo "alsa-modules-2.6.29.1-tinycore.tczm" >  ${THE_APP}.tcz${LIBRARY}${MODULE}.dep
echo "input-2.6.29.1-tinycore.tczm"        >> ${THE_APP}.tcz${LIBRARY}${MODULE}.dep
echo "bash.tcz"                            >> ${THE_APP}.tcz${LIBRARY}${MODULE}.dep
echo "alsa.tczl"                           >> ${THE_APP}.tcz${LIBRARY}${MODULE}.dep
echo "clean build"
rm -rf build
echo "package for tce submit"
cd ..
mv -f extension ../
cd ..
cp ${THE_APP}.tce${LIBRARY}${MODULE}.info extension/
cp ${THE_APP}.tcz${LIBRARY}${MODULE}.info extension/
find extension -not -type d > ${THE_APP}.list
echo ${THE_APP}.tcbuild >> ${THE_APP}.list
echo ${THE_APP}-${VERSION}.tar.bz2 >> ${THE_APP}.list
tar cf ${THE_APP}.tar -T ${THE_APP}.list
rm -rf ${THE_APP}-${VERSION}
rm -rf extension
bcrypt ${THE_APP}.tar
