check-version-mismatch.bbclass: avoid single '(' in version output
PATCH 1/7 check-version-mismatch.bbclass: avoid single '(' in version output
From: Chen Qi <[email protected]>
Avoid a single '(' in version. For example, we want to extract the '2.30.31' instead of '2.30.31(2' for lvm2.
--- meta-oe/classes/check-version-mismatch.bbclass | 2 ++ 1 file changed, 2 insertions(+)
meta-oe/classes/check-version-mismatch.bbclass +2 -0
@@ -93,6 +93,8 @@ python do_package_check_version_mismatch() { version = version[1:] if version.endswith(")") and "(" not in version: version = version[:-1] + if not version.endswith(")") and "(" in version: + version = version.split('(')[0] # handle extra version info version = version + match.group("extra") + match.group("extra2") possible_versions.append(version)
Signature · 1 line
2.49.0
PATCH 2/7 check-version-mismatch.bbclass: avoid meaningless checking
From: Chen Qi <[email protected]>
If users set CHECK_VERSION_PN for a recipe and its value is a single '%', then it matches anything. So there's no point doing any further check.
--- meta-oe/classes/check-version-mismatch.bbclass | 8 ++++++++ 1 file changed, 8 insertions(+)
meta-oe/classes/check-version-mismatch.bbclass +8 -0
@@ -205,6 +205,14 @@ python do_package_check_version_mismatch() { os.makedirs(debug_directory, exist_ok=True) data_lines.append("pv: %s\n" % pv) + # handle a special case: a pure % means matching all, no point in further checking + if pv == "%": + if enable_debug: + data_lines.append("FINAL RESULT: MATCH (%s matches all, skipped)\n\n" % pv) + with open(debug_data_file, "w") as f: + f.writelines(data_lines) + return + got_quick_match_result = False # handle python3-xxx recipes quickly __regex_python_module_version__ = re.compile(r"(?:^|.*:)Version: (?P<version>.*)$")
Signature · 1 line
2.49.0
PATCH 3/7 conf/version-check.conf: skip piglit
In reply to [email protected]From: Chen Qi <[email protected]>
piglit is an open-source test suite for OpenGL implementations. It contains a whole lot of programs which all do not give out any version information. Running version check for piglit is a waste of time (~1h), so setting a '%' to skip it.
--- meta-oe/conf/version-check.conf | 1 + 1 file changed, 1 insertion(+)
meta-oe/conf/version-check.conf +1 -0
@@ -13,6 +13,7 @@ CHECK_VERSION_PV:pn-vim-tiny = "${@'.'.join(d.getVar('PV').split('.')[:-1])}" CHECK_VERSION_PV:pn-ncurses = "${PV}.%" CHECK_VERSION_PV:pn-alsa-tools = "%" CHECK_VERSION_PV:pn-gst-examples = "%" +CHECK_VERSION_PV:pn-piglit = "%" CHECK_VERSION_PV:pn-libedit = "${@d.getVar('PV').split('-')[1]}" # meta-oe
Signature · 1 line
2.49.0
PATCH 4/7 check-version-mismatch.bbclass: ensure sysroot is available
In reply to [email protected]From: Chen Qi <[email protected]>
We need to ensure sysroot is available for this version check task, otherwise, running binaries might fail because of lack of libraries from sysroot.
--- meta-oe/classes/check-version-mismatch.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta-oe/classes/check-version-mismatch.bbclass +1 -1
@@ -393,7 +393,7 @@ python do_package_check_version_mismatch() { bb.debug(1, "No stale process") } -addtask do_package_check_version_mismatch after do_package before do_build +addtask do_package_check_version_mismatch after do_prepare_recipe_sysroot do_package before do_build do_build[rdeptask] += "do_package_check_version_mismatch" do_rootfs[recrdeptask] += "do_package_check_version_mismatch"
Signature · 1 line
2.49.0
PATCH 5/7 check-version-mismatch.bbclass: handle non-elf executables
In reply to [email protected]From: Chen Qi <[email protected]>
Using qemu to run non-elf executables such as shell scripts directly is destined to fail. In such case, we check its interperter and try out best to run it accordingly.
We'll also need to skip the "/etc" directory as files under it are configuration files and init scripts. And the init script will send SIGTERM and SIGKILL to all processes, giving users annoying behavior.
--- .../classes/check-version-mismatch.bbclass | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+)
meta-oe/classes/check-version-mismatch.bbclass +60 -0
@@ -11,6 +11,7 @@ python do_package_check_version_mismatch() { import subprocess import shutil import signal + import glob classes_skip = ["nopackage", "image", "native", "cross", "crosssdk", "cross-canadian"] for cs in classes_skip:
@@ -171,6 +172,42 @@ python do_package_check_version_mismatch() { else: return True + def is_elf_binary(fexec): + fexec_real = os.path.realpath(fexec) + elf = oe.qa.ELFFile(fexec_real) + try: + elf.open() + elf.close() + return True + except: + return False + + def get_shebang(fexec): + try: + with open(fexec, 'r') as f: + first_line = f.readline().strip() + if first_line.startswith("#!"): + return first_line + else: + return None + except Exception as e: + return None + + def get_interpreter_from_shebang(shebang): + if not shebang: + return None + hosttools_path = d.getVar("TMPDIR") + "/hosttools" + if "/sh" in shebang: + return hosttools_path + "/sh" + elif "/bash" in shebang: + return hosttools_path + "/bash" + elif "python" in shebang: + return hosttools_path + "/python3" + elif "perl" in shebang: + return hosttools_path + "/perl" + else: + return None + # helper function to get PKGV, useful for recipes such as perf def get_pkgv(pn): pkgdestwork = d.getVar("PKGDESTWORK")
@@ -273,6 +310,9 @@ python do_package_check_version_mismatch() { return skipped_directories = [".debug", "ptest", "installed-tests", "tests", "test", "__pycache__", "testcases"] + # avoid checking configuration files, they don't give useful version information and some init scripts + # will kill all processes + skipped_directories.append("etc") pkgd_libdir = pkgd + d.getVar("libdir") pkgd_base_libdir = pkgd + d.getVar("base_libdir") extra_exec_libdirs = []
@@ -310,8 +350,28 @@ python do_package_check_version_mismatch() { # first we extend qemu_exec to include library path if needed if extra_exec_libdirs: qemu_exec += ":" + ":".join(extra_exec_libdirs) + orig_qemu_exec = qemu_exec for fexec in executables: + qemu_exec = orig_qemu_exec for version_option in ["--version", "-V", "-v", "--help"]: + if not is_elf_binary(fexec): + shebang = get_shebang(fexec) + interpreter = get_interpreter_from_shebang(shebang) + if not interpreter: + bb.debug(1, "file %s is not supported to run" % fexec) + elif interpreter.endswith("perl"): + perl5lib_extra = pkgd + d.getVar("libdir") + "/perl5/site_perl" + for p in glob.glob("%s/usr/share/*" % pkgd): + perl5lib_extra += ":%s" % p + qemu_exec += " -E PERL5LIB=%s:$PERL5LIB %s" % (perl5lib_extra, interpreter) + elif interpreter.endswith("python3"): + pythonpath_extra = glob.glob("%s%s/python3*/site-packages" % (pkgd, d.getVar("libdir"))) + if pythonpath_extra: + qemu_exec += " -E PYTHONPATH=%s:$PYTHONPATH %s" % (pythonpath_extra[0], interpreter) + else: + qemu_exec += " %s" % interpreter + # remove the '-E LD_LIBRARY_PATH=xxx' + qemu_exec = re.sub(r"-E\s+LD_LIBRARY_PATH=\S+", "", qemu_exec) version_check_cmd_full = "%s %s %s" % (qemu_exec, fexec, version_option) version_check_cmd = version_check_cmd_full #version_check_cmd = "%s %s" % (os.path.relpath(fexec, pkgd), version_option)
Signature · 1 line
2.49.0
PATCH 6/7 conf/version-check.conf: skip version check for a few recipes
In reply to [email protected]From: Chen Qi <[email protected]>
Now check-version-mismatch.bbclass can check scripts' output beside elf binaries output. We need to skip a few recipe. These recipes' scripts give some version information, but they are version information of scripts themselves instead of the package. There's no executable in these packages that can give out useful version information.
--- meta-oe/conf/version-check.conf | 5 +++++ 1 file changed, 5 insertions(+)
meta-oe/conf/version-check.conf +5 -0
@@ -14,6 +14,11 @@ CHECK_VERSION_PV:pn-ncurses = "${PV}.%" CHECK_VERSION_PV:pn-alsa-tools = "%" CHECK_VERSION_PV:pn-gst-examples = "%" CHECK_VERSION_PV:pn-piglit = "%" +CHECK_VERSION_PV:pn-kernel-devsrc = "%" +CHECK_VERSION_PV:pn-qemuwrapper-cross = "%" +CHECK_VERSION_PV:pn-gnu-config = "%" +CHECK_VERSION_PV:pn-sysvinit-inittab = "%" +CHECK_VERSION_PV:pn-opkg-utils = "%" CHECK_VERSION_PV:pn-libedit = "${@d.getVar('PV').split('-')[1]}" # meta-oe
Signature · 1 line
2.49.0
PATCH 7/7 check-version-mismatch.bbclass: skip go/src directory
In reply to [email protected]From: Chen Qi <[email protected]>
Files under it are source files. And if go/src locate under /usr/lib, this will result in very long LD_LIBRARY_PATH causing failure.
--- meta-oe/classes/check-version-mismatch.bbclass | 1 + 1 file changed, 1 insertion(+)
meta-oe/classes/check-version-mismatch.bbclass +1 -0
@@ -313,6 +313,7 @@ python do_package_check_version_mismatch() { # avoid checking configuration files, they don't give useful version information and some init scripts # will kill all processes skipped_directories.append("etc") + skipped_directories.append("go/src") pkgd_libdir = pkgd + d.getVar("libdir") pkgd_base_libdir = pkgd + d.getVar("base_libdir") extra_exec_libdirs = []
Signature · 1 line
2.49.0