Packaging howto

From Rost Lab Open


The recipes and guides on this page may be relevant only to ROSTLAB members, however we thought that it may also provide useful examples for anyone going into Deb and RPM packaging. When reading through this page please keep this in mind and use your own judgment as you try to apply the examples.

Resources and Documentation

When packaging you will need to referer to the following documentation

automake and autoconf

We really should use these. It is not so hard. For examples see: proftmb, predictnls, loctree. Good example and introduction Autoconf Complete Guide

  1. Create an initial in the top directory of the package:
AC_INIT([__packagename__], [1.0.0], [])
AC_CONFIG_FILES([Makefile] [__subdir1__/Makefile] [__subdir2__/Makefile])
  1. Create an initial in the top directory of the package: Change the longer leading space to ONE TAB! (Makefile-like) Automake Complete Guide
 dist_bin_SCRIPTS = loctree
 dist_pkgdata_DATA = loctreerc.default
 dist_man_MANS = loctree.1
 dist_noinst_DATA =

 SUBDIRS = example jscript perl

         sed -e 's|__pkgdatadir__|$(pkgdatadir)|g;s|__sysconfdir__|$(sysconfdir)|g;' "$<" > "$@"

 loctree.1:      loctree.pod
         pod2man -c 'User Commands' -r "$(VERSION)" $< $@

         rm -f loctree.pod loctree.1

         rm -rf `find '$(distdir)' -name .svn`

         mkdir -p '$(DESTDIR)$(pkgdatadir)'
         cp -r '$(srcdir)'/{example,jscript,perl} '$(DESTDIR)$(pkgdatadir)/'
         rm -rf `find '$(DESTDIR)$(pkgdatadir)' -name .svn`
         chmod -R u+w '$(DESTDIR)$(pkgdatadir)'

         find '$(DESTDIR)$(pkgdatadir)/loctreerc.default' '$(DESTDIR)$(pkgdatadir)'/perl -type f -exec sed -i -e 's|__datadir__|$(datadir)|g;s|__pkgdatadir__|$(pkgdatadir)|g;s|__sysconfdir__|$(sysconfdir)|g;' '{}' \;

         sed -i -e 's|__pkgdatadir__|$(pkgdatadir)|g;s|__sysconfdir__|$(sysconfdir)|g;' "$(DESTDIR)$(bindir)/loctree"
  1. Edit the above file and tailor it to your needs. Look at other examples or EVEN(!) the documentation of automake: info automake.
  2. Place this to subdirectories:
 pkgdataexampledir = $(pkgdatadir)/example
 dist_pkgdataexample_DATA = $(srcdir)/tmdfast*
         rm -rf `find $(distdir) -name .svn`
  1. aclocal
  2. autoconf
  3. automake -a
    • Create/edit the missing files it complains about with special attention to COPYING, where the licence and copyright goes
  4. ./configure --prefix=/tmp/some_test_dir
  5. make
  6. make distcheck
    • If the above is successful a tar.gz package file is created. In their final versions packages should pass the make distcheck test.
  7. When preparing the Debian package add --sysconfdir=/etc to the ./configure line of debian/rules

Native Packages

These packages contain the 'debian' directory at their root and have '3.0 (native)' in debian/source/format.


  1. debuild

Check Built Package Contents

  1. debc

Releasing a new upstream / getting a new version into the FTP area

  1. cp it (! - no -a, that screws up access) to its respective project area, for profisis this is: ~software/free/
  2. ssh rostlab sudo -u ftp /mnt/project/ftp/bin/cronscript

When a tar ball is ready

  1. go to empty dir
  2. cp tar.gz to that dir
  3. tar -xvzf *.tar.gz
  4. cd new_dir
  5. dh_make -e -f ../the_package.tar.gz
  6. review all the files in the new dir 'debian' created in step 5
    • If you use automake/autoconf, add this to the ./configure line in debian/rules:
    • older than 5 years we use GPL
  7. dpkg-buildpackage (in "package dir"==dir with 'debian' dir in it)
  8. if no success: back to step 6
  9. if success: cd .. (to dir with package_version.tar.gz)
  10. svn-inject -O new_package*.dsc file:///mnt/project/subversion/debpacks
  11. move new dir that is an svn WC to your debian build dir structure
    mv new_wc_dir ~/Development/DEBIAN/.
  12. move tarball from tarballs to ~debrepo/DEBIAN/tarballs/
  13. cd to new WC in debian build structure
  14. Review all files in debian subdir - you will have to delete most
  15. Architecture in control is 'all' for packages with NO binaries, 'any' otherwise
  16. svn-buildpackage

Reprepro, Releasing a Debian Package, Package Upload

I recommend you set up a shell alias like:

