Chapter 8. More on packaging

Table of Contents

8.1. Package customization
8.2. Customized debian/rules
8.3. Variables for debian/rules
8.4. Novo lançamento do autor
8.5. Manage patch queue with dquilt
8.6. Build commands
8.7. Note on sbuild
8.8. Special build cases
8.9. Enviar orig.tar.gz
8.10. Envios saltados
8.11. Relatórios de bug

Let’s describe more basics on Debian packaging.

All customization data for the Debian source package resides in the debian/ directory as presented in Section 5.7, “Passo 3: Modificação dos ficheiros modelo””:

When these are not sufficient to make a good Debian package, -p1 patches of debian/patches/* files are deployed to modify the upstream source. These are applied in the sequence defined in the debian/patches/series file before building the package as presented in Section 5.9, “Step 3 (alternatives): Modification to the upstream source”.

Você deve endereçar a causa raiz do problema de empacotamento Debian pela maneira menos invasiva. O pacote gerado será mais robusto para atualizações futuras neste modo.

[Note]Note

Envie a patch que endereça a causa raiz para o maintainer do autor se esta for útil para o autor.

Flexible customization of the Section 6.5, “debian/rules file” is realized by adding appropriate override_dh_* targets and their rules.

Sempre que alguma operação especial é requerida para um certo comando dh_foo invocado pelo comando dh, qualquer execução automática dele pode ser sobreposta ao adicionar o alvo makefile override_dh_foo no ficheiro debian/rules.

O processo de compilação pode ser personalizado via interface fornecida pelo autor como argumentos para os comandos do sistema de compilação de fonte de autor, tais como:

  • configure,
  • Makefile,
  • python -m build, or
  • Build.PL.

If this is the case, you should add the override_dh_auto_build target with dh_auto_build -- arguments. This ensures passing arguments to the build system after the default parameters that dh_auto_build usually passes.

[Tip]Tip

Please try not to execute the bare build system commands directly if they are supported by the dh_auto_build command.

Veja:

Algumas definições de variável úteis para personalizar o debian/rules podem ser encontradas em ficheiros sob /usr/share/dpkg/. A notar:

pkg-info.mk
Set DEB_SOURCE, DEB_VERSION, DEB_VERSION_EPOCH_UPSTREAM, DEB_VERSION_UPSTREAM_REVISION, DEB_VERSION_UPSTREAM, and DEB_DISTRIBUTION variables obtained from dpkg-parsechangelog(1). (useful for backport support etc..)
vendor.mk
Set DEB_VENDOR and DEB_PARENT_VENDOR variables; and dpkg_vendor_derives_from macro obtained from dpkg-vendor(1). (useful for vendor support (Debian, Ubuntu, …​).)
architecture.mk
Set DEB_HOST_* and DEB_BUILD_* variables obtained from dpkg-architecture(1).
buildflags.mk
Set CFLAGS, CPPFLAGS, CXXFLAGS, OBJCFLAGS, OBJCXXFLAGS, GCJFLAGS, FFLAGS, FCFLAGS, and LDFLAGS build flags obtained from dpkg-buildflags(1).

Por exemplo, você pode adicionar uma opção extra ao CONFIGURE_FLAGS para alvo linux-any de arquitecturas ao adicionar o seguinte ao debian/rules:

DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
 ...
ifeq ($(DEB_HOST_ARCH_OS),linux)
CONFIGURE_FLAGS += --enable-wayland
endif

Veja Section 9.10, “Multiarch””, dpkg-architecture(1) e dpkg-buildflags(1).

When a new upstream release tarball foo-newvwesion.tar.gz is released, the Debian source package can be updated by invoking commands in the old source tree as:

$ uscan
 ... foo-newversion.tar.gz downloaded
$ uupdate -v newversion ../foo-newversion.tar.gz
  • The debian/watch file in the old source tree must be a valid one.
  • This make symlink ../foo_newvwesion.orig.tar.gz pointing to ../foo-newvwesion.tar.gz.
  • Files are extracted from ../foo-newvwesion.tar.gz to ../foo-newversion/
  • Files are copied from ../foo-oldversion/debian/ to ../foo-newvesion/debian/ .

After the above, you should refresh debian/patches/* files (see Section 8.5, “Manage patch queue with dquilt”) and update debian/changelog with the dch(1) command.

When debian uupdate is specified at the end of line in the debian/watch file, uscan automatically executes uupdate(1) after downloading the tarball.

You can add, drop, and refresh debian/patches/* files with dquilt to manage patch queue.

  • Add a new patch debian/patches/bugname.patch recording the upstream source modification on the file buggy_file as:

    $ dquilt push -a
    $ dquilt new bugname.patch
    $ dquilt add buggy_file
    $ vim buggy_file
      ...
    $ dquilt refresh
    $ dquilt header -e
    $ dquilt pop -a
  • Drop (== disable) an existing patch

    • Comment out pertinent line in debian/patches/series
    • Erase the patch itself (optional)
  • Refresh debian/patches/* files to make dpkg-source -b work as expected after updating a Debian package to the new upstream release.

     $ uscan; uupdate  # updating to the new upstream release
     $ while dquilt push; do dquilt refresh ; done
     $ dquilt pop -a
    • If conflicts are encountered with dquilt push in the above, resolve them and run dquilt refresh manually for each of them.

Here is a recap of popular low level package build commands. There are many ways to do the same thing.

  • dpkg-buildpackage = núcleo da ferramenta de compilação de pacote
  • debuild = dpkg-buildpackage + lintian (compilação sob as variáveis de ambiente higienizadas)
  • schroot = núcleo da ferramenta de ambiente chroot de Debian
  • sbuild = dpkg-buildpackage on custom schroot (build in the chroot)

The sbuild(1) command is a wrapper script of dpkg-buildpackage which builds Debian binary packages in a chroot environment managed by the schroot(1) command. For example, building for Debian unstable suite can be done as:

 $ sudo sbuild -d unstable

In schroot(1) terminology, this builds a Debian package in a clean ephemeral chroot chroot:unstable-amd64-sbuild started as a copy of the clean minimal persistent chroot source:unstable-amd64-sbuild.

This build environment was set up as described in Section 4.6, “sbuild setup” with sbuild-debian-developer-setup -s unstable which essentially did the following:

 $ sudo mkdir -p /srv/chroot/dist-amd64-sbuild
 $ sudo sbuild-createchroot unstable /srv/chroot/unstable-amd64-sbuild http://deb.debian.org/debian
 $ sudo usermod -a -G sbuild <your_user_name>
 $ sudo newgrp -

The schroot(1) configuration for unstable-amd64-sbuild was generated at /etc/schroot/chroot.d/unstable-amd64-sbuild.$suffix :

[unstable-amd64-sbuild]
description=Debian sid/amd64 autobuilder
groups=root,sbuild
root-groups=root,sbuild
profile=sbuild
type=directory
directory=/srv/chroot/unstable-amd64-sbuild
union-type=overlay

Aqui:

  • The profile defined in the /etc/schroot/sbuild/ directory is used to setup the chroot environment.
  • /srv/chroot/unstable-amd64-sbuild directory holds the chroot filesystem.
  • /etc/sbuild/unstable-amd64-sbuild is symlinked to /srv/chroot/unstable-amd64-sbuild .

You can update this source chroot source:unstable-amd64-sbuild by:

 $ sudo sbuild-update -udcar unstable

You can log into this source chroot source:unstable-amd64-sbuild by:

 $ sudo sbuild-shell unstable
[Tip]Tip

If your source chroot filesystem is missing packages such as libeatmydata1, ccache, and lintian for your needs, you may want to install these by logging into it.

The orig.tar.gz file may need to be uploaded for a Debian revision other than 0 or 1 under some exceptional cases (e.g., for a security upload).

When an essential package becomes a non-essential one (e.g., adduser), you need to remove it manually from the existing chroot environment for its use by piuparts.

Quando você faz o primeiro envio do pacote para o arquivo, você tem de incluir a fonte orig.tar.gz original, também.

Se o número de revisão Debian do pacote for um de 1 ou 0, isto é a predefinição. Caso contrário, você tem de fornecer a opção do dpkg-buildpackage -sa ao comando dpkg-buildpackage.

  • dpkg-buildpackage -sa
  • debuild -sa
  • sbuild
  • For gbp buildpackage, edit the ~/.gbp.conf file.
[Tip]Tip

Por outro lado, a opção -sd irá forçar a exclusão da fonte orig.tar.gz original.

[Tip]Tip

Envios de segurança requerem incluir o ficheiro orig.tar.gz.

Se você criou múltiplas entradas no debian/changelog enquanto saltou envios, você tem de criar um ficheiro *_.changes apropriado que inclui todas as alterações desde o último envio. Isto pode ser feito ao especificar a opção do dpkg-buildpackage -v com a última versão enviada, ex., 1.2.

  • dpkg-buildpackage -v1.2
  • debuild -v1.2
  • sbuild --debbuildopts -v1.2
  • Para gbp buildpackage, edite o ficheiro ~/.gbp.conf.

The reportbug(1) command used for the bug report of binarypackage can be customized by the files in usr/share/bug/binarypackage/.

O comando dh_bugfiles instala estes ficheiros a partir dos ficheiros modelo no directório debian/.

  • debian/pacote-binário.bug-controlusr/share/bug/pacote-binário/control

    • Este ficheiro contém algumas direcções tais como redirecionar o relatório de bug para outro pacote.
  • debian/pacote-binário.bug-presubjusr/share/bug/pacote-binário/presubj

    • Este ficheiro é mostrado ao utilizador pelo comando reportbug.
  • debian/pacote-binário.bug-scriptusr/share/bug/pacote-binário ou usr/share/bug/pacote-binário/script

    • O comando reportbug corre este script para gerar um ficheiro modelo para o relatório de bug.

See dh_bugfiles(1) and reportbug’s Features for Developers (README.developers)”

[Tip]Tip

Se você está sempre a lembrar o relatador de bug de algo ou a pergunta sobre a sua situação, use estes ficheiros para o automatizar.