On cleaning and distcleaning ...

... and CDBS and "FTBFS if built twice in a row"

Yesterday I closed two bugs of mine (424331 and 424392) of the "FTBFS if built twice in a row" class. Shame on me, they were open since too long. Both packages use autotools and, on the Debian side, CDBS.

For both packages the fix was as simple as adding:


to debian/rules.

The rationale for that is rather obvious (now that I've thought about it of course). CDBS per default uses "distclean" as the upstream target which is invoked when "debian/rules clean" is executed. Unfortunately, "distcheck" (used by upstream to create the distribution tarball) does not check that "distclean" leave the distribution tarball as it was before the build. So nothing grants a priory that stuff removed by "distclean" is rebuildable with just the build-deps.

A lot of packages come with generated sources (for example by XSLT or by some template toolkits) included in the source package, if that stuff is removed by mistake during distclean you'll see yet another instance of this kind of bugs.

I bet a lot of other "FTBFS if built twice in a row" bugs out there have been fixed this way or can still be fixed with the addition of the line above.

Update: changed this post, the first writing was made thinking at "maintainer-clean" instead of "distclean"