diff --git a/SOURCES/0001-Use-g_list_free_full-where-easily-possible.patch b/SOURCES/0001-Use-g_list_free_full-where-easily-possible.patch
new file mode 100644
index 0000000..9ae5a7a
--- /dev/null
+++ b/SOURCES/0001-Use-g_list_free_full-where-easily-possible.patch
@@ -0,0 +1,258 @@
+From f4bae6ba2f20caa6e3bf6fa7a7ea52eaf2180beb Mon Sep 17 00:00:00 2001
+From: Pino Toscano <ptoscano@redhat.com>
+Date: Thu, 20 Dec 2018 10:56:25 +0100
+Subject: [PATCH] Use g_list_free_full where easily possible
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Use g_list_free_full instead of g_list_foreach + g_list_free, so the
+lists are cleared with a single call.
+
+test-isodetect gets a void* wrapper, so there is no need to add casts
+everywhere.
+
+Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
+(cherry picked from commit 4fe69c9fe31befe3caa55bbaac0bcfa5e605f028)
+---
+ osinfo/osinfo_deployment.c    |  8 +-------
+ osinfo/osinfo_entity.c        |  7 +------
+ osinfo/osinfo_filter.c        |  9 +--------
+ osinfo/osinfo_loader.c        |  3 +--
+ osinfo/osinfo_os.c            |  8 +-------
+ osinfo/osinfo_platform.c      |  8 +-------
+ osinfo/osinfo_product.c       |  5 ++---
+ osinfo/osinfo_productfilter.c |  9 +--------
+ tests/test-isodetect.c        | 17 +++++++++++------
+ 9 files changed, 20 insertions(+), 54 deletions(-)
+
+diff --git a/osinfo/osinfo_deployment.c b/osinfo/osinfo_deployment.c
+index 7191ac3..a79b32f 100644
+--- a/osinfo/osinfo_deployment.c
++++ b/osinfo/osinfo_deployment.c
+@@ -114,18 +114,12 @@ osinfo_deployment_get_property(GObject *object,
+ 
+ 
+ 
+-static void osinfo_device_link_free(gpointer data, gpointer opaque G_GNUC_UNUSED)
+-{
+-    g_object_unref(OSINFO_DEVICELINK(data));
+-}
+-
+ static void
+ osinfo_deployment_finalize(GObject *object)
+ {
+     OsinfoDeployment *deployment = OSINFO_DEPLOYMENT(object);
+ 
+-    g_list_foreach(deployment->priv->deviceLinks, osinfo_device_link_free, NULL);
+-    g_list_free(deployment->priv->deviceLinks);
++    g_list_free_full(deployment->priv->deviceLinks, g_object_unref);
+ 
+     g_object_unref(deployment->priv->os);
+     g_object_unref(deployment->priv->platform);
+diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c
+index 20b9115..a776baa 100644
+--- a/osinfo/osinfo_entity.c
++++ b/osinfo/osinfo_entity.c
+@@ -146,15 +146,10 @@ osinfo_entity_class_init(OsinfoEntityClass *klass)
+     g_type_class_add_private(klass, sizeof(OsinfoEntityPrivate));
+ }
+ 
+-static void osinfo_entity_param_value_free(gpointer value, gpointer opaque G_GNUC_UNUSED)
+-{
+-    g_free(value);
+-}
+ 
+ static void osinfo_entity_param_values_free(gpointer values)
+ {
+-    g_list_foreach(values, osinfo_entity_param_value_free, NULL);
+-    g_list_free(values);
++    g_list_free_full(values, g_free);
+ }
+ 
+ 
+diff --git a/osinfo/osinfo_filter.c b/osinfo/osinfo_filter.c
+index 7f06d43..1c38735 100644
+--- a/osinfo/osinfo_filter.c
++++ b/osinfo/osinfo_filter.c
+@@ -88,17 +88,10 @@ OsinfoFilter *osinfo_filter_new(void)
+ }
+ 
+ 
+-static void
+-osinfo_filter_prop_constraint_free(gpointer value, gpointer opaque G_GNUC_UNUSED)
+-{
+-    g_free(value);
+-}
+-
+ static void
+ osinfo_filter_prop_constraints_free(gpointer props)
+ {
+-    g_list_foreach(props, osinfo_filter_prop_constraint_free, NULL);
+-    g_list_free(props);
++    g_list_free_full(props, g_free);
+ }
+ 
+ 
+diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
+index dca23f1..d580b66 100644
+--- a/osinfo/osinfo_loader.c
++++ b/osinfo/osinfo_loader.c
+@@ -1898,8 +1898,7 @@ static void osinfo_loader_entity_files_free(OsinfoLoaderEntityFiles *files)
+ {
+     if (!files)
+         return;
+-    g_list_foreach(files->extensions, (GFunc)g_object_unref, NULL);
+-    g_list_free(files->extensions);
++    g_list_free_full(files->extensions, g_object_unref);
+     if (files->master)
+         g_object_unref(files->master);
+     g_free(files);
+diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
+index 4f74331..b77c687 100644
+--- a/osinfo/osinfo_os.c
++++ b/osinfo/osinfo_os.c
+@@ -75,11 +75,6 @@ enum {
+ 
+ static void osinfo_os_finalize(GObject *object);
+ 
+-static void osinfo_device_link_free(gpointer data, gpointer opaque G_GNUC_UNUSED)
+-{
+-    g_object_unref(OSINFO_DEVICELINK(data));
+-}
+-
+ static void
+ osinfo_os_get_property(GObject    *object,
+                         guint       property_id,
+@@ -112,8 +107,7 @@ osinfo_os_finalize(GObject *object)
+ {
+     OsinfoOs *os = OSINFO_OS(object);
+ 
+-    g_list_foreach(os->priv->deviceLinks, osinfo_device_link_free, NULL);
+-    g_list_free(os->priv->deviceLinks);
++    g_list_free_full(os->priv->deviceLinks, g_object_unref);
+     g_object_unref(os->priv->medias);
+     g_object_unref(os->priv->trees);
+     g_object_unref(os->priv->variants);
+diff --git a/osinfo/osinfo_platform.c b/osinfo/osinfo_platform.c
+index b17eef6..c949a83 100644
+--- a/osinfo/osinfo_platform.c
++++ b/osinfo/osinfo_platform.c
+@@ -52,18 +52,12 @@ struct _OsinfoPlatformDeviceLink {
+     gchar *driver;
+ };
+ 
+-static void osinfo_device_link_free(gpointer data, gpointer opaque G_GNUC_UNUSED)
+-{
+-    g_object_unref(OSINFO_DEVICELINK(data));
+-}
+-
+ static void
+ osinfo_platform_finalize(GObject *object)
+ {
+     OsinfoPlatform *platform = OSINFO_PLATFORM(object);
+ 
+-    g_list_foreach(platform->priv->deviceLinks, osinfo_device_link_free, NULL);
+-    g_list_free(platform->priv->deviceLinks);
++    g_list_free_full(platform->priv->deviceLinks, g_object_unref);
+ 
+     /* Chain up to the parent class */
+     G_OBJECT_CLASS(osinfo_platform_parent_class)->finalize(object);
+diff --git a/osinfo/osinfo_product.c b/osinfo/osinfo_product.c
+index 1bd7017..27cb89c 100644
+--- a/osinfo/osinfo_product.c
++++ b/osinfo/osinfo_product.c
+@@ -82,7 +82,7 @@ enum {
+     PROP_LOGO,
+ };
+ 
+-static void osinfo_product_link_free(gpointer data, gpointer opaque G_GNUC_UNUSED)
++static void osinfo_product_link_free(gpointer data)
+ {
+     struct _OsinfoProductProductLink *prodlink = data;
+     g_object_unref(prodlink->otherProduct);
+@@ -95,8 +95,7 @@ osinfo_product_finalize(GObject *object)
+ {
+     OsinfoProduct *product = OSINFO_PRODUCT(object);
+ 
+-    g_list_foreach(product->priv->productLinks, osinfo_product_link_free, NULL);
+-    g_list_free(product->priv->productLinks);
++    g_list_free_full(product->priv->productLinks, osinfo_product_link_free);
+ 
+     /* Chain up to the parent class */
+     G_OBJECT_CLASS(osinfo_product_parent_class)->finalize(object);
+diff --git a/osinfo/osinfo_productfilter.c b/osinfo/osinfo_productfilter.c
+index 16976c2..addd3dc 100644
+--- a/osinfo/osinfo_productfilter.c
++++ b/osinfo/osinfo_productfilter.c
+@@ -97,17 +97,10 @@ OsinfoProductFilter *osinfo_productfilter_new(void)
+ }
+ 
+ 
+-static void
+-osinfo_productfilter_product_constraint_free(gpointer value, gpointer opaque G_GNUC_UNUSED)
+-{
+-    g_object_unref(value);
+-}
+-
+ static void
+ osinfo_productfilter_product_constraints_free(gpointer relshps)
+ {
+-    g_list_foreach(relshps, osinfo_productfilter_product_constraint_free, NULL);
+-    g_list_free(relshps);
++    g_list_free_full(relshps, g_object_unref);
+ }
+ 
+ static void
+diff --git a/tests/test-isodetect.c b/tests/test-isodetect.c
+index 7214531..b5591bc 100644
+--- a/tests/test-isodetect.c
++++ b/tests/test-isodetect.c
+@@ -46,6 +46,14 @@ static void free_iso(struct ISOInfo *info)
+     g_free(info);
+ }
+ 
++/* void* wrapper for free_iso, so it can be used where a void* parameter
++ * is required (e.g. g_list_free_full), with no need for casts.
++ */
++static void free_iso_void(void *info)
++{
++    free_iso((struct ISOInfo *)info);
++}
++
+ static gboolean load_langs(GFile *file, struct ISOInfo *info, GError **error)
+ {
+     char *path;
+@@ -242,8 +250,7 @@ static GList *load_distro(GFile *dir, const gchar *shortid, GError **error) {
+     return ret;
+ 
+  error:
+-    g_list_foreach(ret, (GFunc)free_iso, NULL);
+-    g_list_free(ret);
++    g_list_free_full(ret, free_iso_void);
+     ret = NULL;
+     goto cleanup;
+ }
+@@ -288,8 +295,7 @@ static GList *load_distros(GFile *dir, GError **error)
+     return ret;
+ 
+  error:
+-    g_list_foreach(ret, (GFunc)free_iso, NULL);
+-    g_list_free(ret);
++    g_list_free_full(ret, free_iso_void);
+     ret = NULL;
+     goto cleanup;
+ }
+@@ -370,8 +376,7 @@ static void test_one(const gchar *vendor)
+         tmp = tmp->next;
+     }
+ 
+-    g_list_foreach(isos, (GFunc)free_iso, NULL);
+-    g_list_free(isos);
++    g_list_free_full(isos, free_iso_void);
+ 
+     g_object_unref(loader);
+ }
+-- 
+2.21.0
+
diff --git a/SOURCES/0002-loader-Replace-strcmp-with-g_str_equal.patch b/SOURCES/0002-loader-Replace-strcmp-with-g_str_equal.patch
new file mode 100644
index 0000000..9c0229d
--- /dev/null
+++ b/SOURCES/0002-loader-Replace-strcmp-with-g_str_equal.patch
@@ -0,0 +1,134 @@
+From f0f5147e25e188f6b6cbd734a20cc573e863e82b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
+Date: Tue, 4 Sep 2018 21:31:35 +0200
+Subject: [PATCH] loader: Replace strcmp() with g_str_equal()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1335291
+
+Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
+Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
+(cherry picked from commit fc431d26ca4d61213e72fa373354828909550033)
+---
+ osinfo/osinfo_loader.c | 68 +++++++++++++++++++++---------------------
+ 1 file changed, 34 insertions(+), 34 deletions(-)
+
+diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
+index d580b66..898dee9 100644
+--- a/osinfo/osinfo_loader.c
++++ b/osinfo/osinfo_loader.c
+@@ -1115,22 +1115,22 @@ static OsinfoMedia *osinfo_loader_media(OsinfoLoader *loader,
+     for (i = 0; i < nnodes; i++) {
+         if (!nodes[i]->children ||
+             nodes[i]->children->type != XML_TEXT_NODE ||
+-            (strcmp((const gchar *)nodes[i]->name,
+-                    OSINFO_MEDIA_PROP_VOLUME_ID) != 0 &&
+-             strcmp((const gchar *)nodes[i]->name,
+-                    OSINFO_MEDIA_PROP_SYSTEM_ID) != 0 &&
+-             strcmp((const gchar *)nodes[i]->name,
+-                    OSINFO_MEDIA_PROP_PUBLISHER_ID) != 0 &&
+-             strcmp((const gchar *)nodes[i]->name,
+-                    OSINFO_MEDIA_PROP_APPLICATION_ID) != 0 &&
+-             strcmp((const gchar *)nodes[i]->name,
+-                    OSINFO_MEDIA_PROP_LANG) != 0 &&
+-             strcmp((const gchar *)nodes[i]->name,
+-                    OSINFO_MEDIA_PROP_VOLUME_SIZE) != 0))
++            (!g_str_equal((const gchar *)nodes[i]->name,
++                          OSINFO_MEDIA_PROP_VOLUME_ID) &&
++             !g_str_equal((const gchar *)nodes[i]->name,
++                          OSINFO_MEDIA_PROP_SYSTEM_ID) &&
++             !g_str_equal((const gchar *)nodes[i]->name,
++                          OSINFO_MEDIA_PROP_PUBLISHER_ID) &&
++             !g_str_equal((const gchar *)nodes[i]->name,
++                          OSINFO_MEDIA_PROP_APPLICATION_ID) &&
++             !g_str_equal((const gchar *)nodes[i]->name,
++                          OSINFO_MEDIA_PROP_LANG) &&
++             !g_str_equal((const gchar *)nodes[i]->name,
++                          OSINFO_MEDIA_PROP_VOLUME_SIZE)))
+             continue;
+ 
+-        if (strcmp((const gchar *)nodes[i]->name,
+-                   OSINFO_MEDIA_PROP_LANG) == 0) {
++        if (g_str_equal((const gchar *)nodes[i]->name,
++                        OSINFO_MEDIA_PROP_LANG)) {
+             gchar *regex = (gchar *)xmlGetProp(nodes[i], BAD_CAST "regex");
+             if (g_strcmp0(regex, "true") == 0) {
+                 gchar *datamap;
+@@ -1195,23 +1195,23 @@ static OsinfoTree *osinfo_loader_tree(OsinfoLoader *loader,
+             nodes[i]->children->type != XML_TEXT_NODE)
+             continue;
+ 
+-        if (strcmp((const gchar *)nodes[i]->name,
+-                   OSINFO_TREE_PROP_TREEINFO_FAMILY + sizeof("treeinfo-")) == 0)
++        if (g_str_equal((const gchar *)nodes[i]->name,
++                        OSINFO_TREE_PROP_TREEINFO_FAMILY + sizeof("treeinfo-")))
+             osinfo_entity_set_param(OSINFO_ENTITY(tree),
+                                     OSINFO_TREE_PROP_TREEINFO_FAMILY,
+                                     (const gchar *)nodes[i]->children->content);
+-        else if (strcmp((const gchar *)nodes[i]->name,
+-                        OSINFO_TREE_PROP_TREEINFO_VARIANT + sizeof("treeinfo-")) == 0)
++        else if (g_str_equal((const gchar *)nodes[i]->name,
++                             OSINFO_TREE_PROP_TREEINFO_VARIANT + sizeof("treeinfo-")))
+             osinfo_entity_set_param(OSINFO_ENTITY(tree),
+                                     OSINFO_TREE_PROP_TREEINFO_VARIANT,
+                                     (const gchar *)nodes[i]->children->content);
+-        else if (strcmp((const gchar *)nodes[i]->name,
+-                        OSINFO_TREE_PROP_TREEINFO_VERSION + sizeof("treeinfo-")) == 0)
++        else if (g_str_equal((const gchar *)nodes[i]->name,
++                             OSINFO_TREE_PROP_TREEINFO_VERSION + sizeof("treeinfo-")))
+             osinfo_entity_set_param(OSINFO_ENTITY(tree),
+                                     OSINFO_TREE_PROP_TREEINFO_VERSION,
+                                     (const gchar *)nodes[i]->children->content);
+-        else if (strcmp((const gchar *)nodes[i]->name,
+-                        OSINFO_TREE_PROP_TREEINFO_ARCH + sizeof("treeinfo-")) == 0)
++        else if (g_str_equal((const gchar *)nodes[i]->name,
++                             OSINFO_TREE_PROP_TREEINFO_ARCH + sizeof("treeinfo-")))
+             osinfo_entity_set_param(OSINFO_ENTITY(tree),
+                                     OSINFO_TREE_PROP_TREEINFO_ARCH,
+                                     (const gchar *)nodes[i]->children->content);
+@@ -1264,14 +1264,14 @@ static OsinfoResources *osinfo_loader_resources(OsinfoLoader *loader,
+     for (i = 0; i < nnodes; i++) {
+         if (!nodes[i]->children ||
+             nodes[i]->children->type != XML_TEXT_NODE ||
+-            (strcmp((const gchar *)nodes[i]->name,
+-                    OSINFO_RESOURCES_PROP_CPU) != 0 &&
+-             strcmp((const gchar *)nodes[i]->name,
+-                    OSINFO_RESOURCES_PROP_N_CPUS) != 0 &&
+-             strcmp((const gchar *)nodes[i]->name,
+-                    OSINFO_RESOURCES_PROP_RAM) != 0 &&
+-             strcmp((const gchar *)nodes[i]->name,
+-                    OSINFO_RESOURCES_PROP_STORAGE) != 0))
++            (!g_str_equal((const gchar *)nodes[i]->name,
++                          OSINFO_RESOURCES_PROP_CPU) &&
++             !g_str_equal((const gchar *)nodes[i]->name,
++                          OSINFO_RESOURCES_PROP_N_CPUS) &&
++             !g_str_equal((const gchar *)nodes[i]->name,
++                          OSINFO_RESOURCES_PROP_RAM) &&
++             !g_str_equal((const gchar *)nodes[i]->name,
++                          OSINFO_RESOURCES_PROP_STORAGE)))
+             continue;
+ 
+         osinfo_entity_set_param(OSINFO_ENTITY(resources),
+@@ -1367,13 +1367,13 @@ static OsinfoDeviceDriver *osinfo_loader_driver(OsinfoLoader *loader,
+     for (i = 0; i < nnodes; i++) {
+         if (nodes[i]->children &&
+             nodes[i]->children->type == XML_TEXT_NODE &&
+-            (strcmp((const gchar *)nodes[i]->name,
+-                    OSINFO_DEVICE_DRIVER_PROP_FILE) == 0)) {
++            (g_str_equal((const gchar *)nodes[i]->name,
++                         OSINFO_DEVICE_DRIVER_PROP_FILE))) {
+             osinfo_entity_add_param(OSINFO_ENTITY(driver),
+                                     (const gchar *)nodes[i]->name,
+                                     (const gchar *)nodes[i]->children->content);
+-        } else if (strcmp((const gchar *)nodes[i]->name,
+-                          OSINFO_DEVICE_DRIVER_PROP_DEVICE) == 0) {
++        } else if (g_str_equal((const gchar *)nodes[i]->name,
++                               OSINFO_DEVICE_DRIVER_PROP_DEVICE)) {
+             xmlChar *device_id = xmlGetProp(nodes[i], BAD_CAST "id");
+             OsinfoDevice *device = osinfo_loader_get_device(loader,
+                                                             (gchar *)device_id);
+-- 
+2.21.0
+
diff --git a/SOURCES/0003-loader-properly-load-the-treeinfo-attributes.patch b/SOURCES/0003-loader-properly-load-the-treeinfo-attributes.patch
new file mode 100644
index 0000000..cfbff3d
--- /dev/null
+++ b/SOURCES/0003-loader-properly-load-the-treeinfo-attributes.patch
@@ -0,0 +1,57 @@
+From 5e09667f547a21a5621f6cafbe82aeb85bad7071 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fabiano@fidencio.org>
+Date: Sun, 2 Dec 2018 16:37:57 +0100
+Subject: [PATCH] loader: properly load the treeinfo attributes
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+treeinfo attributes haven't been loaded properly due to the change done
+in ab2ab35f, changing the hardcoded 9 to sizeof("treeinfo-").
+
+The problem here is that size("treeinfo-") is 10, causing that any
+comparison to fail.
+
+Let's change the sizeof("treeinfo-") to strlen("treeinfo-").
+
+Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
+Reviewed-by: Christophe Fergeau <cfergeau@redhat.com>
+(cherry picked from commit d56e33b47c806522378f267b50c354e48df25f98)
+---
+ osinfo/osinfo_loader.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
+index 898dee9..85f51ab 100644
+--- a/osinfo/osinfo_loader.c
++++ b/osinfo/osinfo_loader.c
+@@ -1196,22 +1196,22 @@ static OsinfoTree *osinfo_loader_tree(OsinfoLoader *loader,
+             continue;
+ 
+         if (g_str_equal((const gchar *)nodes[i]->name,
+-                        OSINFO_TREE_PROP_TREEINFO_FAMILY + sizeof("treeinfo-")))
++                        OSINFO_TREE_PROP_TREEINFO_FAMILY + strlen("treeinfo-")))
+             osinfo_entity_set_param(OSINFO_ENTITY(tree),
+                                     OSINFO_TREE_PROP_TREEINFO_FAMILY,
+                                     (const gchar *)nodes[i]->children->content);
+         else if (g_str_equal((const gchar *)nodes[i]->name,
+-                             OSINFO_TREE_PROP_TREEINFO_VARIANT + sizeof("treeinfo-")))
++                             OSINFO_TREE_PROP_TREEINFO_VARIANT + strlen("treeinfo-")))
+             osinfo_entity_set_param(OSINFO_ENTITY(tree),
+                                     OSINFO_TREE_PROP_TREEINFO_VARIANT,
+                                     (const gchar *)nodes[i]->children->content);
+         else if (g_str_equal((const gchar *)nodes[i]->name,
+-                             OSINFO_TREE_PROP_TREEINFO_VERSION + sizeof("treeinfo-")))
++                             OSINFO_TREE_PROP_TREEINFO_VERSION + strlen("treeinfo-")))
+             osinfo_entity_set_param(OSINFO_ENTITY(tree),
+                                     OSINFO_TREE_PROP_TREEINFO_VERSION,
+                                     (const gchar *)nodes[i]->children->content);
+         else if (g_str_equal((const gchar *)nodes[i]->name,
+-                             OSINFO_TREE_PROP_TREEINFO_ARCH + sizeof("treeinfo-")))
++                             OSINFO_TREE_PROP_TREEINFO_ARCH + strlen("treeinfo-")))
+             osinfo_entity_set_param(OSINFO_ENTITY(tree),
+                                     OSINFO_TREE_PROP_TREEINFO_ARCH,
+                                     (const gchar *)nodes[i]->children->content);
+-- 
+2.21.0
+
diff --git a/SOURCES/0004-db-improve-_guess_os_from_tree-checks.patch b/SOURCES/0004-db-improve-_guess_os_from_tree-checks.patch
new file mode 100644
index 0000000..bcf2036
--- /dev/null
+++ b/SOURCES/0004-db-improve-_guess_os_from_tree-checks.patch
@@ -0,0 +1,38 @@
+From 327e4c4f27fdedefc89317e4a42f5382fadefbf3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fabiano@fidencio.org>
+Date: Sun, 2 Dec 2018 16:37:59 +0100
+Subject: [PATCH] db: improve _guess_os_from_tree() checks
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Do not check against a distro which doesn't have treeinfo data as
+match_regex() would just match whatever we compare to it.
+
+Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
+Reviewed-by: Christophe Fergeau <cfergeau@redhat.com>
+(cherry picked from commit 705b08bb3fa44a2266abdd5d145544c67ef0d882)
+---
+ osinfo/osinfo_db.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
+index fa14c6d..4f8684a 100644
+--- a/osinfo/osinfo_db.c
++++ b/osinfo/osinfo_db.c
+@@ -763,6 +763,12 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db,
+             const gchar *os_version = osinfo_tree_get_treeinfo_version(os_tree);
+             const gchar *os_arch = osinfo_tree_get_treeinfo_arch(os_tree);
+ 
++            if (os_family == NULL &&
++                os_variant == NULL &&
++                os_version == NULL &&
++                os_arch == NULL)
++                continue;
++
+             if (match_regex(os_family, tree_family) &&
+                 match_regex(os_variant, tree_variant) &&
+                 match_regex(os_version, tree_version) &&
+-- 
+2.21.0
+
diff --git a/SOURCES/0005-tree-cleanup-load_key_info.patch b/SOURCES/0005-tree-cleanup-load_key_info.patch
new file mode 100644
index 0000000..23f18ec
--- /dev/null
+++ b/SOURCES/0005-tree-cleanup-load_key_info.patch
@@ -0,0 +1,113 @@
+From c90388dda9f8f694e4458ca315430b0d37336530 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
+Date: Mon, 10 Dec 2018 15:42:21 +0100
+Subject: [PATCH] tree: cleanup load_key_info()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Instead of doing the same checks for key or group not found all over the
+place, let's just add a new function that does that and replace the old
+check for the new function.
+
+Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
+Reviewed-by: Christophe Fergeau <cfergeau@redhat.com>
+(cherry picked from commit 6eab80bac760dc44dbefe403ef67a3a80dca2392)
+---
+ osinfo/osinfo_tree.c | 63 ++++++++++++++++++++++++--------------------
+ 1 file changed, 35 insertions(+), 28 deletions(-)
+
+diff --git a/osinfo/osinfo_tree.c b/osinfo/osinfo_tree.c
+index 565ccfe..f256f8a 100644
+--- a/osinfo/osinfo_tree.c
++++ b/osinfo/osinfo_tree.c
+@@ -472,6 +472,13 @@ static gboolean is_str_empty(const gchar *str) {
+     return ret;
+ }
+ 
++static gboolean is_unknown_group_or_key_error(const GError *error)
++{
++    return (g_error_matches(error, G_KEY_FILE_ERROR,
++                            G_KEY_FILE_ERROR_KEY_NOT_FOUND) ||
++            g_error_matches(error, G_KEY_FILE_ERROR,
++                            G_KEY_FILE_ERROR_GROUP_NOT_FOUND));
++}
+ 
+ static OsinfoTree *load_keyinfo(const gchar *location,
+                                 const gchar *content,
+@@ -493,44 +500,44 @@ static OsinfoTree *load_keyinfo(const gchar *location,
+                                    G_KEY_FILE_NONE, error))
+         goto cleanup;
+ 
+-    if (!(family = g_key_file_get_string(file, "general", "family", error)) &&
+-        (*error && (*error)->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND &&
+-         (*error)->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND))
+-        goto cleanup;
++    if (!(family = g_key_file_get_string(file, "general", "family", error))) {
++        if (!is_unknown_group_or_key_error(*error))
++            goto cleanup;
++    }
+ 
+-    if (!(variant = g_key_file_get_string(file, "general", "variant", error)) &&
+-        (*error && (*error)->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND &&
+-         (*error)->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND))
+-        goto cleanup;
++    if (!(variant = g_key_file_get_string(file, "general", "variant", error))) {
++        if (!is_unknown_group_or_key_error(*error))
++            goto cleanup;
++    }
+ 
+-    if (!(version = g_key_file_get_string(file, "general", "version", error)) &&
+-        (*error && (*error)->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND &&
+-         (*error)->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND))
+-        goto cleanup;
++    if (!(version = g_key_file_get_string(file, "general", "version", error))) {
++        if (!is_unknown_group_or_key_error(*error))
++            goto cleanup;
++    }
+ 
+-    if (!(arch = g_key_file_get_string(file, "general", "arch", error)) &&
+-        (*error && (*error)->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND &&
+-         (*error)->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND))
+-        goto cleanup;
++    if (!(arch = g_key_file_get_string(file, "general", "arch", error))) {
++        if (!is_unknown_group_or_key_error(*error))
++            goto cleanup;
++    }
+ 
+ 
+     if (arch) {
+         group = g_strdup_printf("images-%s", arch);
+ 
+-        if (!(kernel = g_key_file_get_string(file, group, "kernel", error)) &&
+-            (*error && (*error)->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND &&
+-             (*error)->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND))
+-            goto cleanup;
++        if (!(kernel = g_key_file_get_string(file, group, "kernel", error))) {
++            if (!is_unknown_group_or_key_error(*error))
++                goto cleanup;
++        }
+ 
+-        if (!(initrd = g_key_file_get_string(file, group, "initrd", error)) &&
+-            (*error && (*error)->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND &&
+-             (*error)->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND))
+-            goto cleanup;
++        if (!(initrd = g_key_file_get_string(file, group, "initrd", error))) {
++            if (!is_unknown_group_or_key_error(*error))
++                goto cleanup;
++        }
+ 
+-        if (!(bootiso = g_key_file_get_string(file, group, "boot.iso", error)) &&
+-            (*error && (*error)->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND &&
+-             (*error)->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND))
+-            goto cleanup;
++        if (!(bootiso = g_key_file_get_string(file, group, "boot.iso", error))) {
++            if (!is_unknown_group_or_key_error(*error))
++                goto cleanup;
++        }
+     }
+ 
+     tree = osinfo_tree_new(location, arch ? arch : "i386");
+-- 
+2.21.0
+
diff --git a/SOURCES/0006-tree-cleanup-non-fatal-errors-in-load_key_info.patch b/SOURCES/0006-tree-cleanup-non-fatal-errors-in-load_key_info.patch
new file mode 100644
index 0000000..15969b6
--- /dev/null
+++ b/SOURCES/0006-tree-cleanup-non-fatal-errors-in-load_key_info.patch
@@ -0,0 +1,80 @@
+From d5fbca9987b595c3f277a39cc04aca810bde02bc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
+Date: Mon, 10 Dec 2018 15:46:17 +0100
+Subject: [PATCH] tree: cleanup non-fatal errors in load_key_info()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+There are errors which are not fatal and just ignored in load_keyinfo.
+However, as those have not been cleaned up, we could see messages like:
+(lt-osinfo-detect:20658): GLib-WARNING **: GError set over the top of a
+previous GError or uninitialized memory.
+This indicates a bug in someone's code. You must ensure an error is NULL
+before it's set.
+The overwriting error message was: Key file does not have key “boot.iso”
+in group “images-x86_64”
+
+In order to avoid this, let's just call g_clear_error() after situations
+where an error may have been set but it can just be ignored.
+
+Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
+Reviewed-by: Christophe Fergeau <cfergeau@redhat.com>
+(cherry picked from commit 1c4deff7dc94da6157f64c398a58375a2c97e35b)
+---
+ osinfo/osinfo_tree.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/osinfo/osinfo_tree.c b/osinfo/osinfo_tree.c
+index f256f8a..ef82807 100644
+--- a/osinfo/osinfo_tree.c
++++ b/osinfo/osinfo_tree.c
+@@ -503,21 +503,25 @@ static OsinfoTree *load_keyinfo(const gchar *location,
+     if (!(family = g_key_file_get_string(file, "general", "family", error))) {
+         if (!is_unknown_group_or_key_error(*error))
+             goto cleanup;
++        g_clear_error(error);
+     }
+ 
+     if (!(variant = g_key_file_get_string(file, "general", "variant", error))) {
+         if (!is_unknown_group_or_key_error(*error))
+             goto cleanup;
++        g_clear_error(error);
+     }
+ 
+     if (!(version = g_key_file_get_string(file, "general", "version", error))) {
+         if (!is_unknown_group_or_key_error(*error))
+             goto cleanup;
++        g_clear_error(error);
+     }
+ 
+     if (!(arch = g_key_file_get_string(file, "general", "arch", error))) {
+         if (!is_unknown_group_or_key_error(*error))
+             goto cleanup;
++        g_clear_error(error);
+     }
+ 
+ 
+@@ -527,16 +531,19 @@ static OsinfoTree *load_keyinfo(const gchar *location,
+         if (!(kernel = g_key_file_get_string(file, group, "kernel", error))) {
+             if (!is_unknown_group_or_key_error(*error))
+                 goto cleanup;
++            g_clear_error(error);
+         }
+ 
+         if (!(initrd = g_key_file_get_string(file, group, "initrd", error))) {
+             if (!is_unknown_group_or_key_error(*error))
+                 goto cleanup;
++            g_clear_error(error);
+         }
+ 
+         if (!(bootiso = g_key_file_get_string(file, group, "boot.iso", error))) {
+             if (!is_unknown_group_or_key_error(*error))
+                 goto cleanup;
++            g_clear_error(error);
+         }
+     }
+ 
+-- 
+2.21.0
+
diff --git a/SOURCES/0007-tree-Also-check-fore-treeinfo-in-addition-to-.treein.patch b/SOURCES/0007-tree-Also-check-fore-treeinfo-in-addition-to-.treein.patch
new file mode 100644
index 0000000..bdb11f2
--- /dev/null
+++ b/SOURCES/0007-tree-Also-check-fore-treeinfo-in-addition-to-.treein.patch
@@ -0,0 +1,136 @@
+From 5d327081b489bd58e5fbafc5cff9c893b46e996c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
+Date: Mon, 25 Mar 2019 11:44:29 +0100
+Subject: [PATCH] tree: Also check fore "treeinfo" in addition to ".treeinfo"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Akamai CDN hosted files can't start with a dot, making trees published to
+a CDN having their ".treeinfo" files renamed to "treeinfo".
+
+https://gitlab.com/libosinfo/libosinfo/issues/18
+
+Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
+Reviewed-by: Cole Robinson <crobinso@redhat.com>
+(cherry picked from commit e8e0ca9024847aca9d079ffb34a2bbd0494fe978)
+---
+ osinfo/osinfo_tree.c | 67 +++++++++++++++++++++++++++++++++-----------
+ 1 file changed, 50 insertions(+), 17 deletions(-)
+
+diff --git a/osinfo/osinfo_tree.c b/osinfo/osinfo_tree.c
+index ef82807..eaac54f 100644
+--- a/osinfo/osinfo_tree.c
++++ b/osinfo/osinfo_tree.c
+@@ -35,6 +35,7 @@ typedef struct _CreateFromLocationAsyncData CreateFromLocationAsyncData;
+ struct _CreateFromLocationAsyncData {
+     GFile *file;
+     gchar *location;
++    gchar *treeinfo;
+ 
+     GTask *res;
+ 
+@@ -594,6 +595,11 @@ static OsinfoTree *load_keyinfo(const gchar *location,
+     return tree;
+ }
+ 
++static void
++osinfo_tree_create_from_location_async_helper(const gchar *url,
++                                              const gchar *treeinfo,
++                                              GCancellable *cancellable,
++                                              CreateFromLocationAsyncData *data);
+ 
+ static void on_location_read(GObject *source,
+                              GAsyncResult *res,
+@@ -613,7 +619,17 @@ static void on_location_read(GObject *source,
+                                      &length,
+                                      NULL,
+                                      &error)) {
+-        g_prefix_error(&error, _("Failed to load .treeinfo file: "));
++        /* It means no ".treeinfo" file has been found. Try again, this time
++         * looking for a "treeinfo" file. */
++        if (g_str_equal(data->treeinfo, ".treeinfo")) {
++            osinfo_tree_create_from_location_async_helper(data->location,
++                                                          "treeinfo",
++                                                          g_task_get_cancellable(data->res),
++                                                          data);
++            return;
++        }
++
++        g_prefix_error(&error, _("Failed to load .treeinfo|treeinfo file: "));
+         g_task_return_error(data->res, error);
+         create_from_location_async_data_free(data);
+         return;
+@@ -635,6 +651,35 @@ static void on_location_read(GObject *source,
+     g_free(content);
+ }
+ 
++static void
++osinfo_tree_create_from_location_async_helper(const gchar *url,
++                                              const gchar *treeinfo,
++                                              GCancellable *cancellable,
++                                              CreateFromLocationAsyncData *data)
++{
++    gchar *location;
++
++    g_return_if_fail(url != NULL);
++    g_return_if_fail(treeinfo != NULL);
++
++    location = g_strdup_printf("%s/%s", url, treeinfo);
++
++    g_clear_object(&data->file);
++    data->file = g_file_new_for_uri(location);
++
++    g_free(data->location);
++    data->location = g_strdup(url);
++
++    g_free(data->treeinfo);
++    data->treeinfo = g_strdup(treeinfo);
++
++    g_file_load_contents_async(data->file,
++                               cancellable,
++                               on_location_read,
++                               data);
++    g_free(location);
++}
++
+ /**
+  * osinfo_tree_create_from_location_async:
+  * @location: the location of an installation tree
+@@ -652,11 +697,6 @@ void osinfo_tree_create_from_location_async(const gchar *location,
+                                             gpointer user_data)
+ {
+     CreateFromLocationAsyncData *data;
+-    gchar *treeinfo;
+-
+-    g_return_if_fail(location != NULL);
+-
+-    treeinfo = g_strdup_printf("%s/.treeinfo", location);
+ 
+     data = g_slice_new0(CreateFromLocationAsyncData);
+     data->res = g_task_new(NULL,
+@@ -665,17 +705,10 @@ void osinfo_tree_create_from_location_async(const gchar *location,
+                            user_data);
+     g_task_set_priority(data->res, priority);
+ 
+-    data->file = g_file_new_for_uri(treeinfo);
+-    data->location = g_strdup(location);
+-
+-    /* XXX priority ? */
+-    /* XXX probe other things besides just tree info */
+-    g_file_load_contents_async(data->file,
+-                               cancellable,
+-                               on_location_read,
+-                               data);
+-
+-    g_free(treeinfo);
++    osinfo_tree_create_from_location_async_helper(location,
++                                                  ".treeinfo",
++                                                  cancellable,
++                                                  data);
+ }
+ 
+ 
+-- 
+2.21.0
+
diff --git a/SOURCES/0008-tree-Avoid-use-of-memory-after-it-s-freed.patch b/SOURCES/0008-tree-Avoid-use-of-memory-after-it-s-freed.patch
new file mode 100644
index 0000000..9bf2ee5
--- /dev/null
+++ b/SOURCES/0008-tree-Avoid-use-of-memory-after-it-s-freed.patch
@@ -0,0 +1,50 @@
+From ba648511089973f86b5345abfab9fd2fdbdd9ca6 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
+Date: Tue, 21 May 2019 13:29:18 +0200
+Subject: [PATCH] tree: Avoid use of memory after it's freed
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+We've been passing data->location as the @url argument of
+osinfo_tree_create_from_location_async_helper(), freeing it and trying
+to g_strdup() it as the new content of data->location.
+
+In order to avoid doing so, let's set the data->location only once, in
+the first caller of osinfo_tree_create_from_location_async_helper(), as
+its content is always going to be the same doesn't matter the treeinfo
+format to be used with.
+
+Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
+Reviewed-by: Cole Robinson <crobinso@redhat.com>
+(cherry picked from commit d7bc838a96acf5f058e13d2b49157b4ba396cd87)
+---
+ osinfo/osinfo_tree.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/osinfo/osinfo_tree.c b/osinfo/osinfo_tree.c
+index eaac54f..2e6a4ee 100644
+--- a/osinfo/osinfo_tree.c
++++ b/osinfo/osinfo_tree.c
+@@ -667,9 +667,6 @@ osinfo_tree_create_from_location_async_helper(const gchar *url,
+     g_clear_object(&data->file);
+     data->file = g_file_new_for_uri(location);
+ 
+-    g_free(data->location);
+-    data->location = g_strdup(url);
+-
+     g_free(data->treeinfo);
+     data->treeinfo = g_strdup(treeinfo);
+ 
+@@ -705,6 +702,8 @@ void osinfo_tree_create_from_location_async(const gchar *location,
+                            user_data);
+     g_task_set_priority(data->res, priority);
+ 
++    data->location = g_strdup(location);
++
+     osinfo_tree_create_from_location_async_helper(location,
+                                                   ".treeinfo",
+                                                   cancellable,
+-- 
+2.21.0
+
diff --git a/SOURCES/0009-tree-Cleanup-_create_from_location_async_helper.patch b/SOURCES/0009-tree-Cleanup-_create_from_location_async_helper.patch
new file mode 100644
index 0000000..603e27e
--- /dev/null
+++ b/SOURCES/0009-tree-Cleanup-_create_from_location_async_helper.patch
@@ -0,0 +1,92 @@
+From be4906d64b091397b897d351fd09c1146bc10f93 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
+Date: Tue, 21 May 2019 13:33:27 +0200
+Subject: [PATCH] tree: Cleanup _create_from_location_async_helper()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+There's no need to pass neither the URL nor the cancellable to this
+function as those can be taken directly from data.
+
+Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
+Reviewed-by: Cole Robinson <crobinso@redhat.com>
+(cherry picked from commit dfda02598034737610b69fdd08d62f62cbf5b0cb)
+---
+ osinfo/osinfo_tree.c | 27 ++++++++-------------------
+ 1 file changed, 8 insertions(+), 19 deletions(-)
+
+diff --git a/osinfo/osinfo_tree.c b/osinfo/osinfo_tree.c
+index 2e6a4ee..df03303 100644
+--- a/osinfo/osinfo_tree.c
++++ b/osinfo/osinfo_tree.c
+@@ -596,10 +596,8 @@ static OsinfoTree *load_keyinfo(const gchar *location,
+ }
+ 
+ static void
+-osinfo_tree_create_from_location_async_helper(const gchar *url,
+-                                              const gchar *treeinfo,
+-                                              GCancellable *cancellable,
+-                                              CreateFromLocationAsyncData *data);
++osinfo_tree_create_from_location_async_helper(CreateFromLocationAsyncData *data,
++                                              const gchar *treeinfo);
+ 
+ static void on_location_read(GObject *source,
+                              GAsyncResult *res,
+@@ -622,10 +620,7 @@ static void on_location_read(GObject *source,
+         /* It means no ".treeinfo" file has been found. Try again, this time
+          * looking for a "treeinfo" file. */
+         if (g_str_equal(data->treeinfo, ".treeinfo")) {
+-            osinfo_tree_create_from_location_async_helper(data->location,
+-                                                          "treeinfo",
+-                                                          g_task_get_cancellable(data->res),
+-                                                          data);
++            osinfo_tree_create_from_location_async_helper(data, "treeinfo");
+             return;
+         }
+ 
+@@ -652,17 +647,14 @@ static void on_location_read(GObject *source,
+ }
+ 
+ static void
+-osinfo_tree_create_from_location_async_helper(const gchar *url,
+-                                              const gchar *treeinfo,
+-                                              GCancellable *cancellable,
+-                                              CreateFromLocationAsyncData *data)
++osinfo_tree_create_from_location_async_helper(CreateFromLocationAsyncData *data,
++                                              const gchar *treeinfo)
+ {
+     gchar *location;
+ 
+-    g_return_if_fail(url != NULL);
+     g_return_if_fail(treeinfo != NULL);
+ 
+-    location = g_strdup_printf("%s/%s", url, treeinfo);
++    location = g_strdup_printf("%s/%s", data->location, treeinfo);
+ 
+     g_clear_object(&data->file);
+     data->file = g_file_new_for_uri(location);
+@@ -671,7 +663,7 @@ osinfo_tree_create_from_location_async_helper(const gchar *url,
+     data->treeinfo = g_strdup(treeinfo);
+ 
+     g_file_load_contents_async(data->file,
+-                               cancellable,
++                               g_task_get_cancellable(data->res),
+                                on_location_read,
+                                data);
+     g_free(location);
+@@ -704,10 +696,7 @@ void osinfo_tree_create_from_location_async(const gchar *location,
+ 
+     data->location = g_strdup(location);
+ 
+-    osinfo_tree_create_from_location_async_helper(location,
+-                                                  ".treeinfo",
+-                                                  cancellable,
+-                                                  data);
++    osinfo_tree_create_from_location_async_helper(data, ".treeinfo");
+ }
+ 
+ 
+-- 
+2.21.0
+
diff --git a/SOURCES/0010-db-improve-_guess_os_from_media-checks.patch b/SOURCES/0010-db-improve-_guess_os_from_media-checks.patch
new file mode 100644
index 0000000..3501a0b
--- /dev/null
+++ b/SOURCES/0010-db-improve-_guess_os_from_media-checks.patch
@@ -0,0 +1,39 @@
+From ff471e84587597029ab0f1f67b1dc11f5578a0ee Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
+Date: Mon, 14 Jan 2019 17:08:11 +0100
+Subject: [PATCH] db: improve _guess_os_from_media() checks
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Do not check against a distro which doesn't have *any* of the values we
+use to check as match_regex() would just match whatever we compare to
+it.
+
+Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
+(cherry picked from commit 8969c436ebc6e9610172b124e638efea21d9eae8)
+---
+ osinfo/osinfo_db.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
+index 4f8684a..5dc0aac 100644
+--- a/osinfo/osinfo_db.c
++++ b/osinfo/osinfo_db.c
+@@ -577,6 +577,13 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db,
+             const gchar *os_application = osinfo_media_get_application_id(os_media);
+             gint64 os_vol_size = osinfo_media_get_volume_size(os_media);
+ 
++            if (os_volume == NULL &&
++                os_system == NULL &&
++                os_publisher == NULL &&
++                os_application == NULL &&
++                os_vol_size <= 0)
++                continue;
++
+             if (os_vol_size <= 0)
+                 os_vol_size = media_vol_size;
+ 
+-- 
+2.21.0
+
diff --git a/SPECS/libosinfo.spec b/SPECS/libosinfo.spec
index debadb4..c9765c7 100644
--- a/SPECS/libosinfo.spec
+++ b/SPECS/libosinfo.spec
@@ -3,11 +3,25 @@
 Summary: A library for managing OS information for virtualization
 Name: libosinfo
 Version: 1.1.0
-Release: 2%{?dist}%{?extra_release}
+Release: 3%{?dist}%{?extra_release}
 License: LGPLv2+
 Group: Development/Libraries
 Source: https://releases.pagure.io/%{name}/%{name}-%{version}.tar.gz
 URL: https://libosinfo.org/
+
+### Patches ###
+# https://bugzilla.redhat.com/show_bug.cgi?id=1712458
+Patch0001: 0001-Use-g_list_free_full-where-easily-possible.patch
+Patch0002: 0002-loader-Replace-strcmp-with-g_str_equal.patch
+Patch0003: 0003-loader-properly-load-the-treeinfo-attributes.patch
+Patch0004: 0004-db-improve-_guess_os_from_tree-checks.patch
+Patch0005: 0005-tree-cleanup-load_key_info.patch
+Patch0006: 0006-tree-cleanup-non-fatal-errors-in-load_key_info.patch
+Patch0007: 0007-tree-Also-check-fore-treeinfo-in-addition-to-.treein.patch
+Patch0008: 0008-tree-Avoid-use-of-memory-after-it-s-freed.patch
+Patch0009: 0009-tree-Cleanup-_create_from_location_async_helper.patch
+Patch0010: 0010-db-improve-_guess_os_from_media-checks.patch
+
 BuildRequires: intltool
 BuildRequires: glib2-devel
 BuildRequires: check-devel
@@ -57,6 +71,9 @@ This package provides the Vala bindings for libosinfo library.
 
 %prep
 %setup -q
+for p in %patches ; do
+    %__patch -p1 -i $p
+done
 
 %build
 %configure --enable-introspection=yes --enable-vala=yes
@@ -108,6 +125,10 @@ rm -fr %{buildroot}
 %{_datadir}/vala/vapi/libosinfo-1.0.vapi
 
 %changelog
+* Thu May 23 2019 Fabiano Fidêncio <fidencio@redhat.com> - 1.1.0-3
+- Resolves: rhbz#1712458 - [machines] The function of 'Auto-detect guest
+                           operating system' is not available on rhel 7.7
+
 * Wed Jun 06 2018 Richard Hughes <rhughes@redhat.com> 1.1.0-2
 - New upstream release 1.1.0
 - Resolves: #1584263