Message ID | 20240221090005.54520-1-felix.moessbauer@siemens.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [isar-cip-core,1/1] swupdate: use to_boolean to compare boolean variables | expand |
On Wed, 2024-02-21 at 10:00 +0100, Felix Moessbauer wrote: > When checking if boolean wariables are enabled / disabled, a ---------------------------^ @Jan please fix this typo when merging (in case no v2 is required). Felix > comparison > against "0" or "1" is error prone, as a user might use other values > like > "True" to enable it. For that, bitbake offers the to_boolean. > > Reported-by: Cheng shu Mou <chengshu.mou@siemens.com> > Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> > --- > recipes-core/swupdate/swupdate.inc | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/recipes-core/swupdate/swupdate.inc b/recipes- > core/swupdate/swupdate.inc > index cb1716b..7a4214f 100644 > --- a/recipes-core/swupdate/swupdate.inc > +++ b/recipes-core/swupdate/swupdate.inc > @@ -23,7 +23,7 @@ def get_bootloader_dependencies(d): > if bootloader == "efibootguard": > return "libebgenv-dev" > if bootloader == "u-boot": > - if d.getVar("U_BOOT_CONFIG_PACKAGE") == "1": > + if bb.utils.to_boolean(d.getVar("U_BOOT_CONFIG_PACKAGE")): > return "libubootenv u-boot-{}- > config".format(d.getVar("MACHINE")) > else: > return "libubootenv" > @@ -32,7 +32,7 @@ def get_bootloader_dependencies(d): > DEPENDS += "${@get_bootloader_dependencies(d)}" > DEPENDS += "${@bb.utils.contains('DEB_BUILD_PROFILES', 'mtd', 'mtd- > utils', '', d)}" > > -DEB_BUILD_PROFILES += "${@'pkg.swupdate.nosigning' if not > d.getVar('SWU_SIGNED') == '1' else ''}" > +DEB_BUILD_PROFILES += "${@'pkg.swupdate.nosigning' if not > bb.utils.to_boolean(d.getVar('SWU_SIGNED')) else ''}" > > # deactivate hardware compability for simple a/b rootfs update > DEB_BUILD_PROFILES += "pkg.swupdate.nohwcompat"
diff --git a/recipes-core/swupdate/swupdate.inc b/recipes-core/swupdate/swupdate.inc index cb1716b..7a4214f 100644 --- a/recipes-core/swupdate/swupdate.inc +++ b/recipes-core/swupdate/swupdate.inc @@ -23,7 +23,7 @@ def get_bootloader_dependencies(d): if bootloader == "efibootguard": return "libebgenv-dev" if bootloader == "u-boot": - if d.getVar("U_BOOT_CONFIG_PACKAGE") == "1": + if bb.utils.to_boolean(d.getVar("U_BOOT_CONFIG_PACKAGE")): return "libubootenv u-boot-{}-config".format(d.getVar("MACHINE")) else: return "libubootenv" @@ -32,7 +32,7 @@ def get_bootloader_dependencies(d): DEPENDS += "${@get_bootloader_dependencies(d)}" DEPENDS += "${@bb.utils.contains('DEB_BUILD_PROFILES', 'mtd', 'mtd-utils', '', d)}" -DEB_BUILD_PROFILES += "${@'pkg.swupdate.nosigning' if not d.getVar('SWU_SIGNED') == '1' else ''}" +DEB_BUILD_PROFILES += "${@'pkg.swupdate.nosigning' if not bb.utils.to_boolean(d.getVar('SWU_SIGNED')) else ''}" # deactivate hardware compability for simple a/b rootfs update DEB_BUILD_PROFILES += "pkg.swupdate.nohwcompat"
When checking if boolean wariables are enabled / disabled, a comparison against "0" or "1" is error prone, as a user might use other values like "True" to enable it. For that, bitbake offers the to_boolean. Reported-by: Cheng shu Mou <chengshu.mou@siemens.com> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> --- recipes-core/swupdate/swupdate.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)