summaryrefslogtreecommitdiff
path: root/classes/patch-auto-append.bbclass
diff options
context:
space:
mode:
authorStefan Christ <s.christ@phytec.de>2016-05-04 08:46:54 +0200
committerStefan Müller-Klieser <s.mueller-klieser@phytec.de>2016-10-31 14:33:43 +0100
commitb3bf0ff0d68999956e497491941b92c94dd23938 (patch)
tree548a2b7a1ab238ae160323b6badbfb5ea4cdc9c7 /classes/patch-auto-append.bbclass
parentceff324a0e38412a422761f51cfce38d29bbfba0 (diff)
downloadmeta-phytec-b3bf0ff0d68999956e497491941b92c94dd23938.tar.bz2
meta-phytec-b3bf0ff0d68999956e497491941b92c94dd23938.zip
classes: add patch-auto-append.bbclass
In a KSP project you have to mostly patch the kernel. If there is no extra kernel repository, the patches are included in the meta layer. While development it's annoying to constantly update the list of patches in the SRC_URI. Especially if the name of a patch file changes afterwards. Here the patch-auto-append class comes to rescue. Just include the three lines inherit patch-auto-append PATCH_AUTO_APPEND_DIRS_prepend := "${THISDIR}/${PN}" FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" in your bbappend and you never have to update the SRC_URI again. Signed-off-by: Stefan Christ <s.christ@phytec.de> Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
Diffstat (limited to 'classes/patch-auto-append.bbclass')
-rw-r--r--classes/patch-auto-append.bbclass35
1 files changed, 35 insertions, 0 deletions
diff --git a/classes/patch-auto-append.bbclass b/classes/patch-auto-append.bbclass
new file mode 100644
index 0000000..f1a3134
--- /dev/null
+++ b/classes/patch-auto-append.bbclass
@@ -0,0 +1,35 @@
+#
+# Usage of bbclass patch-auto-append:
+#
+# # In a bbappend
+# inherit patch-auto-append
+# PATCH_AUTO_APPEND_DIRS_prepend := "${THISDIR}/${PN}"
+# FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+#
+# NOTES:
+# - Use := instead of +=. Otherwise ${THISDIR} is not resolved to directory
+# of bbappend.
+# - Every path in PATCH_AUTO_APPEND_DIRS must also be in FILESEXTRAPATHS.
+# Bitbake won't find the patches.
+
+PATCH_AUTO_APPEND_DIRS ??= ""
+
+# bbclass internal:
+
+def _list_patches_in_dirs(d):
+ import os
+ # TODO improve whitespace parsing '.strip(" ")' will not catch all cases.
+ dirs = d.getVar("PATCH_AUTO_APPEND_DIRS", True).strip(" ").split(" ")
+ src_uri_patches = []
+ for dir in dirs: # Use order of directory in PATCH_AUTO_APPEND_DIRS
+ for filename in (f for f in os.listdir(dir)):
+ path = os.path.join(dir, filename)
+ print(path, filename)
+
+ if os.path.isfile(path) and filename.endswith(".patch"):
+ # TODO Escape evil characters ;-)
+ src_uri_patches.append("file://" + filename)
+
+ return " ".join(src_uri_patches)
+
+SRC_URI_append = " ${@_list_patches_in_dirs(d)}"