[Libosinfo] [libosinfo PATCH 3/3] osinfo-detect: Be aware of tree's os variants

Daniel P. Berrangé berrange at redhat.com
Fri Apr 12 08:26:16 UTC 2019


On Fri, Apr 12, 2019 at 10:19:54AM +0200, Fabiano Fidêncio wrote:
> In the same way done for medias, make the tree detection aware of
> os-variants.
> 
> https://gitlab.com/libosinfo/libosinfo/issues/25
> 
> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
> ---
>  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 a753bfa..4eef703 100644
> --- a/tools/osinfo-detect.c
> +++ b/tools/osinfo-detect.c
> @@ -201,9 +201,37 @@ static void print_os_tree(OsinfoOs *os, OsinfoTree *tree, OsinfoTree *matched_tr
>          if (bootiso)
>              g_print("OSINFO_TREE_BOOT_ISO=%s\n", bootiso);

We should be printing info about variants in the machine readable
section too IMHO - that's a pre-existing bug for media too.

>      } else {
> -        const gchar *name = osinfo_product_get_name(OSINFO_PRODUCT(os));
> +        OsinfoOsVariantList *variants;
> +        const gchar *name;
> +        guint num_variants;
> +
> +        variants = osinfo_tree_get_os_variants(matched_tree);
> +        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));
> +        }
>  
>          g_print(_("Tree is an installer for OS '%s'\n"), name);
> +
> +        if (num_variants > 1) {
> +            guint i;
> +
> +            g_print(_("Available OS variants on tree:\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);
>      }
>  }
>  
> -- 
> 2.20.1
> 
> _______________________________________________
> Libosinfo mailing list
> Libosinfo at redhat.com
> https://www.redhat.com/mailman/listinfo/libosinfo

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the Libosinfo mailing list