blob: e1939353832971b637946dbe7889e85e296334aa [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001# This class is to be inherited by recipes where there are patches located inside
2# the fetched source code which need to be applied.
3
4# The following variables need to be set:
5# LOCAL_SRC_PATCHES_INPUT_DIR is the directory from where the patches are located
6# LOCAL_SRC_PATCHES_DEST_DIR is the directory where the patches will be applied
7
8do_patch[depends] += "quilt-native:do_populate_sysroot"
9
10LOCAL_SRC_PATCHES_INPUT_DIR ??= ""
11LOCAL_SRC_PATCHES_DEST_DIR ??= "${LOCAL_SRC_PATCHES_INPUT_DIR}"
12
13python() {
14 if not d.getVar('LOCAL_SRC_PATCHES_INPUT_DIR'):
15 bb.warn("LOCAL_SRC_PATCHES_INPUT_DIR variable needs to be set.")
16}
17
18apply_local_src_patches() {
19
20 input_dir="${LOCAL_SRC_PATCHES_INPUT_DIR}"
21 dest_dir="${LOCAL_SRC_PATCHES_DEST_DIR}"
22
23 if [ ! -d "$input_dir" ] ; then
24 bbfatal "LOCAL_SRC_PATCHES_INPUT_DIR=$input_dir not found."
25 fi
26
27 if [ ! -d "$dest_dir" ] ; then
28 bbfatal "LOCAL_SRC_PATCHES_DEST_DIR=$dest_dir not found."
29 fi
30
31 cd $dest_dir
32 export QUILT_PATCHES=./patches-extra
33 mkdir -p patches-extra
34
35 for patch in $(find $input_dir -type f -name *.patch -or -name *.diff | sort)
36 do
37 patch_basename=`basename $patch`
38 if ! quilt applied $patch_basename >/dev/null ; then
39 bbdebug 1 "Applying $patch_basename in $dest_dir."
40 echo $patch_basename >> patches-extra/series
41 cp $patch patches-extra
42 quilt push $patch_basename
43 else
44 bbdebug 1 "$patch_basename already applied."
45 fi
46 done
47}
48do_patch[postfuncs] += "apply_local_src_patches"