User Tools

Site Tools


doc:devel:patches

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:devel:patches [2012/12/30 10:33]
hhm changed link to quilt reference - old one was broken
doc:devel:patches [2015/07/10 19:20] (current)
kevindb [Adding a new patch] spelling fix
Line 1: Line 1:
 ====== Working with patches ====== ====== Working with patches ======
- +OpenWrt ​Buildroot ​integrates //[[wp>​Quilt (software)|quilt]]// for easy patch management.
-The OpenWrt ​build system ​integrates //quilt// for easy patch management.+
 This document outlines some common patching tasks like adding a new patch or editing existing ones. This document outlines some common patching tasks like adding a new patch or editing existing ones.
  
Line 9: Line 8:
 containing common //diff// and //patch// options must be created in the local home directory. containing common //diff// and //patch// options must be created in the local home directory.
  
-<​code>​cat > ~/.quiltrc <<​EOF +<​code>​cat > ~/.quiltrc <<​EOF 
-QUILT_DIFF_ARGS="​--no-timestamps --no-index -pab --color=auto"​ +QUILT_DIFF_ARGS="​--no-timestamps --no-index -p ab --color=auto"​ 
-QUILT_REFRESH_ARGS="​--no-timestamps --no-index -pab"+QUILT_REFRESH_ARGS="​--no-timestamps --no-index -p ab"
 QUILT_PATCH_OPTS="​--unified"​ QUILT_PATCH_OPTS="​--unified"​
 QUILT_DIFF_OPTS="​-p"​ QUILT_DIFF_OPTS="​-p"​
Line 20: Line 19:
   * The other variables control the patch format property like a/, b/ directory names and no timestamps   * The other variables control the patch format property like a/, b/ directory names and no timestamps
   * FreeBSD does not support the ''​%%--color=auto%%''​ option and ''​-pab''​ must be written as ''​-p ab''​   * FreeBSD does not support the ''​%%--color=auto%%''​ option and ''​-pab''​ must be written as ''​-p ab''​
 +  * :!: "-p ab" is working with quilt 0.63 on Linux and is documented in man page.
 ===== Adding a new patch ===== ===== Adding a new patch =====
  
 To add a completely new patch to an existing package //example// start with preparing the source directory: To add a completely new patch to an existing package //example// start with preparing the source directory:
  
-| ''​make package///​example///​{clean,​prepare} V=s **QUILT=1**''​ |+| ''​make package///​example//​/​{clean,​prepare} V=s **QUILT=1**''​ | 
 + 
 +For host-side packages, you may want to detail the make target: 
 + 
 +| ''​make package///​example///​host/​{clean,​prepare} V=s **QUILT=1**''​ |
  
 This unpacks the source tarball and prepares existing patches as //quilt patch series// (if any). This unpacks the source tarball and prepares existing patches as //quilt patch series// (if any).
Line 33: Line 36:
 Change to the prepared source directory. ​ Change to the prepared source directory. ​
  
-| ''​cd build_dir/​target-*/​example-*''​ |+| ''​cd build_dir/​target-*/​example-*''​ |
 Note : It can happen that you need to go one level lower as the source is extracted in build_dir/​target-*/​BUILD_VARIANT/​example-* . This happens when multiple build variants of a package are defined in the Makefile. ​ Note : It can happen that you need to go one level lower as the source is extracted in build_dir/​target-*/​BUILD_VARIANT/​example-* . This happens when multiple build variants of a package are defined in the Makefile. ​
  
 Apply all existing patches using //quilt push//. Apply all existing patches using //quilt push//.
  
-| ''​quilt push -a''​ |+| ''​quilt push -a''​ |
  
  
 Create a new, empty patch file with the //quilt new// command: Create a new, empty patch file with the //quilt new// command:
  
-| ''​quilt new 010-main_code_fix.patch''​ |+| ''​quilt new 010-main_code_fix.patch''​ |
  
   * The name should start with a number, followed by a hyphen and a very short description of what is changed   * The name should start with a number, followed by a hyphen and a very short description of what is changed
-  * The choosen ​number should be higher than any existing patch - use //quilt series// to see the list of patches+  * The chosen ​number should be higher than any existing patch - use //quilt series// to see the list of patches
   * The patch file name should be short but descriptive   * The patch file name should be short but descriptive
  
Line 54: Line 57:
 A shortcut for both adding a file and open it in an editor is the //quilt edit// command: A shortcut for both adding a file and open it in an editor is the //quilt edit// command:
  
