sipX on Debian

We have created Debian packages of sipX, the Open Source SIP PBX for Linux from SIPfoundry.

The steps involved in creating these packages are documented on the following pages.

Create a build chroot on Debian Sarge
First we need to create a clean build environment. You can either use an entire machine for that or create a chroot environment. We will use a chroot,
Install build dependencies
To be able to build packages on a system you need the so-called build-dependencies to be installed. On a GNU/Linux system this is usually gcc, the GNU compiler and all of the GNU autobuild packages. There might be others depending on the project.
Download and unpack sipX source
To start building the packages you first need the source code. There are conventions to follow regarding the naming of the source tarballs when building packages for Debian/Ubuntu.
Check-out Debian trees
The /debian tree of files for every particular packet are currently in Calivia's Subversion repository.
Build source and binary packages

Once everything is in place we can start the build process.
Create Debian package repository
Assuming all of the packages built fine we can now put them into a repository that can be used as a source for apt.

Build environment

Install Sun JDK

sudo apt-get sudo apt-get install fakeroot java-package lynx # download .bin from lynx http://java.sun.com/ fakeroot make-jpkg jdk-1_5_0_06-linux-i586.bin sudo dpkg -i sun-j2sdk1.5_1.5.0+update06_i386.deb

Create the Build Chroot

The process for both distributions is basically the same. We started on Ubuntu Breezy, but then moved to Debian Sarge.

Debian

apt-get install debootstrap dchroot sudo
mkdir /chroot/sarge
debootstrap --variant=buildd sarge /chroot/sarge http://mirrors.kernel.org/debian/

cp /etc/apt/sources.list /chroot/sarge/etc/apt/

vi /etc/fstab
proc-chroot    /var/chroot/proc        proc    defaults        0      0
devpts-chroot  /var/chroot/dev/pts    devpts  defaults        0      0

vi /etc/dchroot.conf
sarge /chroot/sarge

cp /etc/ passwd /chroot/sarge/etc
sed 's/\([^:]*\):[^:]*:/\1:*:/' /etc/shadow | tee /chroot/sarge/etc/shadow
cp /etc/group /chroot/sarge/etc/
cp /etc/hosts /chroot/sarge/etc/
cp /etc/sudoers /chroot/sarge/etc/

chroot /chroot/sarge/

apt-get update

apt-get install wget debconf devscripts gnupg nano subversion sudo

Ubuntu

The DebootstrapChroot page on the Ubuntu Wiki has excellent instructions on how to build a build chroot for Ubuntu (Breezy, Dapper and below). We do not intend to duplicate the complete and current documentation, so please refer to the Ubuntu Wiki.

Debian devscripts

sudo apt-get install devscripts

debchange, dch

Tool for maintenance of the debian/changelog file in a source package.

Environment variables

Set DEBEMAIL to the e-mail address you want to show up in the changelog Set DEBFULLNAME to the name you want to set in the changelog

Get the Source

The following script will get the source tarballs and MD5 files for version 3.0.1, check the MD5 hash and unpack the tar.gz. Libraries are renamed from sipX<em>package</em>lib to libsipx<em>package</em> to conform to the Debian Library Packaging Guide. Furthermore, all source tarballs are renamed to (lib)sipx<em>package</em>_version.orig.tar.gz. The script will then fetch the /debian tree from the Calivia sipX Debian subversion repository for every package. After that, packages are ready to be built. Alternatively, use wget to get all source tarballs with one command:
wget -r -l 1 -A .gz,.md5 -nd --cut-dirs=3 http://www.sipfoundry.org/pub/sipX/3.0/SRC/
-r
Recursive
-l 1
Depth 1
-A .gz,.md5
Accept files only with this suffix
-nd
No directory names in file name
--cut-dirs=3
Remove 3 levels of sub-directory names

Fetch sipX source and /debian

#!/bin/sh

W=`pwd`

wget -r -l 1 -A .gz,.md5 -nd --cut-dirs=3 http://www.sipfoundry.org/pub/sipX/3.0/SRC/

echo "** sipX*Lib"
for PACKAGE in {port,tack,media,mediaadapter,commserver,call}; do
        echo "**sipx${PACKAGE}lib "
        cd $W
        mv sipx${PACKAGE}lib-3.0.1.tar.gz libsipx${PACKAGE}_3.0.1.orig.tar.gz
        tar xzf libsipx${PACKAGE}_3.0.1.orig.tar.gz
        cd sipx${PACKAGE}lib-3.0.1 && \
                mkdir debian && \
                cd debian && \
                svn co http://scm.calivia.com/svn/sipx/debian/tags/3.0.1/sipx${PACKAGE}lib .
        echo "** sipx${PACKAGE}lib done"
done;

echo "** sipX*"
for PACKAGE in {vxml,publisher,proxy,registry,config,pbx}; do
        echo "**sipx${PACKAGE} "
        cd $W
        mv sipx${PACKAGE}-3.0.1.tar.gz sipx${PACKAGE}_3.0.1.orig.tar.gz
        tar xzf sipx${PACKAGE}_3.0.1.orig.tar.gz
        cd sipx${PACKAGE}-3.0.1 && \
                mkdir debian && \
                cd debian && \
                svn co http://scm.calivia.com/svn/sipx/debian/tags/3.0.1/sipx${PACKAGE} .
        echo "** sipx${PACKAGE} done"
done;

Fetch mod_cplusplus source and /debian

#!/bin/sh

W=`pwd`

echo "** mod_cplusplus"
cd $W
wget -nv http://unc.dl.sourceforge.net/sourceforge/modcplusplus/mod_cplusplus-1.5.2.tar.gz
mv mod_cplusplus-1.5.2.tar.gz libapache-mod-cplusplus_1.5.2.orig.tar.gz
tar xzf libapache-mod-cplusplus_1.5.2.orig.tar.gz
cd mod_cplusplus-1.5.2 && \
      mkdir debian && \
      cd debian && \
      svn co http://scm.calivia.com/svn/sipx/debian/mod_cplusplus .
echo "** mod_cplusplus done"
cd $W

Create tarballs from subversion repository

To create source tarballs from a subversion checkout, do the following in every toplevel directory:
autoreconf --install --force
&#046;/configure
make dist
#!/bin/sh

P=`pwd`

case "$1" in
  download)
        echo "config"
        svn co http://scm.sipfoundry.org/rep/sipX/branches/3.0/config config
        for S in {sipXportLib,sipXtackLib,sipXmediaLib,sipXmediaadapterLib,sipXcallLib,sipXcommserverLib,sipXvxml,sipXpublisher,sipXregistry,sipXproxy,sipXconfig,sipXpbx}; do
                echo "$S"
                svn co http://scm.sipfoundry.org/rep/sipX/branches/3.0/$S/ $S
        done
        ;;

  update)
        for S in {sipXportLib,sipXtackLib,sipXmediaLib,sipXmediaadapterLib,sipXcallLib,sipXcommserverLib,sipXvxml,sipXpublisher,sipXregistry,sipXproxy,sipXconfig,sipXpbx}; do
                echo "$S"
                cd $P/$S
                svn update
                autoreconf --install --force
                &#046;/configure
                make dist
        done
        ;;
  *)
        echo "Usage: $0 {download|update}"
esac

Creating patches with Debian dpatch

dpatch patch-template -p "httpd.conf.patch" "Patch LoadModule for Debian" > debian/patches/httpd.conf.dpatch
My debian/patches/00list loks like this:
httpd.conf.in.diff
And this is how the patch looks like (debian/patches/httpd.conf.in.diff). Note that the patch is relative to the debian/ directory.
#! /bin/sh /usr/share/dpatch/dpatch-run
## httpd.conf.in.diff.dpatch by  <msl@calivia.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Patch LoadModule for Debian

@DPATCH@

