summaryrefslogtreecommitdiff
path: root/osinfo/osinfo_tree.c
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2021-11-25 12:29:29 +0000
committerDaniel P. Berrangé <berrange@redhat.com>2022-02-04 14:14:49 +0000
commit6a21d0ca1071fc225ef11b4cee57be3c2a62264b (patch)
treeb2ae7a8e0302157bc25812dcf594326de6f3e2a2 /osinfo/osinfo_tree.c
parentdf78f0734e59a9140d1126917d825f9f8fcd3514 (diff)
downloadlibosinfo-6a21d0ca1071fc225ef11b4cee57be3c2a62264b.tar.gz
osinfo: honour tree architecture when matching
The tree matching code currently ignores the tree architecture which is generally ok, since osinfo_tree_create_from_location will leave it set to NULL. None the less, if an architecture is provided for the unknown tree, we should only return results that match this architecture. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'osinfo/osinfo_tree.c')
-rw-r--r--osinfo/osinfo_tree.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/osinfo/osinfo_tree.c b/osinfo/osinfo_tree.c
index cedeadc..60deb52 100644
--- a/osinfo/osinfo_tree.c
+++ b/osinfo/osinfo_tree.c
@@ -463,9 +463,10 @@ OsinfoTree *osinfo_tree_new(const gchar *id,
"id", id,
NULL);
- osinfo_entity_set_param(OSINFO_ENTITY(tree),
- OSINFO_TREE_PROP_ARCHITECTURE,
- architecture);
+ if (architecture)
+ osinfo_entity_set_param(OSINFO_ENTITY(tree),
+ OSINFO_TREE_PROP_ARCHITECTURE,
+ architecture);
return tree;
}
@@ -1203,11 +1204,13 @@ OsinfoTree *osinfo_tree_create_from_treeinfo(const gchar *treeinfo,
*/
gboolean osinfo_tree_matches(OsinfoTree *tree, OsinfoTree *reference)
{
+ const gchar *tree_arch = osinfo_tree_get_architecture(tree);
const gchar *tree_treeinfo_family = osinfo_tree_get_treeinfo_family(tree);
const gchar *tree_treeinfo_variant = osinfo_tree_get_treeinfo_variant(tree);
const gchar *tree_treeinfo_version = osinfo_tree_get_treeinfo_version(tree);
const gchar *tree_treeinfo_arch = osinfo_tree_get_treeinfo_arch(tree);
+ const gchar *reference_arch = osinfo_tree_get_architecture(reference);
const gchar *reference_treeinfo_family = osinfo_tree_get_treeinfo_family(reference);
const gchar *reference_treeinfo_variant = osinfo_tree_get_treeinfo_variant(reference);
const gchar *reference_treeinfo_version = osinfo_tree_get_treeinfo_version(reference);
@@ -1216,7 +1219,10 @@ gboolean osinfo_tree_matches(OsinfoTree *tree, OsinfoTree *reference)
if (!osinfo_tree_has_treeinfo(reference))
return FALSE;
- if (match_regex(reference_treeinfo_family, tree_treeinfo_family) &&
+ if ((!tree_arch ||
+ g_str_equal(reference_arch, tree_arch) ||
+ g_str_equal(reference_arch, "all")) &&
+ match_regex(reference_treeinfo_family, tree_treeinfo_family) &&
match_regex(reference_treeinfo_variant, tree_treeinfo_variant) &&
match_regex(reference_treeinfo_version, tree_treeinfo_version) &&
match_regex(reference_treeinfo_arch, tree_treeinfo_arch))