[Libosinfo] [[PATCH v3] 5/6] tools: osinfo-detect prints variant
Zeeshan Ali (Khattak)
zeeshanak at gnome.org
Thu Nov 28 15:10:23 UTC 2013
If a particular variant is matched against, osinfo-detect should print
the name of that variant rather than the OS itself.
---
tools/osinfo-detect.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/tools/osinfo-detect.c b/tools/osinfo-detect.c
index 0f837de..cf737f2 100644
--- a/tools/osinfo-detect.c
+++ b/tools/osinfo-detect.c
@@ -136,12 +136,40 @@ static void print_media(OsinfoMedia *media)
g_print("OSINFO_MEDIA=%s\n",
osinfo_entity_get_id(OSINFO_ENTITY(media)));
} else {
- const gchar *name = osinfo_product_get_name(OSINFO_PRODUCT(os));
+ OsinfoOsVariantList *variants;
+ const gchar *name;
+ guint num_variants;
+
+ variants = osinfo_media_get_os_variants(media);
+ num_variants = osinfo_list_get_length(OSINFO_LIST(variants));
+ if (num_variants == 1) {
+ OsinfoEntity *variant;
+
+ variant = osinfo_list_get_nth(OSINFO_LIST(variants), 0);
+ name = osinfo_os_variant_get_name(OSINFO_OS_VARIANT(variant));
+ } else {
+ name = osinfo_product_get_name(OSINFO_PRODUCT(os));
+ }
if (osinfo_media_get_installer (media))
g_print(_("Media is an installer for OS '%s'\n"), name);
if (osinfo_media_get_live (media))
g_print(_("Media is live media for OS '%s'\n"), name);
+
+ if (num_variants > 1) {
+ guint i;
+
+ g_print(_("Available OS variants on media:\n"));
+ for (i = 0; i < num_variants; i++) {
+ OsinfoEntity *variant;
+
+ variant = osinfo_list_get_nth(OSINFO_LIST(variants), i);
+ name = osinfo_os_variant_get_name(OSINFO_OS_VARIANT(variant));
+ g_print("%s\n", name);
+ }
+ }
+
+ g_clear_object(&variants);
}
g_object_unref(os);
}
--
1.8.4.2
More information about the Libosinfo
mailing list