diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-26 16:31:17 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-29 23:07:13 +0000 |
commit | f0627490711f29f0e308a0afc4fc4f8e54f58dec (patch) | |
tree | f49726d00a0643813151df56f386efa4665be926 /meta/classes | |
parent | 1dbcdfcdf8dd367b0b0440ba8ea7b79ac85a1a37 (diff) | |
download | poky-f0627490711f29f0e308a0afc4fc4f8e54f58dec.tar.gz |
sanity/lib: Replace usage of LooseVersion() with bb.utils.vercmp_string_op()
distutils is going away and we have functionality in bitbake which can
handle these comparisions so switch to the bb.utils function.
(From OE-Core rev: fe624b520e6c75e16a8f394785ab0216341402f9)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/sanity.bbclass | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass index 9fbc9c18e7..0e20589b22 100644 --- a/meta/classes/sanity.bbclass +++ b/meta/classes/sanity.bbclass | |||
@@ -462,13 +462,12 @@ def check_sanity_validmachine(sanity_data): | |||
462 | # Patch before 2.7 can't handle all the features in git-style diffs. Some | 462 | # Patch before 2.7 can't handle all the features in git-style diffs. Some |
463 | # patches may incorrectly apply, and others won't apply at all. | 463 | # patches may incorrectly apply, and others won't apply at all. |
464 | def check_patch_version(sanity_data): | 464 | def check_patch_version(sanity_data): |
465 | from distutils.version import LooseVersion | ||
466 | import re, subprocess | 465 | import re, subprocess |
467 | 466 | ||
468 | try: | 467 | try: |
469 | result = subprocess.check_output(["patch", "--version"], stderr=subprocess.STDOUT).decode('utf-8') | 468 | result = subprocess.check_output(["patch", "--version"], stderr=subprocess.STDOUT).decode('utf-8') |
470 | version = re.search(r"[0-9.]+", result.splitlines()[0]).group() | 469 | version = re.search(r"[0-9.]+", result.splitlines()[0]).group() |
471 | if LooseVersion(version) < LooseVersion("2.7"): | 470 | if bb.utils.vercmp_string_op(version, "2.7", "<"): |
472 | 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" | 471 | 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" |
473 | else: | 472 | else: |
474 | return None | 473 | return None |
@@ -478,7 +477,6 @@ def check_patch_version(sanity_data): | |||
478 | # Unpatched versions of make 3.82 are known to be broken. See GNU Savannah Bug 30612. | 477 | # Unpatched versions of make 3.82 are known to be broken. See GNU Savannah Bug 30612. |
479 | # Use a modified reproducer from http://savannah.gnu.org/bugs/?30612 to validate. | 478 | # Use a modified reproducer from http://savannah.gnu.org/bugs/?30612 to validate. |
480 | def check_make_version(sanity_data): | 479 | def check_make_version(sanity_data): |
481 | from distutils.version import LooseVersion | ||
482 | import subprocess | 480 | import subprocess |
483 | 481 | ||
484 | try: | 482 | try: |
@@ -486,7 +484,7 @@ def check_make_version(sanity_data): | |||
486 | except subprocess.CalledProcessError as e: | 484 | except subprocess.CalledProcessError as e: |
487 | return "Unable to execute make --version, exit code %d\n%s\n" % (e.returncode, e.output) | 485 | return "Unable to execute make --version, exit code %d\n%s\n" % (e.returncode, e.output) |
488 | version = result.split()[2] | 486 | version = result.split()[2] |
489 | if LooseVersion(version) == LooseVersion("3.82"): | 487 | if bb.utils.vercmp_string_op(version, "3.82", "=="): |
490 | # Construct a test file | 488 | # Construct a test file |
491 | f = open("makefile_test", "w") | 489 | f = open("makefile_test", "w") |
492 | f.write("makefile_test.a: makefile_test_a.c makefile_test_b.c makefile_test.a( makefile_test_a.c makefile_test_b.c)\n") | 490 | f.write("makefile_test.a: makefile_test_a.c makefile_test_b.c makefile_test.a( makefile_test_a.c makefile_test_b.c)\n") |
@@ -539,12 +537,11 @@ def check_wsl(d): | |||
539 | # built buildtools-extended-tarball) | 537 | # built buildtools-extended-tarball) |
540 | # | 538 | # |
541 | def check_gcc_version(sanity_data): | 539 | def check_gcc_version(sanity_data): |
542 | from distutils.version import LooseVersion | ||
543 | import subprocess | 540 | import subprocess |
544 | 541 | ||
545 | build_cc, version = oe.utils.get_host_compiler_version(sanity_data) | 542 | build_cc, version = oe.utils.get_host_compiler_version(sanity_data) |
546 | if build_cc.strip() == "gcc": | 543 | if build_cc.strip() == "gcc": |
547 | if LooseVersion(version) < LooseVersion("7.5"): | 544 | if bb.utils.vercmp_string_op(version, "7.5", "<"): |
548 | return "Your version of gcc is older than 7.5 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" | 545 | return "Your version of gcc is older than 7.5 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" |
549 | return None | 546 | return None |
550 | 547 | ||
@@ -552,14 +549,13 @@ def check_gcc_version(sanity_data): | |||
552 | # but earlier versions do not; this needs to work properly for sstate | 549 | # but earlier versions do not; this needs to work properly for sstate |
553 | # Version 1.28 is needed so opkg-build works correctly when reproducibile builds are enabled | 550 | # Version 1.28 is needed so opkg-build works correctly when reproducibile builds are enabled |
554 | def check_tar_version(sanity_data): | 551 | def check_tar_version(sanity_data): |
555 | from distutils.version import LooseVersion | ||
556 | import subprocess | 552 | import subprocess |
557 | try: | 553 | try: |
558 | result = subprocess.check_output(["tar", "--version"], stderr=subprocess.STDOUT).decode('utf-8') | 554 | result = subprocess.check_output(["tar", "--version"], stderr=subprocess.STDOUT).decode('utf-8') |
559 | except subprocess.CalledProcessError as e: | 555 | except subprocess.CalledProcessError as e: |
560 | return "Unable to execute tar --version, exit code %d\n%s\n" % (e.returncode, e.output) | 556 | return "Unable to execute tar --version, exit code %d\n%s\n" % (e.returncode, e.output) |
561 | version = result.split()[3] | 557 | version = result.split()[3] |
562 | if LooseVersion(version) < LooseVersion("1.28"): | 558 | if bb.utils.vercmp_string_op(version, "1.28", "<"): |
563 | 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" | 559 | 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" |
564 | return None | 560 | return None |
565 | 561 | ||
@@ -567,14 +563,13 @@ def check_tar_version(sanity_data): | |||
567 | # The kernel tools assume git >= 1.8.3.1 (verified needed > 1.7.9.5) see #6162 | 563 | # The kernel tools assume git >= 1.8.3.1 (verified needed > 1.7.9.5) see #6162 |
568 | # The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped | 564 | # The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped |
569 | def check_git_version(sanity_data): | 565 | def check_git_version(sanity_data): |
570 | from distutils.version import LooseVersion | ||
571 | import subprocess | 566 | import subprocess |
572 | try: | 567 | try: |
573 | result = subprocess.check_output(["git", "--version"], stderr=subprocess.DEVNULL).decode('utf-8') | 568 | result = subprocess.check_output(["git", "--version"], stderr=subprocess.DEVNULL).decode('utf-8') |
574 | except subprocess.CalledProcessError as e: | 569 | except subprocess.CalledProcessError as e: |
575 | return "Unable to execute git --version, exit code %d\n%s\n" % (e.returncode, e.output) | 570 | return "Unable to execute git --version, exit code %d\n%s\n" % (e.returncode, e.output) |
576 | version = result.split()[2] | 571 | version = result.split()[2] |
577 | if LooseVersion(version) < LooseVersion("1.8.3.1"): | 572 | if bb.utils.vercmp_string_op(version, "1.8.3.1", "<"): |
578 | 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" | 573 | 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" |
579 | return None | 574 | return None |
580 | 575 | ||
@@ -796,9 +791,8 @@ def check_sanity_everybuild(status, d): | |||
796 | status.addresult('The system requires at least Python 3.6 to run. Please update your Python interpreter.\n') | 791 | status.addresult('The system requires at least Python 3.6 to run. Please update your Python interpreter.\n') |
797 | 792 | ||
798 | # Check the bitbake version meets minimum requirements | 793 | # Check the bitbake version meets minimum requirements |
799 | from distutils.version import LooseVersion | ||
800 | minversion = d.getVar('BB_MIN_VERSION') | 794 | minversion = d.getVar('BB_MIN_VERSION') |
801 | if (LooseVersion(bb.__version__) < LooseVersion(minversion)): | 795 | if bb.utils.vercmp_string_op(bb.__version__, minversion, "<"): |
802 | status.addresult('Bitbake version %s is required and version %s was found\n' % (minversion, bb.__version__)) | 796 | status.addresult('Bitbake version %s is required and version %s was found\n' % (minversion, bb.__version__)) |
803 | 797 | ||
804 | sanity_check_locale(d) | 798 | sanity_check_locale(d) |