Chapter 7. Sanitization of the source

Table of Contents

7.1. Fix with Files-Excluded
7.2. Fix with debian/rules clean
7.3. Fix with extend-diff-ignore
7.4. Fix with tar-ignore
7.5. Fix with git clean -dfx

There are a few cases which require to sanitize the source to prevent contaminating the generated Debian source package.

Existem vários métodos de evitar a inclusão de conteúdos indesejáveis.

This is suitable for avoiding non DFSG contents in the upstream source tarball.

  • Lista os ficheiros a serem removidos na estrofe Files-Excluded do ficheiro debian/copyright.
  • Lista o URL para descarregar o tarball do autor no ficheiro debian/watch.
  • Corre o comando uscan para descarregar o novo tarball de autor.

    • Alternatively, use the gbp import-orig --uscan --pristine-tar command.
  • mk-origtargz invoked from uscan removes excluded files from the upstream tarball and repack it as a clean tarball.
  • O tarball resultante tem o número de versão com um sufixo adicional +dfsg.

See COPYRIGHT FILE EXAMPLES in mk-origtargz(1).

This is suitable for avoiding auto-generated files and removes them in the debian/rules clean target

[Note]Note

The debian/rules clean target is called before the dpkg-source --build command by the dpkg-buildpackage command and the dpkg-source --build command ignores removed files.

This is for the non-native Debian package.

The problem of extraneous diffs can be fixed by ignoring changes made to parts of the source tree by adding the extend-diff-ignore=…​ line in the debian/source/options file.

debian/source/options to exclude the config.sub, config.guess and Makefile files: 

# Don't store changes on autogenerated files
extend-diff-ignore = "(^|/)(config\.sub|config\.guess|Makefile)$"

[Note]Note

Esta abordagem funciona sempre, mesmo quando você não consegue remover o ficheiro. Assim poupa-lhe de ter de fazer uma salvaguarda do ficheiro não-modificado apenas para ser capaz de o restaurar antes da próxima compilação.

[Tip]Tip

Se em vez disto for usado o ficheiro debian/source/local-options, você pode esconder esta definição do pacote fonte gerado. Isto pode ser útil quando os ficheiros VCS locais não-standard interferem com o seu empacotamento.

This is for the native Debian package.

You can exclude some files in the source tree from the generated tarball by tweaking the file glob by adding the tar-ignore=…​ lines in the debian/source/options or debian/source/local-options files.

[Note]Note

If, for example, the source package of a native package needs files with the file extension .o as a part of the test data, the setting in Section 4.5, “devscripts setup” is too aggressive. You can work around this problem by dropping the -I option for DEBUILD_DPKG_BUILDPACKAGE_OPTS in Section 4.5, “devscripts setup” while adding the tar-ignore=…​ lines in the debian/source/local-options file for each package.

The problem of extraneous contents in the second build can be avoided by restoring the source tree by committing the source tree to the Git repository before the first build.

Você pode restaurar a árvore fonte antes da segunda compilação de pacote. Por exemplo:

 $ git reset --hard
 $ git clean -dfx

This works because the dpkg-source command ignores the contents of the typical VCS files in the source tree with the DEBUILD_DPKG_BUILDPACKAGE_OPTS setting in `"Section 4.5, “devscripts setup”`".

[Tip]Tip

If the source tree is not managed by a VCS, you should run git init; git add -A .; git commit before the first build.