CallWeaver Debian Install Script

Debian Install Script

This script creates .deb packages of the latest Spandsp-package by fetching the source and applying the debian-patch for it. It removes libspandsp3, libspandsp-dev and libspandsp-doc before installing the newly compiled package.

After this it fetches the latest svn-versions of callweaver and callweaver-sound, and creates .deb packages that can be installed simply with dpkg -i package.deb

#/bin/sh

#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 18.6.2007

#Check from http://www.soft-switch.org/downloads/spandsp/
#The latest version of Spandsp. The current version
#18.6.2007 is 0.0.4pre3

SPANDSP_VERSION=0.0.4
SPANDSP_RELEASE=pre3
SPANDSP_DEBIAN_PATCH=spandsp_0.0.4~pre1-1.diff

##################################
## Nothing set after this line
##################################

CURRENT_DATE_AND_TIME=`date -R`
SPANDSP_DEB_FILE=libspandsp3_$SPANDSP_VERSION-1_i386.deb
SPANDSP_FILE=spandsp-$SPANDSP_VERSION$SPANDSP_RELEASE.tgz
SPANDSP_DEBIAN_PATCH_FILE=$SPANDSP_DEBIAN_PATCH.gz

if [ -f $SPANDSP_FILE ];
#This part works
  then
    echo "File exists: $SPANDSP_FILE" 
  else
    echo "Fetching $SPANDSP_FILE" 
    wget http://www.soft-switch.org/downloads/spandsp/$SPANDSP_FILE
fi

if [ -f $SPANDSP_DEBIAN_PATCH_FILE ];
  then
    echo "File exists: $SPANDSP_DEBIAN_PATCH_FILE" 
  else
    echo "Fetching $SPANDSP_DEBIAN_PATCH_FILE" 
    wget ftp://ftp.debian.org/debian/pool/main/s/spandsp/$SPANDSP_DEBIAN_PATCH_FILE
fi

if [ -d spandsp-$SPANDSP_VERSION ];
#this stage works
  then
  echo "Directory exists: spandsp-$SPANDSP_VERSION" 
  else
  tar xvfz $SPANDSP_FILE $SPANDSP
fi

if [ -d spandsp-$SPANDSP_VERSION/debian ]; then
echo "Already patched: spandsp-$SPANDSP_VERSION" 
else
  cd spandsp-$SPANDSP_VERSION
  gunzip -c ../$SPANDSP_DEBIAN_PATCH_FILE |patch -p1
  cat > debian/changelog_tmp << EOF
spandsp ($SPANDSP_VERSION-1) experimental; 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
  cd ..
fi

if [ -f $SPANDSP_DEB_FILE ]; then
  echo "Spandsp deb-packages already exist" 
else
  cd spandsp-$SPANDSP_VERSION
  chmod +x debian/rules
  fakeroot dpkg-buildpackage
  apt-get remove libspandsp3 libspandsp-dev libspandsp-doc
  cd ..
  dpkg -i *.deb
fi

update_callweaver()
{
  if [ ! -d callweaver ];then
    mkdir callweaver
    echo 000 > callweaver/current_trunk_version
  fi
  CALLWEAVER_REVISON=`svn info http://svn.callweaver.org/callweaver/trunk |grep Revision |cut -f2 -d " "`
  if [ $CALLWEAVER_REVISON != `cat callweaver/current_trunk_version` ]; then
    if [ -f callweaver/debian/changelog ];then
      rm callweaver/debian/changelog
    fi
    svn co http://svn.callweaver.org/callweaver/trunk callweaver
    CALLWEAVER_VERSION=`cat callweaver/debian/changelog  |grep urgency |cut -f2 -d: |cut -f2 -d "(" |cut -f1 -d "~"`
    echo "$CALLWEAVER_REVISION" > callweaver/current_trunk_version
    cat > callweaver/debian/changelog_tmp << EOF
callweaver ($CALLWEAVER_VERSION-trunk-$CALLWEAVER_REVISON-1) experimental; urgency=low

  * fixed inclusion of embedded sqlite shared object, as well as the paths containing .org where they shouldn't

 -- 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
fi
  cd callweaver
  sh bootstrap.sh
  chmod a+x debian/rules
  fakeroot dpkg-buildpackage
  cd ..
}

update_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
    if [ -f callweaver-sounds/debian/changelog ];then
      rm callweaver-sounds/debian/changelog
    fi
    svn co http://svn.callweaver.org/callweaver-sounds/trunk callweaver-sounds
    CALLWEAVER_SOUNDS_VERSION=`cat callweaver-sounds/debian/changelog  |grep urgency |cut -f2 -d: |cut -f2 -d "(" |cut -f1 -d ")"`
    echo $CALLWEAVER_SOUNDS_REVISION > callweaver-sounds/current_trunk_version
    cat > callweaver-sounds/debian/changelog_tmp << EOF
callweaver-sounds ($CALLWEAVER_SOUNDS_VERSION-trunk-$CALLWEAVER_SOUNDS_REVISION-1) experimental; 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
  fi
    cd callweaver-sounds
    chmod a+x debian/rules
    touch build-stamp
    fakeroot dpkg-buildpackage
    cd ..
}

  update_callweaver_sounds
  update_callweaver