-| ''​quilt edit src/​main.c''​ |+| ''​quilt edit src/​main.c''​ |
  
   * ''​src/​main.c''​ gets added to ''​010-main_code_fix.patch''​   * ''​src/​main.c''​ gets added to ''​010-main_code_fix.patch''​
Line 64: Line 67:
 After the changes are finished, they can be reviewed with the //quilt diff// command. After the changes are finished, they can be reviewed with the //quilt diff// command.
  
-| ''​quilt diff''​ |+| ''​quilt diff''​ |
  
  
Line 70: Line 73:
 file with the changes made. file with the changes made.
  
-| ''​quilt refresh''​ |+| ''​quilt refresh''​ |
  
  
 Change back to the toplevel directory of the buildroot. Change back to the toplevel directory of the buildroot.
  
-| ''​cd ../​../​../''​ |+| ''​cd ../​../​../''​ |
  
  
 To move the new patch file over to the buildroot, run //update// on the package: To move the new patch file over to the buildroot, run //update// on the package:
  
- ''​make package///​example///​update V=s''​ |+| ''​make package///​example///​update V=s''​ |
  
  
 Finally rebuild the package to test the changes: Finally rebuild the package to test the changes:
  
-| ''​make package///​example///​{clean,​compile} V=s''​ |+| ''​make package///​example///​{clean,​compile} ​package/​index ​V=s''​ |
  
 If problems occur, the patch needs to be edited again to solve the issues. If problems occur, the patch needs to be edited again to solve the issues.
 Refer to the section below to learn how to edit existing patches. Refer to the section below to learn how to edit existing patches.
- 
  
 ===== Edit an existing patch ===== ===== Edit an existing patch =====
Line 95: Line 97:
 Start with preparing the source directory: Start with preparing the source directory:
  
-| ''​make package///​example///​{clean,​prepare} V=s **QUILT=1**''​ |+| ''​make package///​example///​{clean,​prepare} V=s **QUILT=1**''​ |
  
  
 Change to the prepared source directory. Change to the prepared source directory.
  
-| ''​cd build_dir/​target-*/​example-*''​ |+| ''​cd build_dir/​target-*/​example-*''​ |
  
 List the patches available: List the patches available:
  
-| ''​quilt series''​ |+| ''​quilt series''​ |
  
 Advance to the patch that needs to be edited: Advance to the patch that needs to be edited:
  
-| ''​quilt push 010-main_code_fix.patch''​ |+| ''​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   * When passing a valid patch filename to //push//, //quilt// will only apply the series until it reaches the specified patch
Line 117: Line 119:
 Edit the patched files using the //quilt edit// command, repeat for every file that needs changes. Edit the patched files using the //quilt edit// command, repeat for every file that needs changes.
  
-| ''​quilt edit src/​main.c''​ |+| ''​quilt edit src/​main.c''​ |
  
 Check which files are to be included in the patch: Check which files are to be included in the patch:
  
-| ''​quilt files''​ |+| ''​quilt files''​ |
  
 Review the changes with //quilt diff//. Review the changes with //quilt diff//.
  
-| ''​quilt diff''​ |+| ''​quilt diff''​ |
  
  
 If the diff looks okay, proceed with //quilt refresh// to update the current patch with the changes made. If the diff looks okay, proceed with //quilt refresh// to update the current patch with the changes made.
  
-| ''​quilt refresh''​ |+| ''​quilt refresh''​ |
  
  
 Change back to the toplevel diretory of the buildroot. Change back to the toplevel diretory of the buildroot.
  
-| ''​cd ../​../​../''​ |+| ''​cd ../​../​../''​ |
  
  
 To move the updated patch file over to the buildroot, run //update// on the package: To move the updated patch file over to the buildroot, run //update// on the package:
  
- ''​make package///​example///​update V=s''​ |+| ''​make package///​example///​update V=s''​ |
  
  
 Finally rebuild the package to test the changes: Finally rebuild the package to test the changes:
  
-| ''​make package///​example///​{clean,​compile} V=s''​ |+| ''​make package///​example///​{clean,​compile} ​package/​index ​V=s''​ | 
  
  
Line 151: Line 154:
  
 The process for modifying kernel patches is the same as for packages, only the make targets and directories differ.\\ The process for modifying kernel patches is the same as for packages, only the make targets and directories differ.\\
