From 4ab24b9900d4f58c2e0589bf6d24b231924a61e6 Mon Sep 17 00:00:00 2001 From: pvdputte Date: Fri, 11 Oct 2024 13:19:41 +0200 Subject: [PATCH] use /etc/os-release to detect distribution and version Will return e.g. ('debian','12'). Cfr. https://github.com/sni/Thruk/issues/1387 --- configure | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/configure b/configure index 2f1842a68..014013a17 100755 --- a/configure +++ b/configure @@ -216,6 +216,25 @@ sub _get_os { } else { die "Unable to detect distribution and version from $release_file\n"; } + } elsif(-e '/etc/os-release') { + my $release_file = '/etc/os-release'; + open(my $fh, '<', $release_file) or die("cannot read $release_file: $!"); + foreach (<$fh>) { + if (/^ID="?(.*?)"?$/) { + $os = $1; + } + if (/^VERSION_ID="?(.*?)"?$/) { + $version = $1; + $version =~ s/\..*$//gmx; # we only need the major number + } + } + close $fh; + + if ($os && $version) { + return($os, 0+$version); + } else { + die "Unable to detect distribution and version from $release_file\n"; + } } return($os, $version);