Building a Debian package from a source tarball
For a person who has learnt Linux packaging on RPM-based systems in the first instance, it is annoying to find that there is no easy way (that I can discern) for building a binary Debian package directly from a source code tarball. I'm talking here about a source code tarball that is somehow 'packaging aware', i.e. it includes certain metadata that the packaging utility can use.
On RPM systems, one can tell people to download a generic myprog.tar.bz2 file and then run "rpmbuild -ta myprog.tar.bz2". However, there is no comparable option in the Debian world. The only requirement for the 'rpmbuild -ta' command is that the tarball contain a 'myprog.spec' file inside. RPM also has a spec file that includes support for a 'preprocessor' language, allowing a single .spec file to be crafted for a wide range of architectures; this again is a lack that makes distribution of Debian-capable tarballs impossible across a range of distros/releases.
This page presents a simple script, called dtar which tries to perform an equivalent task in the Debian world.
dtar has been written as a general-purpose tool. Any source-code tarball that includes the 'debian/*' files should be able to be built directly with it.
This script needs you to first install the packages python-debian and python-apt from the Ubuntu repositories.
If you have any feedback about dtar, let me know.
Using dtar to build a binary .deb for ASCEND
To create a binary package for ASCEND, place the dtar script on your path, and obtain a source code tarball for ASCEND. Then run dtar. For example,
cd ~ svn co svn://ascend.cheme.cmu.edu.au/ascend/code/trunk ascend cd ascend export PATH=$PATH:~/ascend/tools/dtar scons dist # this will create dist/ascend-VERSION.tar.bz2 and dist/debian.tar.gz (whatever VERSION currently is) dtar dist/ascend-VERSION.tar.bz2 dist/debian.tar.gz # this will create *.deb, *.dsc, *.orig.tar.gz *.diff.gz files in your ~/ascend directory
Installing the resulting packages
To install your freshly-build ASCEND .deb packages, you can just
cd ~/ascend sudo dpkg -i *.deb
ASCEND will then be accessible from your Applications menu, you will have syntax highlighting of ASCEND when you use GEDIT ('Text Editor' in Accessories menu), and you can double-click ASCEND model files to run them or edit them.
Problems and improvements
This script works pretty nicely for local building of a binary package. It means that you can install your package in such a way that you don't have to worry about remembering how to remove it later, and you don't have to remember complicated commands to build new versions of your package: you just need to (manually) update the 'debian/changelog' when you want to make a new release.
A problem still exists, which is that, when attempting to correct minor packaging problems when using packaging tools such as Ubuntu PPA, if you attempt to upload multiple different version of the same source code tarball using 'dput', your package will be rejected. So we need a way to build a package by somehow using a 'delta' between an old tarball and a new one.
A partial solution to this problem has been implemented, which is the option to allow all the debian/* files to be packaged in a separate 'debian metafiles tarball' (debian.tar.gz, as indicated in the suggested usage above). This approach works well with the OpenSUSE Build Service, but is cumbersome in general, because there is nothing to detect whether or not the tarball has changed and needs to be renumbered/renamed.
A better solution would be to somehow cache the last uploaded version of the tarball, and when a new tarball is encountered, to compare it and create a patch file as required. This is clearly processor-intensive, but the aim of this tool is to make packaging from tarballs easy, not to create the optimally efficient packaging system. The consequential practise from this packaging convention would be to only bump ASCEND version numbers *after* important changes have been made, because 'clean' tarballs will only be uploaded at a version number change.
It would also be good if some better way of packaging debian/* files could be worked out. Something like the .spec file format could be conceived, which some preprocessing capability added. That would allow conditional generation of distro-specific debian metafiles by dtar.
The changelog text file embedded within the debian/* archive contains the email address of the person who packaged the file. This email address is also used to refer to the GPG key that must be used to successfully sign the resulting file. If that signature is not available, the package building process currently fails. Instead, a warning should be returned that unsigned packages were produced.