Capítulo 8. Sanitização da fonte

Índice

8.1. Corrige com Files-Excluded
8.2. Corrigir com debian/rules clean
8.3. Corrigir com extend-diff-ignore
8.4. Corrigir com tar-ignore
8.5. Corrigir com git clean -dfx

There are a few cases that require sanitizing the source to prevent contamination of the generated Debian source package.

There are several methods to avoid including undesirable content.

This method is suitable for avoiding non-https://www.debian.org/social_contract.html#guidelines[DFSG] compliant content 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.

    • Em alternativa, use o comando gbp import-orig --uscan --pristine-tar.
  • mk-origtargz invocado de uscan remove ficheiros excluídos do tarball do autor e re-empacota-o como um tarball limpo.
  • O tarball resultante tem o número de versão com um sufixo adicional +dfsg.

Veja EXEMPLOS DE FICHEIROS COPYRIGHT em mk-origtargz(1).

This method is suitable for avoiding auto-generated files by removing them in the "debian/rules clean" target.

[Nota]Nota

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

Isto é para o pacote não-nativo Debian.

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

debian/source/options para excluir os ficheiros config.sub, config.guess e Makefile

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

[Nota]Nota

This approach always works, even when you can’t remove the file. It saves you from having to make a backup of the unmodified file just to restore it before the next build.

[Dica]Dica

If you use the debian/source/local-options file instead, you can hide this setting from the generated source package. This may be useful when local non-standard VCS files interfere with your packaging.

Isto é para o pacote nativo Debian.

You can exclude certain files in the source tree from the generated tarball by adjusting the file glob. Add the "tar-ignore=…​" lines in the debian/source/options or debian/source/local-options files.

[Nota]Nota

For example, if the source package of a native package needs files with the .o extension as part of the test data, the setting in Secção 4.5, “Configuração do devscripts may be too aggressive. You can work around this by dropping the -I option for DEBUILD_DPKG_BUILDPACKAGE_OPTS in Secção 4.5, “Configuração do devscripts and adding the "tar-ignore=…​" lines in the debian/source/local-options file for each package.

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

You can restore the source tree before the second package build. For example:

 $ git reset --hard
 $ git clean -dfx

This works because the dpkg-source command ignores the contents of typical VCS files in the source tree, as specified by the DEBUILD_DPKG_BUILDPACKAGE_OPTS setting in Secção 4.5, “Configuração do devscripts”.

[Dica]Dica

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