Skip to contentSkip to conversation

Add support for custom package patches

PATCH New spdawson at gmail.com 2 participants 3 messages Oct 30, 2012 – Oct 31, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add support for custom package patches

From: Simon Dawson <[email protected]>

Add a configuration item to allow a space-separated list of directories to be specified, from which custom package patches will be applied.

---
 Config.in              |    7 +++++++
 package/pkg-generic.mk |   28 ++++++++++++++++------------
 2 files changed, 23 insertions(+), 12 deletions(-)
Config.in +7 -0
index dab7787..13a7daf 100644
@@ -415,6 +415,13 @@ config BR2_PACKAGE_OVERRIDE_FILE
 	  as the source directory for a particular package. See the
 	  Buildroot documentation for more details on this feature.
 
+config BR2_CUSTOM_PACKAGE_PATCH_DIRS
+	string "custom package patch directories"
+	help
+	  You may specify a space-separated list of directories containing
+	  custom package patches. Note that any custom patches for a package
+	  will be applied AFTER the Buildroot patch set for the package.
+
 endmenu
 
 source "toolchain/Config.in"
package/pkg-generic.mk +16 -12
index 270da60..d77662e 100644
@@ -69,6 +69,20 @@ else
 	@true # Nothing to do to source a local package
 endif
 
+# Apply package patches from the specified directory
+define pkg-apply-patch-directory
+	if test -d $(1); then \
+	  if test "$(wildcard $(1)/$(NAMEVER)*.patch*)"; then \
+	    support/scripts/apply-patches.sh $(@D) $(1) $(NAMEVER)\*.patch $(NAMEVER)\*.patch.$(ARCH) || exit 1; \
+	  else \
+	    support/scripts/apply-patches.sh $(@D) $(1) $(RAWNAME)\*.patch $(RAWNAME)\*.patch.$(ARCH) || exit 1; \
+	    if test -d $(1)/$(NAMEVER); then \
+	      support/scripts/apply-patches.sh $(@D) $(1)/$(NAMEVER) \*.patch \*.patch.$(ARCH) || exit 1; \
+	    fi; \
+	  fi; \
+	fi;
+endef
+
 # Patch
 #
 # The RAWNAME variable is the lowercased package name, which allows to
@@ -79,18 +93,8 @@ $(BUILD_DIR)/%/.stamp_patched:
 	@$(call MESSAGE,"Patching $($(PKG)_DIR_PREFIX)/$(RAWNAME)")
 	$(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
 	$(if $($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $($(PKG)_PATCH))
-	$(Q)( \
-	if test -d $($(PKG)_DIR_PREFIX)/$(RAWNAME); then \
-	  if test "$(wildcard $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER)*.patch*)"; then \
-	    support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(NAMEVER)\*.patch $(NAMEVER)\*.patch.$(ARCH) || exit 1; \
-	  else \
-	    support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(RAWNAME)\*.patch $(RAWNAME)\*.patch.$(ARCH) || exit 1; \
-	    if test -d $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER); then \
-	      support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER) \*.patch \*.patch.$(ARCH) || exit 1; \
-	    fi; \
-	  fi; \
-	fi; \
-	)
+	$(Q)($(call pkg-apply-patch-directory,$($(PKG)_DIR_PREFIX)/$(RAWNAME)))
+	$(Q)($(foreach	patchdir,$(call qstrip,$(BR2_CUSTOM_PACKAGE_PATCH_DIRS)),$(call pkg-apply-patch-directory,$(patchdir))))
 	$(foreach hook,$($(PKG)_POST_PATCH_HOOKS),$(call $(hook))$(sep))
 	$(Q)touch $@
 
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 Add support for custom package patches

Quoted 4 lines · spdawson at gmail.com

From: Simon Dawson<[email protected]>

Add a configuration item to allow a space-separated list of directories to be specified, from which custom package patches will be applied.

Good idea!

Quoted 2 lines

but some potential improvements below.

Quoted 10 lines
---
  Config.in              |    7 +++++++
  package/pkg-generic.mk |   28 ++++++++++++++++------------
  2 files changed, 23 insertions(+), 12 deletions(-)
Config.in +0 -0
index dab7787..13a7daf 100644

Config.in config BR2_PACKAGE_OVERRIDE_FILE · line 419

Quoted 5 lines
Config.in +2 -0
@@ -415,6 +415,13 @@ config BR2_PACKAGE_OVERRIDE_FILE
  	  as the source directory for a particular package. See the
  	  Buildroot documentation for more details on this feature.
 
+config BR2_CUSTOM_PACKAGE_PATCH_DIRS
+	string "custom package patch directories"

I would call it extra patch dirs, otherwise it sounds like it's overriding
the BR patch set.

