s

Quilt For Openwrt


Table of Contents

2 Description

Quilt allows you to easily manage large numbers of patches by keeping track of the changes each patch makes.
Patches can be applied, un-applied, refreshed, and more.

3 Install quilt

audo apt-get install quilt
              

4 Adding a package patch

4.1 prepare the source directory with `QUILT=1'

make package/example/{clean,prepare} V=s QUILT=1
                

For host-side packages, use:

make package/example/host/{clean,prepare} V=s QUILT=1
                

4.2 enter the package source directory

cd build_dir/target-*/example-*
                

4.3 check all patches (not mandatory)

quilt series
                

4.4 apply all patches

quilt push -a
                

4.5 create a new, empty patch file

quilt new 000-abc.patch
                
  • The name should start with a number, followed by a hyphen and a very short description of what is changed
  • The chosen number should be higher than any existing patch - use quilt series to see the list of patches

4.6 associate files with the new patch

while (not finished) {
    quilt add file
}
                

Repeat that for any file that needs to be modified.

4.7 check files associated with the new patch

quilt files
                

4.8 do modification

Do modification to the added files of the patch

4.9 review the modification

quilt diff
                

4.10 update the patch file with the changes made

quilt refresh
                

4.11 change back to the toplevel directory

cd ../../../
                

4.12 move the new patch file over to the buildroot

make package/example/update V=s
                

The generated patch located in:

build_dir/target-*/example-*/patches/000-abc.patch
                

4.13 Finally rebuild the package to test the changes

make package/example/{clean,compile} package/index V=s
                

5 Adding a kernel patch

The process for modifying kernel patches is the same as for packages, only the make targets and directories differ.

5.1 prepare the kernel tree

make target/linux/{clean,prepare} V=s QUILT=1
                

5.2 enter the kernel source directory

cd build_dir/target-*/linux-*/linux-3.*
                

5.3 check all patches (not mandatory)

quilt series
                

5.4 apply all patches

quilt push -a
                

5.5 create a new, empty patch file

quilt new platform/000-abc.patch
                

Note: for the kernel, an additional subdirectory for patches is used, generic/ contains
patches common to all architectures, and platform/ contains patches specific to the current target.

Patches should be named with the correct prefix, platform/000-abc.patch or generic/000-abc.patch.
If not, the update may not work correctly.

5.6 do modification

Do modification to the added files of the patch

5.7 review the modification

quilt diff
                

5.8 update the patch file with the changes made

quilt refresh
                

5.9 change back to the toplevel directory

cd ../../../../
                

5.10 move the new patch file over to the buildroot

make target/linux/update V=s
                

The generated patch located in:

build_dir/target-*/linux-*/linux-3.*/patches/generic
                

or:

build_dir/target-*/linux-*/linux-3.*/patches/platform
                

5.11 verify whether our patch is applied or not

make target/linux/{clean,prepare} V=s QUILT=1
                

6 Edit an existing patch

6.1 prepare the source directory

make package/example/{clean,prepare} V=s QUILT=1
                

6.2 change to the prepared source directory

cd build_dir/target-*/example-*
                

6.3 list the patches available

quilt series
                

6.4 Advance to the patch that needs to be edited

quilt push 010-main_code_fix.patch
                
  • When passing a valid patch filename to push, quilt will only apply the series until it reaches the specified patch
  • If unsure, use `quilt series' to see existing patches and `quilt top' to see the current position
  • If the current position is beyound the desired patch, use `quilt pop' to remove patches in the reverse order
  • You can use the "force" push option to interactively apply a broken patch

6.5 edit the files included in the patch

first check which files are included in the patch

quilt files
                

then modify it.

6.6 review the changes

quilt diff
                

6.7 update the patch withe the changes

quilt refresh
                

6.8 go back to the toplevel diretory of the buildroot

cd ../../../
                

6.9 move the updated patch file over to the buildroot

make package/example/update V=s
                

6.10 Finally rebuild the package to test the changes

make package/example/{clean,compile} V=s