Debian

Building debian packages

1
  apt-get install -y devscripts gdebi-core build-essential

Using dpkg-buildpackage

debian/control

  Source: hello
  Section: devel
  Priority: optional
  Maintainer: John Doe 
  Build-Depends: debhelper (>= 9)

  Package: hello
  Architecture: all
  Depends: python
  Description: John's hello package
               John's package is written in Python
               and prints a greeting.
               .
               It is awesome.

debian/changelog

https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog

  hello (2.0.0-1) stretch; urgency=medium

    ,,* Initial packaging work with dpkg-buildpackage.

   -- John Doe   Thu, 06 Jul 2017 09:19:24 +0000

debian/compat

1
  echo 10 > debian/compat

debian/rules

The rules file is a Makefile. Must contain three targets:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
  #!/usr/bin/make -f

  clean:
      @# Do nothing

  build:
      @# Do nothing

  binary:
      mkdir -p debian/hello
      mkdir -p debian/hello/usr/bin
      cp hello debian/hello/usr/bin/
      dh_gencontrol
      dh_builddeb

Using debhelper

debian/rules

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
  #!/usr/bin/make -f

  PACKAGEVERSION=1.2.3

  %:
      dh $@

  # remove compilation products
  override_dh_auto_clean:

  # compile application if necessary
  override_dh_auto_build:

  # install application into the package root directory
  override_dh_auto_install:

  # override package version
  override_dh_gencontrol:
      dh_gencontrol -- -v$(PACKAGEVERSION)

Systemd integration

debian/control

  Build-Depends: debhelper (>= 9), dh-systemd

debian/rules

1
2
  %:
      dh $@ --with=systemd

debian/package.service

systemd service file