Re: Modifying a file from another package (rather than replacing it)
Am 25.12.2010 13:25, schrieb Ben Hutchings:
>> I've written a couple of extensions to pbuilder. When my package gets
>> installed, a file from the pbuilder package (/usr/sbin/pbuilder) must be
>> modified for my extension to work. I'm looking for the "proper" way to
>> apply a patch to that file.
> This is not a good idea. What happens if the patch fails? What if two
> packages try to patch pbuilder?
The diversion is added in preinst and removed in postrm. The patch is
applied in postinst.
If the diversion fails, so does preinst, and postinst should not get
called. So I only patch the file after it has been diverted to my package.
I didn't find anything on dpkg-divert's return code in its man page. But
from its source, I guess it exits with a non-zero status if you try to
divert an already diverted file.
What happens if the patch fails, I'm not that sure. Certainly, postinst
fails. I would hope that this triggers postrm to be called with the
about-install argument, which would remove the diversion.
> If you cannot accomplish what you want using an existing hook then
> perhaps you should ask the pbuilder maintainer to add a new hook.
Well, a new hook probably won't do. I've written to additional
"commands": buildmodule and buildootmodule. One patches and packages
single kernel modules, the other builds out-of-tree kernel modules with
module-assistant and dkms. In both cases, the idea is to do this for a
well-defined kernel, independent of the host machine's environment.