@@ -15,7 +15,7 @@ SRC_URI = "apt://${PN}"
MAINTAINER = "isar-users <isar-users@googlegroups.com>"
CHANGELOG_V = "<orig-version>+isar"
-DEB_BUILD_OPTIONS += "${@ 'nocheck' if d.getVar('ISAR_CROSS_COMPILE') == '1' else '' }"
+DEB_BUILD_OPTIONS += "${@ 'nocheck' if bb.utils.to_boolean(d.getVar('ISAR_CROSS_COMPILE')) else '' }"
do_prepare_build() {
deb_add_changelog
@@ -181,7 +181,7 @@ def isar_export_proxies(d):
variables = ['http_proxy', 'HTTP_PROXY', 'https_proxy', 'HTTPS_PROXY',
'ftp_proxy', 'FTP_PROXY' ]
- if d.getVar('BB_NO_NETWORK') == "1":
+ if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')):
for v in variables:
d.setVar(v, deadend_proxy)
for v in [ 'no_proxy', 'NO_PROXY' ]:
@@ -190,10 +190,10 @@ def isar_export_proxies(d):
return bb.utils.export_proxies(d)
def isar_export_ccache(d):
- if d.getVar('USE_CCACHE') == '1':
+ if bb.utils.to_boolean(d.getVar('USE_CCACHE')):
os.environ['CCACHE_DIR'] = '/ccache'
os.environ['PATH_PREPEND'] = '/usr/lib/ccache'
- if d.getVar('CCACHE_DEBUG') == '1':
+ if bb.utils.to_boolean(d.getVar('CCACHE_DEBUG')):
os.environ['CCACHE_DEBUG'] = '1'
os.environ['CCACHE_DEBUGDIR'] = '/ccache/debug'
else:
@@ -31,7 +31,7 @@ python() {
def isar_can_build_compat(d):
return (d.getVar('COMPAT_DISTRO_ARCH') is not None and
- d.getVar('ISAR_ENABLE_COMPAT_ARCH') == '1')
+ bb.utils.to_boolean(d.getVar('ISAR_ENABLE_COMPAT_ARCH')))
################################################################################
# package recipe modifications when building *-compat:
@@ -9,7 +9,7 @@ python __anonymous() {
import pwd
d.setVar('SCHROOT_USER', pwd.getpwuid(os.geteuid()).pw_name)
- mode = d.getVar('ISAR_CROSS_COMPILE')
+ mode = bb.utils.to_boolean(d.getVar('ISAR_CROSS_COMPILE'))
# support derived schroots
flavor = d.getVar('SBUILD_FLAVOR')
@@ -22,7 +22,7 @@ python __anonymous() {
if distro_arch != host_arch and \
(package_arch == host_arch or \
- (package_arch in [distro_arch, compat_arch, '${BUILD_ARCH}'] and mode == "1")):
+ (package_arch in [distro_arch, compat_arch, '${BUILD_ARCH}'] and mode)):
d.setVar('BUILD_ARCH', host_arch)
schroot_dir = d.getVar('SCHROOT_HOST_DIR', False)
sbuild_dep = "sbuild-chroot-host" + flavor_suffix + ":do_build"
@@ -15,7 +15,7 @@ inherit essential
DEPENDS ?= ""
RPROVIDES ?= "${PROVIDES}"
-DEPENDS:append:riscv64 = "${@' crossbuild-essential-riscv64' if d.getVar('ISAR_CROSS_COMPILE') == '1' and d.getVar('PN') != 'crossbuild-essential-riscv64' else ''}"
+DEPENDS:append:riscv64 = "${@' crossbuild-essential-riscv64' if bb.utils.to_boolean(d.getVar('ISAR_CROSS_COMPILE')) and d.getVar('PN') != 'crossbuild-essential-riscv64' else ''}"
DEB_BUILD_PROFILES ?= ""
DEB_BUILD_OPTIONS ?= ""
@@ -218,7 +218,7 @@ dpkg_runbuild() {
def isar_deb_build_profiles(d):
deb_build_profiles = d.getVar('DEB_BUILD_PROFILES')
- if d.getVar('ISAR_CROSS_COMPILE') == "1":
+ if bb.utils.to_boolean(d.getVar('ISAR_CROSS_COMPILE')):
deb_build_profiles += ' cross'
return deb_build_profiles.strip()
@@ -313,7 +313,7 @@ python do_devshell() {
isar_export_proxies(d)
isar_export_ccache(d)
isar_export_build_settings(d)
- if d.getVar('USE_CCACHE') == '1':
+ if bb.utils.to_boolean(d.getVar('USE_CCACHE')):
bb.build.exec_func('schroot_configure_ccache', d)
schroot = d.getVar('SBUILD_CHROOT')
@@ -13,7 +13,7 @@ CONTAINER_IMAGE_NAME ?= "${PN}-${DISTRO}-${DISTRO_ARCH}"
CONTAINER_IMAGE_TAG ?= "${PV}-${PR}"
python() {
- if not d.getVar('USING_CONTAINER') == '1':
+ if not bb.utils.to_boolean(d.getVar('USING_CONTAINER')):
return
for t in d.getVar('CONTAINER_TYPES').split():
t_clean = t.replace('-', '_').replace('.', '_')
@@ -5,7 +5,7 @@
#
USING_WIC = "${@bb.utils.contains('IMAGE_BASETYPES', 'wic', '1', '0', d)}"
-WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if d.getVar('USING_WIC') == '1' else ''}"
+WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if bb.utils.to_boolean(d.getVar('USING_WIC')) else ''}"
WKS_FILE ??= "sdimage-efi"
@@ -16,7 +16,7 @@ do_copy_wks_template () {
}
python () {
- if not d.getVar('USING_WIC') == '1':
+ if not bb.utils.to_boolean(d.getVar('USING_WIC')):
return
if d.getVar('WIC_IMAGER_INSTALL'):
@@ -26,7 +26,7 @@ python() {
# and not for the builder architecture
depends = d.getVar('DEPENDS')
if depends is not None and d.getVar('HOST_ARCH') != d.getVar('DISTRO_ARCH') \
- and d.getVar('ISAR_CROSS_COMPILE') != '1':
+ and not bb.utils.to_boolean(d.getVar('ISAR_CROSS_COMPILE')):
new_deps = []
for dep in depends.split():
if dep.endswith('-native'):
@@ -16,7 +16,7 @@ PATCH_GIT_USER_EMAIL ?= "isar.patch@isar"
inherit terminal
python () {
- if d.getVar('PATCHTOOL') == 'git' and d.getVar('PATCH_COMMIT_FUNCTIONS') == '1':
+ if d.getVar('PATCHTOOL') == 'git' and bb.utils.to_boolean(d.getVar('PATCH_COMMIT_FUNCTIONS')):
extratasks = bb.build.tasksbetween('do_unpack', 'do_patch', d)
try:
extratasks.remove('do_unpack')
@@ -65,7 +65,7 @@ python patch_task_postfunc() {
if os.path.exists(srcsubdir):
if func == 'do_patch':
- haspatches = (d.getVar('PATCH_HAS_PATCHES_DIR') == '1')
+ haspatches = bb.utils.to_boolean(d.getVar('PATCH_HAS_PATCHES_DIR'))
patchdir = os.path.join(srcsubdir, 'patches')
if os.path.exists(patchdir):
shutil.rmtree(patchdir)
@@ -57,7 +57,7 @@ TAR_TRANSFORM:class-sdk = " --transform='s|rootfs|${IMAGE_FULLNAME}|'"
# bitbake dependencies
SDKDEPENDS += "sdk-files ${SDK_INSTALL}"
-SDKDEPENDS:append:riscv64 = "${@' crossbuild-essential-riscv64' if d.getVar('ISAR_CROSS_COMPILE') == '1' and d.getVar('PN') != 'crossbuild-essential-riscv64' else ''}"
+SDKDEPENDS:append:riscv64 = "${@' crossbuild-essential-riscv64' if bb.utils.to_boolean(d.getVar('ISAR_CROSS_COMPILE')) and d.getVar('PN') != 'crossbuild-essential-riscv64' else ''}"
DEPENDS:class-sdk = "${SDKDEPENDS}"
SDKROOTFSDEPENDS = ""
@@ -68,10 +68,10 @@ SDKROOTFSVARDEPS = ""
SDKROOTFSVARDEPS:class-sdk = "SDK_INCLUDE_ISAR_APT"
do_rootfs_install[vardeps] += "${SDKROOTFSVARDEPS}"
-ROOTFS_POSTPROCESS_COMMAND:remove = "${@'rootfs_cleanup_isar_apt' if d.getVar('SDK_INCLUDE_ISAR_APT') == '1' else ''}"
+ROOTFS_POSTPROCESS_COMMAND:remove = "${@'rootfs_cleanup_isar_apt' if bb.utils.to_boolean(d.getVar('SDK_INCLUDE_ISAR_APT')) else ''}"
# additional SDK steps
-ROOTFS_CONFIGURE_COMMAND:append:class-sdk = " ${@'rootfs_configure_isar_apt_dir' if d.getVar('SDK_INCLUDE_ISAR_APT') == '1' else ''}"
+ROOTFS_CONFIGURE_COMMAND:append:class-sdk = " ${@'rootfs_configure_isar_apt_dir' if bb.utils.to_boolean(d.getVar('SDK_INCLUDE_ISAR_APT')) else ''}"
rootfs_configure_isar_apt_dir() {
# Copy isar-apt instead of mounting:
sudo cp -Trpfx --reflink=auto ${REPO_ISAR_DIR}/${DISTRO} ${ROOTFSDIR}/isar-apt
@@ -158,7 +158,7 @@ INHERIT += "isar-events sstate"
# Buildstats requires IMAGE_ROOTFS to be always defined
IMAGE_ROOTFS ??= "${WORKDIR}/rootfs"
-INHERIT += "${@'buildstats' if d.getVar('USE_BUILDSTATS') == '1' else ''}"
+INHERIT += "${@'buildstats' if bb.utils.to_boolean(d.getVar('USE_BUILDSTATS')) else ''}"
# Default values for ccache
USE_CCACHE ??= "0"
@@ -10,9 +10,9 @@ FILESPATH:append := ":${FILE_DIRNAME}/files"
DESCRIPTION ?= "Custom U-Boot"
PROVIDES += "u-boot-${MACHINE} u-boot-${MACHINE}-dev"
-PROVIDES += "${@'u-boot-tools' if d.getVar('U_BOOT_TOOLS_PACKAGE') == '1' else ''}"
+PROVIDES += "${@'u-boot-tools' if bb.utils.to_boolean(d.getVar('U_BOOT_TOOLS_PACKAGE')) else ''}"
PROVIDES += "${@('u-boot-config u-boot-' + d.getVar('MACHINE') + '-config') \
- if d.getVar('U_BOOT_CONFIG_PACKAGE') == '1' else ''}"
+ if bb.utils.to_boolean(d.getVar('U_BOOT_CONFIG_PACKAGE')) else ''}"
inherit dpkg
@@ -26,9 +26,9 @@ DEPLOY_ISAR_BOOTSTRAP ?= ""
DISTRO_BOOTSTRAP_BASE_PACKAGES = "locales"
DISTRO_BOOTSTRAP_BASE_PACKAGES:append:gnupg = ",gnupg"
DISTRO_BOOTSTRAP_BASE_PACKAGES:append:https-support = ",ca-certificates"
-DISTRO_VARS_PREFIX ?= "${@'HOST_' if d.getVar('BOOTSTRAP_FOR_HOST') == '1' else ''}"
-BOOTSTRAP_DISTRO = "${@d.getVar('HOST_DISTRO' if d.getVar('BOOTSTRAP_FOR_HOST') == '1' else 'DISTRO')}"
-BOOTSTRAP_BASE_DISTRO = "${@d.getVar('HOST_BASE_DISTRO' if d.getVar('BOOTSTRAP_FOR_HOST') == '1' else 'BASE_DISTRO')}"
+DISTRO_VARS_PREFIX ?= "${@'HOST_' if bb.utils.to_boolean(d.getVar('BOOTSTRAP_FOR_HOST')) else ''}"
+BOOTSTRAP_DISTRO = "${@d.getVar('HOST_DISTRO' if bb.utils.to_boolean(d.getVar('BOOTSTRAP_FOR_HOST')) else 'DISTRO')}"
+BOOTSTRAP_BASE_DISTRO = "${@d.getVar('HOST_BASE_DISTRO' if bb.utils.to_boolean(d.getVar('BOOTSTRAP_FOR_HOST')) else 'BASE_DISTRO')}"
FILESEXTRAPATHS:append = ":${BBPATH}"
inherit deb-dl-dir
@@ -11,5 +11,5 @@ require sbuild-chroot.inc
SBUILD_CHROOT_PREINSTALL ?= " \
${SBUILD_CHROOT_PREINSTALL_COMMON} \
- ${@' apt-utils' if d.getVar('ISAR_ENABLE_COMPAT_ARCH') == '1' else ''} \
+ ${@' apt-utils' if bb.utils.to_boolean(d.getVar('ISAR_ENABLE_COMPAT_ARCH')) else ''} \
"
@@ -27,7 +27,7 @@ python() {
d.appendVar('SBUILD_CHROOT_PREINSTALL_COMMON',
' libstdc++-{}-dev:{}'.format(distro_gcc, distro_arch))
- if d.getVar('ISAR_ENABLE_COMPAT_ARCH') == '1':
+ if bb.utils.to_boolean(d.getVar('ISAR_ENABLE_COMPAT_ARCH')):
compat_arch = d.getVar('COMPAT_DISTRO_ARCH')
d.appendVar('SBUILD_CHROOT_COMPAT_PREINSTALL',
' libc6-dev:{}'.format(compat_arch))
@@ -47,7 +47,7 @@ SBUILD_CHROOT_PREINSTALL_COMMON = " \
fakeroot \
build-essential \
debhelper \
- ${@ 'ccache' if d.getVar('USE_CCACHE') == '1' else ''} \
+ ${@ 'ccache' if bb.utils.to_boolean(d.getVar('USE_CCACHE')) else ''} \
devscripts \
equivs \
"
@@ -44,7 +44,7 @@ KSELFTEST_SKIP_TARGETS ?= ""
KSELFTEST_FORCE_TARGETS ?= "0"
KSELFTEST_ARGS = "${@ "TARGETS=\"${KSELFTEST_TARGETS}\"" if d.getVar('KSELFTEST_TARGETS') else ''}"
-KSELFTEST_ARGS .= "${@ " FORCE_TARGETS=1" if d.getVar('KSELFTEST_FORCE_TARGETS') == '1' else ''}"
+KSELFTEST_ARGS .= "${@ " FORCE_TARGETS=1" if bb.utils.to_boolean(d.getVar('KSELFTEST_FORCE_TARGETS')) else ''}"
KSELFTEST_ARGS .= "${@ " SKIP_TARGETS=\"${KSELFTEST_SKIP_TARGETS}\"" if d.getVar('KSELFTEST_SKIP_TARGETS') else ''}"
do_prepare_build[cleandirs] += "${S}/debian"
@@ -139,7 +139,7 @@ def config_fragments(d):
def get_additional_build_profiles(d):
profiles = d.getVar('BASE_DISTRO')
- if d.getVar('KERNEL_LIBC_DEV_DEPLOY') != '1':
+ if not bb.utils.to_boolean(d.getVar('KERNEL_LIBC_DEV_DEPLOY')):
profiles += ' nolibcdev'
return profiles
When comparing user-defined boolean variables (e.g. ENABLE_<FOO>), a comparison against the string "0" or "1" is error-prone, as the user might use other strings which also denote True / False. For that, bitbake offers the bb.utils.to_boolean function. This patch refactors all these patterns which are in scope of ISAR. The parts which are copied from OE are not touched, as well as the WIC plugins. Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> --- meta-isar/recipes-app/hello/hello.bb | 2 +- meta/classes/base.bbclass | 6 +++--- meta/classes/compat.bbclass | 2 +- meta/classes/crossvars.bbclass | 4 ++-- meta/classes/dpkg-base.bbclass | 6 +++--- meta/classes/imagetypes_container.bbclass | 2 +- meta/classes/imagetypes_wic.bbclass | 4 ++-- meta/classes/multiarch.bbclass | 2 +- meta/classes/patch.bbclass | 4 ++-- meta/classes/sdk.bbclass | 6 +++--- meta/conf/bitbake.conf | 2 +- meta/recipes-bsp/u-boot/u-boot-custom.inc | 4 ++-- meta/recipes-core/isar-bootstrap/isar-bootstrap.inc | 6 +++--- meta/recipes-devtools/sbuild-chroot/sbuild-chroot-target.bb | 2 +- meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc | 4 ++-- meta/recipes-kernel/kselftest/kselftest.inc | 2 +- meta/recipes-kernel/linux/linux-custom.inc | 2 +- 17 files changed, 30 insertions(+), 30 deletions(-)