https://gitlab.com/libosinfo/libosinfo/issues/20 Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- osinfo/osinfo_db.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c index 2cecaf6..6885a3f 100644 --- a/osinfo/osinfo_db.c +++ b/osinfo/osinfo_db.c @@ -544,6 +544,7 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db, { OsinfoOs *ret = NULL; GList *oss = NULL; + GList *unknown_oss = NULL; GList *os_iter; const gchar *media_arch; const gchar *media_volume; @@ -587,6 +588,11 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db, os_vol_size <= 0) continue; + if (g_str_equal(os_arch, "unknown")) { + unknown_oss = g_list_prepend(unknown_oss, os); + continue; + } + if (os_vol_size <= 0) os_vol_size = media_vol_size; @@ -606,11 +612,51 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db, g_list_free(medias); g_object_unref(media_list); + if (ret) + goto end; + } + + for (os_iter = unknown_oss; os_iter; os_iter = os_iter->next) { + OsinfoOs *os = OSINFO_OS(os_iter->data); + OsinfoMediaList *media_list = osinfo_os_get_media_list(os); + GList *medias = osinfo_list_get_elements(OSINFO_LIST(media_list)); + GList *media_iter; + + medias = g_list_sort(medias, media_volume_compare); + + for (media_iter = medias; media_iter; media_iter = media_iter->next) { + OsinfoMedia *os_media = OSINFO_MEDIA(media_iter->data); + const gchar *os_volume = osinfo_media_get_volume_id(os_media); + const gchar *os_system = osinfo_media_get_system_id(os_media); + const gchar *os_publisher = osinfo_media_get_publisher_id(os_media); + const gchar *os_application = osinfo_media_get_application_id(os_media); + gint64 os_vol_size = osinfo_media_get_volume_size(os_media); + + if (os_vol_size <= 0) + os_vol_size = media_vol_size; + + if (match_regex(os_volume, media_volume) && + match_regex(os_application, media_application) && + match_regex(os_system, media_system) && + match_regex(os_publisher, media_publisher) && + os_vol_size == media_vol_size) { + ret = os; + if (matched_media != NULL) + *matched_media = os_media; + break; + } + } + + g_list_free(medias); + g_object_unref(media_list); + if (ret) break; } + end: g_list_free(oss); + g_list_free(unknown_oss); return ret; } -- 2.20.1 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo