Richard W.M. Jones
2017-Oct-12 09:39 UTC
[Libguestfs] [PATCH] daemon: inspection: Add support for NeoKylin (RHBZ#1476081).
Thanks: Qingzheng Zhang --- daemon/inspect_fs.ml | 7 +++++++ daemon/inspect_fs_unix.ml | 16 +++++++++++++++- daemon/inspect_types.ml | 2 ++ daemon/inspect_types.mli | 1 + generator/actions_inspection.ml | 4 ++++ inspector/virt-inspector.rng | 1 + 6 files changed, 30 insertions(+), 1 deletion(-) diff --git a/daemon/inspect_fs.ml b/daemon/inspect_fs.ml index 93a9f4732..f639bf3b9 100644 --- a/daemon/inspect_fs.ml +++ b/daemon/inspect_fs.ml @@ -253,6 +253,7 @@ and check_package_format { distro } | Some DISTRO_MAGEIA | Some DISTRO_MANDRIVA | Some DISTRO_MEEGO + | Some DISTRO_NEOKYLIN | Some DISTRO_OPENSUSE | Some DISTRO_ORACLE_LINUX | Some DISTRO_REDHAT_BASED @@ -307,6 +308,12 @@ and check_package_management { distro; version } (* Probably parsing the release file failed, see RHBZ#1332025. *) None + | Some DISTRO_NEOKYLIN -> + (* We don't have access to NeoKylin for testing, but it is + * supposed to be a Fedora derivative. + *) + Some PACKAGE_MANAGEMENT_DNF + | Some DISTRO_CENTOS | Some DISTRO_ORACLE_LINUX | Some DISTRO_REDHAT_BASED diff --git a/daemon/inspect_fs_unix.ml b/daemon/inspect_fs_unix.ml index ce48942bd..3b57899cc 100644 --- a/daemon/inspect_fs_unix.ml +++ b/daemon/inspect_fs_unix.ml @@ -53,6 +53,7 @@ let re_minix = PCRE.compile "^(\\d+)\\.(\\d+)(\\.(\\d+))?" let re_openbsd = PCRE.compile "^OpenBSD (\\d+|\\?)\\.(\\d+|\\?)" let re_frugalware = PCRE.compile "Frugalware (\\d+)\\.(\\d+)" let re_pldlinux = PCRE.compile "(\\d+)\\.(\\d+) PLD Linux" +let re_neokylin_version = PCRE.compile "^V(\\d+)Update(\\d+)$" let arch_binaries [ "/bin/bash"; "/bin/ls"; "/bin/echo"; "/bin/rm"; "/bin/sh" ] @@ -94,7 +95,7 @@ let rec parse_os_release release_file data else if key = "PRETTY_NAME" then data.product_name <- Some value else if key = "VERSION_ID" then - parse_version_from_major_minor value data + parse_os_release_version_id value data ) ) lines; @@ -124,6 +125,18 @@ let rec parse_os_release release_file data | _ -> true ) +and parse_os_release_version_id value data + (* NeoKylin uses a non-standard format in the VERSION_ID + * field (RHBZ#1476081). + *) + if PCRE.matches re_neokylin_version value then ( + let major = int_of_string (PCRE.sub 1) + and minor = int_of_string (PCRE.sub 2) in + data.version <- Some (major, minor) + ) + else + parse_version_from_major_minor value data + (* ID="fedora" => Some DISTRO_FEDORA *) and distro_of_os_release_id = function | "alpine" -> Some DISTRO_ALPINE_LINUX @@ -135,6 +148,7 @@ and distro_of_os_release_id = function | "fedora" -> Some DISTRO_FEDORA | "frugalware" -> Some DISTRO_FRUGALWARE | "mageia" -> Some DISTRO_MAGEIA + | "neokylin" -> Some DISTRO_NEOKYLIN | "opensuse" -> Some DISTRO_OPENSUSE | "pld" -> Some DISTRO_PLD_LINUX | "rhel" -> Some DISTRO_RHEL diff --git a/daemon/inspect_types.ml b/daemon/inspect_types.ml index 1da41064d..333d2679a 100644 --- a/daemon/inspect_types.ml +++ b/daemon/inspect_types.ml @@ -82,6 +82,7 @@ and distro | DISTRO_MAGEIA | DISTRO_MANDRIVA | DISTRO_MEEGO + | DISTRO_NEOKYLIN | DISTRO_NETBSD | DISTRO_OPENBSD | DISTRO_OPENSUSE @@ -210,6 +211,7 @@ and string_of_distro = function | DISTRO_MAGEIA -> "mageia" | DISTRO_MANDRIVA -> "mandriva" | DISTRO_MEEGO -> "meego" + | DISTRO_NEOKYLIN -> "neokylin" | DISTRO_NETBSD -> "netbsd" | DISTRO_OPENBSD -> "openbsd" | DISTRO_OPENSUSE -> "opensuse" diff --git a/daemon/inspect_types.mli b/daemon/inspect_types.mli index 5c2151e14..d873df8c9 100644 --- a/daemon/inspect_types.mli +++ b/daemon/inspect_types.mli @@ -89,6 +89,7 @@ and distro | DISTRO_MAGEIA | DISTRO_MANDRIVA | DISTRO_MEEGO + | DISTRO_NEOKYLIN | DISTRO_NETBSD | DISTRO_OPENBSD | DISTRO_OPENSUSE diff --git a/generator/actions_inspection.ml b/generator/actions_inspection.ml index d67d00833..675a7e2e2 100644 --- a/generator/actions_inspection.ml +++ b/generator/actions_inspection.ml @@ -226,6 +226,10 @@ Mandriva. MeeGo. +=item \"neokylin\" + +NeoKylin. + =item \"netbsd\" NetBSD. diff --git a/inspector/virt-inspector.rng b/inspector/virt-inspector.rng index 857a02766..314785202 100644 --- a/inspector/virt-inspector.rng +++ b/inspector/virt-inspector.rng @@ -90,6 +90,7 @@ <value>mageia</value> <value>mandriva</value> <value>meego</value> + <value>neokylin</value> <value>netbsd</value> <value>openbsd</value> <value>opensuse</value> -- 2.13.2
Pino Toscano
2017-Oct-12 14:34 UTC
Re: [Libguestfs] [PATCH] daemon: inspection: Add support for NeoKylin (RHBZ#1476081).
On Thursday, 12 October 2017 11:39:34 CEST Richard W.M. Jones wrote:> Thanks: Qingzheng Zhang > --- > daemon/inspect_fs.ml | 7 +++++++ > daemon/inspect_fs_unix.ml | 16 +++++++++++++++- > daemon/inspect_types.ml | 2 ++ > daemon/inspect_types.mli | 1 + > generator/actions_inspection.ml | 4 ++++ > inspector/virt-inspector.rng | 1 + > 6 files changed, 30 insertions(+), 1 deletion(-)LGTM, although un-testable (with a real guest, I mean)... :-/ -- Pino Toscano
Possibly Parallel Threads
- [PATCH v2] daemon: add inspector support for MS-DOS distro
- [PATCH] daemon: add inspector support for MS-DOS distro
- [PATCH] inspect: recognize the Kali Linux distribution (RHBZ#1544227)
- [PATCH v12 08/11] daemon: Implement inspection types and utility functions.
- [PATCH] inspect: handle os-release "opensuse-tumbleweed" as opensuse