Using quilt with ooo-build

# quilt and ooo-build

quilt is a tool to manage a stack of patches. And you can use it in ooo-build.

## Getting and installing quilt

quilt's home is http://savannah.nongnu.org/projects/quilt At the time of writing, its download directory was not yet restored on savannah.

Mirrors are e.g. ftp://ftp.debian.org/debian/pool/main/q/quilt/ or (currently more up-to-date): http://graal.ens-lyon.fr/~mquinson/debian/dists/unstable/main/source/devel/

Unpack and install.

Add this to your `~/.quiltrc`:

    # -p : Show which C function each change is in.
    QUILT_DIFF_OPTS="-p${QUILT_DIFF_OPTS:+ $QUILT_DIFF_OPTS}"

## Setting up your source tree for quilt

### Unapply old patches

If you're starting from a clean OOo source, you can skip this section.

quilt doesn't know about the ooo-build patches yet. If your tree was patched by ooo-build, revert the patches by running:

    ooo-build/patches/apply.pl ooo-build/patches/OOO_1_1_0 $OOBUILDDIR --distro=$DISTRO -R

$OOBUILDDIR is the path to your OOo source tree, $DISTRO is what you used for `--with-distro=` when you ran configure

### Tell quilt about the ooo-build patches

quilt expects patches in the patches subdir of the source tree:

    ln -s /path/to/ooo-build/patches $OOBUILDDIR

quilt gets the list of patches from a `series' file, similar to ooo-build's apply files. You can generate a series file by running

    ooo-build/patches/apply.pl ooo-build/patches/OOO_1_1_0 --series-from=$DISTRO > series

in your working directory.

Now you can apply the patches with quilt using `quilt push`, and revert them with `quilt pop` (one at a time, use the `-a` switch to push/pop all).

A smoke test for your quilt setup (and the ooo-build patches) is:

    quilt push -a
    quilt pop -a
    quilt push -a
    quilt pop -a

There should be no failure.

## Use it

Now's a good time to read quilt.pdf from the quilt 0.29 (or later) tarball or http://savannah.nongnu.org/cgi-bin/viewcvs/quilt/quilt/doc/quilt.pdf.

### Create a new patch with quilt

Let's say you want to create a patch for Issue 13473 LINK tags in HTML export of presentations Maybe you want to write your patch on top of all the other patches. Run `quilt push -a` to apply all patches.

In the OOo source tree run `quilt new patches/OOO_1_1/sd-export-html-link-rel.diff` to create the new patch.

You'll have to edit `sd/source/filter/html/htmlex.cxx`. Run `quilt add sd/source/filter/html/htmlex.cxx`. Quilt will make a backup copy of the file. Later it can use that copy to create the diff.

Now edit sd/source/filter/html/htmlex.cxx, compile, test, edit again, ...

When you're finished (or just want to know what you have changed in the file), run `quilt refresh -p0`. You can shorten refresh to ref, the -p0 is necessary because in ooo-build all patches are expected to be in -p0 format.

If you're confident that your patch is fine, add it to the apply file, write the ChangeLog entry and commit.

The neat thing is that you couldn't do this with a simple cvs diff, because htmlex.cxx is modified by other patches as well.

## Hints

- Always run quilt in the top source dir.
- Don't forget to `quilt add` files before modifying them. This is inconvenient, I know.
- It's no problem if you add a file you're not changing. Diffing will be some milliseconds slower, but the patch will be fine.
- Don't cvs update ooo-build when some patches are applied. It's hard to revert patches that have been changed in cvs. Run `quilt pop -a` before cvs update. Regenerate the series file afterwards if necessary.
- If you did cvs update when patches were applied, maybe `quilt pop -a -f` can rescue you (-f as in force).
- You can create series files for each distro, use `--export-series-to=debian-series` and symlink `series` to the one you want to work on. Don't forget to `quilt pop -a` before changing the symlink.

## Problems

- quilt has problems with hand-made patches that change file a, then file b, then file a again.

Last modified: Wed Jan 7 11:20:01 CET 2004