Bitbake recipe is missing do_patch task

Viewed 524

I have a basic recipe file for a kernel module, looks like this:

SUMMARY = "my package"
AUTHOR = "me"
PRIORITY = "required"
PR = "r1"
SECTION = "base"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI = "file://foo_${PV}.tgz"
SRC_URI += " file://foo.patch;patch=1;apply=yes "

inherit module

EXTRA_OEMAKE += "PREFIX=${D}"
EXTRA_OEMAKE_append_task-install = " -C ${STAGING_KERNEL_DIR} M=${S}"
EXTRA_OEMAKE += "KERNELDIR=${STAGING_KERNEL_DIR}"

I created a patch for the source code: foo.patch and placed it in the files directory. The bewildering part is that I am not getting any errors, the patch is just not getting applied. the do_fetch, and do_unpack seem to find the patch file just fine i.e. if I navigate to the work directory I find the patch file.

Based on a few searches I have tried various attribute additions to the patch file line with little success. for example:

SRC_URI += " file://foo.patch;patch=1;apply=yes;pnum=0 "
SRC_URI += " file://foo.patch "
SRC_URI += " file://foo.patch;patch=1;apply=yes;patchdir=${WORKDIR} "

One thing I noticed is the output from bitbake -c listtasks foo:

NOTE: Executing RunQueue Tasks
do_build                   Default task for a recipe - depends on all other normal tasks required to 'build' a recipe
do_buildclean              Call 'make clean' or equivalent in 
do_checkuri                Validates the SRC_URI value
do_checkuriall             Validates the SRC_URI value for all recipes required to build a target
do_clean                   Removes all output files for a target
do_cleanall                Removes all output files, shared state cache, and downloaded source files for a target
do_cleansstate             Removes all output files and shared state cache for a target
do_compile                 Compiles the source in the compilation directory
do_configure               Configures the source by enabling and disabling any build-time and configuration options for the software being built
do_devpyshell              Starts an interactive Python shell for development/debugging
do_devshell                Starts a shell with the environment set up for development/debugging
do_fetch                   Fetches the source code
do_fetchall                Fetches all remote sources required to build a target
do_install                 Copies files from the compilation directory to a holding area
do_listtasks               Lists all defined tasks for a target
do_make_scripts            
do_package                 Analyzes the content of the holding area and splits it into subsets based on available packages and files
do_package_qa              Runs QA checks on packaged files
do_package_write_rpm       Creates the actual RPM packages and places them in the Package Feed area
do_packagedata             Creates package metadata used by the build system to generate the final packages
do_populate_lic            Writes license information for the recipe that is collected later when the image is constructed
do_populate_sysroot        Copies a subset of files installed by do_install into the sysroot in order to make them available to other recipes
do_prepare_recipe_sysroot  
do_unpack                  Unpacks the source code into a working directory

do_patch is not listed!? This doesn't seem right to me, but then again my patch is not being applied after being coped to ${WORKDIR} and I am not getting any errors. Do I need to inherit some class to get the do_patch task? There is not a log.do_patch in the temp directory either. Any ideas?

2 Answers

This probably has to do with building your package from external source.

Long story short, if EXTERNALSRC variable is set for your package, you would not get do_patch task when listing or executing tasks. Having this variable set might have benefits if that package is frequently changed, but if you do need to still have do_patch you should change it in your auto.conf and/or local.conf files in your Yocto build system.

I am still unsure why my recipe does not have the 'do_patch' task, but as a work around created a custom task that seems to have done the trick. I have appended the following to my recipe:

do_mypatch(){
    patch ${WORKDIR}/foo.c < ${WORKDIR}/foo.patch
}

addtask mypatch before do_compile

To verify: I executed bitbake -c listtasks foo. here is the output:

NOTE: Executing RunQueue Tasks
do_build                   Default task for a recipe - depends on all other normal tasks required to 'build' a recipe
do_buildclean              Call 'make clean' or equivalent in 
do_checkuri                Validates the SRC_URI value
do_checkuriall             Validates the SRC_URI value for all recipes required to build a target
do_clean                   Removes all output files for a target
do_cleanall                Removes all output files, shared state cache, and downloaded source files for a target
do_cleansstate             Removes all output files and shared state cache for a target
do_compile                 Compiles the source in the compilation directory
do_configure               Configures the source by enabling and disabling any build-time and configuration options for the software being built
do_devpyshell              Starts an interactive Python shell for development/debugging
do_devshell                Starts a shell with the environment set up for development/debugging
do_fetch                   Fetches the source code
do_fetchall                Fetches all remote sources required to build a target
do_install                 Copies files from the compilation directory to a holding area
do_listtasks               Lists all defined tasks for a target
do_make_scripts            
do_mypatch                 
do_package                 Analyzes the content of the holding area and splits it into subsets based on available packages and files
do_package_qa              Runs QA checks on packaged files
do_package_write_rpm       Creates the actual RPM packages and places them in the Package Feed area
do_packagedata             Creates package metadata used by the build system to generate the final packages
do_populate_lic            Writes license information for the recipe that is collected later when the image is constructed
do_populate_sysroot        Copies a subset of files installed by do_install into the sysroot in order to make them available to other recipes
do_prepare_recipe_sysroot  
do_unpack                  Unpacks the source code into a working directory

notice my new custom task is present: do_mypatch

If anyone can comment or knows the answer as to why my recipe was not given the do_patch task please provide.

Related