Development/Patching External Libraries

From The Document Foundation Wiki
Jump to: navigation, search

Creating Patches for External Project

External libraries are being integrated in gbuild. In order to simplify the generation of patches for such libraries, gbuild has been fitted with few improvements.

For the purpose of this document, <module> means a top-level module, <target> means the name associated with the package unpacked. By convention you should have a file named external/<module>/UnpackedTarball_<target>.mk

First, one need to make sure to have a 'pristine reference' to be able to make the patch.

make <module>.clean
patches=t make <module>

Be careful, if you do not generate the reference copy upfront, you won't be able to generate a patch. The safer way is simply to export patches=t in the beginning of the session, to be safe.

The files you can edit are in workdir/UnpackedTarball/<module>

you can build them by doing:

cd external/<module>
make -r

If a simple make does not detect the changes you've made, you can try make -r <target>.rebuild instead of make -r. This special target will try to force a rebuild.

Beware that you cannot do make clean to force a rebuild as it would delete the change you've made to the Unpacked sources and replace them with a new pristine copy.

Once you are satisfied with your changes, you can generate a patch using

cd <module>
make <target>.genpatch

This will create a patches named <target>.new.patch.1

you can then move that file to the appropriate location in the module, and update UnpackedTarball_<target>.mk to add that new patch in the list of patches to apply.

Note: the .1 suffix indicate that this patch need to be applied with -p1. in general the convention is that a patch's filename, if it end with .<n> -- where <n> is a digit -- indicate a patch that need to be applied with -p <n>. Currently the default level is -p3 for historical reasons. This naming convention allow for an easy transition from the legacy situation.