From a35629866c4860759ab1942d8bba070e0bfe0046 Mon Sep 17 00:00:00 2001
From: Wang Guoquan <wangguoquan03@foxmail.com>
Date: Tue, 10 Sep 2024 16:11:03 +0800
Subject: [PATCH] libguestfs: Support openEuler

    openEuler is simliar to CentOS,
    but the ID is not lower-case string, as below,

    NAME="openEuler"
    VERSION="24.03 (LTS)"
    ID="openEuler"
    VERSION_ID="24.03"
    PRETTY_NAME="openEuler 24.03 (LTS)"
    ANSI_COLOR="0;31"

Signed-off-by: Wang Guoquan <wangguoquan03@foxmail.com>
---
 daemon/inspect_fs.ml            | 5 +++++
 daemon/inspect_fs_unix.ml       | 1 +
 daemon/inspect_types.ml         | 2 ++
 daemon/inspect_types.mli        | 1 +
 generator/actions_inspection.ml | 4 ++++
 m4/guestfs-appliance.m4         | 5 +++--
 6 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/daemon/inspect_fs.ml b/daemon/inspect_fs.ml
index dd1312470..d83c00e8e 100644
--- a/daemon/inspect_fs.ml
+++ b/daemon/inspect_fs.ml
@@ -267,6 +267,7 @@ and check_package_format { distro } =
   | Some DISTRO_MEEGO
   | Some DISTRO_NEOKYLIN
   | Some DISTRO_OPENCLOUDOS
+  | Some DISTRO_OPENEULER
   | Some DISTRO_OPENMANDRIVA
   | Some DISTRO_OPENSUSE
   | Some DISTRO_ORACLE_LINUX
@@ -385,6 +386,10 @@ and check_package_management { distro; version } =
 
   | Some DISTRO_OPENCLOUDOS ->
      Some PACKAGE_MANAGEMENT_DNF
+
+  | Some DISTRO_OPENEULER->
+     Some PACKAGE_MANAGEMENT_DNF
+
   | Some DISTRO_BUILDROOT
   | Some DISTRO_CIRROS
   | Some DISTRO_COREOS
diff --git a/daemon/inspect_fs_unix.ml b/daemon/inspect_fs_unix.ml
index 2b690795d..60ced2591 100644
--- a/daemon/inspect_fs_unix.ml
+++ b/daemon/inspect_fs_unix.ml
@@ -157,6 +157,7 @@ and distro_of_os_release_id = function
   | "kylin" -> Some DISTRO_KYLIN
   | "mageia" -> Some DISTRO_MAGEIA
   | "neokylin" -> Some DISTRO_NEOKYLIN
+  | "openEuler" -> Some DISTRO_OPENEULER
   | "openmandriva" -> Some DISTRO_OPENMANDRIVA
   | "opencloudos" -> Some DISTRO_OPENCLOUDOS
   | "opensuse" -> Some DISTRO_OPENSUSE
diff --git a/daemon/inspect_types.ml b/daemon/inspect_types.ml
index f162ada25..c9406eb9e 100644
--- a/daemon/inspect_types.ml
+++ b/daemon/inspect_types.ml
@@ -90,6 +90,7 @@ and distro =
   | DISTRO_NEOKYLIN
   | DISTRO_NETBSD
   | DISTRO_OPENBSD
+  | DISTRO_OPENEULER
   | DISTRO_OPENMANDRIVA
   | DISTRO_OPENCLOUDOS
   | DISTRO_OPENSUSE
@@ -228,6 +229,7 @@ and string_of_distro = function
   | DISTRO_NEOKYLIN -> "neokylin"
   | DISTRO_NETBSD -> "netbsd"
   | DISTRO_OPENBSD -> "openbsd"
+  | DISTRO_OPENEULER -> "openEuler"
   | DISTRO_OPENMANDRIVA -> "openmandriva"
   | DISTRO_OPENCLOUDOS -> "opencloudos"
   | DISTRO_OPENSUSE -> "opensuse"
diff --git a/daemon/inspect_types.mli b/daemon/inspect_types.mli
index c775f9da0..2aabe23e9 100644
--- a/daemon/inspect_types.mli
+++ b/daemon/inspect_types.mli
@@ -97,6 +97,7 @@ and distro =
   | DISTRO_NEOKYLIN
   | DISTRO_NETBSD
   | DISTRO_OPENBSD
+  | DISTRO_OPENEULER
   | DISTRO_OPENMANDRIVA
   | DISTRO_OPENCLOUDOS
   | DISTRO_OPENSUSE
diff --git a/generator/actions_inspection.ml b/generator/actions_inspection.ml
index 33086abd3..94661f17c 100644
--- a/generator/actions_inspection.ml
+++ b/generator/actions_inspection.ml
@@ -254,6 +254,10 @@ NetBSD.
 
 OpenBSD.
 
+=item \"openEuler\"
+
+openEuler.
+
 =item \"openmandriva\"
 
 OpenMandriva Lx.
diff --git a/m4/guestfs-appliance.m4 b/m4/guestfs-appliance.m4
index f52bf034a..f315c96d6 100644
--- a/m4/guestfs-appliance.m4
+++ b/m4/guestfs-appliance.m4
@@ -120,7 +120,8 @@ if test "x$ENABLE_APPLIANCE" = "xyes"; then
                         [OPENSUSE* | SLED | SLES],[DISTRO=SUSE],
                         [ARCH | MANJARO | ARTIX],[DISTRO=ARCHLINUX],
                         [OPENMANDRIVA],[DISTRO=OPENMANDRIVA],
-                        [OPENCLOUDOS],[DISTRO=OPENCLOUDOS])
+                        [OPENCLOUDOS],[DISTRO=OPENCLOUDOS],
+                        [OPENEULER],[DISTRO=OPENEULER])
                 AC_MSG_RESULT([$DISTRO (from /etc/os-release)])
             else
                 AC_MSG_ERROR([/etc/os-release not available, please specify the distro using --with-distro=DISTRO])
@@ -130,7 +131,7 @@ if test "x$ENABLE_APPLIANCE" = "xyes"; then
     AC_SUBST([DISTRO])
 fi
 AM_CONDITIONAL([HAVE_RPM],
-    [AS_CASE([$DISTRO], [REDHAT | SUSE | OPENMANDRIVA | MAGEIA | OPENCLOUDOS ], [true],
+    [AS_CASE([$DISTRO], [REDHAT | SUSE | OPENMANDRIVA | MAGEIA | OPENCLOUDOS | OPENEULER ], [true],
                         [*], [false])])
 AM_CONDITIONAL([HAVE_DPKG],
     [AS_CASE([$DISTRO], [DEBIAN | UBUNTU ], [true],
-- 
2.43.0

