mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
inspect: recognize the Void Linux distribution
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user