From 2391815114649ff6e669a412ef509559e912d622 Mon Sep 17 00:00:00 2001 From: Abdul Karim Date: Thu, 5 Dec 2024 11:21:22 +0000 Subject: [PATCH] ncm-spma: fix to retain rpms listed in whitelist. bug fix to not remove packages listed in whitelist. In order to match, need to remove the epoch value which gets added in rpm earlier. --- ncm-spma/src/main/perl/spma/dnf.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ncm-spma/src/main/perl/spma/dnf.pm b/ncm-spma/src/main/perl/spma/dnf.pm index 2e0bfaba1e..c15865b639 100755 --- a/ncm-spma/src/main/perl/spma/dnf.pm +++ b/ncm-spma/src/main/perl/spma/dnf.pm @@ -559,10 +559,14 @@ sub Configure $will_remove->delete($rpm); } + # set rpm with version without epoch, epoch is added between version and package name, e.g audit-0:3.1.2-1.el8.x86_64, -0: is epoch. + # remove the epoch part and combine package name and version + # below will give audit-3.1.2-1.el8.x86_64, which will be used to compare against any rpm in whitelist. + my $rpm_without_epoch = $rpm =~ s/-\d+:/-/r; # Do not remove whitelisted packages. if (defined($whitelist)) { for my $white_pkg (@$whitelist) { - if (index($rpm_version, $white_pkg) == 0 || match_glob($white_pkg, $rpm_version)) { + if (index($rpm_without_epoch, $white_pkg) == 0 || match_glob($white_pkg, $rpm_without_epoch)) { $will_remove->delete($rpm); $whitelisted->insert($rpm); }