arm/classes: Introduce apply_local_src_patches bbclass
PATCH 1/2 arm/classes: Introduce apply_local_src_patches bbclass
From: Diego Sueiro <[email protected]>
This class is to be inherited by recipes where there are patches located inside the fetched source code which need to be applied.
The following variables need to be set:LOCAL_SRC_PATCHES_INPUT_DIR is the directory from where the patches are located LOCAL_SRC_PATCHES_DEST_DIR is the directory where the patches will be applied
--- .../classes/apply_local_src_patches.bbclass | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 meta-arm/classes/apply_local_src_patches.bbclass
meta-arm/classes/apply_local_src_patches.bbclass new file +48 -0
@@ -0,0 +1,48 @@ +# This class is to be inherited by recipes where there are patches located inside +# the fetched source code which need to be applied. + +# The following variables need to be set: +# LOCAL_SRC_PATCHES_INPUT_DIR is the directory from where the patches are located +# LOCAL_SRC_PATCHES_DEST_DIR is the directory where the patches will be applied + +do_patch[depends] += "quilt-native:do_populate_sysroot" + +LOCAL_SRC_PATCHES_INPUT_DIR ??= "" +LOCAL_SRC_PATCHES_DEST_DIR ??= "${LOCAL_SRC_PATCHES_INPUT_DIR}" + +python() { + if not d.getVar('LOCAL_SRC_PATCHES_INPUT_DIR'): + bb.warn("LOCAL_SRC_PATCHES_INPUT_DIR variable needs to be set.") +} + +apply_local_src_patches() { + + input_dir="${LOCAL_SRC_PATCHES_INPUT_DIR}" + dest_dir="${LOCAL_SRC_PATCHES_DEST_DIR}" + + if [ ! -d "$input_dir" ] ; then + bbfatal "LOCAL_SRC_PATCHES_INPUT_DIR=$input_dir not found." + fi + + if [ ! -d "$dest_dir" ] ; then + bbfatal "LOCAL_SRC_PATCHES_DEST_DIR=$dest_dir not found." + fi + + cd $dest_dir + export QUILT_PATCHES=./patches-extra + mkdir -p patches-extra + + for patch in $(find $input_dir -type f -name *.patch -or -name *.diff) + do + patch_basename=`basename $patch` + if ! quilt applied $patch_basename >/dev/null ; then + bbdebug 1 "Applying $patch_basename in $dest_dir." + echo $patch_basename >> patches-extra/series + cp $patch patches-extra + quilt push $patch_basename + else + bbdebug 1 "$patch_basename already applied." + fi + done +} +do_patch[postfuncs] += "apply_local_src_patches"
Signature · 1 line
2.25.1
PATCH 2/2 arm/trusted-firmware-m: Fix local source patches application
From: Diego Sueiro <[email protected]>
As TF-M ships patches that it needs applied to mbedcrypto, we apply them as part of do_patch by using a postfunc. There is an issue when do_patch is executed after do_deploy_source_date_epoch_setscene and apply_local_patches tries to apply the patches already applied.
To fix this, make usage of the apply_local_src_patches bbclass.
--- .../trusted-firmware-m/trusted-firmware-m_1.6.0.bb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.6.0.bb +3 -4
@@ -108,10 +108,9 @@ export OPENSSL_MODULES="${STAGING_LIBDIR_NATIVE}/ossl-modules" # TF-M ships patches that it needs applied to mbedcrypto, so apply them # as part of do_patch. -apply_local_patches() { - cat ${S}/lib/ext/mbedcrypto/*.patch | patch -p1 -d ${S}/../mbedtls -} -do_patch[postfuncs] += "apply_local_patches" +LOCAL_SRC_PATCHES_INPUT_DIR = "${S}/lib/ext/mbedcrypto" +LOCAL_SRC_PATCHES_DEST_DIR = "${S}/../mbedtls" +inherit apply_local_src_patches do_configure[cleandirs] = "${B}" do_configure() {
Signature · 1 line
2.25.1
Jon Mason
AppliedQuoted 6 lines · Peter Hoyes
This class is to be inherited by recipes where there are patches located inside the fetched source code which need to be applied.
The following variables need to be set:
LOCAL_SRC_PATCHES_INPUT_DIRis the directory from where the patches are locatedLOCAL_SRC_PATCHES_DEST_DIRis the directory where the patches will be applied
Applied, thanks!
[1/2] arm/classes: Introduce apply_local_src_patches bbclass
commit: 7fcff00498480d72ad536e785b2297f39dd1071e
[2/2] arm/trusted-firmware-m: Fix local source patches application
commit: f7c9f58eeb446130e2af77bf2b26be95b6134cefBest regards,
Signature · 1 line
Jon Mason <[email protected]>