category

Debian Packaging 2018-12-10 link

Managing servers is way easier if you package up your projects as packages. This is a list of steps that results in a Debian package.

Build machine setup

  1. Make sure you have the required dependencies: apt install build-essential dh-make git-buildpackage
  2. Optionally install a custom package key to your apt repo: curl https://example.org/example.asc | apt-key add -
  3. Optionally add a custom repository to the pbuilder config: echo 'OTHERMIRROR="deb https://example.org/debian buster main"' >> /etc/pbuilderrc
  4. Make sure you have a build environment in the right distribution: cowbuilder create --distribution buster --basepath /var/cache/pbuilder/base-buster.cow --keyring /etc/apt/trusted.gpg --debootstrapopts "--include=apt-transport-https,ca-certificates"

Package configuration

  1. Make sure the repository has a Makefile in the root directory which accepts the following targets:
    • build
    • test
    • clean
    • install (make sure to install all files relative to ${DESTDIR}
  2. Tag the first release with the version number: git tag v1.2.3
  3. Create a branch for the debian version you're targeting: git checkout -b debian/buster
  4. Set your name: export DEBFULLNAME="John Doe"
  5. Set your email: export EMAIL=yourmail@example.org
  6. Create template debian control files: dh_make --single --createorig --packagename yourpackagename-with-hypens_1.2.3
  7. Create the pristine-tar branch: pristine-tar commit ../yourpackagename-with-hypens_1.2.3.orig.tar.xz master
  8. Remove the files you don't need in the debian folder. Make sure you keep the following ones: changelog, compat, control, rules, source/format.
  9. Fill in the changelog
  10. Fill in the control file: https://www.debian.org/doc/manuals/maint-guide/dreq.en.html
  11. Commit the debian folder to the debian/buster branch.
  12. Build: gbp buildpackage --git-pristine-tar --git-pristine-tar-commit --git-upstream-tag='v%(version)s' --git-pbuilder --git-debian-branch=debian/buster --git-dist=buster

New version

  1. Update the cowbuilder base system: DIST=buster git-pbuilder --update
  2. Tag the new version on develop: git tag v1.2.4
  3. Switch to the debian branch: git checkout debian/buster
  4. Merge develop in: git merge develop
  5. Update the changelog, make sure you update the top version number to be the same as the tag: gbp dch --release --auto --debian-branch=debian/buster
  6. Commit the changelog: git commit debian/changelog
  7. Build: gbp buildpackage --git-pristine-tar --git-pristine-tar-commit --git-upstream-tag='v%(version)s' --git-pbuilder --git-debian-branch=debian/buster --git-dist=buster