summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Stergiopoulos <andreas.stergiopoulos@smile.fr>2025-10-13 17:59:51 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-10-16 10:53:10 +0100
commit38bf36294502677bca32171f3f63f36af67b7dec (patch)
tree529a959496674f65ca2f77275d83df9283810404
parent454a237bb9c4416cd7750af58f229c7e9bc12f08 (diff)
downloadpoky-38bf36294502677bca32171f3f63f36af67b7dec.tar.gz
sanity.bbclass: Remove tool version repetition for gcc, patch, git, make, tar
This commit mainly changes the way that error messages are printed when sanity checking for the version numbers of gcc, patch, git, make and tar. It affects the following functions: check_patch_version(), check_make_version(), check_gcc_version(), check_tar_version(), check_git_version() Before this commit, the minimum version number and the error string were hard-coded string literals which the programmer had to maintain manually and independently. With this change, the version is defined once in each function and then used both for checking and for error printing. Additionally, the affected error messages have been made to spill over multiple lines for better source code readability. Link to the relevant discussion: https://lists.openembedded.org/g/openembedded-core/topic/115491380#msg224131 This change has been tested by changing the version string and making sure that the test fails and the proper minimum version is reported in the error message. Suggested-By: Yoann Congal <yoann.congal@smile.fr> (From OE-Core rev: 27a4ce7b34946200e35adfab1ace512a531fc560) Signed-off-by: Andreas Stergiopoulos <andreas.stergiopoulos@smile.fr> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-global/sanity.bbclass32
1 files changed, 22 insertions, 10 deletions
diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass
index 439dc5ad75..6934e071a3 100644
--- a/meta/classes-global/sanity.bbclass
+++ b/meta/classes-global/sanity.bbclass
@@ -434,11 +434,14 @@ def check_sanity_validmachine(sanity_data):
434def check_patch_version(sanity_data): 434def check_patch_version(sanity_data):
435 import re, subprocess 435 import re, subprocess
436 436
437 patch_minimum_version = "2.7"
438
437 try: 439 try:
438 result = subprocess.check_output(["patch", "--version"], stderr=subprocess.STDOUT).decode('utf-8') 440 result = subprocess.check_output(["patch", "--version"], stderr=subprocess.STDOUT).decode('utf-8')
439 version = re.search(r"[0-9.]+", result.splitlines()[0]).group() 441 version = re.search(r"[0-9.]+", result.splitlines()[0]).group()
440 if bb.utils.vercmp_string_op(version, "2.7", "<"): 442 if bb.utils.vercmp_string_op(version, patch_minimum_version, "<"):
441 return "Your version of patch is older than 2.7 and has bugs which will break builds. Please install a newer version of patch.\n" 443 return ("Your version of patch is older than %s and has bugs which will break builds. "
444 "Please install a newer version of patch.\n" % patch_minimum_version)
442 else: 445 else:
443 return None 446 return None
444 except subprocess.CalledProcessError as e: 447 except subprocess.CalledProcessError as e:
@@ -446,6 +449,7 @@ def check_patch_version(sanity_data):
446 449
447# Glibc needs make 4.0 or later, we may as well match at this point 450# Glibc needs make 4.0 or later, we may as well match at this point
448def check_make_version(sanity_data): 451def check_make_version(sanity_data):
452 make_minimum_version = "4.0"
449 import subprocess 453 import subprocess
450 454
451 try: 455 try:
@@ -453,8 +457,8 @@ def check_make_version(sanity_data):
453 except subprocess.CalledProcessError as e: 457 except subprocess.CalledProcessError as e:
454 return "Unable to execute make --version, exit code %d\n%s\n" % (e.returncode, e.output) 458 return "Unable to execute make --version, exit code %d\n%s\n" % (e.returncode, e.output)
455 version = result.split()[2] 459 version = result.split()[2]
456 if bb.utils.vercmp_string_op(version, "4.0", "<"): 460 if bb.utils.vercmp_string_op(version, make_minimum_version, "<"):
457 return "Please install a make version of 4.0 or later.\n" 461 return "Please install a make version of %s or later.\n" % make_minimum_version
458 462
459 if bb.utils.vercmp_string_op(version, "4.2.1", "=="): 463 if bb.utils.vercmp_string_op(version, "4.2.1", "=="):
460 distro = oe.lsb.distro_identifier() 464 distro = oe.lsb.distro_identifier()
@@ -511,9 +515,12 @@ def check_userns():
511# built buildtools-extended-tarball) 515# built buildtools-extended-tarball)
512# 516#
513def check_gcc_version(sanity_data): 517def check_gcc_version(sanity_data):
518 gcc_minimum_version = "10.1"
514 version = oe.utils.get_host_gcc_version(sanity_data) 519 version = oe.utils.get_host_gcc_version(sanity_data)
515 if bb.utils.vercmp_string_op(version, "10.1", "<"): 520 if bb.utils.vercmp_string_op(version, gcc_minimum_version, "<"):
516 return "Your version of gcc is older than 10.1 and will break builds. Please install a newer version of gcc (you could use the project's buildtools-extended-tarball or use scripts/install-buildtools).\n" 521 return ("Your version of gcc is older than %s and will break builds. Please install a newer "
522 "version of gcc (you could use the project's buildtools-extended-tarball or use "
523 "scripts/install-buildtools).\n" % gcc_minimum_version)
517 return None 524 return None
518 525
519# Tar version 1.24 and onwards handle overwriting symlinks correctly 526# Tar version 1.24 and onwards handle overwriting symlinks correctly
@@ -521,6 +528,7 @@ def check_gcc_version(sanity_data):
521# Version 1.28 is needed so opkg-build works correctly when reproducible builds are enabled 528# Version 1.28 is needed so opkg-build works correctly when reproducible builds are enabled
522# Gtar is assumed at to be used as tar in poky 529# Gtar is assumed at to be used as tar in poky
523def check_tar_version(sanity_data): 530def check_tar_version(sanity_data):
531 tar_minimum_version = "1.28"
524 import subprocess 532 import subprocess
525 try: 533 try:
526 result = subprocess.check_output(["tar", "--version"], stderr=subprocess.STDOUT).decode('utf-8') 534 result = subprocess.check_output(["tar", "--version"], stderr=subprocess.STDOUT).decode('utf-8')
@@ -529,8 +537,10 @@ def check_tar_version(sanity_data):
529 if not "GNU" in result: 537 if not "GNU" in result:
530 return "Your version of tar is not gtar. Please install gtar (you could use the project's buildtools-tarball from our last release or use scripts/install-buildtools).\n" 538 return "Your version of tar is not gtar. Please install gtar (you could use the project's buildtools-tarball from our last release or use scripts/install-buildtools).\n"
531 version = result.split()[3] 539 version = result.split()[3]
532 if bb.utils.vercmp_string_op(version, "1.28", "<"): 540 if bb.utils.vercmp_string_op(version, tar_minimum_version, "<"):
533 return "Your version of tar is older than 1.28 and does not have the support needed to enable reproducible builds. Please install a newer version of tar (you could use the project's buildtools-tarball from our last release or use scripts/install-buildtools).\n" 541 return ("Your version of tar is older than %s and does not have the support needed to enable reproducible "
542 "builds. Please install a newer version of tar (you could use the project's buildtools-tarball from "
543 "our last release or use scripts/install-buildtools).\n" % tar_minimum_version)
534 544
535 try: 545 try:
536 result = subprocess.check_output(["tar", "--help"], stderr=subprocess.STDOUT).decode('utf-8') 546 result = subprocess.check_output(["tar", "--help"], stderr=subprocess.STDOUT).decode('utf-8')
@@ -545,14 +555,16 @@ def check_tar_version(sanity_data):
545# The kernel tools assume git >= 1.8.3.1 (verified needed > 1.7.9.5) see #6162 555# The kernel tools assume git >= 1.8.3.1 (verified needed > 1.7.9.5) see #6162
546# The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped 556# The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped
547def check_git_version(sanity_data): 557def check_git_version(sanity_data):
558 git_minimum_version = "1.8.3.1"
548 import subprocess 559 import subprocess
549 try: 560 try:
550 result = subprocess.check_output(["git", "--version"], stderr=subprocess.DEVNULL).decode('utf-8') 561 result = subprocess.check_output(["git", "--version"], stderr=subprocess.DEVNULL).decode('utf-8')
551 except subprocess.CalledProcessError as e: 562 except subprocess.CalledProcessError as e:
552 return "Unable to execute git --version, exit code %d\n%s\n" % (e.returncode, e.output) 563 return "Unable to execute git --version, exit code %d\n%s\n" % (e.returncode, e.output)
553 version = result.split()[2] 564 version = result.split()[2]
554 if bb.utils.vercmp_string_op(version, "1.8.3.1", "<"): 565 if bb.utils.vercmp_string_op(version, git_minimum_version, "<"):
555 return "Your version of git is older than 1.8.3.1 and has bugs which will break builds. Please install a newer version of git.\n" 566 return ("Your version of git is older than %s and has bugs which will break builds. "
567 "Please install a newer version of git.\n" % git_minimum_version)
556 return None 568 return None
557 569
558# Check the required perl modules which may not be installed by default 570# Check the required perl modules which may not be installed by default