mirror of
https://git.yoctoproject.org/poky
synced 2026-09-16 09:49:35 +02:00
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>
This commit is contained in:
@@ -462,13 +462,12 @@ def check_sanity_validmachine(sanity_data):
|
|||||||
# Patch before 2.7 can't handle all the features in git-style diffs. Some
|
# Patch before 2.7 can't handle all the features in git-style diffs. Some
|
||||||
# patches may incorrectly apply, and others won't apply at all.
|
# patches may incorrectly apply, and others won't apply at all.
|
||||||
def check_patch_version(sanity_data):
|
def check_patch_version(sanity_data):
|
||||||
from distutils.version import LooseVersion
|
|
||||||
import re, subprocess
|
import re, subprocess
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.check_output(["patch", "--version"], stderr=subprocess.STDOUT).decode('utf-8')
|
result = subprocess.check_output(["patch", "--version"], stderr=subprocess.STDOUT).decode('utf-8')
|
||||||
version = re.search(r"[0-9.]+", result.splitlines()[0]).group()
|
version = re.search(r"[0-9.]+", result.splitlines()[0]).group()
|
||||||
if LooseVersion(version) < LooseVersion("2.7"):
|
if bb.utils.vercmp_string_op(version, "2.7", "<"):
|
||||||
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"
|
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"
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
@@ -478,7 +477,6 @@ def check_patch_version(sanity_data):
|
|||||||
# Unpatched versions of make 3.82 are known to be broken. See GNU Savannah Bug 30612.
|
# Unpatched versions of make 3.82 are known to be broken. See GNU Savannah Bug 30612.
|
||||||
# Use a modified reproducer from http://savannah.gnu.org/bugs/?30612 to validate.
|
# Use a modified reproducer from http://savannah.gnu.org/bugs/?30612 to validate.
|
||||||
def check_make_version(sanity_data):
|
def check_make_version(sanity_data):
|
||||||
from distutils.version import LooseVersion
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -486,7 +484,7 @@ def check_make_version(sanity_data):
|
|||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
return "Unable to execute make --version, exit code %d\n%s\n" % (e.returncode, e.output)
|
return "Unable to execute make --version, exit code %d\n%s\n" % (e.returncode, e.output)
|
||||||
version = result.split()[2]
|
version = result.split()[2]
|
||||||
if LooseVersion(version) == LooseVersion("3.82"):
|
if bb.utils.vercmp_string_op(version, "3.82", "=="):
|
||||||
# Construct a test file
|
# Construct a test file
|
||||||
f = open("makefile_test", "w")
|
f = open("makefile_test", "w")
|
||||||
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")
|
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):
|
|||||||
# built buildtools-extended-tarball)
|
# built buildtools-extended-tarball)
|
||||||
#
|
#
|
||||||
def check_gcc_version(sanity_data):
|
def check_gcc_version(sanity_data):
|
||||||
from distutils.version import LooseVersion
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
build_cc, version = oe.utils.get_host_compiler_version(sanity_data)
|
build_cc, version = oe.utils.get_host_compiler_version(sanity_data)
|
||||||
if build_cc.strip() == "gcc":
|
if build_cc.strip() == "gcc":
|
||||||
if LooseVersion(version) < LooseVersion("7.5"):
|
if bb.utils.vercmp_string_op(version, "7.5", "<"):
|
||||||
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"
|
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"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -552,14 +549,13 @@ def check_gcc_version(sanity_data):
|
|||||||
# but earlier versions do not; this needs to work properly for sstate
|
# but earlier versions do not; this needs to work properly for sstate
|
||||||
# Version 1.28 is needed so opkg-build works correctly when reproducibile builds are enabled
|
# Version 1.28 is needed so opkg-build works correctly when reproducibile builds are enabled
|
||||||
def check_tar_version(sanity_data):
|
def check_tar_version(sanity_data):
|
||||||
from distutils.version import LooseVersion
|
|
||||||
import subprocess
|
import subprocess
|
||||||
try:
|
try:
|
||||||
result = subprocess.check_output(["tar", "--version"], stderr=subprocess.STDOUT).decode('utf-8')
|
result = subprocess.check_output(["tar", "--version"], stderr=subprocess.STDOUT).decode('utf-8')
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
return "Unable to execute tar --version, exit code %d\n%s\n" % (e.returncode, e.output)
|
return "Unable to execute tar --version, exit code %d\n%s\n" % (e.returncode, e.output)
|
||||||
version = result.split()[3]
|
version = result.split()[3]
|
||||||
if LooseVersion(version) < LooseVersion("1.28"):
|
if bb.utils.vercmp_string_op(version, "1.28", "<"):
|
||||||
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"
|
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"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -567,14 +563,13 @@ def check_tar_version(sanity_data):
|
|||||||
# The kernel tools assume git >= 1.8.3.1 (verified needed > 1.7.9.5) see #6162
|
# The kernel tools assume git >= 1.8.3.1 (verified needed > 1.7.9.5) see #6162
|
||||||
# The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped
|
# The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped
|
||||||
def check_git_version(sanity_data):
|
def check_git_version(sanity_data):
|
||||||
from distutils.version import LooseVersion
|
|
||||||
import subprocess
|
import subprocess
|
||||||
try:
|
try:
|
||||||
result = subprocess.check_output(["git", "--version"], stderr=subprocess.DEVNULL).decode('utf-8')
|
result = subprocess.check_output(["git", "--version"], stderr=subprocess.DEVNULL).decode('utf-8')
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
return "Unable to execute git --version, exit code %d\n%s\n" % (e.returncode, e.output)
|
return "Unable to execute git --version, exit code %d\n%s\n" % (e.returncode, e.output)
|
||||||
version = result.split()[2]
|
version = result.split()[2]
|
||||||
if LooseVersion(version) < LooseVersion("1.8.3.1"):
|
if bb.utils.vercmp_string_op(version, "1.8.3.1", "<"):
|
||||||
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"
|
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"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -796,9 +791,8 @@ def check_sanity_everybuild(status, d):
|
|||||||
status.addresult('The system requires at least Python 3.6 to run. Please update your Python interpreter.\n')
|
status.addresult('The system requires at least Python 3.6 to run. Please update your Python interpreter.\n')
|
||||||
|
|
||||||
# Check the bitbake version meets minimum requirements
|
# Check the bitbake version meets minimum requirements
|
||||||
from distutils.version import LooseVersion
|
|
||||||
minversion = d.getVar('BB_MIN_VERSION')
|
minversion = d.getVar('BB_MIN_VERSION')
|
||||||
if (LooseVersion(bb.__version__) < LooseVersion(minversion)):
|
if bb.utils.vercmp_string_op(bb.__version__, minversion, "<"):
|
||||||
status.addresult('Bitbake version %s is required and version %s was found\n' % (minversion, bb.__version__))
|
status.addresult('Bitbake version %s is required and version %s was found\n' % (minversion, bb.__version__))
|
||||||
|
|
||||||
sanity_check_locale(d)
|
sanity_check_locale(d)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def find_latest_numeric_release(url, d):
|
|||||||
maxstr=""
|
maxstr=""
|
||||||
for link in get_links_from_url(url, d):
|
for link in get_links_from_url(url, d):
|
||||||
try:
|
try:
|
||||||
# TODO use LooseVersion
|
# TODO use bb.utils.vercmp_string_op()
|
||||||
release = float(link)
|
release = float(link)
|
||||||
except:
|
except:
|
||||||
release = 0
|
release = 0
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import logging
|
|||||||
import oe.classutils
|
import oe.classutils
|
||||||
import shlex
|
import shlex
|
||||||
from bb.process import Popen, ExecutionError
|
from bb.process import Popen, ExecutionError
|
||||||
from distutils.version import LooseVersion
|
|
||||||
|
|
||||||
logger = logging.getLogger('BitBake.OE.Terminal')
|
logger = logging.getLogger('BitBake.OE.Terminal')
|
||||||
|
|
||||||
@@ -86,10 +85,10 @@ class Konsole(XTerminal):
|
|||||||
def __init__(self, sh_cmd, title=None, env=None, d=None):
|
def __init__(self, sh_cmd, title=None, env=None, d=None):
|
||||||
# Check version
|
# Check version
|
||||||
vernum = check_terminal_version("konsole")
|
vernum = check_terminal_version("konsole")
|
||||||
if vernum and LooseVersion(vernum) < '2.0.0':
|
if vernum and bb.utils.vercmp_string_op(vernum, "2.0.0", "<"):
|
||||||
# Konsole from KDE 3.x
|
# Konsole from KDE 3.x
|
||||||
self.command = 'konsole -T "{title}" -e {command}'
|
self.command = 'konsole -T "{title}" -e {command}'
|
||||||
elif vernum and LooseVersion(vernum) < '16.08.1':
|
elif vernum and bb.utils.vercmp_string_op(vernum, "16.08.1", "<"):
|
||||||
# Konsole pre 16.08.01 Has nofork
|
# Konsole pre 16.08.01 Has nofork
|
||||||
self.command = 'konsole --nofork --workdir . -p tabtitle="{title}" -e {command}'
|
self.command = 'konsole --nofork --workdir . -p tabtitle="{title}" -e {command}'
|
||||||
XTerminal.__init__(self, sh_cmd, title, env, d)
|
XTerminal.__init__(self, sh_cmd, title, env, d)
|
||||||
@@ -260,7 +259,7 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
|
|||||||
|
|
||||||
def check_tmux_version(desired):
|
def check_tmux_version(desired):
|
||||||
vernum = check_terminal_version("tmux")
|
vernum = check_terminal_version("tmux")
|
||||||
if vernum and LooseVersion(vernum) < desired:
|
if vernum and bb.utils.vercmp_string_op(vernum, desired, "<"):
|
||||||
return False
|
return False
|
||||||
return vernum
|
return vernum
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user