Quick Debian Packaging HOWTO

Quick Debian Packaging HOWTO

This is a quick Debian package creation HOWTO for Debian newbies (i.e. me). This is trying to mirror the same kind of process that I use for creating Fedora/RHEL RPMs and is for private packages, so I ignore all of the requiments for changing the upstream software to meet the Debian projects requirements (such as correctly specifying the copyright).

  1. Get packages to do the build:
    sudo apt-get install -y pbuilder devscripts
  1. Create working directory:
    mkdir pkg
    cd pkg
  1. Grab source:
    wget http://example.com/foo-1.2.3.tar.gz
    tar zxf foo-1.2.3.tar.gz
    cd foo-1.2.3
  1. Build skeleton:
    DEBFULLNAME=“Jonathan Barber” dh_make -p foo_1.2.3 -f ../foo-1.2.3.tar.gz  -s -e jbarber@sp.up.pt -c bsd
    1. Add patches to the source, first by adding a completely new file that doesn’t already exist:
      export QUILT_PATCHES=debian/patches
      quilt new makefile.def
      quilt add Makefile.def
      cat <<‘EOF’ > Makefile.def

      EOF
      quilt refresh
      quilt header -e
  1. Add a new diff in a seperate patch:
    quilt new install.patch
    quilt add Makefile
    cat <<‘EOF’ > Makefile

    EOF
    quilt refresh
    quilt header -e
  1. Now go back and modify the first patch:

    quilt pop
    cat <<‘EOF’ > Makefile.def

    EOF
    quilt refresh
    quilt push
  1. Modify debian/control to include build dependencies (“Build-Reqs”)
  1. Modify debian/rules so it knows how to build the source
  1. Build source deb:

    dpkg-buildpackage -S
  1. Build .deb in clean environment:

    pbuilder —create —distribution stable
    (cd ..; pbuilder —build *.dsc)
  1. If it fails, make changes, then rerun:

    dpkg-buildpackage -S
    (cd ..; pbuilder —build *.dsc)
  1. The output from pbuilder is left in /var/cache/pbuilder/result by default

Outstanding issues are discovering how to build the source package without having all of the Build-Reqs installed. But I don’t know if this is possible…

Further documentation is available at: