1// -*- mode:doc -*- ; 2// vim: set syntax=asciidoc: 3 4[[customize-patches]] 5=== Adding project-specific patches 6 7It is sometimes useful to apply 'extra' patches to packages - on top of 8those provided in Buildroot. This might be used to support custom 9features in a project, for example, or when working on a new 10architecture. 11 12The +BR2_GLOBAL_PATCH_DIR+ configuration option can be used to specify 13a space separated list of one or more directories containing package 14patches. 15 16For a specific version +<packageversion>+ of a specific package 17+<packagename>+, patches are applied from +BR2_GLOBAL_PATCH_DIR+ as 18follows: 19 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 30. Patches will then be applied from a +<package-patch-dir>+ as 31 follows: 32+ 33* If a +series+ file exists in the package directory, then patches are 34 applied according to the +series+ file; 35+ 36* Otherwise, patch files matching +*.patch+ are applied in 37 alphabetical order. So, to ensure they are applied in the right 38 order, it is highly recommended to name the patch files like this: 39 +<number>-<description>.patch+, where +<number>+ refers to the 40 'apply order'. 41 42For information about how patches are applied for a package, see 43xref:patch-apply-order[] 44 45The +BR2_GLOBAL_PATCH_DIR+ option is the preferred method for 46specifying a custom patch directory for packages. It can be used to 47specify a patch directory for any package in buildroot. It should also 48be used in place of the custom patch directory options that are 49available for packages such as U-Boot and Barebox. By doing this, it 50will allow a user to manage their patches from one top-level 51directory. 52 53The exception to +BR2_GLOBAL_PATCH_DIR+ being the preferred method for 54specifying custom patches is +BR2_LINUX_KERNEL_PATCH+. 55+BR2_LINUX_KERNEL_PATCH+ should be used to specify kernel patches that 56are available at a URL. *Note:* +BR2_LINUX_KERNEL_PATCH+ specifies kernel 57patches that are applied after patches available in +BR2_GLOBAL_PATCH_DIR+, 58as it is done from a post-patch hook of the Linux package. 59 60