Quoted 15 lines
Config.in +5 -0
+	help
+	  You may specify a space-separated list of directories containing
+	  custom package patches. Note that any custom patches for a package
+	  will be applied AFTER the Buildroot patch set for the package.
+
  endmenu
 
  source "toolchain/Config.in"
package/pkg-generic.mk +0 -0
index 270da60..d77662e 100644
@@ -69,6 +69,20 @@ else
  	@true # Nothing to do to source a local package
  endif

package/pkg-generic.mk else · line 80

Quoted 10 lines
package/pkg-generic.mk +9 -0
 
+# Apply package patches from the specified directory
+define pkg-apply-patch-directory
+	if test -d $(1); then \
+	  if test "$(wildcard $(1)/$(NAMEVER)*.patch*)"; then \
+	    support/scripts/apply-patches.sh $(@D) $(1) $(NAMEVER)\*.patch $(NAMEVER)\*.patch.$(ARCH) || exit 1; \
+	  else \
+	    support/scripts/apply-patches.sh $(@D) $(1) $(RAWNAME)\*.patch $(RAWNAME)\*.patch.$(ARCH) || exit 1; \
+	    if test -d $(1)/$(NAMEVER); then \
+	      support/scripts/apply-patches.sh $(@D) $(1)/$(NAMEVER) \*.patch \*.patch.$(ARCH) || exit 1; \

For the custom patch dirs, we may also want to support the
$(1)/$(RAWNAME)/*.patch pattern. So that would give:

	    elif test -d $(1)/$(RAWNAME); then \
	      support/scripts/apply-patches.sh $(@D) $(1)/$(RAWNAME) \*.patch \*.patch.$(ARCH) || exit 1; \

We should also get rid of the patch.$(ARCH) pattern, but that's
a separate issue.

Quoted 16 lines
package/pkg-generic.mk +5 -4
+	    fi; \
+	  fi; \
+	fi;
+endef
+
  # Patch
  #
  # The RAWNAME variable is the lowercased package name, which allows to
@@ -79,18 +93,8 @@ $(BUILD_DIR)/%/.stamp_patched:
  	@$(call MESSAGE,"Patching $($(PKG)_DIR_PREFIX)/$(RAWNAME)")
  	$(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
  	$(if $($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $($(PKG)_PATCH))
-	$(Q)( \
-	if test -d $($(PKG)_DIR_PREFIX)/$(RAWNAME); then \
-	  if test "$(wildcard $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER)*.patch*)"; then \
-	    support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(NAMEVER)\*.patch $(NAMEVER)\*.patch.$(ARCH) || exit 1; \

package/pkg-generic.mk $(BUILD_DIR)/%/.stamp_patched: · line 97

Quoted 10 lines
package/pkg-generic.mk +2 -8
-	  else \
-	    support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(RAWNAME)\*.patch $(RAWNAME)\*.patch.$(ARCH) || exit 1; \
-	    if test -d $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER); then \
-	      support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER) \*.patch \*.patch.$(ARCH) || exit 1; \
-	    fi; \
-	  fi; \
-	fi; \
-	)
+	$(Q)($(call pkg-apply-patch-directory,$($(PKG)_DIR_PREFIX)/$(RAWNAME)))
+	$(Q)($(foreach	patchdir,$(call qstrip,$(BR2_CUSTOM_PACKAGE_PATCH_DIRS)),$(call pkg-apply-patch-directory,$(patchdir))))

This actually looks a lot nicer!

package/pkg-generic.mk $(BUILD_DIR)/%/.stamp_patched: · line 100

Quoted 3 lines
package/pkg-generic.mk +0 -0
  	$(foreach hook,$($(PKG)_POST_PATCH_HOOKS),$(call $(hook))$(sep))
  	$(Q)touch $@
 

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
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
#2 lore raw

PATCH 1/1 Add support for custom package patches

Quoted 2 lines · Arnout Vandecappelle

but some potential improvements below.

Hi Arnout. Thanks for the feedback.

Quoted 6 lines

Config.in config BR2_PACKAGE_OVERRIDE_FILE · line 419

Quoted 2 lines
Config.in +2 -0
+config BR2_CUSTOM_PACKAGE_PATCH_DIRS
+       string "custom package patch directories"

I would call it extra patch dirs, otherwise it sounds like it's overriding
the BR patch set.

Yes, agreed.

Quoted 6 lines

For the custom patch dirs, we may also want to support the
$(1)/$(RAWNAME)/*.patch pattern. So that would give:

            elif test -d $(1)/$(RAWNAME); then \
              support/scripts/apply-patches.sh $(@D) $(1)/$(RAWNAME)

\*.patch \*.patch.$(ARCH) || exit 1; \

Yes, good idea.

I'll fix my patch, and resubmit.

Simon.