Skip to content

Commit

Permalink
cmtlib: Fix version check for RPM packages
Browse files Browse the repository at this point in the history
Make the version info for RPM packages look the same
as the output for DEB packages.  While at it also fix
the type annotations.

Signed-off-by: David Weinehall <[email protected]>
  • Loading branch information
taotriad committed Aug 4, 2023
1 parent 821e251 commit 76cf68c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmtlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def check_rpm_versions(rpm_packages: List[str]) -> List[Tuple[str, str, str, Lis
"""

rpm_versions = []
rpm_versions_dict = {}
rpm_versions_dict: Dict[str, Dict] = {}

yum_path = cmtio.secure_which(FilePath("/usr/bin/yum"), fallback_allowlist = ["/usr/bin"],
security_policy = SecurityPolicy.ALLOWLIST_RELAXED)
Expand Down Expand Up @@ -648,12 +648,14 @@ def check_rpm_versions(rpm_packages: List[str]) -> List[Tuple[str, str, str, Lis
rpm_versions_dict[package]["installed"] = version
elif section == "available":
rpm_versions_dict[package]["available"].append(version)
# Now summarise
# Now summarise

for package, data in rpm_versions_dict.items():
candidate = "<none>"
if len(data["available"]) > 0:
candidate = data["available"][-1]
if data["installed"] == candidate:
candidate = ""
rpm_versions.append((package, data["installed"], candidate, list(reversed(data["available"]))))

return rpm_versions
Expand Down Expand Up @@ -747,6 +749,9 @@ def identify_k8s_distro() -> str:
if k8s_distro is None and tmp_k8s_distro is not None:
k8s_distro = tmp_k8s_distro

if k8s_distro is None:
k8s_distro = "<unknown>"

return k8s_distro

def identify_distro() -> str:
Expand Down

0 comments on commit 76cf68c

Please sign in to comment.