It’s quite common that the upstream build system generates/updates some files but does not clean them up properly when you call
make clean. In that case, when you rebuild the package a second time in the same tree, the generated Debian source package will contain those changes.
You usually don’t want those changes. They make your package harder to review because they contain unneeded modifications (either directly in the
.diff.gz with the old source format, or in a new patch in
debian/patches/debian-changes-<ver> with the “3.0 (quilt)” source format).
I’ll show you 3 ways to avoid this problem. They are all workarounds, the proper fix would be to improve the upstream build system to really clean up the generated files. This is usually possible for files that are “created”, but it’s much more cumbersome for files that are “updated” (you would have to keep a backup of the original file so that you can restore it).
The traditional fix
Instead of relying on the upstream build system to do the work, we modify the clean target in debian/rules to remove the files that are left-over. Since “debian/rules clean” is always called before a source package is built, those generated files are not included as changes compared to what upstream provided.
A common work-around: always build from a clean state
As you have noted, the problem only happens when you build (source and binaries) twice in a row in the same tree. Some VCS-helper tools always build the Debian package in a temporary tree which is exported from the VCS. This is the case of svn-buildpackage by default and of git-buildpackage if you use its
I don’t like this solution because it solves the problem only for the maintainer. Anyone else who is working on top of the package without using the same VCS-helper tool would be affected by the problem.
A new way to avoid the problem
Since it’s now possible to store dpkg-source options in the source package itself, we can conveniently have everybody use the
--extend-diff-ignore option. It tells dpkg-source to ignore some files when checking whether we have made changes to upstream files.
For example if you want to ignore changes made on the files “config.sub”, “config.guess” and “Makefile” you could put this in debian/source/options:
# Don't store changes on autogenerated files extend-diff-ignore = "(^|/)(config\.sub|config\.guess|Makefile)$"
You need to know a bit about Perl regular expressions since that’s what is used by dpkg-source to match the filenames to exclude.
Note that this approach always works, even when you can’t remove the file. So it saves you having to make a backup of the unmodified file just to be able to restore it before the next build.
Found it useful? Be sure to not miss other packaging tips (or lessons), click here to subscribe to my free newsletter and get new articles by email.