210 lines
7.7 KiB
Diff
210 lines
7.7 KiB
Diff
|
From a98532ac7d6c79889703603d9f4ab008f0febd53 Mon Sep 17 00:00:00 2001
|
||
|
From: Neil Hanlon <neil@resf.org>
|
||
|
Date: Fri, 10 Dec 2021 08:50:48 +0000
|
||
|
Subject: [PATCH] Add detection support for Rocky Linux (CentOS/RHEL-like)
|
||
|
|
||
|
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2030709
|
||
|
Thanks: label@rockylinux.org
|
||
|
|
||
|
---
|
||
|
|
||
|
RWMJ notes: I fixed the original patch so it compiled. This patch
|
||
|
sets osinfo to "rocky8", which doesn't exist in the osinfo db yet.
|
||
|
Arguably we might want to set this to "centos8", but we can see what
|
||
|
libosinfo decides to do. Here is partial virt-inspector output on a
|
||
|
Rocky Linux disk image:
|
||
|
|
||
|
$ ./run virt-inspector -a disk.img
|
||
|
<?xml version="1.0"?>
|
||
|
<operatingsystems>
|
||
|
<operatingsystem>
|
||
|
<root>/dev/rl/root</root>
|
||
|
<name>linux</name>
|
||
|
<arch>x86_64</arch>
|
||
|
<distro>rocky</distro>
|
||
|
<product_name>Rocky Linux 8.5 (Green Obsidian)</product_name>
|
||
|
<major_version>8</major_version>
|
||
|
<minor_version>5</minor_version>
|
||
|
<package_format>rpm</package_format>
|
||
|
<package_management>dnf</package_management>
|
||
|
<hostname>localhost.localdomain</hostname>
|
||
|
<osinfo>rocky8</osinfo>
|
||
|
<mountpoints>
|
||
|
<mountpoint dev="/dev/rl/root">/</mountpoint>
|
||
|
<mountpoint dev="/dev/sda1">/boot</mountpoint>
|
||
|
</mountpoints>
|
||
|
<filesystems>
|
||
|
<filesystem dev="/dev/rl/root">
|
||
|
<type>xfs</type>
|
||
|
<uuid>fed8331f-9f25-40cd-883e-090cd640559d</uuid>
|
||
|
</filesystem>
|
||
|
<filesystem dev="/dev/rl/swap">
|
||
|
<type>swap</type>
|
||
|
<uuid>6da2c121-ea7d-49ce-98a3-14a37fceaadd</uuid>
|
||
|
</filesystem>
|
||
|
<filesystem dev="/dev/sda1">
|
||
|
<type>xfs</type>
|
||
|
<uuid>4efafe61-2d20-4d93-8055-537e09bfd033</uuid>
|
||
|
</filesystem>
|
||
|
</filesystems>
|
||
|
(cherry picked from commit 631962c0e88a321646846be91d0fbea1ba14e263)
|
||
|
---
|
||
|
daemon/inspect_fs.ml | 2 ++
|
||
|
daemon/inspect_fs_unix.ml | 13 ++++++++++++-
|
||
|
daemon/inspect_types.ml | 2 ++
|
||
|
daemon/inspect_types.mli | 1 +
|
||
|
generator/actions_inspection.ml | 4 ++++
|
||
|
lib/inspect-icon.c | 1 +
|
||
|
lib/inspect-osinfo.c | 4 ++++
|
||
|
7 files changed, 26 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/daemon/inspect_fs.ml b/daemon/inspect_fs.ml
|
||
|
index 77f0f6aea..9c73d97ef 100644
|
||
|
--- a/daemon/inspect_fs.ml
|
||
|
+++ b/daemon/inspect_fs.ml
|
||
|
@@ -259,6 +259,7 @@ and check_package_format { distro } =
|
||
|
| None -> None
|
||
|
| Some DISTRO_ALTLINUX
|
||
|
| Some DISTRO_CENTOS
|
||
|
+ | Some DISTRO_ROCKY
|
||
|
| Some DISTRO_FEDORA
|
||
|
| Some DISTRO_MAGEIA
|
||
|
| Some DISTRO_MANDRIVA
|
||
|
@@ -329,6 +330,7 @@ and check_package_management { distro; version } =
|
||
|
Some PACKAGE_MANAGEMENT_DNF
|
||
|
|
||
|
| Some DISTRO_CENTOS
|
||
|
+ | Some DISTRO_ROCKY
|
||
|
| Some DISTRO_ORACLE_LINUX
|
||
|
| Some DISTRO_REDHAT_BASED
|
||
|
| Some DISTRO_RHEL
|
||
|
diff --git a/daemon/inspect_fs_unix.ml b/daemon/inspect_fs_unix.ml
|
||
|
index 7f6eb92e9..63cb279d0 100644
|
||
|
--- a/daemon/inspect_fs_unix.ml
|
||
|
+++ b/daemon/inspect_fs_unix.ml
|
||
|
@@ -32,6 +32,8 @@ let re_rhel_no_minor = PCRE.compile "Red Hat.*release (\\d+)"
|
||
|
let re_centos_old = PCRE.compile "CentOS.*release (\\d+).*Update (\\d+)"
|
||
|
let re_centos = PCRE.compile "CentOS.*release (\\d+)\\.(\\d+)"
|
||
|
let re_centos_no_minor = PCRE.compile "CentOS.*release (\\d+)"
|
||
|
+let re_rocky = PCRE.compile "Rocky Linux.*release (\\d+)\\.(\\d+)"
|
||
|
+let re_rocky_no_minor = PCRE.compile "Rocky Linux.*release (\\d+)"
|
||
|
let re_scientific_linux_old =
|
||
|
PCRE.compile "Scientific Linux.*release (\\d+).*Update (\\d+)"
|
||
|
let re_scientific_linux =
|
||
|
@@ -106,7 +108,7 @@ let rec parse_os_release release_file data =
|
||
|
* we detect that situation then bail out and use the release
|
||
|
* files instead.
|
||
|
*)
|
||
|
- | { distro = Some (DISTRO_DEBIAN|DISTRO_CENTOS);
|
||
|
+ | { distro = Some (DISTRO_DEBIAN|DISTRO_CENTOS|DISTRO_ROCKY);
|
||
|
version = Some (_, 0) } ->
|
||
|
false
|
||
|
|
||
|
@@ -155,6 +157,7 @@ and distro_of_os_release_id = function
|
||
|
| "pardus" -> Some DISTRO_PARDUS
|
||
|
| "pld" -> Some DISTRO_PLD_LINUX
|
||
|
| "rhel" -> Some DISTRO_RHEL
|
||
|
+ | "rocky" -> Some DISTRO_ROCKY
|
||
|
| "sles" | "sled" -> Some DISTRO_SLES
|
||
|
| "ubuntu" -> Some DISTRO_UBUNTU
|
||
|
| "void" -> Some DISTRO_VOID_LINUX
|
||
|
@@ -405,6 +408,10 @@ let linux_root_tests : tests = [
|
||
|
DISTRO_CENTOS;
|
||
|
"/etc/centos-release", parse_generic ~rex:re_centos_no_minor
|
||
|
DISTRO_CENTOS;
|
||
|
+ "/etc/rocky-release", parse_generic ~rex:re_rocky
|
||
|
+ DISTRO_ROCKY;
|
||
|
+ "/etc/rocky-release", parse_generic ~rex:re_rocky_no_minor
|
||
|
+ DISTRO_ROCKY;
|
||
|
"/etc/altlinux-release", parse_generic DISTRO_ALTLINUX;
|
||
|
"/etc/redhat-release", parse_generic ~rex:re_fedora
|
||
|
DISTRO_FEDORA;
|
||
|
@@ -420,6 +427,10 @@ let linux_root_tests : tests = [
|
||
|
DISTRO_CENTOS;
|
||
|
"/etc/redhat-release", parse_generic ~rex:re_centos_no_minor
|
||
|
DISTRO_CENTOS;
|
||
|
+ "/etc/redhat-release", parse_generic ~rex:re_rocky
|
||
|
+ DISTRO_ROCKY;
|
||
|
+ "/etc/redhat-release", parse_generic ~rex:re_rocky_no_minor
|
||
|
+ DISTRO_ROCKY;
|
||
|
"/etc/redhat-release", parse_generic ~rex:re_scientific_linux_old
|
||
|
DISTRO_SCIENTIFIC_LINUX;
|
||
|
"/etc/redhat-release", parse_generic ~rex:re_scientific_linux
|
||
|
diff --git a/daemon/inspect_types.ml b/daemon/inspect_types.ml
|
||
|
index e2bc7165c..9395c51f9 100644
|
||
|
--- a/daemon/inspect_types.ml
|
||
|
+++ b/daemon/inspect_types.ml
|
||
|
@@ -95,6 +95,7 @@ and distro =
|
||
|
| DISTRO_PLD_LINUX
|
||
|
| DISTRO_REDHAT_BASED
|
||
|
| DISTRO_RHEL
|
||
|
+ | DISTRO_ROCKY
|
||
|
| DISTRO_SCIENTIFIC_LINUX
|
||
|
| DISTRO_SLACKWARE
|
||
|
| DISTRO_SLES
|
||
|
@@ -228,6 +229,7 @@ and string_of_distro = function
|
||
|
| DISTRO_PLD_LINUX -> "pldlinux"
|
||
|
| DISTRO_REDHAT_BASED -> "redhat-based"
|
||
|
| DISTRO_RHEL -> "rhel"
|
||
|
+ | DISTRO_ROCKY -> "rocky"
|
||
|
| DISTRO_SCIENTIFIC_LINUX -> "scientificlinux"
|
||
|
| DISTRO_SLACKWARE -> "slackware"
|
||
|
| DISTRO_SLES -> "sles"
|
||
|
diff --git a/daemon/inspect_types.mli b/daemon/inspect_types.mli
|
||
|
index 43c79818f..29c76e8ab 100644
|
||
|
--- a/daemon/inspect_types.mli
|
||
|
+++ b/daemon/inspect_types.mli
|
||
|
@@ -102,6 +102,7 @@ and distro =
|
||
|
| DISTRO_PLD_LINUX
|
||
|
| DISTRO_REDHAT_BASED
|
||
|
| DISTRO_RHEL
|
||
|
+ | DISTRO_ROCKY
|
||
|
| DISTRO_SCIENTIFIC_LINUX
|
||
|
| DISTRO_SLACKWARE
|
||
|
| DISTRO_SLES
|
||
|
diff --git a/generator/actions_inspection.ml b/generator/actions_inspection.ml
|
||
|
index 0c6d39b43..f8b744993 100644
|
||
|
--- a/generator/actions_inspection.ml
|
||
|
+++ b/generator/actions_inspection.ml
|
||
|
@@ -278,6 +278,10 @@ Some Red Hat-derived distro.
|
||
|
|
||
|
Red Hat Enterprise Linux.
|
||
|
|
||
|
+=item \"rocky\"
|
||
|
+
|
||
|
+Rocky Linux.
|
||
|
+
|
||
|
=item \"scientificlinux\"
|
||
|
|
||
|
Scientific Linux.
|
||
|
diff --git a/lib/inspect-icon.c b/lib/inspect-icon.c
|
||
|
index 725af574b..3bffa4f80 100644
|
||
|
--- a/lib/inspect-icon.c
|
||
|
+++ b/lib/inspect-icon.c
|
||
|
@@ -138,6 +138,7 @@ guestfs_impl_inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r,
|
||
|
else if (STREQ (distro, "rhel") ||
|
||
|
STREQ (distro, "redhat-based") ||
|
||
|
STREQ (distro, "centos") ||
|
||
|
+ STREQ (distro, "rocky") ||
|
||
|
STREQ (distro, "scientificlinux") ||
|
||
|
STREQ (distro, "oraclelinux")) {
|
||
|
r = icon_rhel (g, guestfs_inspect_get_major_version (g, root), &size);
|
||
|
diff --git a/lib/inspect-osinfo.c b/lib/inspect-osinfo.c
|
||
|
index db38d87f7..90e57e6df 100644
|
||
|
--- a/lib/inspect-osinfo.c
|
||
|
+++ b/lib/inspect-osinfo.c
|
||
|
@@ -47,6 +47,10 @@ guestfs_impl_inspect_get_osinfo (guestfs_h *g, const char *root)
|
||
|
else if (major == 6)
|
||
|
return safe_asprintf (g, "%s%d.%d", distro, major, minor);
|
||
|
}
|
||
|
+ else if (STREQ (distro, "rocky")) {
|
||
|
+ if (major >= 8)
|
||
|
+ return safe_asprintf (g, "%s%d", distro, major);
|
||
|
+ }
|
||
|
else if (STREQ (distro, "debian")) {
|
||
|
if (major >= 4)
|
||
|
return safe_asprintf (g, "%s%d", distro, major);
|
||
|
--
|
||
|
2.19.1.3.g30247aa5d201
|
||
|
|