From 1866e2162bc9d5f5c1d84d476287c45a89bd8fb5 Mon Sep 17 00:00:00 2001 From: Nicolas Charles Date: Wed, 30 Mar 2022 09:47:59 +0200 Subject: [PATCH] Fix detection of service pack on SLES15 --- .../Agent/Task/Inventory/Linux/Distro/NonLSB.pm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/FusionInventory/Agent/Task/Inventory/Linux/Distro/NonLSB.pm b/lib/FusionInventory/Agent/Task/Inventory/Linux/Distro/NonLSB.pm index 96968f5838..626bede7e7 100644 --- a/lib/FusionInventory/Agent/Task/Inventory/Linux/Distro/NonLSB.pm +++ b/lib/FusionInventory/Agent/Task/Inventory/Linux/Distro/NonLSB.pm @@ -119,10 +119,19 @@ sub _getDistroData { }; if ($name eq 'SuSE') { - $data->{SERVICE_PACK} = getFirstMatch( - file => '/etc/SuSE-release', - pattern => qr/^PATCHLEVEL = ([0-9]+)/ - ); + # SLES15 doesn't have /etc/SuSE-release + if (-e '/etc/SuSE-release') { + $data->{SERVICE_PACK} = getFirstMatch( + file => '/etc/SuSE-release', + pattern => qr/^PATCHLEVEL = ([0-9]+)/ + ); + } else { + # fall back by checking if there's a -SP in the current version + # if so, split by -SP + if ($version =~ m/\-SP.+/) { + ($data->{VERSION}, $data->{SERVICE_PACK}) = $version =~ m/(.*)-SP(.*)/; + } + } } return $data;