From 3a7a12ba4719adb4ced38ad702f7facd05539f6b Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 10 Nov 2016 14:15:49 +0100 Subject: [PATCH 01/15] classes/sysvinit.oeclass: prepare for USE flag semantics change Currently, setting MACHINE_USE_foo_sysvinit_stop = "0" means the USE_foo_sysvinit_stop variable ends up being unset rather than having the value "0". This is counter-intuitive, so we'll change that later. To prepare for that while preserving back- and forward-compatibility, make the documented way to disable the start/stop script to set the value to the token False. Inside do_install_sysvinit, we recognize anything that is False in the eyes of python as well as the legacy string "0". After that, anything other than a two-digit string is a user error, and we don't do anybody any services by silently ignoring that. Because of the huge semantic difference between "0" and "00", and because False conveys the intention much better than any string value would, people are strongly encouraged to update their recipes, distro and machine configs etc. to use False instead of "0". Since the current OE-lite lexer internally translates the token False to the string "0", this can be safely be done with or without a meta/core containing this patch. --- classes/sysvinit.oeclass | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/classes/sysvinit.oeclass b/classes/sysvinit.oeclass index a75ca56b..8b817741 100644 --- a/classes/sysvinit.oeclass +++ b/classes/sysvinit.oeclass @@ -7,7 +7,13 @@ ## (declare this to RECIPE_FLAGS) ## SYSVINIT_SCRIPT_ Set this to the name of your initscript. ## _sysvinit_start Set this to the start level. -## _sysvinit_stop (optional) Set this to the stop level. +## _sysvinit_stop Set this to the stop level. +## +## The level must be a two-digit string. To omit the start/stop +## script, set _sysvinit_start / _sysvinit_stop to False, e.g. +## +## DEFAULT_USE_sshd_sysvinit_stop = False ## ## @useflag sysvinit Enable or disable sysvinit. Enabled by default by base ## distro conf. @@ -28,6 +34,7 @@ CLASS_FLAGS += "sysvinit" do_install[postfuncs] += "do_install_sysvinit" python do_install_sysvinit () { import os + import re path = d.get("D") os.chdir(path) @@ -49,6 +56,17 @@ python do_install_sysvinit () { prio = d.get("USE_" + option) if not prio: continue + # "0" is the legacy way of disabling, and also what the token + # False currently translates to. + if prio == "0": + continue + + # Anything but a two-digit string (or False, or "0") is a hard + # error. + if not re.match("[0-9][0-9]$", prio): + bb.error("Invalid value of 'USE_%s': %s" % (option, prio)) + bb.error("Must be two-digit string or False") + return False if start_symlink: name = option[0:-len("_sysvinit_start")] From a93584ff9ff59ca867403930a4a908cd40a026f6 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 10 Nov 2016 15:09:28 +0100 Subject: [PATCH 02/15] oelite/cookbook.py: preserve meaning of setting USE flag to 0 With the proposed change to useflags.oeclass, we will end up setting a bunch of previously undefined USE_* variables to 0. We need to keep treating that as a false value. --- lib/oelite/cookbook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oelite/cookbook.py b/lib/oelite/cookbook.py index 739faa09..e0dadb44 100644 --- a/lib/oelite/cookbook.py +++ b/lib/oelite/cookbook.py @@ -664,7 +664,7 @@ def compatible_use_flags(meta): return True for name in flags.split(): val = meta.get("USE_"+name) - if not val: + if not val or val == "0": debug("skipping %s:%s_%s (required %s USE flag not set)"%( recipe_type, meta.get("PN"), meta.get("PV"), name)) From 944d4fb176e4a4ee4028417361f9f5218d4a0338 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 09:28:26 +0100 Subject: [PATCH 03/15] classes/crontab.oeclass: only invoke do_install_crontab if USE_crontab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One cannot combine flag and override assignments, so the most "obvious" thing do_install[postfuncs]:>USE_crontab += " do_install_crontab" doesn't work. Instead, two different idioms for achieving the same thing can be found: (a) what is done here, unconditionally add the postfunc, but then do an early return if the USE flag is not set. (b) use an intermediate variable which is empty by default but has an override assignment conditional - this is e.g. found in u-boot.oeclass. With my intended change of USE flag semantics, idiom (a) will break when the USE flag has the value "0", since that string is considered true in python. Instead of adding ugly »... and foo != "0"«, use this opportunity to standardize on idiom (b). I believe that is also slightly more correct, since it avoids potentially confusing "running postfunc do_install_crontab" in do_install.log when the user knows he disabled USE_crontab. --- classes/crontab.oeclass | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/classes/crontab.oeclass b/classes/crontab.oeclass index 66114447..2d1a8abf 100644 --- a/classes/crontab.oeclass +++ b/classes/crontab.oeclass @@ -13,13 +13,12 @@ require conf/crontab.conf CRONTAB_DEPENDS = " crond" RDEPENDS_${PN}:>USE_crontab = "${CRONTAB_DEPENDS}" -do_install[postfuncs] += "do_install_crontab" +DO_INSTALL_CRONTAB = "" +DO_INSTALL_CRONTAB:USE_crontab = "do_install_crontab" +do_install[postfuncs] += "${DO_INSTALL_CRONTAB}" python do_install_crontab () { import os - if not d.get('USE_crontab'): - return - options = ((d.get('RECIPE_FLAGS') or "").split() + (d.get('CLASS_FLAGS') or "").split()) ddir = d.get('D') From 48e9180d7efdac062b01634902b36dddcdb85e6e Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 09:45:10 +0100 Subject: [PATCH 04/15] classes/runit.oeclass: change conditional postfunc idiom See the previous patch (classes/crontab.oeclass) for the rationale. Anthing that breaks because it relied on this postfunc getting run and doing the os.chdir before the early return really deserves to break, and can at best be used as /dev/urandom fodder. --- classes/runit.oeclass | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/classes/runit.oeclass b/classes/runit.oeclass index 9ee87492..53543359 100644 --- a/classes/runit.oeclass +++ b/classes/runit.oeclass @@ -18,15 +18,14 @@ CLASS_FLAGS += "runit" RDEPENDS_RUNIT ?= "runit" RDEPENDS_${PN}:>USE_runit = " ${RDEPENDS_RUNIT}" -do_install[postfuncs] += "do_install_runit" +DO_INSTALL_RUNIT = "" +DO_INSTALL_RUNIT:USE_runit = "do_install_runit" +do_install[postfuncs] += "${DO_INSTALL_RUNIT}" python do_install_runit () { import stat path = d.get("D") os.chdir(path) - if not bb.data.getVar('USE_runit', d, True): - return - options = ((d.get("RECIPE_FLAGS") or "").split() + (d.get("CLASS_FLAGS") or "").split()) runitservicedir = bb.data.getVar('runitservicedir', d, True) From a685a2535f8a508997c1add82054ab1bf74099ea Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 09:58:13 +0100 Subject: [PATCH 05/15] classes/sysvinit.oeclass: only invoke do_install_sysvinit if USE_sysvinit See previous patches for rationale. --- classes/sysvinit.oeclass | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/sysvinit.oeclass b/classes/sysvinit.oeclass index 8b817741..cea348f5 100644 --- a/classes/sysvinit.oeclass +++ b/classes/sysvinit.oeclass @@ -31,15 +31,15 @@ RDEPENDS_${PN}:>USE_sysvinit = " ${RDEPENDS_SYSVINIT}" CLASS_FLAGS += "sysvinit" -do_install[postfuncs] += "do_install_sysvinit" +DO_INSTALL_SYSVINIT = "" +DO_INSTALL_SYSVINIT:USE_sysvinit = "do_install_sysvinit" +do_install[postfuncs] += "${DO_INSTALL_SYSVINIT}" python do_install_sysvinit () { import os import re path = d.get("D") os.chdir(path) - if not d.get("USE_sysvinit"): - return options = ((d.get("RECIPE_FLAGS") or "").split() + (d.get("CLASS_FLAGS") or "").split()) From c494da31120eca9f2c3f59ff6ea24e80ddb70efc Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 10:56:42 +0100 Subject: [PATCH 06/15] classes/chrpath.oeclass: use True instead of "1" The parser ensures this is a no-op, but using True serves as documentation that this really is a boolean flag, and not something where the string value is used. It also prepares for a possibly distant future or alternate universe where the parser actually stores the Python object True when meeting the token True. --- classes/chrpath.oeclass | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/chrpath.oeclass b/classes/chrpath.oeclass index 8653a211..c5366d04 100644 --- a/classes/chrpath.oeclass +++ b/classes/chrpath.oeclass @@ -18,12 +18,12 @@ CHRPATH_DIRS = "${base_bindir} ${bindir} ${base_sbindir} ${sbindir} \ CHRPATH_REPLACE_DIRS = "${CHRPATH_DIRS}" CHRPATH_STRIP_DIRS = "" -## @useflag chrpath_machine_strip When this flag is set, rpaths will be -## stripped from elf files of machine recipes. When this flag is not -## set, rpath in elf files of machine recipes will be replaced with +## @useflag chrpath_machine_strip When this flag is True, rpaths will be +## stripped from elf files of machine recipes. When this flag is +## False, rpath in elf files of machine recipes will be replaced with ## $ORIGIN relative paths. CLASS_FLAGS += "chrpath_machine_strip" -DEFAULT_USE_chrpath_machine_strip = "1" +DEFAULT_USE_chrpath_machine_strip = True MACHINE_CHRPATH_REPLACE_DIRS:USE_chrpath_machine_strip = "" MACHINE_CHRPATH_STRIP_DIRS:USE_chrpath_machine_strip = "${CHRPATH_DIRS}" MACHINE_CHRPATH_REPLACE_DIRS = "${CHRPATH_DIRS}" From 6d97f8144e9d8e1bb9e2e5f9ee06bd21a9c68a84 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 11:00:10 +0100 Subject: [PATCH 07/15] classes/cpio-image.oeclass: use False instead of "0" --- classes/cpio-image.oeclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/cpio-image.oeclass b/classes/cpio-image.oeclass index e2c501d5..4ae60494 100644 --- a/classes/cpio-image.oeclass +++ b/classes/cpio-image.oeclass @@ -13,7 +13,7 @@ inherit image image_mdev image_inetd image_crontab image_makedevs image_inittab CLASS_FLAGS += "ramdisk_image \ ramdisk_image_name ramdisk_image_compression" -DEFAULT_USE_ramdisk_image = "0" +DEFAULT_USE_ramdisk_image = False DEFAULT_USE_ramdisk_image_name = "${IMAGE_BASENAME}" DEFAULT_USE_ramdisk_image_compression = "none" From b785c5dd68560116e8e0ebf679aac4feb33ab911 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 11:01:26 +0100 Subject: [PATCH 08/15] classes/gettext.oeclass: use False instead of "0" --- classes/gettext.oeclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/gettext.oeclass b/classes/gettext.oeclass index cf03e753..c40d6736 100644 --- a/classes/gettext.oeclass +++ b/classes/gettext.oeclass @@ -13,7 +13,7 @@ DEPENDS_GETTEXT_NLS:USE_nls = "${DEPENDS_GETTEXT}" DEPENDS_GETTEXT = "host:gettext native:gettext-utils host:libiconv host:libintl" CLASS_FLAGS += "nls" -DEFAULT_USE_nls = "0" +DEFAULT_USE_nls = False EXTRA_OECONF_GETTEXT = "--disable-nls" EXTRA_OECONF_GETTEXT:USE_nls = "--enable-nls" From 8ee08bb080840395152d667337ad3bdaae555813 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 11:04:42 +0100 Subject: [PATCH 09/15] classes/kernel.oeclass: use False instead of "0" This is a boolean flag, so use a boolean token instead of a string. Currently a no-op due to the OE-lite lexer/parser, but nevertheless serves as documentation. --- classes/kernel.oeclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/kernel.oeclass b/classes/kernel.oeclass index ad914da6..fdd24b74 100644 --- a/classes/kernel.oeclass +++ b/classes/kernel.oeclass @@ -195,7 +195,7 @@ KERNEL_UIMAGE_DEPENDS = "${@['', 'native:util/mkimage']['${USE_kernel_imagetype} CLASS_FLAGS += "kernel_uimage \ kernel_uimage_entrypoint kernel_uimage_loadaddress kernel_uimage_name" KERNEL_UIMAGE_DEPENDS:USE_kernel_uimage = "native:util/mkimage" -DEFAULT_USE_kernel_uimage = "0" +DEFAULT_USE_kernel_uimage = False DEFAULT_USE_kernel_uimage_name = "${DISTRO}/${PV}/${MACHINE}" KERNEL_COMPILE_POSTFUNCS:>USE_kernel_uimage = " do_compile_kernel_uimage" From aa89a7f2753bab3f28ffc73bad97b2fe425f7581 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 11:06:58 +0100 Subject: [PATCH 10/15] classes/sdk-image.oeclass: use True instead of "1" Using the token True serves as documentation that these are really boolean flags. --- classes/sdk-image.oeclass | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/sdk-image.oeclass b/classes/sdk-image.oeclass index d8ab9a54..ae867fcf 100644 --- a/classes/sdk-image.oeclass +++ b/classes/sdk-image.oeclass @@ -66,19 +66,19 @@ RDEPENDS_SDK_LIBC_EXTRA = "target:libnss-files-dev target:libnss-dns-dev" RDEPENDS_SDK_LIBC_EXTRA:TARGET_LIBC_uclibc = "" CLASS_FLAGS += "sdk_cxx" -DEFAULT_USE_sdk_cxx = "1" +DEFAULT_USE_sdk_cxx = True RDEPENDS_SDK += "${RDEPENDS_SDK_CXX}" RDEPENDS_SDK_CXX = "" RDEPENDS_SDK_CXX:USE_sdk_cxx = "gcc-g++ target:libstdc++-dev" CLASS_FLAGS += "sdk_gdb" -DEFAULT_USE_sdk_gdb = "1" +DEFAULT_USE_sdk_gdb = True RDEPENDS_SDK += "${RDEPENDS_SDK_GDB}" RDEPENDS_SDK_GDB = "" RDEPENDS_SDK_GDB:USE_sdk_gdb = "gdb" CLASS_FLAGS += "sdk_uboot_mkimage" -DEFAULT_USE_sdk_uboot_mkimage = "1" +DEFAULT_USE_sdk_uboot_mkimage = True RDEPENDS_SDK += "${RDEPENDS_SDK_UBOOT_MKIMAGE}" RDEPENDS_SDK_UBOOT_MKIMAGE = "" RDEPENDS_SDK_UBOOT_MKIMAGE:USE_sdk_uboot_mkimage = "${UBOOT_MKIMAGE}" From b31300ddf3b1744753b0f3e3714624c3f937041a Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 11:08:39 +0100 Subject: [PATCH 11/15] conf/distro/uclibc.conf: use boolean tokens to initialize boolean flags The OE-lite lexer/parser in its current form makes this a semantic noop (the strings "0" and "1" are still what gets stored), but this serves as documentation that these are really just meant as boolean flags. --- conf/distro/uclibc.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/distro/uclibc.conf b/conf/distro/uclibc.conf index eaae46d9..2dcfb1a0 100644 --- a/conf/distro/uclibc.conf +++ b/conf/distro/uclibc.conf @@ -6,5 +6,5 @@ def uclinux_arch_fixup(d): if d.get("MACHINE_CPU").startswith("m68k-mcf"): d.set("MACHINE_OS", "uclinux-uclibc") -DISTRO_USE_busybox_ash = "0" -DISTRO_USE_busybox_hush = "1" +DISTRO_USE_busybox_ash = False +DISTRO_USE_busybox_hush = True From f8775a1aaa2626693e46134c71a3dfc39a7c286e Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 11:11:06 +0100 Subject: [PATCH 12/15] conf/fstab.conf: use True rather than "1" --- conf/fstab.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/fstab.conf b/conf/fstab.conf index a974d906..b278fec5 100644 --- a/conf/fstab.conf +++ b/conf/fstab.conf @@ -1,4 +1,4 @@ fstabfixupdir = "${sysconfdir}/fstab.d" CLASS_FLAGS += "fstab" -DEFAULT_USE_fstab = "1" +DEFAULT_USE_fstab = True From ae3b7abc65c1e311f8781f564d99b05bfa0f29ce Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 11:11:33 +0100 Subject: [PATCH 13/15] conf/inittab.conf: use True rather than "1" --- conf/inittab.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/inittab.conf b/conf/inittab.conf index 74837f9c..a5e1affd 100644 --- a/conf/inittab.conf +++ b/conf/inittab.conf @@ -1,4 +1,4 @@ inittabfixupdir = "${sysconfdir}/inittab.d" CLASS_FLAGS += "inittab" -DEFAULT_USE_inittab = "1" +DEFAULT_USE_inittab = True From 23390a38c43f69a6f9edc65e5a87fdb8756a8e44 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 11:13:20 +0100 Subject: [PATCH 14/15] conf/makedevs.conf: use True rather than "1" --- conf/makedevs.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/makedevs.conf b/conf/makedevs.conf index 6c8cf672..4683e041 100644 --- a/conf/makedevs.conf +++ b/conf/makedevs.conf @@ -11,4 +11,4 @@ devtabledir = "${sysconfdir}/devtable.d" MAKDEVS_FILES ?= "" CLASS_FLAGS += "makedevs" -DEFAULT_USE_makedevs = "1" +DEFAULT_USE_makedevs = True From 31c7db1b65c1231d6408be18f4cf8cbf06d90d4a Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 11 Nov 2016 11:18:50 +0100 Subject: [PATCH 15/15] base-version.oe: use True rather than "1" USE_basefiles_manifest_version is a boolean flag, unlike for example USE_basefiles_version, which is expected to be a filename (i.e., a string). --- recipes/base-version/base-version.oe | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/base-version/base-version.oe b/recipes/base-version/base-version.oe index b5d802d2..0062e098 100644 --- a/recipes/base-version/base-version.oe +++ b/recipes/base-version/base-version.oe @@ -35,7 +35,7 @@ OESTACK_VERSION[nohash] = "1" RECIPE_FLAGS += "basefiles_manifest_version" BASE_VERSION:USE_basefiles_manifest_version = "${OESTACK_VERSION}" -DEFAULT_USE_basefiles_manifest_version = "1" +DEFAULT_USE_basefiles_manifest_version = True RECIPE_FLAGS += "basefiles_version" BASE_VERSION_POSTFUNCS:>USE_basefiles_version = " do_install_basefiles_version"