From f408f4dc840281e50438c5daf8baed79dad072f4 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 13 Sep 2016 09:42:00 +0100 Subject: Fix building metadata on repos with mixed architecture content Only disable multiarch packages if a native package of the same name exists. --- libappstream-builder/asb-context.c | 57 +++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/libappstream-builder/asb-context.c b/libappstream-builder/asb-context.c index 12addc1..ce37895 100644 --- a/libappstream-builder/asb-context.c +++ b/libappstream-builder/asb-context.c @@ -1112,38 +1112,51 @@ asb_context_disable_older_pkgs (AsbContext *ctx) } } -static void -asb_context_disable_multiarch_pkgs (AsbContext *ctx) +/* return the first package in the repo that matches the name and arch */ +static AsbPackage * +asb_context_get_package_by_name_arch (AsbContext *ctx, + const gchar *name, + const gchar *arch) { AsbContextPrivate *priv = GET_PRIVATE (ctx); - AsbPackage *pkg; - const gchar *arch; - gboolean found_arch = FALSE; guint i; - - /* are there any 64-bit packages in the repo? */ for (i = 0; i < priv->packages->len; i++) { - pkg = ASB_PACKAGE (g_ptr_array_index (priv->packages, i)); - if (g_strcmp0 (asb_package_get_arch (pkg), "x86_64") == 0) { - found_arch = TRUE; - break; + AsbPackage *pkg = ASB_PACKAGE (g_ptr_array_index (priv->packages, i)); + if (g_strcmp0 (asb_package_get_name (pkg), name) == 0 && + g_strcmp0 (asb_package_get_arch (pkg), arch) == 0) { + return pkg; } } - if (!found_arch) - return; + return NULL; +} - /* disable any alternate-arch packages */ +static void +asb_context_disable_multiarch_pkgs (AsbContext *ctx) +{ + AsbContextPrivate *priv = GET_PRIVATE (ctx); + guint i; + + /* are there any non 64-bit packages in the repo with 64-bit versions */ for (i = 0; i < priv->packages->len; i++) { - pkg = ASB_PACKAGE (g_ptr_array_index (priv->packages, i)); - arch = asb_package_get_arch (pkg); + AsbPackage *pkg = ASB_PACKAGE (g_ptr_array_index (priv->packages, i)); + AsbPackage *pkg64; + const gchar *arch = asb_package_get_arch (pkg); + const gchar *name = asb_package_get_name (pkg); if (arch == NULL) continue; - if (g_strcmp0 (arch, "x86_64") != 0 && - g_strcmp0 (arch, "noarch") != 0) { - g_debug ("disabling alternate-arch %s", - asb_package_get_filename (pkg)); - asb_package_set_enabled (pkg, FALSE); - } + if (g_strcmp0 (arch, "x86_64") == 0) + continue; + if (g_strcmp0 (arch, "noarch") == 0) + continue; + pkg64 = asb_context_get_package_by_name_arch (ctx, + name, + "x86_64"); + if (pkg64 == NULL) + continue; + g_debug ("disabling alternate-arch %s as native exists %s", + asb_package_get_filename (pkg), + asb_package_get_filename (pkg64)); + asb_package_set_enabled (pkg, FALSE); } } -- cgit v1.2.1