Using quilt in Debian source packages.
- This page is aimed at people who want to make some changes to a Debian source package which is already using quilt.
- The intention is not to explain quilt, but to offer some Debian specific tips
If you want to understand how quilt work, install the package and read /usr/share/doc/quilt/quilt.pdf.gz
There is an extensive guide on quilt and packaging: Debian New Maintainers' Guide.
A comprehensive yet succinct tutorial on quilt, How to use quilt to manage patches in Debian packages, published by Raphaël Hertzog (coauthor of the New Maintainers' Guide above)
A How-To from the Debian Perl Group: Quilt for Debian Maintainers.
There is also a Quilt Tutorial (PDF), though dated (2006)
If using a git packaging workflow, consider using gbp-pq(1) for quilt patch management.
quilt works with some directories : it creates a .pc/ and a patches/ directory.
Those directories can be created when you do
$ quilt import some_package.diff.gz
Using quilt with Debian source packages
Situation: you have downloaded a Debian source package which uses quilt and want to fix a bug and then submit a patch to the maintainers.
Using .quiltrc configuration file
Place a .quiltrc configuration file in your home directory with the following lines.
QUILT_PATCHES=debian/patches QUILT_NO_DIFF_INDEX=1 QUILT_NO_DIFF_TIMESTAMPS=1 QUILT_REFRESH_ARGS="-p ab" QUILT_DIFF_ARGS="--color=auto" # If you want some color when using `quilt diff`.
Alternatively, you can add these lines to .bashrc. Otherwise, run them in your shell or terminal before using quilt
export QUILT_PATCHES=debian/patches export QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index"
To apply quilt options only when inside a Debian source package, you can setup your ~/.quiltrc something like this:
d=. ; while [ ! -d $d/debian -a `readlink -e $d` != / ]; do d=$d/..; done if [ -d $d/debian ] && [ -z $QUILT_PATCHES ]; then # if in Debian packaging tree with unset $QUILT_PATCHES QUILT_PATCHES="debian/patches" QUILT_PATCH_OPTS="--reject-format=unified" QUILT_DIFF_ARGS="-p ab --no-timestamps --no-index --color=auto" QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index" QUILT_COLORS="diff_hdr=1;32:diff_add=1;34:diff_rem=1;31:diff_hunk=1;33:diff_ctx=35:diff_cctx=33" if ! [ -d $d/debian/patches ]; then mkdir $d/debian/patches; fi fi
Basic quilt tasks
Making a new patch
apt-get source decides whether to apply the patches based on the format of the package. For some packages, you will have to apply the patches as specified here. For others, they will be automatically applied.
First step: apply existing patches to the source
quilt push -a
to "push" all existing patches onto the source tree (when you build a package, this is done by the build scripts)
Creating a new patch
quilt new myPatch.diff # this is the patch name
quilt add README # Where 'README' is the name of file you want to modify. You have to do that for all files you modify before you change them; one quilt patch can change multiple files
Now make changes to the source
Now, make your changes to the files added to the patch: edit it, or replace it with an already modified file stored in a different directory.
Updating a patch with changes made to its files
quilt refresh #you can do this as often as you like
Finish your editing
quilt pop -a #this un-applies all patches so that the source returns to the downloaded condition
Editing an existing patch
quilt supports multiple patches, but you are only ever change one of them.
This is the patch last pushed.
To edit an existing patch, start by pushing it
quilt push myPatch.diff
Now edit it, and when ready
quilt refresh myPatch.diff #note: command line completion may save you some typing
quilt pop -a