HOWTO: Rebuilding Debian's nginx package with an added module

  1. Make sure you have the basic build tools installed by running apt-get install build-essential devscripts
  2. Set up the DEBEMAIL and DEBFULLNAME environment variables (used by the debian build tools)
  3. Get the packages needed to build nginx-extras with the command apt-get build-deb nginx-extras
  4. Get the source package with the command apt-get source nginx-extras

    Note: this created a new directory 'nginx-version' that holds the debian package as distributed by debian. We'll be making all changes in that directory.

    Note: If you get the error E: You must put some 'source' URIs in your sources.list' you need to edit /etc/apt/sources.list to add a source repository (copy the line for your normal debian repository changing the 'deb' to 'deb-src'), and then run 'apt-get update'

  5. Specifically we'll add the source of any modules we want to add into the 'debian/modules' subdirectory (List of nginx 3th party modules with download links). For example we'll add the form input module, downloading and extracting it to create 'debian/modules/form-input-nginx-module-0.10'
  6. Edit debian/rules so it picks up the new module for building by adding --add-module=$(MODULESDIR)/form-input-nginx-module-0.10 to the configure target of the package you want to change (this means the 'extras_configure_flags' for nginx-extras)
  7. Edit the changelog with debchange --local +custom
  8. Build the package by running dpkg-buildpackage -b -uc (if you have gpg set up, leave of the '-uc')

    The build package will be a sibling of the 'nginx-version' directory where we've been making our changes