--- . . /etc/httpd.conf.in        2005-11-02 19:08:40.000000000 +0000
+++ . . /etc/httpd.conf.in.patched        2006-01-12 10:45:31.000000000 +0000
@@ -232,14 +232,10 @@
# LoadModule foo_module @APACHE2_MOD@/mod_foo.so
#
LoadModule ssl_module @APACHE2_MOD@/mod_ssl.so
-LoadModule access_module @APACHE2_MOD@/mod_access.so
-LoadModule auth_module @APACHE2_MOD@/mod_auth.so
LoadModule auth_anon_module @APACHE2_MOD@/mod_auth_anon.so
LoadModule auth_dbm_module @APACHE2_MOD@/mod_auth_dbm.so
LoadModule auth_digest_module @APACHE2_MOD@/mod_auth_digest.so
LoadModule include_module @APACHE2_MOD@/mod_include.so
-LoadModule log_config_module @APACHE2_MOD@/mod_log_config.so
-LoadModule env_module @APACHE2_MOD@/mod_env.so
LoadModule mime_magic_module @APACHE2_MOD@/mod_mime_magic.so
LoadModule cern_meta_module @APACHE2_MOD@/mod_cern_meta.so
LoadModule expires_module @APACHE2_MOD@/mod_expires.so
@@ -247,22 +243,15 @@
LoadModule headers_module @APACHE2_MOD@/mod_headers.so
LoadModule usertrack_module @APACHE2_MOD@/mod_usertrack.so
LoadModule unique_id_module @APACHE2_MOD@/mod_unique_id.so
-LoadModule setenvif_module @APACHE2_MOD@/mod_setenvif.so
-LoadModule mime_module @APACHE2_MOD@/mod_mime.so
LoadModule dav_module @APACHE2_MOD@/mod_dav.so
-LoadModule status_module @APACHE2_MOD@/mod_status.so
-LoadModule autoindex_module @APACHE2_MOD@/mod_autoindex.so
LoadModule asis_module @APACHE2_MOD@/mod_asis.so
LoadModule info_module @APACHE2_MOD@/mod_info.so
LoadModule dav_fs_module @APACHE2_MOD@/mod_dav_fs.so
LoadModule vhost_alias_module @APACHE2_MOD@/mod_vhost_alias.so
-LoadModule negotiation_module @APACHE2_MOD@/mod_negotiation.so
-LoadModule dir_module @APACHE2_MOD@/mod_dir.so
LoadModule imap_module @APACHE2_MOD@/mod_imap.so
LoadModule actions_module @APACHE2_MOD@/mod_actions.so
LoadModule speling_module @APACHE2_MOD@/mod_speling.so
LoadModule userdir_module @APACHE2_MOD@/mod_userdir.so
-LoadModule alias_module @APACHE2_MOD@/mod_alias.so
LoadModule rewrite_module @APACHE2_MOD@/mod_rewrite.so
LoadModule proxy_module @APACHE2_MOD@/mod_proxy.so
LoadModule proxy_ftp_module @APACHE2_MOD@/mod_proxy_ftp.so

Install sipX on Debian

This page is about installing sipX version 3.0.1 on Debian Sarge from a custom Debian repository. Everything needed to install sipX is either in the default Debian Sarge or the Calivia repository. By following the steps below you will end up with sipX installed and configured on a stock Debian Sarge host in no time. Note: If the host is currently running Apache it will need to be disabled as sipX starts Apache with a custom configuration from /etc/sipxpbx/httpd.conf. This instance of Apache will bind to ports 80 and 8090 (http) and 443 and 8091 (https).

Configure /etc/apt/sources.list

/etc/apt/sources.list

# choose a mirror close to you!
deb http://scm.calivia.com/pub/sipx/debian unstable main
After adding new package sources, Debian must be told about them. apt-get update will fetch the information about what is available from all the repository URLs in /etc/apt/sources.list.

Install Sun J2RE 1.5 and create symlinks for keytool

Two symlinks need to be created for Java keytool.
apt-get install sun-j2re1.5
ln -s /usr/lib/j2re1.5-sun/bin/keytool /etc/alternatives/keytool
ln -s /etc/alternatives/keytool /usr/bin/keytool

Install sipxpbx

