Building Debian packages with Deb-o-Matic

Today I’ll be telling you about an interesting way to build your Debian packages using Deb-o-Matic, a tool developed and maintained by Luca Falavigna. Some more details about this tool from the package’s description:

Deb-o-Matic is an easy to use build machine for Debian source packages based on pbuilder, written in Python.

It provides a simple tool to automate build of source packages with limited user interaction and a simple configuration. It has some useful features such as automatic update of pbuilder, automatic scan and selection of source packages to build and modules support.

The setup.

Download the package.

apt-get install debomatic

Modify the main configuration file as follows:

[default]
builder: pbuilder
packagedir: /home/john/debomatic # Take note of the following path since we'll need it for later use.
configdir: /etc/debomatic/distributions
pbuilderhooks: /usr/share/debomatic/pbuilderhooks
maxbuilds: 3 # The number of builds you can perform at the same time.
inotify: 1
sleep: 60 # The sleep time between one build and another.
logfile: /var/log/debomatic.log

[gpg]
gpg: 0 # Change to 1 if you want Deb-O-Matic to check the GPG signature of the uploaded packages.
keyring: /etc/debomatic/debomatic.gpg # Add the GPG Keys you want Deb-O-Matic to accept in this keyring.

[modules]
modules: 1 # A list of all the available modules will follow right after.
modulespath: /usr/share/debomatic/modules

[runtime]
alwaysupdate: unstable experimental precise
distblacklist:
modulesblacklist: Lintian Mailer
mapper: {'sid': 'unstable',
'wheezy': 'testing',
'squeeze': 'stable'}

[lintian]
lintopts: -i -I -E --pedantic # Run Lintian in Pedantic mode.

[mailer] # You need an SMTP server running on your machine for the mailer to work. You can have a look at the 'Ssmtp' daemon which is a one-minute-setup MTA, check an example over <a href="https://github.com/averi/config-files/blob/master/backups/offlineimap%20%2B%20ssmtp%20%2B%20imapfilter/ssmtp.conf" target="_blank">here</a>.
fromaddr: debomatic@localhost
smtphost: localhost
smtpport: 25
authrequired: 0
smtpuser: user
smtppass: pass
success: /etc/debomatic/mailer/build_success.mail-template # Update the build success or failure mails as you wish by modifying the relevant files.
failure: /etc/debomatic/mailer/build_failure.mail-template

[internals]
configversion = 010a

The available modules are:

  1.  “Contents“, which acts as a ‘dpkg -c’ over the built packages.
  2. DateStamp“, which displays build start and finish times into a file in the build directory.
  3. Lintian“, which stores Lintian output on top of the built package in the pool directory.
  4. Mailer“, which sends a reply to the uploader once the build has finished.
  5. PrevBuildCleaner“, which deletes all files generated by the previous build.
  6. Repository“, which generates a local repository of built packages.

Configure ‘dput‘ to upload package’s sources to your local repository, edit the /etc/dput.cf file and add this entry:

[debomatic]
method = local
incoming = /home/john/debomatic

or the following if you are going to upload the files to a different machine through SSH:

[debomatic]
login = john
fqdn = debomatic.example.net
method = scp
incoming = /debomatic

Add a new Virtual Host on Apache and access the repository / built packages directly through your browser:

<VirtualHost *:80>

ServerAdmin john@example.net
ServerName debomatic.example.net
DocumentRoot /home/john/debomatic

<Directory /home/john/debomatic>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<Directory>

</VirtualHost>

Start the daemon:

sudo /etc/init.d/debomatic start

(Optional) Add your repository to APT‘s sources.list:

deb http://debomatic.example.net/ unstable main contrib non-free

(Optional) Start Deb-O-Matic at system’s startup by modifying the /etc/init.d/debomatic file at line 21:

- [ -x "$DAEMON" ] || exit 0
- [ "$DEBOMATIC_AUTOSTART" = 0 ] && exit 0

+ [ -x "$DAEMON" ] || exit 0
+ [ "$DEBOMATIC_AUTOSTART" = 1 ] && exit 0

and finally add it to the desired runlevels:

update-rc.d debomatic defaults

Enjoy!