linuxdebianpackagedeb

Create debian package from source file with multiple binaries


I have a C/C++ am autoconf source package for Linux that consist of several binaries, logical in development as many of them share the same source. Some binaries run in a graphical environment, some are server components, some drivers for the server, libs and others are shell commands. I would like to make a proper debian package for this system (I already have a working checkinstall based install).

If I follow the Debian tutorials I can make a package for for all binaries in one. But how do I do if I want to make a package that just install one binary component? In my case installing graphical stuff separate from non-graphical stuff.

As it looks from the tutorials I need to make a separate source package for each package I want to maintain but that sounds stupid and I must have missed something.

Any help or pointers are welcome.


Solution

  • A single source package can be build into multiple binary packages (aka .deb-files, which you can install). This is indeed a very common pattern when creating Debian packages.

    To create multiple binary packages, you need to add a section for each of them to your debian/control file. Something like:

    Source: foobar
    Section: utils
    Priority: optional
    Maintainer: me@example.com
    Build-Depends:
     debhelper (>= 10~),
    Standards-Version: 4.1.1
    Homepage: https://github.com/foobar/foobar
    
    Package: foobar
    Section: utils
    Architecture: any
    Multi-Arch: same
    Depends:
     foobar-common (= ${source:Version}),
     ${misc:Depends},
    Description: foo bar baz
     bla bla bla
    
    Package: foobar-data
    Architecture: all
    Depends:
     ${misc:Depends},
    Description: foo bar baz (architecture independent files)
     furbel wurbel wiznagod blumpl.
     bla bla bla.
     .
     this package contains the binary independent parts
    

    In the simplest case you then need to specify which files go into which package:

    $ cat debian/foobar.install
    foobar usr/bin/
    foobar.1 usr/share/man/man1/
    $ cat debian/foobar-data.install
    data/* usr/share/foobar/
    $
    

    Of course there is plenty of documentation available about this.