Wednesday, 9 October 2013

Let's talk about arch-specific quilt patches.

Up until a couple of days ago, I was blissfully ignorant of the fact
that some packages need to have different distropatches depending on
which arch the package is built for. Unfortunately, the following
debian/rules snippet has come to my attention:

This can currently be found in lp:cordova-ubuntu,
lp:cordova-ubuntu-tests, lp:signon, and possibly others. Does anybody
know where this originated? Everybody I've asked so far has admitted
that they just copied it from somebody else.

I would *hope* that it is obvious to everybody why this is a horrible
abomination that needs to be killed with fire, but just in case you
don't see the problem here, I'll explain. It is an enormous
maintainability nightmare. It re-invents precisely what it is that
quilt is supposed to be doing for you, in a way that is sensitive to
the implementation details of quilt itself. What if quilt's behavior
changes in the future? This snippet will have to be found and updated
everywhere that it exists. What if a bug is found in this snippet?
Again it will have to be found and fixed everywhere. It becomes a
sloppy copy&paste hackjob.

Instead, I would like to propose an alternative that is superior
because it does not rely on any quilt implementation details, and is
written in half as many lines of code:

The only change necessary to make this work is to rename the existing
debian/patches/series to debian/patches/series.all, and make sure that
the debian directory does not ship with a debian/patches/series file
(its presence in the source tree would prevent it from being generated
at build time).

This works because debian/rules is really a Makefile. So we allow
dh_quilt_* rules to run unmodified, but we tell `make` that it needs
to create debian/patches/series first, and we tell it that that file
can be created by concatenating series.all with series.[arch].

Better yet, this implementation ignores missing files, so if you have
no patches that apply to all arches, you can omit the 'series.all'
file harmlessly. If you only have one patch and it's only for armhf,
you need only a 'series.armhf' file. if you were then to try and build
on amd64, you'd get an empty debian/patches/series file, because
series.all and series.amd64 could not be found, so cat created an
empty series file for you. Quilt then goes on to harmlessly not apply
any patches.

What does the community think about this? Can anybody find a flaw with
my proposed method? Improvements are welcome ;-)

ubuntu-devel mailing list
Modify settings or unsubscribe at: