diff mbox series

[1/1] package/ti-k3-r5-loader: support patching in same way as u-boot

Message ID SEZPR06MB6485AC9540285CAFE0BC075B80ED2@SEZPR06MB6485.apcprd06.prod.outlook.com
State New
Headers show
Series [1/1] package/ti-k3-r5-loader: support patching in same way as u-boot | expand

Commit Message

Marc Murphy May 16, 2024, 8:18 p.m. UTC
From ed5da96fa289155a362e6415de39a461e18935e8 Mon Sep 17 00:00:00 2001
From: Marc Murphy <marc.murphy@sancloud.com>
Date: Thu, 16 May 2024 17:09:14 +0100
Subject: [PATCH 1/1] package/ti-k3-r5-loader: support patching in same way as
 u-boot

Signed-off-by: Marc Murphy <marc.murphy@sancloud.com>
---
 boot/ti-k3-r5-loader/Config.in          | 12 ++++++++++++
 boot/ti-k3-r5-loader/ti-k3-r5-loader.mk | 19 +++++++++++++++++++
 2 files changed, 31 insertions(+)

--
2.25.1
diff mbox series

Patch

diff --git a/boot/ti-k3-r5-loader/Config.in b/boot/ti-k3-r5-loader/Config.in
index c276528fad..0e26a15369 100644
--- a/boot/ti-k3-r5-loader/Config.in
+++ b/boot/ti-k3-r5-loader/Config.in
@@ -69,6 +69,18 @@  config BR2_TARGET_TI_K3_R5_LOADER_VERSION
                if BR2_TARGET_TI_K3_R5_LOADER_CUSTOM_GIT || \
                   BR2_TARGET_TI_K3_R5_LOADER_CUSTOM_HG  || \
                   BR2_TARGET_TI_K3_R5_LOADER_CUSTOM_SVN
+
+config BR2_TARGET_TI_K3_R5_LOADER_PATCH
+       string "Custom U-Boot patches"
+       default ""
+       help
+         A space-separated list of patches to apply to U-Boot.
+         Each patch can be described as an URL, a local file path,
+         or a directory. In the case of a directory, all files
+         matching *.patch in the directory will be applied.
+
+         Most users may leave this empty
+
 choice
        prompt "U-Boot Configuration"
        default BR2_TARGET_TI_K3_R5_LOADER_USE_DEFCONFIG
diff --git a/boot/ti-k3-r5-loader/ti-k3-r5-loader.mk b/boot/ti-k3-r5-loader/ti-k3-r5-loader.mk
index 98a6d473f1..b45f30b4b0 100644
--- a/boot/ti-k3-r5-loader/ti-k3-r5-loader.mk
+++ b/boot/ti-k3-r5-loader/ti-k3-r5-loader.mk
@@ -60,6 +60,25 @@  TI_K3_R5_LOADER_KCONFIG_DEPENDENCIES = \
        $(BR2_BISON_HOST_DEPENDENCY) \
        $(BR2_FLEX_HOST_DEPENDENCY)

+# Analogous code exists in linux/linux.mk. Basically, the generic
+# package infrastructure handles downloading and applying remote
+# patches. Local patches are handled depending on whether they are
+# directories or files.
+TI_K3_R5_LOADER_PATCHES = $(call qstrip,$(BR2_TARGET_TI_K3_R5_LOADER_PATCH))
+TI_K3_R5_LOADER_PATCH = $(filter ftp://% http://% https://%,$(TI_K3_R5_LOADER_PATCHES))
+
+define TI_K3_R5_LOADER_APPLY_LOCAL_PATCHES
+       for p in $(filter-out ftp://% http://% https://%,$(TI_K3_R5_LOADER_PATCHES)) ; do \
+               if test -d $$p ; then \
+                       $(APPLY_PATCHES) $(@D) $$p \*.patch || exit 1 ; \
+               else \
+                       $(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` || exit 1; \
+               fi \
+       done
+endef
+
+TI_K3_R5_LOADER_POST_PATCH_HOOKS += TI_K3_R5_LOADER_APPLY_LOCAL_PATCHES
+
 ifeq ($(BR2_TARGET_TI_K3_R5_LOADER_USE_DEFCONFIG),y)
 TI_K3_R5_LOADER_KCONFIG_DEFCONFIG = $(call qstrip,$(BR2_TARGET_TI_K3_R5_LOADER_BOARD_DEFCONFIG))_defconfig
 else ifeq ($(BR2_TARGET_TI_K3_R5_LOADER_USE_CUSTOM_CONFIG),y)