The only unmet dependency on Sarge is mod_cplusplus. We provide a Debian package for mod_cplusplus-1.5.2 in our repository (libapache-mod-cplusplus_1.5.2-0_i386.deb and libapache-mod-cplusplus-dev_1.5.2-0_i386.deb). It will be installed along with the other packages by apt. sipXportLib will ask you for information using Debian debconf to create a key and self-signed certificate for both sipXpbx (Apache) and sipXconfig (Jetty). Check out the documentation if you plan to use a certificate from an external authority.
sudo apt-get install sipxpbx

Configure TFTP server

sipXconfig installs tftpd-hpa if it is not already installed. After successful installation of sipXconfig, you need to configure tftpd-hpa to serve the files controlled by sipXconfig. You need to change one line in /etc/inetd.conf:
-tftp          dgram  udp    wait    root  /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot
+tftp          dgram  udp    wait    root  /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/sipxdata/configserver/phone/profile/tftproot/
To activate the change, restart inetd:
/etc/init.d/inetd restart

Start sipXpbx

sipXpbx will be started automatically after it has been installed and configured. Note: startup of sipXconfig takes some time, so don't be alarmed if port 8443 is not up immediately after you started sipXpbx. If it is still not up after 30 seconds or so, check /var/log/sipxpbx/sipxconfig.log for errors. If anything with the certificates is wrong, it will not come up.

Check ports

Once everything is installed, verify all processes are running and all ports are listening. Then, point your browser at http://yourhost and set the superadmin user's password to gain access to sipXconfig.

Build the Packages

Build the package

The lowest package in the dependency tree needs to be built and installed first. After that, you can move your way up the dependency tree. Don't forget to install both binary and -dev package before attempting to build the next package.
dpkg-buildpackage -rfakeroot

Check

The package can be checked using the following command:
dpkg -c ../package.deb

Install the package

The following will install the package without using apt. Dependencies will therefore not be resolved. Should the package have any unresolved dependencies it will simply fail.
dpkg -i ../package.deb
dpkg -i ../package-dev.deb

Create the Debian Package Repository

There is excellent documentation available from both the debian.org site and the Ubuntu Wiki. The Debian Package Repository HowTo provides an in-depth look at how to setup and maintain a Debian package repository. We'll create a 'trivial' repository with just source and binary subdirectories.

Creating the Index Files

dpkg-scanpackages will generate the Packages file and dpkg-scansources the Sources file. dpkg-scanpackages scans the .deb packages; dpkg-scansources scans the .dsc files. It is thus necessary to put the .orig.gz, .diff.gz and .dsc files together. The .changes files are not needed. Note: for testing the binary packages you might want to create binary packages only. Create the two index files as follows:
$ cd my-repository
$ dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz
$ dpkg-scansources source /dev/null | gzip -9c > source/Sources.gz
The Release file in /pub/sipx/debian/dists/unstable/main/binary-i386/ looks like this:
Archive: unstable
Component: main
Origin: Calivia GmbH
Label: Calivia Debian repository
Architecture: i386

Creating the Release files

If you want to enable the users of your repository to use Pinning with your repository, you must include a Release file in every directory containing an index file. (You can read more about pinning in the APT HOWTO). The Release files are simple and short text files of the following form:
Archive: archive
Component: component
Origin: YourCompany
Label: YourCompany Debian repository
Architecture: architecture
Archive
The name of the distribution of Debian the packages in this directory belong to (or are designed for), i.e. stable, testing or unstable.
Component
The component of the packages in the directory, for example main, non-free, or contrib.
Origin
The name of who made the packages.
Label
Some label adequate for the packages or for your repository. Use your fantasy.
Architecture
The architecture of the packages in this directory, such as i386, sparc or source.

Use the new repository

To install packages from the custom repository, you need to add it to your /etc/apt/sources.list.

Useful Debian commands while debugging new packages

Dry-run installation of packages
sudo apt-get install -s packagename
Removing packages and purging configuration
sudo apt-get remove --purge packagename
Update package repository
sudo apt-get update
Clean local cache of downloaded packages in /var/cache/apt/
sudo apt-get clean