alias reprepro='sudo -u debrepo /usr/bin/reprepro --basedir /mnt/home/debrepo/www/debian --ask-passphrase'
  • main section
    sudo -u debrepo /usr/bin/reprepro --basedir /mnt/home/debrepo/www/debian --ask-passphrase include stable <changes_file>
  • non-free
    sudo -u debrepo /usr/bin/reprepro --basedir /mnt/home/debrepo/www/debian --ask-passphrase -C non-free includedeb stable <deb_file> # do not put source in to repo in this case
  • rostonly:
    sudo -u debrepo /usr/bin/reprepro --basedir /mnt/home/debrepo/www/debian --ask-passphrase -C rostonly include stable <changes_file>

Use the passphrase of the repo signing GPG identity 'Rost Lab Repository Signing <>'. This was sent to you in an encrypted email. You may have to enter it a couple of times - this is normal.

See also reprepro and signing section.

Upgrading a package

  1. You do all edits on the tar.gz repo. Make sure to edit changelog and makefile and update the version number (in
  2. make dist
  3. cp new dist file to ~profnet/
  4. cd ~/DEBIAN/profnet
  5. svn-upgrade ~profnet/new_release.tar.gz
  6. edit debian/changelog and commit changes
  7. do a test build: svn-buildpackage -us -uc --svn-ignore
  8. svn-buildpackage
  9. reprepro:
    • main section: reprepro --basedir /mnt/home/debrepo/www/debian include stable <changes_file>
    • non-free: reprepro --basedir /mnt/home/debrepo/www/debian -C non-free includedeb stable <deb_file> # do not put source in to repo in this case
    • rostonly: reprepro --basedir /mnt/home/debrepo/www/debian -C rostonly include stable <changes_file>
    • See reprepro and signing section

Upgrading a package with an upstream source

  1. echo 'DEBRELEASE_DEBS_DIR=../build-area' >> ~/.devscripts (only once when you set up your env)
  2. Check out source from debian med svn co svn+ssh://
  3. cd profisis
  4. ln -s /mnt/home/debrepo/DEBIAN/tarballs
  5. mkdir build-area
  6. cd trunk
  7. uscan --verbose --force-download --destdir ../tarballs/ ( it knows about it because of this line)
  8. svn-buildpackage -us -uc

reprepro and signing

In order to allow all packages to be owned by debrepo:

1. Define this alias in ~/.bashrc:

alias reprepro='sudo -u debrepo /usr/bin/reprepro --basedir /mnt/home/debrepo/www/debian --ask-passphrase'

2. Use reprepro as before, but the password is now the same for everybody:


FYI: The stars above are there purposely. You're not supposed to know the password, silly! If you know what you're doing, ask your friendly system admin to hook you up.

You will have to enter it a couple of times, sorry about that.


User prerequisites

  1. mkdir -p ~/rpmbuild/{BUILD,RPMS,S{OURCE,PEC,RPM}S}
  2. echo "%_topdir $HOME/rpmbuild" > ~/.rpmmacros

For each package

  1. create a spec file named "$(PACKAGE).spec" in package root (not the Debian repository - unless debian is in the main repo) - copy a spec file as a template and edit it
    • Make sure $(PACKAGE).spec is distributed (it makes it into the root of the tar.gz package)
    • Use 'make DESTDIR=${RPM_BUILD_ROOT} install' instead of %makeinstall (especially) for packages that use automake
    • Official groups are in /usr/share/doc/rpm-
    • Built-in macros: [1]
    • Build distributable tar.gz of package
    • Use rpmbuild -ta $(PACKAGE)-*.tar.gz to create rpm and rpms.


When packaging a perl module that works with Build.PL, perform these steps to create the tar archive for RPM generation:

  1. Make sure the <package>.spec file is mentioned in MANIFEST.
  2. perl Build.PL
  3. ./Build
  4. ./Build manifest
  5. ./Build dist
  6. Use rpmbuild -ta $(PACKAGE)-*.tar.gz to create rpm and rpms.

Updating repository meta-data


  1. rebuild the rpm packages from source
    rpmbuild --rebuild /path/to/srpm/foo-
  2. this will create packages in your RPM build path $HOME/rpmbuild/RPMS/
  3. when done building all new packages copy them (! - in order to allow acls to be set) to the RPM repo folder
    cp $HOME/rpmbuild/RPMS/*.rpm /mnt/home/debrepo/www/centos/5/os/x86_64/CentOS
    createrepo --cachedir ~debrepo/CentOS/cache --update ~debrepo/www/centos/5/os/x86_64/; createrepo --cachedir ~debrepo/CentOS/cache --update ~debrepo/www/centos/5/os/SRPMS/

Useful commands

  • Update repository cache and upgrade installed packages:
    yum makecache rostlab && yum update
  • How to get source rpm for something:
    yumdownloader --source patch
  • How to open source rpm:
    rpm --install ~/rpmbuild/SRPMS/patch-2.5.4-31.el5.src.rpm
  • How does the %configure macro expand:
    rpm --eval '%configure'; rpmbuild --showrc