[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Finding files for d/clean when using sbuild



Hi Robin,

On 11/9/20 9:48 PM, Robin Gustafsson wrote:
More than once now, I've made the mistake of missing certain files
that ought to be added to debian/clean. I typically use sbuild when
building packages, so these extra files get thrown out after the build
anyways, so they're not obvious to me.

What's the recommended way to find such left-over files after an sbuild build?

I imagine a diff between the original source tree and whatever's left
after a build and a subsequent clean could accomplish it. The external
command functionality in sbuild could perhaps be used for this. I
thought I'd ask for existing solutions before I put something together
for myself, though.

I have found myself in the same situation, without finding any satisfying solution.

Up until now, I was using two workarounds:

- Using `pbuilder --twice` just to test that. But that's far from ideal since I have I want to stick to sbuild. - Using the `--purge never` option of sbuild that allow to keep the schroot used for building. I can then re-enter the schroot and try to build it a second time from there. Too much manual work.

I tried to give it a more serious thought and I came up with the alternative of using the commands hooks as recommended in #424846[1].

I came up with the following:

$ cat ~/.sbuildrc
$external_commands = {
    "starting-build-commands" => [
'find %SBUILD_PKGBUILD_DIR | sort | while read file; do echo -n "$(stat -c "%n %F %s" "${file}") "; if [ -f ${file} ]; then md5sum "${file}" | cut -d " " -f 1; else echo; fi; done > /tmp/file-list.pre-build'
    ],
    "chroot-cleanup-commands" => [
        'cd %SBUILD_PKGBUILD_DIR && ./debian/rules clean',
'find %SBUILD_PKGBUILD_DIR | sort | while read file; do echo -n "$(stat -c "%n %F %s" "${file}") "; if [ -f ${file} ]; then md5sum "${file}" | cut -d " " -f 1; else echo; fi; done > /tmp/file-list.post-build',
        'diff /tmp/file-list.pre-build /tmp/file-list.post-build'
    ]
};

Disclaimer: This is a quick, ugly hack that has not been tested extensively. I'm certain that given some uncommon case (starting with space in path?) that will break. (And the size doesn't appear to work either)

That being said, it seems to do the trick and catch differences before/after a build + cleanup.

[1]: https://bugs.debian.org/424846
--
Baptiste Beauplat - lyknode

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


Reply to: