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