-:!: For the kernel, an additional subdirectory for patches is used, ''​generic/''​ contains patches common to all architectures and ''​target/''​ contains patches specific to the current target.+:!: 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.
  
 To prepare the kernel tree, use: To prepare the kernel tree, use:
-| ''​make target/​linux/​{clean,​prepare} V=s **QUILT=1**''​ |+| ''​make target/​linux/​{clean,​prepare} V=s **QUILT=1**''​ |
  
-The source tree is in the linux-//​architecture//​ subdirectory:​ +For Attitude Adjustment, the source tree is in the linux-//​architecture//​ subdirectory:​ 
-| ''​cd build_dir/​linux-*/​linux-3.*''​ |+| ''​cd build_dir/​linux-*/​linux-3.*''​ |
  
-Moving the changes back over to the buildroot tree from the build tree is done with: +For Barrier Breaker (trunk), the source tree is in the target-//​architecture//​ subdirectory (potentially with a subarch): 
-| ''​make target/​linux/​update V=s''​ |+| ''​cd build_dir/​target-*/​linux-*/​linux-3.*''​ | 
 + 
 +Moving the changes back over to the buildroot tree from the build tree is done with ( you need to go back to trunk to do this)
 +| ''​make target/​linux/​update ​package/​index ​V=s''​ | 
 + 
 +(:!: 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.) 
 + 
 +Afterwards, if we want to verify whether our patch is applied or not, we can go to the top level directory with 
 +| ''​cd ../​../​../​../''​ | 
 +and preparing again the //linux// folder for some modification with 
 + 
 +| ''​make target/​linux/​{clean,​prepare} V=s QUILT=1''​ | 
 + 
 +During this process all the applied patched will be shown, ours being among them, preceeded by //​generic///​ or // platform/// depending on what directory we placed the patch. Another way of retrieving the applied patches is through 
 + 
 +| ''​quilt series''​ | 
 + 
 +as explained on the previous sections, after having made //make target/​linux/​{clean,​prepare} ...//
  
 ===== Adding or editing toolchain patches ===== ===== Adding or editing toolchain patches =====
Line 167: Line 187:
  
 To prepare the tool tree, use: To prepare the tool tree, use:
-| ''​make toolchain/​gcc/​{clean,​prepare} V=99 **QUILT=1**''​ |+| ''​make toolchain/​gcc/​{clean,​prepare} V=99 **QUILT=1**''​ |
  
 The source tree depends on chosen lib and gcc : The source tree depends on chosen lib and gcc :
-| ''​cd build_dir/​toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/​gcc-4.3.3''​ |+| ''​cd build_dir/​toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/​gcc-4.3.3''​ |
  
 Refreshing the patches is done with: Refreshing the patches is done with:
-| ''​make toolchain/​gcc/​update V=99''​ |+| ''​make toolchain/​gcc/​update V=99''​ |
  
  
Line 182: Line 202:
 whole patch series the //refresh// make target can be used: whole patch series the //refresh// make target can be used:
  
-| ''​make package///​example///​refresh V=s''​ |+| ''​make package///​example///​refresh V=s''​ |
  
 For kernels, use: For kernels, use:
  
-| ''​make target/​linux/​refresh V=s''​ |+| ''​make target/​linux/​refresh V=s''​ |
  
  
Line 210: Line 230:
   * [[http://​linux.die.net/​man/​1/​quilt|Official quilt man page]]   * [[http://​linux.die.net/​man/​1/​quilt|Official quilt man page]]
   * [[http://​git.savannah.gnu.org/​cgit/​quilt.git/​plain/​doc/​quilt.pdf|How To Survive With Many Patches - Introduction to Quilt]] (PDF) (read online [[https://​docs.google.com/​viewer?​url=http%3A%2F%2Fgit.savannah.gnu.org%2Fcgit%2Fquilt.git%2Fplain%2Fdoc%2Fquilt.pdf|here]])   * [[http://​git.savannah.gnu.org/​cgit/​quilt.git/​plain/​doc/​quilt.pdf|How To Survive With Many Patches - Introduction to Quilt]] (PDF) (read online [[https://​docs.google.com/​viewer?​url=http%3A%2F%2Fgit.savannah.gnu.org%2Fcgit%2Fquilt.git%2Fplain%2Fdoc%2Fquilt.pdf|here]])
 +  * [[https://​forum.openwrt.org/​viewtopic.php?​id=43039|Applying patches newbie doubt]]
 +
doc/devel/patches.1356860038.txt.bz2 · Last modified: 2012/12/30 10:33 by hhm