Few improvements to the results of the inspection on some distros. Pino Toscano (5): inspect: factorize list of rolling distros inspect: detect Gentoo from os-release inspect: fully detect Arch Linux from os-release inspect: return osinfo short IDs for rolling distros inspect: correct osinfo ID for ALT Linux >= 8 daemon/inspect_fs_unix.ml | 15 +++++++++------ inspector/expected-archlinux.img.xml | 1 + lib/inspect-osinfo.c | 8 ++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) -- 2.20.1
Pino Toscano
2019-Apr-02 12:56 UTC
[Libguestfs] [PATCH 1/5] inspect: factorize list of rolling distros
Use a static list of rolling distros, so it is easier to handle them differently; use this list for handling the lack of VERSION_ID in os-release files. This is just refactoring, no behaviour changes. --- daemon/inspect_fs_unix.ml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/daemon/inspect_fs_unix.ml b/daemon/inspect_fs_unix.ml index 57a24ef01..8b7096d30 100644 --- a/daemon/inspect_fs_unix.ml +++ b/daemon/inspect_fs_unix.ml @@ -58,6 +58,12 @@ let re_neokylin_version = PCRE.compile "^V(\\d+)Update(\\d+)$" let arch_binaries [ "/bin/bash"; "/bin/ls"; "/bin/echo"; "/bin/rm"; "/bin/sh" ] +(* List of typical rolling distros, to ease handling them for common + * features. + *) +let rolling_distros + [ DISTRO_VOID_LINUX ] + (* Parse a os-release file. * * Only few fields are parsed, falling back to the usual detection if we @@ -102,12 +108,8 @@ let rec parse_os_release release_file data version = Some (_, 0) } -> false - (* Rolling releases: - * Void Linux has no VERSION_ID and no other version/release- - * like file. - *) - | { distro = Some DISTRO_VOID_LINUX; - version = None } -> + (* Rolling distros: no VERSION_ID available. *) + | { distro = Some d; version = None } when List.mem d rolling_distros -> data.version <- Some (0, 0); true -- 2.20.1
Pino Toscano
2019-Apr-02 12:56 UTC
[Libguestfs] [PATCH 2/5] inspect: detect Gentoo from os-release
Add "gentoo" as recognized ID in /etc/os-release, and consider it as rolling distribution (so without VERSION_ID in os-release). This avoids using a not-useful version read from /etc/gentoo-release, e.g. "Gentoo Base System release 2.6". --- daemon/inspect_fs_unix.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/daemon/inspect_fs_unix.ml b/daemon/inspect_fs_unix.ml index 8b7096d30..84283546b 100644 --- a/daemon/inspect_fs_unix.ml +++ b/daemon/inspect_fs_unix.ml @@ -62,7 +62,7 @@ let arch_binaries * features. *) let rolling_distros - [ DISTRO_VOID_LINUX ] + [ DISTRO_GENTOO; DISTRO_VOID_LINUX ] (* Parse a os-release file. * @@ -142,6 +142,7 @@ and distro_of_os_release_id = function | "debian" -> Some DISTRO_DEBIAN | "fedora" -> Some DISTRO_FEDORA | "frugalware" -> Some DISTRO_FRUGALWARE + | "gentoo" -> Some DISTRO_GENTOO | "kali" -> Some DISTRO_KALI_LINUX | "mageia" -> Some DISTRO_MAGEIA | "neokylin" -> Some DISTRO_NEOKYLIN -- 2.20.1
Pino Toscano
2019-Apr-02 12:56 UTC
[Libguestfs] [PATCH 3/5] inspect: fully detect Arch Linux from os-release
Consider Arch Linux as rolling distribution, so it is recognized using /etc/os-release. The end result does not change, although this makes Arch Linux inspected using os-release only, instead of getting inspection details mixed from both os-release and lsb-release. --- daemon/inspect_fs_unix.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/inspect_fs_unix.ml b/daemon/inspect_fs_unix.ml index 84283546b..6006df638 100644 --- a/daemon/inspect_fs_unix.ml +++ b/daemon/inspect_fs_unix.ml @@ -62,7 +62,7 @@ let arch_binaries * features. *) let rolling_distros - [ DISTRO_GENTOO; DISTRO_VOID_LINUX ] + [ DISTRO_ARCHLINUX; DISTRO_GENTOO; DISTRO_VOID_LINUX ] (* Parse a os-release file. * -- 2.20.1
Pino Toscano
2019-Apr-02 12:56 UTC
[Libguestfs] [PATCH 4/5] inspect: return osinfo short IDs for rolling distros
Return the right osinfo short IDs for some rolling Linux distributions, such as Arch Linux, Gentoo, and Void Linux. Their IDs were recently added to osinfo-db. --- inspector/expected-archlinux.img.xml | 1 + lib/inspect-osinfo.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/inspector/expected-archlinux.img.xml b/inspector/expected-archlinux.img.xml index b6c3b9c92..5906cf60f 100644 --- a/inspector/expected-archlinux.img.xml +++ b/inspector/expected-archlinux.img.xml @@ -10,6 +10,7 @@ <package_format>pacman</package_format> <package_management>pacman</package_management> <hostname>archlinux.test</hostname> + <osinfo>archlinux</osinfo> <mountpoints> <mountpoint dev="/dev/sda1">/</mountpoint> </mountpoints> diff --git a/lib/inspect-osinfo.c b/lib/inspect-osinfo.c index e0d19c672..51612bad1 100644 --- a/lib/inspect-osinfo.c +++ b/lib/inspect-osinfo.c @@ -59,6 +59,9 @@ guestfs_impl_inspect_get_osinfo (guestfs_h *g, const char *root) } else if (STREQ (distro, "ubuntu")) return safe_asprintf (g, "%s%d.%02d", distro, major, minor); + else if (STREQ (distro, "archlinux") || STREQ (distro, "gentoo") + || STREQ (distro, "voidlinux")) + return safe_strdup (g, distro); if (major > 0 || minor > 0) return safe_asprintf (g, "%s%d.%d", distro, major, minor); -- 2.20.1
Pino Toscano
2019-Apr-02 12:56 UTC
[Libguestfs] [PATCH 5/5] inspect: correct osinfo ID for ALT Linux >= 8
ALT Linux 8.x has different IDs in osinfo-db, so return the proper IDs for the newest stable series. --- lib/inspect-osinfo.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/inspect-osinfo.c b/lib/inspect-osinfo.c index 51612bad1..90b7ffd86 100644 --- a/lib/inspect-osinfo.c +++ b/lib/inspect-osinfo.c @@ -62,6 +62,11 @@ guestfs_impl_inspect_get_osinfo (guestfs_h *g, const char *root) else if (STREQ (distro, "archlinux") || STREQ (distro, "gentoo") || STREQ (distro, "voidlinux")) return safe_strdup (g, distro); + else if (STREQ (distro, "altlinux")) { + if (major >= 8) + return safe_asprintf (g, "alt%d.%d", major, minor); + return safe_asprintf (g, "%s%d.%d", distro, major, minor); + } if (major > 0 || minor > 0) return safe_asprintf (g, "%s%d.%d", distro, major, minor); -- 2.20.1
Richard W.M. Jones
2019-Apr-03 12:24 UTC
Re: [Libguestfs] [PATCH 5/5] inspect: correct osinfo ID for ALT Linux >= 8
On Tue, Apr 02, 2019 at 02:56:30PM +0200, Pino Toscano wrote:> ALT Linux 8.x has different IDs in osinfo-db, so return the proper IDs > for the newest stable series. > --- > lib/inspect-osinfo.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/lib/inspect-osinfo.c b/lib/inspect-osinfo.c > index 51612bad1..90b7ffd86 100644 > --- a/lib/inspect-osinfo.c > +++ b/lib/inspect-osinfo.c > @@ -62,6 +62,11 @@ guestfs_impl_inspect_get_osinfo (guestfs_h *g, const char *root) > else if (STREQ (distro, "archlinux") || STREQ (distro, "gentoo") > || STREQ (distro, "voidlinux")) > return safe_strdup (g, distro); > + else if (STREQ (distro, "altlinux")) { > + if (major >= 8) > + return safe_asprintf (g, "alt%d.%d", major, minor); > + return safe_asprintf (g, "%s%d.%d", distro, major, minor); > + }ACK series. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Reasonably Related Threads
- [PATCH] inspect: correct osinfo ID for CentOS >= 8
- [PATCH] inspect: return osinfo short IDs for recent Windows versions
- [PATCH v2] inspect: return osinfo short IDs for recent Windows versions
- [PATCH 0/5] Small inspection improvements
- [PATCH] inspect: avoid returning "unknownX.Y" for unknown Linux distros