Skip to content

Commit

Permalink
Fixed issue with yum package module regarding packages with epoch not…
Browse files Browse the repository at this point in the history
… validating

Packages would be installed but the promise would fail due to the installed list not including the epoch number.
The updates list generated by the module included the epoch number so validation would fail.

e.g. findutils:1:4.8.0-7.el9:x86_64 would not match findutils:4.8.0-7.el9:x86_64

Fix this by including epoch in rpm_output_format and removing (none): with sed where the package has no epoch.

Ticket: ENT-12538
Changelog: title
  • Loading branch information
craigcomstock committed Dec 18, 2024
1 parent 691c6b2 commit 47d320a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/packages/vendored/yum.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import re

rpm_cmd = os.environ.get('CFENGINE_TEST_RPM_CMD', "/bin/rpm")
rpm_quiet_option = ["--quiet"]
rpm_output_format = "Name=%{name}\nVersion=%{version}-%{release}\nArchitecture=%{arch}\n"
rpm_output_format = "Name=%{name}\nVersion=%{epoch}:%{version}-%{release}\nArchitecture=%{arch}\n"

yum_cmd = os.environ.get('CFENGINE_TEST_YUM_CMD', "/usr/bin/yum")
yum_options = ["--quiet", "-y"]
Expand Down Expand Up @@ -87,7 +87,7 @@ def get_package_data():
# Absolute file.
sys.stdout.write("PackageType=file\n")
sys.stdout.flush()
return subprocess_call([rpm_cmd, "--qf", rpm_output_format, "-qp", pkg_string])
return subprocess_call([rpm_cmd, "--qf", rpm_output_format, "-qp", pkg_string, "|sed 's/(none)://'"])
elif re.search("[:,]", pkg_string):
# Contains an illegal symbol.
sys.stdout.write(line + "ErrorMessage: Package string with illegal format\n")
Expand All @@ -102,7 +102,7 @@ def list_installed():
# Ignore everything.
sys.stdin.readlines()

return subprocess_call([rpm_cmd, "-qa", "--qf", rpm_output_format])
return subprocess_call([rpm_cmd, "-qa", "--qf", rpm_output_format, "|sed 's/(none)://'"])


def list_updates(online):
Expand Down

0 comments on commit 47d320a

Please sign in to comment.