Differences

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

doc:devel:patches [2012/12/30 10:33]
hhm changed link to quilt reference - old one was broken
doc:devel:patches [2013/04/23 22:35] (current)
jero patch: add clarification for host packages
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 -pab --color=auto"
QUILT_REFRESH_ARGS="--no-timestamps --no-index -pab" QUILT_REFRESH_ARGS="--no-timestamps --no-index -pab"
Line 25: Line 24:
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
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 154: Line 157:
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**'' | 
 + 
 +For Attitude Adjustment, the source tree is in the linux-//architecture// subdirectory: 
 +| ''cd build_dir/linux-*/linux-3.*'' |
-The source tree is in the linux-//architecture// subdirectory: +For Barrier Breaker (trunk), the source tree is in the target-//architecture// subdirectory (potentially with a subarch)
-| ''$ cd build_dir/linux-*/linux-3.*'' |+| ''cd build_dir/target-*/linux-*/linux-3.*'' |
Moving the changes back over to the buildroot tree from the build tree is done with: Moving the changes back over to the buildroot tree from the build tree is done with:
-| ''$ make target/linux/update V=s'' |+| ''make target/linux/update package/index V=s'' | 
 + 
 +The last command for moving the changes back over the buildroot tree seems not to work with Attitude Adjustment 12.09-rc1; since if we typed such a command our patch will be deleted because it had remained in the temporary folder //build_dir// where it was created.So a workaround in order to have our patch applied is moving the patch to the proper folder manually. That is to say, if we have followed the previous sections in which we modified or created a new patch, after issuing'' quilt refresh'', our patch will appear under the next directory 
 + 
 +''~/attitude_adjustment/build_dir/linux-*/linux-*/patches/'' 
 + 
 +Therefore, depending on the changes we want to add to the kernel, we should copy that patch to one of these directories 
 + 
 +  * ''~/attidude_adjustment/target/linux/generic/patches-3.3'' -> it will in theory get applied to all platforms 
 +  * ''~/attidude_adjustment/target/linux/<platform>/patches-3.<3>'' -> it gets only applied to the specific platform you place it 
 + 
 +Thus, we have to move our patch to one of those directories, for example the first one 
 +| ''cp whateverNameYouSet.patch ~/attitude_adjustment/target/linux/generic/patches-3.3/'' | 
 + 
 +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, being our among them, preceede by //generic/// or // platform/// depending on what directory we placed the patch. Another way of retreiving 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 197:
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 212:
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 240:
  * [[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]]
 +

Back to top

doc/devel/patches.1356860038.txt.bz2 · Last modified: 2012/12/30 10:33 by hhm