pkg-generick.mk: support for multiple patch dirs
PATCH 1/2 pkg-generick.mk: support for multiple patch dirs
Adding support for specifying multiple directories in BR2_GLOBAL_PATCH_DIR. This will allow for a layered approach for the patching of a package.
--- Config.in | 20 ++++++++++++-------- package/pkg-generic.mk | 5 ++++- 2 files changed, 16 insertions(+), 9 deletions(-)
Config.in +12 -8
@@ -461,18 +461,22 @@ config BR2_PACKAGE_OVERRIDE_FILE Buildroot documentation for more details on this feature. config BR2_GLOBAL_PATCH_DIR - string "global patch directory" + string "global patch directories" help - You may specify a directory containing global package patches. - For a specific version <packageversion> of a specific package - <packagename>, patches are applied as follows. + You may specify a space seperated list of one or more directories + containing global package patches. For a specific version + <packageversion> of a specific package <packagename>, patches are + applied as follows: - First, the default Buildroot patch set for the package is applied. + First, the default Buildroot patch set for the package is applied + from 'package/<packagename>'. - If the directory $(BR2_GLOBAL_PATCH_DIR)/<packagename>/<packageversion> - exists, then all *.patch files in the directory will be applied. + Then for every directory - <global-patch-dir> - that exists in + BR2_GLOBAL_PATCH_DIR, if the directory + <global-patch-dir>/<packagename>/<packageversion>/ exists, then all + *.patch files in this directory will be applied. - Otherwise, if the directory $(BR2_GLOBAL_PATCH_DIR)/<packagename> exists, + Otherwise, if the directory <global-patch-dir>/<packagename> exists, then all *.patch files in the directory will be applied. endmenu
package/pkg-generic.mk +4 -1
@@ -134,8 +134,11 @@ endif # The RAWNAME variable is the lowercased package name, which allows to # find the package directory (typically package/<pkgname>) and the # prefix of the patches +# +# For BR2_GLOBAL_PATCH_DIR, only generate if it is defined $(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION) -$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(call qstrip,$(BR2_GLOBAL_PATCH_DIR))/$(RAWNAME) +$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX)/$(RAWNAME) +$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS += $(if $(BR2_GLOBAL_PATCH_DIR),$(foreach pdir,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)),$(pdir)/$(RAWNAME))) $(BUILD_DIR)/%/.stamp_patched: @$(call step_start,patch) @$(call MESSAGE,"Patching")
Signature · 1 line
1.7.9.5
PATCH 2/2 manual: update for multiple global patch dirs
Updating the documentation to reflect that multiple directories can now be specified for BR2_GLOBAL_PATCH_DIR. Along with giving an example use case of how to use multiple global patch directories.
--- docs/manual/customize-packages.txt | 69 +++++++++++++++++++++++++++++++----- docs/manual/patch-policy.txt | 13 ++++--- 2 files changed, 69 insertions(+), 13 deletions(-)
docs/manual/customize-packages.txt +60 -9
@@ -8,16 +8,67 @@ It is sometimes useful to apply 'extra' patches to packages - over and above those provided in Buildroot. This might be used to support custom features in a project, for example, or when working on a new architecture. -The +BR2_GLOBAL_PATCH_DIR+ configuration file option can be -used to specify a directory containing global package patches. +The +BR2_GLOBAL_PATCH_DIR+ configuration option can be used to specify +a space separated list of one or more directories containing global +package patches. By specifying multiple global patch directories, a +user could implement a layered approach to patches. This could be +useful when a user has multiple boards that share a common processor +architecture. It is often the case that a subset of patches for a +package that need to be shared between the different boards a user +has. However, each board may require specific patches for the package +that build on top of the common subset of patches. -For a specific version <packageversion> of a specific package <packagename>, -patches are applied as follows. +For a specific version +<packageversion>+ of a specific package ++<packagename>+, patches are applied as follows: -First, the default Buildroot patch set for the package is applied. +. First, the default Buildroot patch set for the package is applied. -If the directory +$(BR2_GLOBAL_PATCH_DIR)/<packagename>/<packageversion>+ -exists, then all +*.patch+ files in the directory will be applied. +. Then for every directory - +<global-patch-dir>+ - that exists in + +BR2_GLOBAL_PATCH_DIR+, the following will be done: ++ +* If the directory + +<global-patch-dir>/<packagename>/<packageversion>/+ exists, then + all *.patch files in this directory will be applied. ++ +* Otherwise, if the directory +<global-patch-dir>/<packagename>+ exists, + then all *.patch files in the directory will be applied. -Otherwise, if the directory +$(BR2_GLOBAL_PATCH_DIR)/<packagename>+ -exists, then all +*.patch+ files in the directory will be applied. +The +BR2_GLOBAL_PATCH_DIR+ option is preferred method for specifying a +custom patch directory for packages. It should be used when patching +Linux, U-Boot, and other packages that already have custom patch +directories options available to them as configuration options. By +doing this, it will allow a user to manage their patches from one +top-level directory.` + +An example directory structure for where a user has multiple +directories specified for +BR2_GLOBAL_PATCH_DIR+ may look like this: + +----- +board/ ++-- common-fooarch +| +-- patches +| +-- linux +| | +-- linux-patch1.patch +| | +-- linux-patch2.patch +| +-- u-boot +| +-- foopkg ++-- fooarch-board + +-- patches + +-- linux + | +-- linux-patch3.patch + +-- u-boot + +-- foopkg +----- + +If the user to have +BR2_GLOBAL_PATCH_DIR+ configuration option set as +follows: + +----- +BR2_GLOBAL_PATCH_DIR="board/common-fooarch board/fooarch-board" +----- + +Then the patches would applied as follows for the Linux kernel: + +. board/common-fooarch/patches/linux/linux-patch1.patch +. board/common-fooarch/patches/linux/linux-patch2.patch +. board/fooarch-board/patches/linux/linux-patch1.patch
docs/manual/patch-policy.txt +9 -4
@@ -50,8 +50,9 @@ Global patch directory ^^^^^^^^^^^^^^^^^^^^^^ The +BR2_GLOBAL_PATCH_DIR+ configuration file option can be -used to specify a directory containing global package patches. See -xref:packages-custom[] for details. +used to specify a space separated list of one or more directories +containing global package patches. See xref:packages-custom[] for +details. How patches are applied
@@ -72,11 +73,15 @@ How patches are applied + * Otherwise, patch files matching +<packagename>-*.patch+ are applied in alphabetical order. - So, to ensure they are applied in the right order, it is hightly - recommended to named the patch files like this: + So, to ensure they are applied in the right order, it is highly + recommended to name the patch files like this: +<packagename>-<number>-<description>.patch+, where +<number>+ refers to the 'apply order'. +. If +BR2_GLOABL_PATCH_DIR+ is defined, the directories will be + enumerated in the order they are specified for patches. The patches + are applied as described in the previous step. + . Run the +<packagename>_POST_PATCH_HOOKS+ commands if defined. If something goes wrong in the steps _3_ or _4_, then the build fails.
Signature · 1 line
1.7.9.5
PATCH 2/2 manual: update for multiple global patch dirs
Quoted 3 lines · Ryan Barnett
Updating the documentation to reflect that multiple directories can now be specified for
BR2_GLOBAL_PATCH_DIR. Along with giving an example use case of how to use multiple global patch directories.
You forgot a signed-off-by line...
Quoted 12 lines
--- docs/manual/customize-packages.txt | 69 +++++++++++++++++++++++++++++++----- docs/manual/patch-policy.txt | 13 ++++--- 2 files changed, 69 insertions(+), 13 deletions(-)docs/manual/customize-packages.txt +0
-0@@ -8,16 +8,67 @@ It is sometimes useful to apply 'extra' patches to packages - over and above those provided in Buildroot. This might be used to support custom features in a project, for example, or when working on a new architecture.
docs/manual/customize-packages.txt It is sometimes useful to apply 'extra' patches to packages - over and · line 17
Quoted 10 lines
docs/manual/customize-packages.txt +7
-2-The +BR2_GLOBAL_PATCH_DIR+ configuration file option can be -used to specify a directory containing global package patches. +The +BR2_GLOBAL_PATCH_DIR+ configuration option can be used to specify +a space separated list of one or more directories containing global +package patches. By specifying multiple global patch directories, a +user could implement a layered approach to patches. This could be +useful when a user has multiple boards that share a common processor +architecture. It is often the case that a subset of patches for a +package that need to be shared between the different boards a user
shouldn't this 'that' be removed?
Quoted 16 lines
docs/manual/customize-packages.txt +8
-5+has. However, each board may require specific patches for the package +that build on top of the common subset of patches. -For a specific version <packageversion> of a specific package <packagename>, -patches are applied as follows. +For a specific version +<packageversion>+ of a specific package ++<packagename>+, patches are applied as follows: -First, the default Buildroot patch set for the package is applied. +. First, the default Buildroot patch set for the package is applied. -If the directory +$(BR2_GLOBAL_PATCH_DIR)/<packagename>/<packageversion>+ -exists, then all +*.patch+ files in the directory will be applied. +. Then for every directory - +<global-patch-dir>+ - that exists in + +BR2_GLOBAL_PATCH_DIR+, the following will be done: ++
docs/manual/customize-packages.txt It is sometimes useful to apply 'extra' patches to packages - over and · line 36
Quoted 10 lines
docs/manual/customize-packages.txt +7
-2+* If the directory + +<global-patch-dir>/<packagename>/<packageversion>/+ exists, then + all *.patch files in this directory will be applied. ++ +* Otherwise, if the directory +<global-patch-dir>/<packagename>+ exists, + then all *.patch files in the directory will be applied. -Otherwise, if the directory +$(BR2_GLOBAL_PATCH_DIR)/<packagename>+ -exists, then all +*.patch+ files in the directory will be applied. +The +BR2_GLOBAL_PATCH_DIR+ option is preferred method for specifying a
the preferred
docs/manual/customize-packages.txt It is sometimes useful to apply 'extra' patches to packages - over and · line 39
Quoted 3 lines
docs/manual/customize-packages.txt +3
-0+custom patch directory for packages. It should be used when patching +Linux, U-Boot, and other packages that already have custom patch +directories options available to them as configuration options. By
Shouldn't this be 'directory options' rather than 'directories options'?
Also, I'm not sure I follow you here: even if there are no custom patch directory options, the global patch dir is useful, right?
docs/manual/customize-packages.txt It is sometimes useful to apply 'extra' patches to packages - over and · line 41
Quoted 2 lines
docs/manual/customize-packages.txt +2
-0+doing this, it will allow a user to manage their patches from one +top-level directory.`
What is the purpose of this backtick here? Is it a typo?
Quoted 12 lines
docs/manual/customize-packages.txt +12
-0+ +An example directory structure for where a user has multiple +directories specified for +BR2_GLOBAL_PATCH_DIR+ may look like this: + +----- +board/ ++-- common-fooarch +| +-- patches +| +-- linux +| | +-- linux-patch1.patch +| | +-- linux-patch2.patch +| +-- u-boot
docs/manual/customize-packages.txt It is sometimes useful to apply 'extra' patches to packages - over and · line 63
Quoted 10 lines
docs/manual/customize-packages.txt +10
-0+| +-- foopkg ++-- fooarch-board + +-- patches + +-- linux + | +-- linux-patch3.patch + +-- u-boot + +-- foopkg +----- + +If the user to have +BR2_GLOBAL_PATCH_DIR+ configuration option set as
to have --> has the
Quoted 36 lines
docs/manual/customize-packages.txt +11
-0+follows: + +----- +BR2_GLOBAL_PATCH_DIR="board/common-fooarch board/fooarch-board" +----- + +Then the patches would applied as follows for the Linux kernel: + +. board/common-fooarch/patches/linux/linux-patch1.patch +. board/common-fooarch/patches/linux/linux-patch2.patch +. board/fooarch-board/patches/linux/linux-patch1.patchdocs/manual/patch-policy.txt +5
-4@@ -50,8 +50,9 @@ Global patch directory ^^^^^^^^^^^^^^^^^^^^^^ The +BR2_GLOBAL_PATCH_DIR+ configuration file option can be -used to specify a directory containing global package patches. See -xref:packages-custom[] for details. +used to specify a space separated list of one or more directories +containing global package patches. See xref:packages-custom[] for +details. How patches are applied@@ -72,11 +73,15 @@ How patches are applied + * Otherwise, patch files matching +<packagename>-*.patch+ are applied in alphabetical order. - So, to ensure they are applied in the right order, it is hightly - recommended to named the patch files like this: + So, to ensure they are applied in the right order, it is highly + recommended to name the patch files like this: +<packagename>-<number>-<description>.patch+, where +<number>+
docs/manual/patch-policy.txt How patches are applied
Quoted 10 lines
docs/manual/patch-policy.txt +4
-1refers to the 'apply order'. +. If +BR2_GLOABL_PATCH_DIR+ is defined, the directories will be + enumerated in the order they are specified for patches. The patches + are applied as described in the previous step. + . Run the +<packagename>_POST_PATCH_HOOKS+ commands if defined. If something goes wrong in the steps _3_ or _4_, then the build fails. --
Best regards,
Thomas
PATCH 1/2 pkg-generick.mk: support for multiple patch dirs
In reply to Ryan BarnettHi Ryan,
Quoted 13 lines · Ryan Barnett
Adding support for specifying multiple directories in
BR2_GLOBAL_PATCH_DIR. This will allow for a layered approach for the patching of a package.--- Config.in | 20 ++++++++++++-------- package/pkg-generic.mk | 5 ++++- 2 files changed, 16 insertions(+), 9 deletions(-)Config.in +0
-0
Config.in config BR2_PACKAGE_OVERRIDE_FILE · line 466
Quoted 10 lines
Config.in +2
-4@@ -461,18 +461,22 @@ config BR2_PACKAGE_OVERRIDE_FILE Buildroot documentation for more details on this feature. config BR2_GLOBAL_PATCH_DIR - string "global patch directory" + string "global patch directories" help - You may specify a directory containing global package patches. - For a specific version <packageversion> of a specific package - <packagename>, patches are applied as follows. + You may specify a space seperated list of one or more directories
separated
Config.in config BR2_PACKAGE_OVERRIDE_FILE · line 472
Quoted 7 lines
Config.in +5
-1+ containing global package patches. For a specific version + <packageversion> of a specific package <packagename>, patches are + applied as follows: - First, the default Buildroot patch set for the package is applied. + First, the default Buildroot patch set for the package is applied + from 'package/<packagename>'.
This is not really correct (although the current code isn't correct either, as you noticed) for packages not residing in package/ (like linux or bootloaders). So I'd rather write something like:
... from the package's directory in Buildroot.
Quoted 20 lines
Config.in +5
-3- If the directory $(BR2_GLOBAL_PATCH_DIR)/<packagename>/<packageversion> - exists, then all *.patch files in the directory will be applied. + Then for every directory - <global-patch-dir> - that exists in + BR2_GLOBAL_PATCH_DIR, if the directory + <global-patch-dir>/<packagename>/<packageversion>/ exists, then all + *.patch files in this directory will be applied. - Otherwise, if the directory $(BR2_GLOBAL_PATCH_DIR)/<packagename> exists, + Otherwise, if the directory <global-patch-dir>/<packagename> exists, then all *.patch files in the directory will be applied. endmenupackage/pkg-generic.mk +0
-0@@ -134,8 +134,11 @@ endif # The RAWNAME variable is the lowercased package name, which allows to # find the package directory (typically package/<pkgname>) and the
package/pkg-generic.mk endif · line 144
Quoted 10 lines
package/pkg-generic.mk +4
-1# prefix of the patches +# +# For BR2_GLOBAL_PATCH_DIR, only generate if it is defined $(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION) -$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(call qstrip,$(BR2_GLOBAL_PATCH_DIR))/$(RAWNAME) +$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX)/$(RAWNAME) +$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS += $(if $(BR2_GLOBAL_PATCH_DIR),$(foreach pdir,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)),$(pdir)/$(RAWNAME))) $(BUILD_DIR)/%/.stamp_patched: @$(call step_start,patch) @$(call MESSAGE,"Patching")
Otherwise, looks good.
Best regards,
Thomas
PATCH 1/2 pkg-generick.mk: support for multiple patch dirs
In reply to Ryan BarnettQuoted 3 lines · Ryan Barnett
Adding support for specifying multiple directories in
BR2_GLOBAL_PATCH_DIR. This will allow for a layered approach for the patching of a package.
[snip]
Quoted 5 lines
package/pkg-generic.mk +0
-0
package/pkg-generic.mk endif · line 141
Quoted 9 lines
package/pkg-generic.mk +4
-1@@ -134,8 +134,11 @@ endif # The RAWNAME variable is the lowercased package name, which allows to # find the package directory (typically package/<pkgname>) and the # prefix of the patches +# +# For BR2_GLOBAL_PATCH_DIR, only generate if it is defined $(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION) -$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(call qstrip,$(BR2_GLOBAL_PATCH_DIR))/$(RAWNAME) +$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX)/$(RAWNAME) +$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS += $(if $(BR2_GLOBAL_PATCH_DIR),$(foreach pdir,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)),$(pdir)/$(RAWNAME)))
I guess you meant to avoid the "overhead" of the foreach whenBR2_GLOBAL_PATCH_DIR is empty? Unfortunately, the condition will always be true because it is "" when empty, and "" is non-empty... So you'd have to qstrip it first. But anyway, the overhead of foreach is nothing, so I think it's both more efficient and easier to read if the condition is removed.
Minor detail: I would have used
$(addsuffix /$(RAWNAME),$(BR2_GLOBAL_PATCH_DIR))
but I guess that's a matter of taste.
Regards,
Arnout
Quoted 4 lines
package/pkg-generic.mk +0
-0$(BUILD_DIR)/%/.stamp_patched: @$(call step_start,patch) @$(call MESSAGE,"Patching")
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
PATCH 1/2 pkg-generick.mk: support for multiple patch dirs
Arnout,
Arnout Vandecappelle <[email protected]> wrote on 12/12/2013 04:11:17 PM:
Quoted 6 lines
package/pkg-generic.mk endif · line 134
Quoted 6 lines
package/pkg-generic.mk +0
-0@@ -134,8 +134,11 @@ endif # The RAWNAME variable is the lowercased package name, which allows
to
Quoted 5 lines
package/pkg-generic.mk endif
Quoted 5 lines
package/pkg-generic.mk +2
-0# find the package directory (typically package/<pkgname>) and the # prefix of the patches +# +# For BR2_GLOBAL_PATCH_DIR, only generate if it is defined $(BUILD_DIR)/%/.stamp_patched: NAMEVER =
$(RAWNAME)-$($(PKG)_VERSION)
Quoted 1 line
package/pkg-generic.mk endif · line 138
Quoted 1 line
package/pkg-generic.mk +0
-1-$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS =
$($(PKG)_DIR_PREFIX)/$(RAWNAME) $(call
qstrip,$(BR2_GLOBAL_PATCH_DIR))/$(RAWNAME)
Quoted 1 line
package/pkg-generic.mk endif · line 140
Quoted 1 line
package/pkg-generic.mk +1
-0+$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS =
$($(PKG)_DIR_PREFIX)/$(RAWNAME)
Quoted 1 line
package/pkg-generic.mk endif · line 141
Quoted 1 line
package/pkg-generic.mk +1
-0+$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS += $(if
$(BR2_GLOBAL_PATCH_DIR),$(foreach pdir,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)),$(pdir)/$(RAWNAME)))
Quoted 4 lines
I guess you meant to avoid the "overhead" of the foreach when
BR2_GLOBAL_PATCH_DIRis empty? Unfortunately, the condition will always be true because it is "" when empty, and "" is non-empty... So you'd
have
Quoted 4 lines
to qstrip it first. But anyway, the overhead of foreach is nothing, so I
think it's both more efficient and easier to read if the condition is removed.
I apologies for not putting a version on my patches. I was in a rush to submit a second version and forgot the step of adding a new version title. Lesson learned (since Thomas Petazzoni)
I wasn't attempting so save the overhead with this check. Rather, I was trying to prevent that when BR2_GLOBAL_PATCH_DIR is empty, from not generating "/$(RAWNAME)" when BR2_GLOBAL_PATCH_DIR is empty which is happening with current implementation of BR2_GLOBAL_PATCH_DIR.
Quoted 4 lines
Minor detail: I would have used
$(addsuffix /$(RAWNAME),$(BR2_GLOBAL_PATCH_DIR))
but I guess that's a matter of taste.
I do prefer this - thanks for the suggestion and I will update with this in mind. This will also make this much simpler as it I can use addsuffix and it will handle the case where BR2_GLOBAL_PATCH_DIR is empty.
I will submit a v3 of this with your suggestions in mind.
Thanks,
-Ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20131213/24745e9f/attachment.html>