How to make a small change to a Debian tool and repackage it?
As always, there's a first time for everything. Recently I wanted to use a mail notifyer on my Ubuntu 6.10 (Edgy Eft) workstation. I thought it would be nice to have an envelop in my toolbar showing me I have new mail. As I'm using the default Gnome desktop, mail-notify looked like the right tool for the job to me. I used the standard Ubuntu/Debian way to install a software package:
apt-get install mail-notify
When I wanted to configure the mailbox to be monitored, I initially did not get any notifications. Which is weird, I receive approximately 200 mails a day (excluding spam). Digging the Internet, it became clear, the TLS/SSL option to connect to a mailserver is disabled by the Debian maintainer of this package. Apparantly he has an issue with the SSL/TLS licencing and as such he has disabled that option. But I never transmit my userid and password in cleartext over the Internet. So here I am, with a nice empty mail notification icon in my system tray, which would remain empty if I didn't solve this.
The obvious solution is of course to rebuild the tool from source. I had to wade through a quite a lot of information before I found the easiest way to make this really work on Ubuntu. Here's how I did it.
You need the development packages every time you compile something. And if you are recompiling a Debian/Ubuntu package from source, you do not need to run the normal package command './configure', which is the standard way in Linux to recompile a package. There are debian tools that will recompile the package, repackage it and install it for you.
- I always run these type of exercises as
root, although there are other ways of doing a package rebuild
(with fakeroot or place
sudo in front of every
command), which
I will not use here.
~$ sudo bash
Password:
# - Get the sources for the debian mail-notification
package:
# apt-get source mail-notification
This will give you a subdirectory (in my case even two subdirectories, as I have a modified /etc/apt/sources.list to include suggested updates). I wanted to stay with the current stable release of 6.10 and not experiment too much, so I restrict the remainder of this writing to the 3.0 version.
mail-notification-3.0.dfsg.1
mail-notification-4.0-rc2 - Get
all the development packages necessary to compile the
mail-notification package (that includes the gtk dev packages)
# apt-get build-dep mail-notification
The 'build-deb' option is very nice to retrieve every piece of software this package is dependent on. If this is your first time trying to compile from source, be prepared for a significant amount of packages to be downloaded.
- Get the development package necessary to compile
mail-notification with SSL support.
# apt-get install libssl-dev
- Change to the source tree directory of mail notify:
# cd mail-notification-3.0.dfsg.1
- With your favorite editor, mine is 'vi', edit the Debian
package configuration file, where the compile options are specified.
Remember, this is Debian/Ubuntu specific, but the way Debian has
implemented package management works rather nicely once you get used to
it. Remove the '--disable-ssl'
option from the line with definition of the variable
DEB_CONFIGURE_EXTRA_FLAGS:
# vi debian/rules
#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/simple-patchsys.mk
include /usr/share/cdbs/1/class/gnome.mk
DEB_INSTALL_MANPAGES_mail-notification := debian/mail-notification.1
DEB_CONFIGURE_SCRIPT_ENV += LDFLAGS=-Wl,--export-dynamic
#DEB_CONFIGURE_EXTRA_FLAGS += --disable-ssl –with-gconf-schema-file-dir=/usr/share/gconf/schemas
DEB_CONFIGURE_EXTRA_FLAGS += --with-gconf-schema-file-dir=/usr/share/gconf/schemas
DEB_DH_MAKESHLIBS_ARGS_mail-notification += --noscripts
DEB_DH_MAKESHLIBS_ARGS_mail-notification-evolution += --noscripts
CFLAGS += -fPIC
AUTOSTARTDIR = debian/mail-notification/etc/xdg/autostart
EVODIR = debian/tmp/usr/lib/evolution/2.8/plugins
BONOBODIR = debian/tmp/usr/lib/bonobo/servers
<snipped> - In
order to stop the update manager from thinking it needs to update this
package from the apt sources, edit the changelog as well and add a
couple of lines at the start of the changelog. I know, there are other
ways to tell Ubuntu/Debian about an updated version, but this is how I
did it:
# vi debian/changelog
mail-notification (3.0.dfsg.1-3ubuntu8a) edgy; urgency=low
* debian/rules: Enable TLS/SSL
-- Martin Sat, 10 Feb 2007 20:28:06 +0100
mail-notification (3.0.dfsg.1-3ubuntu8) edgy; urgency=low
* debian/rules: Fix path to .desktop file to fix FTBFS.
-- Martin Pitt Thu, 12 Oct 2006 10:55:06 +0200
<snipped>Watch the 'a' I added after ubuntu8. You just need to make sure you have a different name here, but not too much different, as I still would like to be notified if and when an official update becomes available.
Another suggestion is to append .0.0.<your-name>.0 to the package version. Make your own choice.
Read the debian new maintainers guide for more information about packaging .deb's. Also write something sensible in the changelog so you know what this package/change is about. - To compile the sources, build the package and install it, you
have to use the package tools:
# dpkg-buildpackage -uc -b
Please read the man page of dpkg-buildpackage in order to get to know more about the options. The package is now completely recompiled with the enabled TLS/SSL option. It will create a new installable package in the parent directory.
- To install the newly build package, go to the parent
directory an issue the package install command.
# cd ..
# dpkg -i mail-notification_3.0.dfsg.1-3ubuntu8a_i386.deb - You can check that SSL support is now
enabled:
# mail-notification --list-features
- Ready. You may have to log out of your GNOME desktop and log back in in order to activate mail-notification and to see the new features. Configure the mail boxes you want to monitor (you can monitor multiple mailboxes!) and enjoy a nice enveloppe indicating new mail has arrived.