Skip to content

Debian templates

The Debian template files debian.yml can be included via

include:
  - project: computing/gitlab-ci-templates
    file: debian.yml

This file provides the following job templates:

.debian:cache

Description

Configures caching of resources used by apt.

Example usage

deb:
  extends:
    - .debian:cache

.debian:base

Extends: .debian:cache

Description

The base Debian job template. This template configures Apt caching, and executes a standard apt-get update as part of the before_script stage.

Example usage

This example adds extra commands to the before_script stage while using a !reference tag to execute all of the template commands as well:

debian:
  extends:
    - .debian:base
  before_script:
    - !reference [".debian:base", before_script]
    - apt-get -y -q install python3
  script:
    - python3 --version

Quote the template job name when using !reference tags

When using gitlab-ci's !reference tags it is important to quote the job name, since it contains a colon (:).

.debian:dsc

Extends: .debian:base

Description

This job builds a Debian source package (.dsc) from a tarball. The .dsc file, along with the Debian orig.tar and debian.tar tarball are uploaded as job artifacts.

With default options, this job approximately runs the following:

tar -xf ${TARBALL}
dpkg-source <tar-directory>/

The job can be configured using the following variables:

Name Default Purpose
DSC_DEPENDENCIES (empty) extra packages to apt-get install before building the Debian source package
TARBALL ${CI_PROJECT_NAME}-*.tar.* the source tarball to build from

Example usage

To build a Debian source package using a tarball from a previous stage:

dsc:
  extends:
    - .debian:dsc
  needs:
    - tarball
  variables:
    TARBALL: myproject-*.tar.gz

.debian:deb

Extends: .debian:base

Description

This job takes in a Debian source package and associated files and builds one or more binary Debian packages (.debs). The .deb packages, as well as any .buildinfo or .changes files are uploaded as job artifacts.

With default options, this job approximately runs the following:

dpkg-source --extract *.dsc src/
cd src
mk-build-deps --install --remove --tool 'apt-get -y -q ${APT_GET_OPTIONS}'
dpkg-buildpackage -us -uc -b

The job can be configured using the following variables:

Name Default Purpose
APT_GET_OPTIONS "-o Debug::pkgProblemResolver=yes --no-install-recommends" Options to pass to apt-get install when installing BuildRequires via mk-build-deps
DSC ${CI_PROJECT_NAME}_*.dsc Debian source package to build from

Example usage

deb:
  extends:
    - .debian:deb
  needs:
    - dsc
  variables:
    DSC: "myproject_*.dsc"

To build out Debian source and binary packages for a Python project in a single job, one might consider something like this:

deb:
  extends:
    # extend from the 'deb' template to upload
    # the binary packages as artifacts automatically
    - .debian:deb
  before_script:
    # run the `before_script` for the source package template
    - !reference [".debian:dsc", before_script]
    # run the `before_script` for the binary package template
    - !reference [".debian:deb", before_script]
  script:
    # generate a tarball
    - python setup.py sdist --dist-dir .
    # generate the source package
    - !reference [".debian:dsc", before_script]
    # generate the binary package
    - !reference [".debian:deb", before_script]

.debian:lint

Extends: .debian:base

Description

Runs lintian against one or more debian package build outputs.

The job can be configured using the following variables:

Name Default Purpose
LINTIAN_OPTIONS --color=auth options to pass to lintian
LINTIAN_TARGET "*.changes" input files for lintian

Example usage

lintian:
  extends:
    - .debian:lint
  needs:
    # pull in packages from the `deb` job
    - deb