customize-packages.txt 3.5 KB

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