Creating Deb Packages from the downloaded material.


The procedure below has been documented right after executing it, instead of the usual during. So beware of missing details.

  1. We create a directory magma-2.15.10 [31] and unzip the files into it, giving:

    -rw-r--r--  1 jurjen jurjen     8931 2008-12-05 11:53 README.txt
    -rw-r--r--  1 jurjen jurjen    12218 2009-01-23 01:53 INSTALL.txt
    -rw-r--r--  1 jurjen jurjen 29660016 2009-06-15 11:14 magma.amd64.exe
    -rwxr-xr-x  1 jurjen jurjen 24230904 2009-06-15 11:14 magma.gen.exe.dyn.i386
    -rw-r--r--  1 jurjen jurjen 28259272 2009-06-15 11:14 magma.intel64.exe
    drwxr-xr-x  2 jurjen jurjen      136 2009-06-15 11:44 ThirdParty
    drwxr-xr-x 18 jurjen jurjen     4096 2009-06-15 11:44 package
    drwxr-xr-x 14 jurjen jurjen     4096 2009-06-15 11:44 libs
    drwxr-xr-x  2 jurjen jurjen      119 2009-06-15 11:44 InternalHelp
    drwxr-xr-x  3 jurjen jurjen     4096 2009-06-15 11:44 doc
    -rwxr-xr-x  1 jurjen jurjen     1394 2009-06-18 13:05 magma

  2. Judging from the INSTALL.txt, magma is usually installed monolithically, with all executables, documentation, license files and whatnot in a single tree. This is particularly well suited for installation on a network share, but it isn't for packages. To create packages, the HTML doc files will go into /usr/share/doc/magma, the config will go into /etc, large parts of the package will go into /usr/shared/magma, and at least a binary or script will have to go into /usr/bin. In order to facilitate that, we modify the magma script a bit, so that it accepts config in /etc/magma/magma.conf, which we also provide:

    # This is where most of Magma goes
    # The admin can install the magmapassfile by hand in /etc/magma
    # If there is no magmapassfile in /etc/magma, look for it in the users' homedir.
    # It won't be distributed with the package, so the default of looking in
    # /usr/share/magma doesn't make sense.
    [ -r $MAGMAPASSFILE ] || MAGMAPASSFILE="~/magmapassfile"
    # The html/pdf help has been relocated at /usr/share/doc/magma

  3. We create a rudimentary Makefile, with an eye already on the multiple packages we want to create. Please note the usage of $(DESTDIR) to ease the use of debhelper scripts.

    install: install-doc install-common install-bin install-bin-i386 install-bin-amd64
    install -d $(DESTDIR)/usr/share/doc/magma/html
    cp -rp doc/* $(DESTDIR)/usr/share/doc/magma/html
    install -d $(DESTDIR)/usr/share/doc/magma
    install -t $(DESTDIR)/usr/share/doc/magma README.txt INSTALL.txt
    install -d $(DESTDIR)/usr/share/doc/magma/ThirdParty
    install -t $(DESTDIR)/usr/share/doc/magma/ThirdParty ThirdParty/*
    install -d $(DESTDIR)/usr/share/magma
    cp -rp InternalHelp $(DESTDIR)/usr/share/magma
    cp -rp package $(DESTDIR)/usr/share/magma
    cp -rp libs $(DESTDIR)/usr/share/magma
    rm -rf \
    $(DESTDIR)/usr/share/doc/magma \
    install -d $(DESTDIR)/usr/share/magma/bin
    install -d $(DESTDIR)/usr/bin
    install magma $(DESTDIR)/usr/bin/
    install-bin-i386: install-bin
    install  magma.gen.exe.dyn.i386 $(DESTDIR)/usr/share/magma/bin
    install-bin-amd64: install-bin
    install magma.amd64.exe $(DESTDIR)/usr/share/magma/bin
    install magma.intel64.exe $(DESTDIR)/usr/share/magma/bin
    install -d $(DESTDIR)/magma
    install -t $(DESTDIR)/magma magma.conf

  4. To build the debian subdirectory, with examples, while in the magma-2.15.10 directory, we issue:

    dh_make -e j.bokma --native -m

  5. We edit debian.control to contain multiple packages:

    Source: magma
    Section: non-free/math 1
    Priority: extra
    Maintainer: Jurjen Bokma <>
    Build-Depends: debhelper (>= 7)
    Standards-Version: 3.7.3
    Package: magma-common
    Section: non-free/math
    Architecture: all
    Depends: ${shlibs:Depends}, ${misc:Depends} 2
    Suggests: magma-doc
    Description: Magma, a powerful mathematics package, common files
    Magma ( is 'a large, well-supported 3
    software package designed to solve computationally hard problems
    in algebra, number theory, geometry and combinatorics. It provides
    a mathematically rigorous environment for computing with algebraic,
    number-theoretic, combinatoric, and geometric objects.'
    This package contains the architecture-independent files.
    Architecture-specific binaries are in the magma-<architecture>
    Package: magma-doc
    Section: non-free/doc
    Architecture: all
    Description: Documentation for Magma
    Magma ( is 'a large, well-supported
    Package: magma-bin-i386
    Section: non-free/math
    Architecture: i386 4
    Depends: magma-common
    Conflicts: magma-amd64
    Description: 32-bit i386 binary for Magma
    Magma ( is 'a large, well-supported
    Package: magma-bin-amd64
    Section: non-free/math
    Architecture: amd64
    Depends: magma-common
    Conflicts: magma-i386
    Description: 64-bit amd64 binaries for Magma
    Magma ( is 'a large, well-supported


    If a package goes into contrib or non-free, both area and section have to be mentioned, like done here.


    The package magma-common doesn't depend on any of the binaries. You could argue that it should, as it provides no functionality of its own, but circular dependencies must not happen. So the only denpendency is the other way around: the magma-bin-* packages depend on magma-common.


    The long decription must be indented by spaces.


    One could argue that the magma-bin-i386 package should also be generated for amd64 architectures. We don't.

  6. Of course as with any packaging, Copyright, README, Changelog etc. must be modified. And proper {pre,post}{install,rm} scripts must be created.

    As Debian/Ubuntu doesn't distinguish between amd64 (x86_64 in RPM/Intel parlance) architecture systems with Intel and AMD processors, and because Magma does, I have the postinst script of the bin-amd64 package install both binaries and try to gues the machine's CPU brand during install. The alternative would be to create different packages and let the sysadmin decide.

  7. To create the i386 and architecture independent files, from magma-2.15.10, call:

    fakeroot dpkg-buildpackage -b -ai386

    Repeat for amd64.

  8. The resulting packages can be checked for errors with lintian:

    lintian ../magma*.deb
    W: magma-doc: zero-byte-file-in-doc-directory usr/share/doc/magma/html/html/rel/images.out
    W: magma-common: package-contains-upstream-install-documentation usr/share/doc/magma-common/INSTALL.txt.gz
    W: magma-common: extra-license-file usr/share/doc/magma/ThirdParty/ATLAS_LICENSE.txt
    W: magma-common: extra-license-file usr/share/doc/magma/ThirdParty/ECM_LICENSE.txt.gz
    W: magma-common: extra-license-file usr/share/doc/magma/ThirdParty/GMP_LICENSE.txt.gz

    I found a few textfiles with execure permissions, and set them properly in the unpacked source. As long as no errors come up, I'm fine for now.

  9. dpkg --contents ../magma-bin-i386_2.15.10_i386.deb
    dpkg --info ../magma-bin-i386_2.15.10_i386.deb
    mkdir /tmp/magma-bin-i386-control
    dpkg --control ../magma-bin-i386_2.15.10_i386.deb /tmp/magma-bin-i386-control

  10. dpkg -i ../magma-bin-i386_2.15.10_i386.deb ../magma-common_2.15.10_all.deb ../magma-doc_2.15.10_all.deb


The file magmapassfile, which determines whether magma is allowed to run on a particular machine, is not packaged, and shouldn't be. When starting with my example config file in /etc/magma/, magma looks for it in /etc/magma/magmapassfile and in ~/magmapassfile.


ToDo (in no particular order):

  • Perhaps use update-alternatives for managing all options.

  • See if we can create a non-native package and use the combined downloaded files as a tar.orig of sorts.

  • Fix a few missed dependencies.

  • Create/generate manpages.

  • Use debconf to determine the architecture and only fall back on autodetection.

  • Install the specialized i386 binaries instead of the generic one.

  • See if we can build all packages at once instead of in an amd64 and then an i386 run.

  • Build the package with PBuilder in a chroot jail.

  • Test installation on Debian Etch and Lenny, and on Ubuntu Hardy, Intrepid and Jaunty.

[31] This dirname is part of the requirements for packaging.