Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel version parsing fixes for OL10, UEK8, and UEK-next #132

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions drgn_tools/debuginfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ def find_debuginfo(
"4.14.35": 5,
"5.4.17": 6,
"5.15.0": 7,
"6.12.0": 8,
}


Expand Down Expand Up @@ -507,11 +508,11 @@ def parse(cls, original: str) -> "KernelVersion":
:returns: A ``KernelVersion`` with fields parsed
"""
version_re = re.compile(
r"(?P<version>\d+\.\d+\.\d+)-(?P<release>[0-9.-]+)"
r"(?P<extraversion1>\.[0-9a-zA-Z._]+?)?"
r"(?P<version>\d+\.\d+\.\d+)-(?P<release>\w+(?:\.\w+)*)"
r"\.el(?P<ol_version>\d+)(?P<extra>uek|ueknext|_(?P<update>\d+)|)"
r"(?P<extraversion2>\.[0-9a-zA-Z._]+?)?"
r"\.(?P<arch>.+)"
r"\.(?P<arch>.+)",
re.ASCII,
)
match = version_re.fullmatch(original)
if not match:
Expand All @@ -521,9 +522,22 @@ def parse(cls, original: str) -> "KernelVersion":
version_tuple = tuple(
int(g) for g in re.split("[.-]", match["version"])
)
release_tuple = tuple(
int(g) for g in re.split("[.-]", match["release"])
)
# The release string is complicated. Normally there are two parts: a
# release that is a normal version number (digits separated by dots),
# and then an optional extra component that could contain text. By
# convention, all the numeric elements get looped into the "release" and
# the remaining elements are the "extraversion".
release_elements = []
extraversion_elements = []
elements = list(match["release"].split("."))
for i, group in enumerate(elements):
try:
release_elements.append(int(group))
except ValueError:
extraversion_elements.extend(elements[i:])
break
release_tuple = tuple(release_elements)
extraversion = ".".join(extraversion_elements)
update = None
if match["update"]:
update = int(match["update"])
Expand All @@ -540,13 +554,13 @@ def parse(cls, original: str) -> "KernelVersion":
return cls(
match["version"],
version_tuple,
match["release"],
".".join(str(n) for n in release_elements),
release_tuple,
int(match.group("ol_version")),
update,
match["arch"],
original,
match["extraversion1"] or "",
extraversion,
match["extraversion2"] or "",
is_uek,
uek_ver,
Expand Down
55 changes: 55 additions & 0 deletions tests/test_debuginfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,50 @@ def parse_check_fields(name: str, **kwargs: Any):
assert getattr(ver, field_name) == value


def test_luci_versions():
# A standard UEK-next version string
parse_check_fields(
"6.11.0-0.el9ueknext.x86_64",
version="6.11.0",
release="0",
ol_version=9,
is_ueknext=True,
)
# The 6.8-era version without the "ueknext" in the extra.
parse_check_fields(
"6.8.0-2.el9uek.x86_64",
version="6.8.0",
release="2",
ol_version=9,
is_ueknext=True,
)
# Here's a fun one without a release string, but with an extraversion thrown
# in.
parse_check_fields(
"6.11.0-testingspecial.el9uek.rc1.x86_64",
version="6.11.0",
release="",
ol_version=9,
extraversion1="testingspecial",
extraversion2=".rc1",
)


def test_uek_versions():
# A made-up UEK8 OL10 version to make sure we are ready:
parse_check_fields(
"6.12.0-2.132.1.el10uek.x86_64",
version="6.12.0",
release="2.132.1",
ol_version=10,
uek_version=8,
)
# UEK7, OL9
parse_check_fields(
"5.15.0-101.103.2.1.el9uek.x86_64",
release="101.103.2.1",
ol_version=9,
uek_version=7,
)

# UEK7, OL8
Expand All @@ -33,6 +71,7 @@ def test_uek_versions():
version="5.15.0",
release="101.103.2.1",
ol_version=8,
uek_version=7,
)

# UEK6, OL8
Expand All @@ -41,6 +80,7 @@ def test_uek_versions():
version="5.4.17",
release="2136.323.7",
ol_version=8,
uek_version=6,
)

# UEK6, OL7
Expand All @@ -49,6 +89,7 @@ def test_uek_versions():
version="5.4.17",
release="2136.323.7",
ol_version=7,
uek_version=6,
)

# An older UEK6
Expand All @@ -57,6 +98,7 @@ def test_uek_versions():
version="5.4.17",
release="2006.5",
ol_version=8,
uek_version=6,
)

# UEK5, OL7
Expand All @@ -65,6 +107,7 @@ def test_uek_versions():
version="4.14.35",
release="2047.528.2.1",
ol_version=7,
uek_version=5,
)

# UEK4, OL7
Expand All @@ -73,6 +116,7 @@ def test_uek_versions():
version="4.1.12",
release="124.48.6",
ol_version=7,
uek_version=4,
)


Expand Down Expand Up @@ -117,19 +161,30 @@ def test_rhck():


def test_uek_aarch64():
# A made-up UEK8 OL10 version to make sure we are ready:
parse_check_fields(
"6.12.0-2.132.1.el10uek.aarch64",
version="6.12.0",
release="2.132.1",
ol_version=10,
uek_version=8,
arch="aarch64",
)
# OL8/9 + UEK7 is the main target
parse_check_fields(
"5.15.0-104.119.4.2.el9uek.aarch64",
version="5.15.0",
release="104.119.4.2",
ol_version=9,
uek_version=7,
arch="aarch64",
)
parse_check_fields(
"5.15.0-106.125.1.el8uek.aarch64",
version="5.15.0",
release="106.125.1",
ol_version=8,
uek_version=7,
arch="aarch64",
)
# no rhck for aarch64
Loading