找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 3778|回复: 2

openwrt/package下如何打patches补丁?

[复制链接]
本帖最后由 bbs007 于 2016-12-26 13:24 编辑

想用patch的修改方式修改openwrt/package/base-files/files/etc/config/system 里的参数,我把补丁放到了openwrt/package/patches/下,
内容为:
--- a/package/base-files/files/etc/config/system
+++ b/package/base-files/files/etc/config/system
@@ -1,6 +1,7 @@
config system
         option hostname        OpenWrt
-        option timezone        UTC
+        option zonename Asia/Shanghai
+        option timezone CST-8

config timeserver ntp
         list server        0.openwrt.pool.ntp.org
但为什么make V=99后,出来的固件还是没有修改?请教是哪里出问题了?
openwrt有它的一套patch方法,尽量按照官方的方法做。曾经用diff试过成功,可是今天有个patch,diff N遍还是应用出错,结果用官方的方法就没问题了。。。当然你这种情况不知道是否路径有问题,而且按照imagebuilder文档,是否直接在files目录加载还更快点。

  1. Working with patches
  2. OpenWrt Buildroot integrates quilt for easy patch management. This document outlines some common patching tasks like adding a new patch or editing existing ones.

  3. Prepare quilt configuration

  4. In order to let quilt create patches in OpenWrts preferred format, a configuration file .quiltrc containing common diff and patch options must be created in the local home directory.

  5. cat > ~/.quiltrc <<EOF
  6. QUILT_DIFF_ARGS="--no-timestamps --no-index -p ab --color=auto"
  7. QUILT_REFRESH_ARGS="--no-timestamps --no-index -p ab"
  8. QUILT_SERIES_ARGS="--color=auto"
  9. QUILT_PATCH_OPTS="--unified"
  10. QUILT_DIFF_OPTS="-p"
  11. EDITOR="nano"
  12. EOF
  13. EDITOR specifies the preferred editor for interactive patch editing
  14. The other variables control the patch format property like a/, b/ directory names and no timestamps
  15. FreeBSD does not support the --color=auto option and -pab must be written as -p ab
  16. :!: "-p ab" is working with quilt 0.63 on Linux and is documented in man page.
  17. Adding a new patch

  18. To add a completely new patch to an existing package example start with preparing the source directory:

  19. make package/example/{clean,prepare} V=s QUILT=1
  20. For host-side packages, you may want to detail the make target:

  21. make package/example/host/{clean,prepare} V=s QUILT=1
  22. This unpacks the source tarball and prepares existing patches as quilt patch series (if any). The verbose output will show where the source got extracted.

  23. Change to the prepared source directory.

  24. cd build_dir/target-*/example-*
  25. 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.

  26. Apply all existing patches using quilt push.

  27. quilt push -a
  28. Create a new, empty patch file with the quilt new command:

  29. quilt new 010-main_code_fix.patch
  30. The name should start with a number, followed by a hyphen and a very short description of what is changed
  31. The chosen number should be higher than any existing patch - use quilt series to see the list of patches
  32. The patch file name should be short but descriptive
  33. After creating the empty patch, files to edit must be associated with it. The quilt add command can be used for that - once the file got added it can be edited as usual.
  34. A shortcut for both adding a file and open it in an editor is the quilt edit command:

  35. quilt edit src/main.c
  36. src/main.c gets added to 010-main_code_fix.patch
  37. The file is opened in the editor specified with EDITOR in .quiltrc
  38. Repeat that for any file that needs to be edited.

  39. After the changes are finished, they can be reviewed with the quilt diff command.

  40. quilt diff
  41. If the diff looks okay, proceed with quilt refresh to update the 010-main_code_fix.patch file with the changes made.

  42. quilt refresh
  43. Change back to the toplevel directory of the buildroot.

  44. cd ../../../
  45. To move the new patch file over to the buildroot, run update on the package:

  46. make package/example/update V=s
  47. Finally rebuild the package to test the changes:

  48. make package/example/{clean,compile} package/index V=s
  49. 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.

  50. Edit an existing patch

  51. Start with preparing the source directory:

  52. make package/example/{clean,prepare} V=s QUILT=1
  53. Change to the prepared source directory.

  54. cd build_dir/target-*/example-*
  55. List the patches available:

  56. quilt series
  57. Advance to the patch that needs to be edited:

  58. quilt push 010-main_code_fix.patch
  59. When passing a valid patch filename to push, quilt will only apply the series until it reaches the specified patch
  60. If unsure, use quilt series to see existing patches and quilt top to see the current position
  61. If the current position is beyound the desired patch, use quilt pop to remove patches in the reverse order
  62. You can use the "force" push option (e.g. quilt push -f 010-main_code_fix.patch) to interactively apply a broken (i.e. has rejects) patch
  63. Edit the patched files using the quilt edit command, repeat for every file that needs changes.

  64. quilt edit src/main.c
  65. Check which files are to be included in the patch:

  66. quilt files
  67. Review the changes with quilt diff.

  68. quilt diff
  69. If the diff looks okay, proceed with quilt refresh to update the current patch with the changes made.

  70. quilt refresh
  71. Change back to the toplevel diretory of the buildroot.

  72. cd ../../../
  73. To move the updated patch file over to the buildroot, run update on the package:

  74. make package/example/update V=s
  75. Finally rebuild the package to test the changes:

  76. make package/example/{clean,compile} package/index V=s
  77. Adding or editing kernel patches

  78. The process for modifying kernel patches is the same as for packages, only the make targets and directories differ.
  79. :!: 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.

  80. To prepare the kernel tree, use:

  81. make target/linux/{clean,prepare} V=s QUILT=1
  82. For Attitude Adjustment, the source tree is in the linux-architecture subdirectory:

  83. cd build_dir/linux-*/linux-3.*
  84. For Barrier Breaker (trunk), the source tree is in the target-architecture subdirectory (potentially with a subarch):

  85. cd build_dir/target-*/linux-*/linux-3.*
  86. 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):

  87. make target/linux/update package/index V=s
  88. (:!: 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.)

  89. Afterwards, if we want to verify whether our patch is applied or not, we can go to the top level directory with

  90. cd ../../../../
  91. and preparing again the linux folder for some modification with

  92. make target/linux/{clean,prepare} V=s QUILT=1
  93. 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

  94. quilt series
  95. as explained on the previous sections, after having made make target/linux/{clean,prepare} …

  96. Adding or editing toolchain patches

  97. For example, gcc:

  98. To prepare the tool tree, use:

  99. make toolchain/gcc/{clean,prepare} V=99 QUILT=1
  100. The source tree depends on chosen lib and gcc :

  101. cd build_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/gcc-4.3.3
  102. Refreshing the patches is done with:

  103. make toolchain/gcc/update V=99
  104. Naming patches

  105. valid for target/linux/generic and <arch>:

  106. The patches-* subdirectories contain the kernel patches applied for every
  107. OpenWrt target. All patches should be named 'NNN-lowercase_shortname.patch'
  108. and sorted into the following categories:

  109. 0xx - upstream backports
  110. 1xx - code awaiting upstream merge
  111. 2xx - kernel build / config / header patches
  112. 3xx - architecture specific patches
  113. 4xx - mtd related patches (subsystem and drivers)
  114. 5xx - filesystem related patches
  115. 6xx - generic network patches
  116. 7xx - network / phy driver patches
  117. 8xx - other drivers
  118. 9xx - uncategorized other patches

  119. ALL patches must be in a way that they are potentially upstreamable, meaning:

  120. - they must contain a proper subject
  121. - they must contain a proper commit message explaining what they change
  122. - they must contain a valid Signed-off-by line
  123. from: PATCHES
  124. Refreshing patches

  125. When a patched package (or kernel) is updated to a newer version, existing patches might not apply cleanly anymore and patch will report fuzz when applying them. To rebase the whole patch series the refresh make target can be used:

  126. make package/example/refresh V=s
  127. For kernels, use:

  128. make target/linux/refresh V=s
  129. Iteratively modify patches without cleaning the source tree

  130. When implementing new changes, it is often required to edit patches multiple times. To speed up the process, it is possible to retain the prepared source tree between edit operations.

  131. Initially prepare the source tree as documented above
  132. Change to the prepared source directory
  133. Advance to the patch needing changes
  134. Edit the files and refresh the patch
  135. Fully apply the remaining patches using quilt push -a (if any)
  136. From the toplevel directory, run make package/example/{compile,install} or make target/linux/{compile,install} for kernels
  137. Test the binary
  138. If further changes are needed, repeat from step 2.
  139. Finally run make package/example/update or make target/linux/update for kernels to copy the changes back to buildroot
  140. Further information

  141. Official quilt man page
  142. How To Survive With Many Patches - Introduction to Quilt (PDF) (read online here)
  143. Applying patches newbie doubt
复制代码


回复

使用道具 举报

百度有说的,quilt做补丁
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-5-20 22:48

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表