Since Void Linux provides only an /etc/os-release with no VERSION_ID
field, then special-case it to avoid that the os-release parsing ignore
it.
This provides basic distro identification, and icon.
---
generator/actions.ml | 4 ++++
inspector/virt-inspector.rng | 1 +
src/guestfs-internal.h | 1 +
src/inspect-fs-unix.c | 14 ++++++++++++--
src/inspect-fs.c | 2 ++
src/inspect-icon.c | 13 +++++++++++++
src/inspect.c | 1 +
7 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/generator/actions.ml b/generator/actions.ml
index b17808e..25d3c0d 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -1183,6 +1183,10 @@ Ubuntu.
The distro could not be determined.
+=item \"voidlinux\"
+
+Void Linux.
+
=item \"windows\"
Windows does not have distributions. This string is
diff --git a/inspector/virt-inspector.rng b/inspector/virt-inspector.rng
index c861c80..c4c423c 100644
--- a/inspector/virt-inspector.rng
+++ b/inspector/virt-inspector.rng
@@ -108,6 +108,7 @@
<value>suse-based</value>
<value>ttylinux</value>
<value>ubuntu</value>
+ <value>voidlinux</value>
<value>windows</value>
<!-- "unknown" is intentionally left out -->
</choice>
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index 0340687..8a36ab7 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -569,6 +569,7 @@ enum inspect_os_distro {
OS_DISTRO_ALTLINUX,
OS_DISTRO_FRUGALWARE,
OS_DISTRO_PLD_LINUX,
+ OS_DISTRO_VOID_LINUX,
};
enum inspect_os_package_format {
diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c
index 0e64e33..4d41086 100644
--- a/src/inspect-fs-unix.c
+++ b/src/inspect-fs-unix.c
@@ -216,6 +216,8 @@ parse_os_release (guestfs_h *g, struct inspect_fs *fs, const char
*filename)
distro = OS_DISTRO_SLES;
else if (VALUE_IS ("ubuntu"))
distro = OS_DISTRO_UBUNTU;
+ else if (VALUE_IS ("void"))
+ distro = OS_DISTRO_VOID_LINUX;
} else if (STRPREFIX (line, "PRETTY_NAME=")) {
free (product_name);
product_name = safe_strndup (g, value, value_len);
@@ -229,10 +231,18 @@ parse_os_release (guestfs_h *g, struct inspect_fs *fs, const char
*filename)
}
/* If we haven't got all the fields, exit right away. */
- if (distro == OS_DISTRO_UNKNOWN || product_name == NULL ||
- version.v_major == -1 || version.v_minor == -1)
+ if (distro == OS_DISTRO_UNKNOWN || product_name == NULL)
return 0;
+ if (version.v_major == -1 || version.v_minor == -1) {
+ /* Void Linux has no VERSION_ID (yet), but since it's a rolling
+ * distro and has no other version/release-like file. */
+ if (distro == OS_DISTRO_VOID_LINUX)
+ version_init_null (&version);
+ else
+ return 0;
+ }
+
/* Apparently, os-release in Debian and CentOS does not provide the full
* version number in VERSION_ID, but just the "major" part of it.
* Hence, if version.v_minor is 0, act as there was no information in
diff --git a/src/inspect-fs.c b/src/inspect-fs.c
index ca96667..c718773 100644
--- a/src/inspect-fs.c
+++ b/src/inspect-fs.c
@@ -499,6 +499,7 @@ guestfs_int_check_package_format (guestfs_h *g, struct inspect_fs
*fs)
case OS_DISTRO_OPENBSD:
case OS_DISTRO_FRUGALWARE:
case OS_DISTRO_PLD_LINUX:
+ case OS_DISTRO_VOID_LINUX:
case OS_DISTRO_UNKNOWN:
fs->package_format = OS_PACKAGE_FORMAT_UNKNOWN;
break;
@@ -583,6 +584,7 @@ guestfs_int_check_package_management (guestfs_h *g, struct inspect_fs
*fs)
case OS_DISTRO_OPENBSD:
case OS_DISTRO_FRUGALWARE:
case OS_DISTRO_PLD_LINUX:
+ case OS_DISTRO_VOID_LINUX:
case OS_DISTRO_UNKNOWN:
fs->package_management = OS_PACKAGE_MANAGEMENT_UNKNOWN;
break;
diff --git a/src/inspect-icon.c b/src/inspect-icon.c
index 2f084b7..e8edee0 100644
--- a/src/inspect-icon.c
+++ b/src/inspect-icon.c
@@ -61,6 +61,7 @@ static char *icon_opensuse (guestfs_h *g, struct inspect_fs *fs, size_t
*size_r)
#if CAN_DO_CIRROS
static char *icon_cirros (guestfs_h *g, struct inspect_fs *fs, size_t *size_r);
#endif
+static char *icon_voidlinux (guestfs_h *g, struct inspect_fs *fs, size_t *size_r);
#if CAN_DO_WINDOWS
static char *icon_windows (guestfs_h *g, struct inspect_fs *fs, size_t *size_r);
#endif
@@ -158,6 +159,10 @@ guestfs_impl_inspect_get_icon (guestfs_h *g, const char *root, size_t
*size_r,
#endif
break;
+ case OS_DISTRO_VOID_LINUX:
+ r = icon_voidlinux (g, fs, &size);
+ break;
+
/* These are just to keep gcc warnings happy. */
case OS_DISTRO_ARCHLINUX:
case OS_DISTRO_BUILDROOT:
@@ -420,6 +425,14 @@ icon_cirros (guestfs_h *g, struct inspect_fs *fs, size_t *size_r)
#endif /* CAN_DO_CIRROS */
+#define VOIDLINUX_ICON "/usr/share/void-artwork/void-logo.png"
+
+static char *
+icon_voidlinux (guestfs_h *g, struct inspect_fs *fs, size_t *size_r)
+{
+ return get_png (g, fs, VOIDLINUX_ICON, size_r, 20480);
+}
+
#if CAN_DO_WINDOWS
/* Windows, as usual, has to be much more complicated and stupid than
diff --git a/src/inspect.c b/src/inspect.c
index bd32d8f..29b4f85 100644
--- a/src/inspect.c
+++ b/src/inspect.c
@@ -291,6 +291,7 @@ guestfs_impl_inspect_get_distro (guestfs_h *g, const char *root)
case OS_DISTRO_TTYLINUX: ret = safe_strdup (g, "ttylinux"); break;
case OS_DISTRO_WINDOWS: ret = safe_strdup (g, "windows"); break;
case OS_DISTRO_UBUNTU: ret = safe_strdup (g, "ubuntu"); break;
+ case OS_DISTRO_VOID_LINUX: ret = safe_strdup (g, "voidlinux"); break;
case OS_DISTRO_UNKNOWN: ret = safe_strdup (g, "unknown"); break;
}
--
2.5.5