Blame SOURCES/0003-Add-detection-support-for-Rocky-Linux-CentOS-RHEL-li.patch

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