From 1d8924c343b2f0022767c1d5d5c059ea9d8f4d7e 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(-)

Index: libguestfs-1.49.5/daemon/inspect_fs.ml
===================================================================
--- libguestfs-1.49.5.orig/daemon/inspect_fs.ml
+++ libguestfs-1.49.5/daemon/inspect_fs.ml
@@ -265,6 +265,7 @@ and check_package_format { distro } =
   | Some DISTRO_MANDRIVA
   | Some DISTRO_MEEGO
   | Some DISTRO_NEOKYLIN
+  | Some DISTRO_OPENEULER
   | Some DISTRO_OPENMANDRIVA
   | Some DISTRO_OPENSUSE
   | Some DISTRO_ORACLE_LINUX
@@ -362,6 +363,9 @@ and check_package_management { distro; v
   | Some DISTRO_PARDUS ->
      Some PACKAGE_MANAGEMENT_PISI
 
+  | Some DISTRO_OPENEULER->
+     Some PACKAGE_MANAGEMENT_DNF
+
   | Some DISTRO_MAGEIA
   | Some DISTRO_MANDRIVA ->
      Some PACKAGE_MANAGEMENT_URPMI
Index: libguestfs-1.49.5/daemon/inspect_fs_unix.ml
===================================================================
--- libguestfs-1.49.5.orig/daemon/inspect_fs_unix.ml
+++ libguestfs-1.49.5/daemon/inspect_fs_unix.ml
@@ -151,6 +151,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
   | "opensuse" -> Some DISTRO_OPENSUSE
   | s when String.is_prefix s "opensuse-" -> Some DISTRO_OPENSUSE
Index: libguestfs-1.49.5/daemon/inspect_types.ml
===================================================================
--- libguestfs-1.49.5.orig/daemon/inspect_types.ml
+++ libguestfs-1.49.5/daemon/inspect_types.ml
@@ -88,6 +88,7 @@ and distro =
   | DISTRO_NEOKYLIN
   | DISTRO_NETBSD
   | DISTRO_OPENBSD
+  | DISTRO_OPENEULER
   | DISTRO_OPENMANDRIVA
   | DISTRO_OPENSUSE
   | DISTRO_ORACLE_LINUX
@@ -222,6 +223,7 @@ and string_of_distro = function
   | DISTRO_NEOKYLIN -> "neokylin"
   | DISTRO_NETBSD -> "netbsd"
   | DISTRO_OPENBSD -> "openbsd"
+  | DISTRO_OPENEULER -> "openeuler"
   | DISTRO_OPENMANDRIVA -> "openmandriva"
   | DISTRO_OPENSUSE -> "opensuse"
   | DISTRO_ORACLE_LINUX -> "oraclelinux"
Index: libguestfs-1.49.5/daemon/inspect_types.mli
===================================================================
--- libguestfs-1.49.5.orig/daemon/inspect_types.mli
+++ libguestfs-1.49.5/daemon/inspect_types.mli
@@ -95,6 +95,7 @@ and distro =
   | DISTRO_NEOKYLIN
   | DISTRO_NETBSD
   | DISTRO_OPENBSD
+  | DISTRO_OPENEULER
   | DISTRO_OPENMANDRIVA
   | DISTRO_OPENSUSE
   | DISTRO_ORACLE_LINUX
Index: libguestfs-1.49.5/generator/actions_inspection.ml
===================================================================
--- libguestfs-1.49.5.orig/generator/actions_inspection.ml
+++ libguestfs-1.49.5/generator/actions_inspection.ml
@@ -250,6 +250,10 @@ NetBSD.
 
 OpenBSD.
 
+=item \"openeuler\"
+
+openEuler.
+
 =item \"openmandriva\"
 
 OpenMandriva Lx.
Index: libguestfs-1.49.5/m4/guestfs-appliance.m4
===================================================================
--- libguestfs-1.49.5.orig/m4/guestfs-appliance.m4
+++ libguestfs-1.49.5/m4/guestfs-appliance.m4
@@ -119,7 +119,8 @@ if test "x$ENABLE_APPLIANCE" = "xyes"; t
                             [DISTRO=REDHAT],
                         [OPENSUSE* | SLED | SLES],[DISTRO=SUSE],
                         [ARCH | MANJARO | ARTIX],[DISTRO=ARCHLINUX],
-                        [OPENMANDRIVA],[DISTRO=OPENMANDRIVA])
+                        [OPENMANDRIVA],[DISTRO=OPENMANDRIVA],
+                        [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])
@@ -129,7 +130,7 @@ if test "x$ENABLE_APPLIANCE" = "xyes"; t
     AC_SUBST([DISTRO])
 fi
 AM_CONDITIONAL([HAVE_RPM],
-    [AS_CASE([$DISTRO], [REDHAT | SUSE | OPENMANDRIVA | MAGEIA ], [true],
+    [AS_CASE([$DISTRO], [REDHAT | SUSE | OPENMANDRIVA | MAGEIA | OPENEULER ], [true],
                         [*], [false])])
 AM_CONDITIONAL([HAVE_DPKG],
     [AS_CASE([$DISTRO], [DEBIAN | UBUNTU ], [true],
