CallWeaver Debian Install Script

Debian Install Script

This script creates deb-packages from the latest spandsp, callweaver, and callweaver-sounds source-packages, and installs them. By re-running the script in the same directory updates either callweaver or callweaver-sounds if there is a newer version available

#/bin/sh

# Version 0.2
#
# Needless to say, Use this script on your own risk!
# Please feel free to enhance this scirpt, cause this code
# is more or less an ugly hack ;-)
# Comments can be sent to me @ callweaver dot org at hertell dot com
# René Hertell 13.10.2008
#
# Please check that you have all needed stuff installed, like
# unixodbc, unixodbc-dev, libsndfile1-dev, libtonezone-dev, libspeexdsp-dev
#
#
# Check from http://www.soft-switch.org/downloads/spandsp/
# what is the latest version of Spandsp.
# On 13.10.2008 the latest version was 0.0.6pre1
SPANDSP_VERSION=0.0.6
SPANDSP_RELEASE=pre1

###################################
## Nothing to do after this line ##
###################################

CURRENT_DATE_AND_TIME=`date -R`
install_spandsp()
{
SPANDSP_FILE=spandsp-$SPANDSP_VERSION$SPANDSP_RELEASE.tgz
if [ ! -f $SPANDSP_FILE ];then
  echo "Fetching $SPANDSP_FILE" 
  wget http://www.soft-switch.org/downloads/spandsp/$SPANDSP_FILE
  if [ -d spandsp-$SPANDSP_VERSION ];then
    rm -rf spandsp-$SPANDSP_VERSION
  fi
  tar xvfz $SPANDSP_FILE

  cd spandsp-$SPANDSP_VERSION
  cat > debian/changelog_tmp << EOF
spandsp ($SPANDSP_VERSION~$SPANDSP_RELEASE-1) unstable; urgency=low

  * Quick version bump ;)

 -- Your name <and.email@address>  $CURRENT_DATE_AND_TIME

EOF
  cat debian/changelog >>  debian/changelog_tmp
  mv  debian/changelog_tmp debian/changelog

  fakeroot debian/rules binary
  cd ..
  dpkg -i libspandsp*$SPANDSP_VERSION~$SPANDSP_RELEASE-1_*.deb
else
  echo "*** libspandsp is up to date           ***" 
fi
}

install_callweaver_sounds()
{
if [ ! -d callweaver-sounds ];then
  mkdir callweaver-sounds
  echo 0000 > callweaver-sounds/current_trunk_version
fi
CALLWEAVER_SOUNDS_REVISION=`svn info http://svn.callweaver.org/callweaver-sounds |grep Revision |cut -f2 -d " "`
if [ $CALLWEAVER_SOUNDS_REVISION != `cat callweaver-sounds/current_trunk_version` ]; then
  echo $CALLWEAVER_SOUNDS_REVISION > callweaver-sounds/current_trunk_version

  if [ -f callweaver-sounds/debian/changelog ];then
    rm callweaver-sounds/debian/changelog
  fi
  rm callweaver-sounds/debian/changelog
  svn co http://svn.callweaver.org/callweaver-sounds/trunk callweaver-sounds
  CALLWEAVER_SOUNDS_VERSION=`cat callweaver-sounds/debian/changelog  |grep -m 1 urgency |cut -f2 -d: |cut -f2 -d "(" |cut -f1 -d ")"`

  cat > callweaver-sounds/debian/changelog_tmp << EOF
callweaver-sounds ($CALLWEAVER_SOUNDS_VERSION-trunk-$CALLWEAVER_SOUNDS_REVISION-1) unstable; urgency=low

  *  Quick version bump ;)

 -- Your name <and.email@address>  $CURRENT_DATE_AND_TIME

EOF
  cat callweaver-sounds/debian/changelog >>  callweaver-sounds/debian/changelog_tmp
  mv  callweaver-sounds/debian/changelog_tmp callweaver-sounds/debian/changelog
  cd callweaver-sounds
  touch build-stamp
  fakeroot debian/rules binary
  cd ..
  dpkg -i callweaver-sounds_$CALLWEAVER_SOUNDS_VERSION-trunk-$CALLWEAVER_SOUNDS_REVISION-1_*.deb
else
  echo "*** Callweaver-sounds is up to date    ***" 
fi
}

install_callweaver()
{

if [ ! -d callweaver ];then
  mkdir callweaver
  echo 000 > callweaver/current_revision_version
  echo 000 > callweaver/current_bootstrap_version
fi

CALLWEAVER_REVISON=`svn info http://svn.callweaver.org/callweaver/branches/rel/1.2/ |grep Revision |cut -f2 -d " "`
BOOTSTRAP_REVISON=`svn info http://svn.callweaver.org/callweaver/branches/rel/1.2/bootstrap.sh |grep "Changed Rev" |cut -f4 -d " "`
if [ $CALLWEAVER_REVISON != `cat callweaver/current_revision_version` ];then
  echo $CALLWEAVER_REVISON > callweaver/current_revision_version
  if [ -f callweaver/debian/changelog ];then
    rm callweaver/debian/changelog
  fi
  svn co http://svn.callweaver.org/callweaver/branches/rel/1.2/ callweaver
  CALLWEAVER_VERSION=`cat callweaver/debian/changelog  |grep -m 1 urgency |cut -f2 -d: |cut -f2 -d "(" |cut -f1 -d "-"`

  cat > callweaver/debian/changelog_tmp << EOF
callweaver ($CALLWEAVER_VERSION-rel-$CALLWEAVER_REVISON-1) unstable; urgency=low

  *  Quick version bump ;)

 -- Your name <and.email@address>  $CURRENT_DATE_AND_TIME

EOF
  cat callweaver/debian/changelog >>  callweaver/debian/changelog_tmp
  mv  callweaver/debian/changelog_tmp callweaver/debian/changelog
  cd callweaver

  if [ $BOOTSTRAP_REVISON != `cat current_bootstrap_version` ];then
    echo $BOOTSTRAP_REVISON > current_bootstrap_version
    sh bootstrap.sh
  fi
  fakeroot debian/rules binary
  cd ..
  dpkg -i callweaver*_$CALLWEAVER_VERSION-rel-$CALLWEAVER_REVISON-1_*.deb

else

  echo "*** Callweaver is up to date             ***" 

fi
}

install_spandsp
install_callweaver_sounds
install_callweaver