1

For one of my requirements, I need to call a specific tasks based on whether a packageconfig variable is defined in another recipes or not.

For example:
We have a recipe called recipes-crypto where, in the .bb file we have:

PACKAGECONFIG[veritysetup] = "--enable-veritysetup,--disable-veritysetup"
BBCLASSEXTEND = "native nativesdk"

Then, in my meta-qti-bsp/classes, I have qimage.class, where I wanted to do like this:

if ${@bb.utils.contains('PACKAGECONFIG', 'veritysetup', 'true', 'false', d)}; then
    #Call some function
fi

But it gives errors:

ERROR: ParseError at /local/mnt/workspace/PINTU/WORK/Y2021/NAD-CORE-WORK/NEW_C10_30Nov/poky/meta-qti-bsp/classes/qimage.bbclass:102: unparsed line: 'if ${@bb.utils.contains('PACKAGECONFIG', 'veritysetup', 'true', 'false', d)}; then'

How to make veritysetup variable get recognised in my class file?

I saw some examples and added this on top:

PACKAGECONFIG_append_class-native = " veritysetup"

But with this also it gives the same error.

I am using this veritysetup command only during build time.
So, I wanted to execute this command if and only if this PACKAGECONFIG variable is defined.

What is the best way to do it ?

Étienne
  • 4,773
  • 2
  • 33
  • 58
  • What you ask for is impossible. Recipes are isolated from each other in Yocto. If you want something that affects more than one recipe you need to define it in configuration. Then all recipes can access it. – Uwe Geuder Dec 19 '21 at 18:23

2 Answers2

3

veritysetup is not a value of PACKAGECONFIG, but it is a flag.

PACKAGECONFIG has many flags and each flag has its value.

For more information about variable flags check this link.

So, here is an example of how to check if that flag is activated:

verity-example.bb

LICENSE = "CLOSED"
PACKAGECONFIG[veritysetup] = "--enable-veritysetup,--disable-veritysetup"

do_check_verity(){
    if [ ${@d.getVarFlag('PACKAGECONFIG', 'veritysetup', False)} ]; then
        bbwarn "veritysetup is activated with value: ${@d.getVarFlags('PACKAGECONFIG').get('veritysetup')}"
    else
        bbwarn "veritysetup is not activated."
    fi
}

addtask do_check_verity

If you run:

bitbake verity-example -c check_verity

You will get the warning:

WARNING: verity-example-1.0-r0 do_sample: veritysetup is activated with value: --enable-veritysetup,--disable-veritysetup

Talel BELHADJSALEM
  • 3,199
  • 1
  • 10
  • 30
0

Actually, I did it in this way and it worked for me.

The following is already enabled in recipes-crypto like this:

PACKAGECONFIG[veritysetup] = "--enable-veritysetup,--disable-veritysetup"

Now, in our .bbclass I just called like this:

DEPENDS += "cryptsetup-native openssl-native"
PACKAGECONFIG_append = " veritysetup"
**==> This is the main part how we can check, if a packageconfig variable is enabled elsewhere or not**

Then I can check the condition like this:

if not bb.utils.contains('PACKAGECONFIG', 'veritysetup', True, False, d):
    //dome something
else:
   //done something else
Étienne
  • 4,773
  • 2
  • 33
  • 58