customize-patches.txt 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // -*- mode:doc -*- ;
  2. [[customize-patches]]
  3. === Adding project-specific patches
  4. It is sometimes useful to apply 'extra' patches to packages - on top of
  5. those provided in Buildroot. This might be used to support custom
  6. features in a project, for example, or when working on a new
  7. architecture.
  8. The +BR2_GLOBAL_PATCH_DIR+ configuration option can be used to specify
  9. a space separated list of one or more directories containing package
  10. patches. By specifying multiple global patch directories, a user could
  11. implement a layered approach to patches. This could be useful when a
  12. user has multiple boards that share a common processor architecture.
  13. It is often the case that a subset of patches for a package need to be
  14. shared between the different boards a user has. However, each board
  15. may require specific patches for the package that build on top of the
  16. common subset of patches.
  17. For a specific version +<packageversion>+ of a specific package
  18. +<packagename>+, patches are applied from +BR2_GLOBAL_PATCH_DIR+ as
  19. follows:
  20. . For every directory - +<global-patch-dir>+ - that exists in
  21. +BR2_GLOBAL_PATCH_DIR+, a +<package-patch-dir>+ will be determined as
  22. follows:
  23. +
  24. * +<global-patch-dir>/<packagename>/<packageversion>/+ if the
  25. directory exists.
  26. +
  27. * Otherwise, +<global-patch-dir>/<packagename>+ if the directory
  28. exists.
  29. . Patches will then be applied from a +<package-patch-dir>+ as
  30. follows:
  31. +
  32. * If a +series+ file exists in the package directory, then patches are
  33. applied according to the +series+ file;
  34. +
  35. * Otherwise, patch files matching +<packagename>-*.patch+
  36. are applied in alphabetical order.
  37. So, to ensure they are applied in the right order, it is highly
  38. recommended to name the patch files like this:
  39. +<packagename>-<number>-<description>.patch+, where +<number>+
  40. refers to the 'apply order'.
  41. For information about how patches are applied for a package, see
  42. xref:patch-apply-order[]
  43. The +BR2_GLOBAL_PATCH_DIR+ option is the preferred method for
  44. specifying a custom patch directory for packages. It can be used to
  45. specify a patch directory for any package in buildroot. It should also
  46. be used in place of the custom patch directory options that are
  47. available for packages such as U-Boot and Barebox. By doing this, it
  48. will allow a user to manage their patches from one top-level
  49. directory.
  50. The exception to +BR2_GLOBAL_PATCH_DIR+ being the preferred method for
  51. specifying custom patches is +BR2_LINUX_KERNEL_PATCH+.
  52. +BR2_LINUX_KERNEL_PATCH+ should be used to specify kernel patches that
  53. are available at an URL. *Note:* +BR2_LINUX_KERNEL_PATCH+ specifies kernel
  54. patches that are applied after patches available in +BR2_GLOBAL_PATCH_DIR+,
  55. as it is done from a post-patch hook of the Linux package.
  56. An example directory structure for where a user has multiple
  57. directories specified for +BR2_GLOBAL_PATCH_DIR+ may look like this:
  58. -----
  59. board/
  60. +-- common-fooarch
  61. | +-- patches
  62. | +-- linux
  63. | | +-- linux-patch1.patch
  64. | | +-- linux-patch2.patch
  65. | +-- uboot
  66. | +-- foopkg
  67. +-- fooarch-board
  68. +-- patches
  69. +-- linux
  70. | +-- linux-patch3.patch
  71. +-- uboot
  72. +-- foopkg
  73. -----
  74. If the user has the +BR2_GLOBAL_PATCH_DIR+ configuration option set as
  75. follows:
  76. -----
  77. BR2_GLOBAL_PATCH_DIR="board/common-fooarch/patches board/fooarch-board/patches"
  78. -----
  79. Then the patches would applied as follows for the Linux kernel:
  80. . board/common-fooarch/patches/linux/linux-patch1.patch
  81. . board/common-fooarch/patches/linux/linux-patch2.patch
  82. . board/fooarch-board/patches/linux/linux-patch3.patch