summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-08-09 11:09:30 +0100
committerRichard Hughes <richard@hughsie.com>2016-08-09 11:12:10 +0100
commit6c64d53e149c2e54357f3540a4e341255a13449f (patch)
treed695d9f450b0efd9d75cd8a61c19921fec7eb02c
parent2ff0073836439f1cc2d544b7afe779890ce68997 (diff)
downloadappstream-glib-6c64d53e149c2e54357f3540a4e341255a13449f.tar.gz
Allow subsuming each property individually
This allows us to define a safe sane subset for merging and dedupe.
-rw-r--r--libappstream-builder/asb-plugin-loader.c2
-rw-r--r--libappstream-builder/plugins/asb-plugin-absorb.c5
-rw-r--r--libappstream-builder/plugins/asb-plugin-appdata.c2
-rw-r--r--libappstream-builder/plugins/asb-plugin-desktop.c4
-rw-r--r--libappstream-builder/plugins/asb-plugin-font.c3
-rw-r--r--libappstream-glib/as-app.c316
-rw-r--r--libappstream-glib/as-app.h110
-rw-r--r--libappstream-glib/as-self-test.c8
-rw-r--r--libappstream-glib/as-store.c15
9 files changed, 314 insertions, 151 deletions
diff --git a/libappstream-builder/asb-plugin-loader.c b/libappstream-builder/asb-plugin-loader.c
index 7b3a294..d013e9b 100644
--- a/libappstream-builder/asb-plugin-loader.c
+++ b/libappstream-builder/asb-plugin-loader.c
@@ -302,7 +302,7 @@ asb_plugin_loader_merge (AsbPluginLoader *plugin_loader, GList *apps)
}
if (as_app_get_kind (AS_APP (app)) == AS_APP_KIND_FIRMWARE) {
as_app_subsume_full (AS_APP (found), AS_APP (app),
- AS_APP_SUBSUME_FLAG_PARTIAL);
+ AS_APP_SUBSUME_FLAG_MERGE);
}
tmp = asb_package_get_nevr (asb_app_get_package (found));
as_app_add_veto (AS_APP (app), "duplicate of %s", tmp);
diff --git a/libappstream-builder/plugins/asb-plugin-absorb.c b/libappstream-builder/plugins/asb-plugin-absorb.c
index 1abb4a9..8f289ba 100644
--- a/libappstream-builder/plugins/asb-plugin-absorb.c
+++ b/libappstream-builder/plugins/asb-plugin-absorb.c
@@ -116,6 +116,9 @@ asb_plugin_merge (AsbPlugin *plugin, GList *list)
/* partially absorb */
as_app_add_veto (app, "partially absorbing %s into %s",
as_app_get_id (app), as_app_get_id (found));
- as_app_subsume_full (found, app, AS_APP_SUBSUME_FLAG_PARTIAL);
+ as_app_subsume_full (found, app,
+ AS_APP_SUBSUME_FLAG_NO_OVERWRITE |
+ AS_APP_SUBSUME_FLAG_MERGE);
+ as_app_remove_metadata (found, "X-Merge-With-Parent");
}
}
diff --git a/libappstream-builder/plugins/asb-plugin-appdata.c b/libappstream-builder/plugins/asb-plugin-appdata.c
index c509fba..b271b39 100644
--- a/libappstream-builder/plugins/asb-plugin-appdata.c
+++ b/libappstream-builder/plugins/asb-plugin-appdata.c
@@ -268,6 +268,6 @@ asb_plugin_merge (AsbPlugin *plugin, GList *list)
"main package %s",
as_app_get_id (app),
as_app_get_pkgname_default (app));
- as_app_subsume_full (found, app, AS_APP_SUBSUME_FLAG_PARTIAL);
+ as_app_subsume_full (found, app, AS_APP_SUBSUME_FLAG_MERGE);
}
}
diff --git a/libappstream-builder/plugins/asb-plugin-desktop.c b/libappstream-builder/plugins/asb-plugin-desktop.c
index 3481340..74ed620 100644
--- a/libappstream-builder/plugins/asb-plugin-desktop.c
+++ b/libappstream-builder/plugins/asb-plugin-desktop.c
@@ -190,7 +190,9 @@ asb_plugin_desktop_refine (AsbPlugin *plugin,
return FALSE;
/* copy all metadata */
- as_app_subsume_full (AS_APP (app), desktop_app, AS_APP_SUBSUME_FLAG_NO_OVERWRITE);
+ as_app_subsume_full (AS_APP (app), desktop_app,
+ AS_APP_SUBSUME_FLAG_NO_OVERWRITE |
+ AS_APP_SUBSUME_FLAG_MERGE);
/* is the icon a stock-icon-name? */
icon = as_app_get_icon_default (AS_APP (app));
diff --git a/libappstream-builder/plugins/asb-plugin-font.c b/libappstream-builder/plugins/asb-plugin-font.c
index 972e117..ce9263e 100644
--- a/libappstream-builder/plugins/asb-plugin-font.c
+++ b/libappstream-builder/plugins/asb-plugin-font.c
@@ -768,7 +768,8 @@ asb_plugin_merge (AsbPlugin *plugin, GList *list)
continue;
}
as_app_subsume_full (found, app,
- AS_APP_SUBSUME_FLAG_NO_OVERWRITE);
+ AS_APP_SUBSUME_FLAG_NO_OVERWRITE |
+ AS_APP_SUBSUME_FLAG_DEDUPE);
as_app_add_veto (app,
"%s was merged into %s",
as_app_get_id (app),
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c
index ebbb132..40418e8 100644
--- a/libappstream-glib/as-app.c
+++ b/libappstream-glib/as-app.c
@@ -3303,197 +3303,241 @@ as_app_subsume_icon (AsApp *app, AsIcon *icon)
}
static void
-as_app_subsume_merge (AsApp *app, AsApp *donor, AsAppSubsumeFlags flags)
+as_app_subsume_private (AsApp *app, AsApp *donor, AsAppSubsumeFlags flags)
{
- AsAppPrivate *papp = GET_PRIVATE (app);
AsAppPrivate *priv = GET_PRIVATE (donor);
+ AsAppPrivate *papp = GET_PRIVATE (app);
+ const gchar *tmp;
+ const gchar *key;
gboolean overwrite;
guint i;
- /* categories */
- for (i = 0; i < priv->categories->len; i++) {
- const gchar *tmp = g_ptr_array_index (priv->categories, i);
- as_app_add_category (app, tmp);
+ /* stop us shooting ourselves in the foot */
+ papp->trust_flags |= AS_APP_TRUST_FLAG_CHECK_DUPLICATES;
+
+ overwrite = (flags & AS_APP_SUBSUME_FLAG_NO_OVERWRITE) == 0;
+
+ /* id-kind */
+ if (flags & AS_APP_SUBSUME_FLAG_KIND) {
+ if (papp->kind == AS_APP_KIND_UNKNOWN)
+ as_app_set_kind (app, priv->kind);
+ }
+
+ /* AppData or AppStream can overwrite the id-kind of desktop files */
+ if (flags & AS_APP_SUBSUME_FLAG_SOURCE_KIND) {
+ if ((priv->source_kind == AS_APP_SOURCE_KIND_APPDATA ||
+ priv->source_kind == AS_APP_SOURCE_KIND_APPSTREAM) &&
+ papp->source_kind == AS_APP_SOURCE_KIND_DESKTOP)
+ as_app_set_kind (app, priv->kind);
+ }
+
+ /* state */
+ if (flags & AS_APP_SUBSUME_FLAG_STATE) {
+ if (papp->state == AS_APP_STATE_UNKNOWN)
+ as_app_set_state (app, priv->state);
+ }
+
+ /* pkgnames */
+ if (flags & AS_APP_SUBSUME_FLAG_BUNDLES) {
+ for (i = 0; i < priv->pkgnames->len; i++) {
+ tmp = g_ptr_array_index (priv->pkgnames, i);
+ as_app_add_pkgname (app, tmp);
+ }
+ }
+
+ /* bundles */
+ if (flags & AS_APP_SUBSUME_FLAG_BUNDLES) {
+ for (i = 0; i < priv->bundles->len; i++) {
+ AsBundle *bundle = g_ptr_array_index (priv->bundles, i);
+ as_app_add_bundle (app, bundle);
+ }
}
/* translations */
- for (i = 0; i < priv->translations->len; i++) {
- AsTranslation *tr = g_ptr_array_index (priv->translations, i);
- as_app_add_translation (app, tr);
+ if (flags & AS_APP_SUBSUME_FLAG_TRANSLATIONS) {
+ for (i = 0; i < priv->translations->len; i++) {
+ AsTranslation *tr = g_ptr_array_index (priv->translations, i);
+ as_app_add_translation (app, tr);
+ }
}
/* releases */
- for (i = 0; i < priv->releases->len; i++) {
- AsRelease *rel= g_ptr_array_index (priv->releases, i);
- as_app_add_release (app, rel);
+ if (flags & AS_APP_SUBSUME_FLAG_RELEASES) {
+ for (i = 0; i < priv->releases->len; i++) {
+ AsRelease *rel= g_ptr_array_index (priv->releases, i);
+ as_app_add_release (app, rel);
+ }
}
/* kudos */
- for (i = 0; i < priv->kudos->len; i++) {
- const gchar *tmp = g_ptr_array_index (priv->kudos, i);
- as_app_add_kudo (app, tmp);
+ if (flags & AS_APP_SUBSUME_FLAG_KUDOS) {
+ for (i = 0; i < priv->kudos->len; i++) {
+ tmp = g_ptr_array_index (priv->kudos, i);
+ as_app_add_kudo (app, tmp);
+ }
+ }
+
+ /* categories */
+ if (flags & AS_APP_SUBSUME_FLAG_CATEGORIES) {
+ for (i = 0; i < priv->categories->len; i++) {
+ tmp = g_ptr_array_index (priv->categories, i);
+ as_app_add_category (app, tmp);
+ }
}
/* permissions */
- for (i = 0; i < priv->permissions->len; i++) {
- const gchar *tmp = g_ptr_array_index (priv->permissions, i);
- as_app_add_permission (app, tmp);
+ if (flags & AS_APP_SUBSUME_FLAG_PERMISSIONS) {
+ for (i = 0; i < priv->permissions->len; i++) {
+ tmp = g_ptr_array_index (priv->permissions, i);
+ as_app_add_permission (app, tmp);
+ }
}
/* extends */
- for (i = 0; i < priv->extends->len; i++) {
- const gchar *tmp = g_ptr_array_index (priv->extends, i);
- as_app_add_extends (app, tmp);
+ if (flags & AS_APP_SUBSUME_FLAG_EXTENDS) {
+ for (i = 0; i < priv->extends->len; i++) {
+ tmp = g_ptr_array_index (priv->extends, i);
+ as_app_add_extends (app, tmp);
+ }
}
/* compulsory_for_desktops */
- for (i = 0; i < priv->compulsory_for_desktops->len; i++) {
- const gchar *tmp = g_ptr_array_index (priv->compulsory_for_desktops, i);
- as_app_add_compulsory_for_desktop (app, tmp);
+ if (flags & AS_APP_SUBSUME_FLAG_COMPULSORY) {
+ for (i = 0; i < priv->compulsory_for_desktops->len; i++) {
+ tmp = g_ptr_array_index (priv->compulsory_for_desktops, i);
+ as_app_add_compulsory_for_desktop (app, tmp);
+ }
}
/* screenshots */
- for (i = 0; i < priv->screenshots->len; i++) {
- AsScreenshot *ss = g_ptr_array_index (priv->screenshots, i);
- as_app_add_screenshot (app, ss);
+ if (flags & AS_APP_SUBSUME_FLAG_SCREENSHOTS) {
+ for (i = 0; i < priv->screenshots->len; i++) {
+ AsScreenshot *ss = g_ptr_array_index (priv->screenshots, i);
+ as_app_add_screenshot (app, ss);
+ }
}
/* reviews */
- for (i = 0; i < priv->reviews->len; i++) {
- AsReview *review = g_ptr_array_index (priv->reviews, i);
- as_app_add_review (app, review);
+ if (flags & AS_APP_SUBSUME_FLAG_REVIEWS) {
+ for (i = 0; i < priv->reviews->len; i++) {
+ AsReview *review = g_ptr_array_index (priv->reviews, i);
+ as_app_add_review (app, review);
+ }
}
/* content_ratings */
- for (i = 0; i < priv->content_ratings->len; i++) {
- AsContentRating *cr = g_ptr_array_index (priv->content_ratings, i);
- as_app_add_content_rating (app, cr);
+ if (flags & AS_APP_SUBSUME_FLAG_CONTENT_RATINGS) {
+ for (i = 0; i < priv->content_ratings->len; i++) {
+ AsContentRating *content_rating;
+ content_rating = g_ptr_array_index (priv->content_ratings, i);
+ as_app_add_content_rating (app, content_rating);
+ }
}
/* provides */
- for (i = 0; i < priv->provides->len; i++) {
- AsProvide *pr = g_ptr_array_index (priv->provides, i);
- as_app_add_provide (app, pr);
+ if (flags & AS_APP_SUBSUME_FLAG_PROVIDES) {
+ for (i = 0; i < priv->provides->len; i++) {
+ AsProvide *pr = g_ptr_array_index (priv->provides, i);
+ as_app_add_provide (app, pr);
+ }
}
/* icons */
- for (i = 0; i < priv->icons->len; i++) {
- AsIcon *ic = g_ptr_array_index (priv->icons, i);
- as_app_subsume_icon (app, ic);
+ if (flags & AS_APP_SUBSUME_FLAG_ICONS) {
+ for (i = 0; i < priv->icons->len; i++) {
+ AsIcon *ic = g_ptr_array_index (priv->icons, i);
+ as_app_subsume_icon (app, ic);
+ }
}
/* mimetypes */
- for (i = 0; i < priv->mimetypes->len; i++) {
- const gchar *tmp = g_ptr_array_index (priv->mimetypes, i);
- as_app_add_mimetype (app, tmp);
+ if (flags & AS_APP_SUBSUME_FLAG_MIMETYPES) {
+ for (i = 0; i < priv->mimetypes->len; i++) {
+ tmp = g_ptr_array_index (priv->mimetypes, i);
+ as_app_add_mimetype (app, tmp);
+ }
}
/* vetos */
- for (i = 0; i < priv->vetos->len; i++) {
- const gchar *tmp = g_ptr_array_index (priv->vetos, i);
- as_app_add_veto (app, "%s", tmp);
- }
-
- /* dictionaries */
- overwrite = (flags & AS_APP_SUBSUME_FLAG_NO_OVERWRITE) == 0;
- as_app_subsume_dict (papp->names, priv->names, overwrite);
- as_app_subsume_dict (papp->comments, priv->comments, overwrite);
- as_app_subsume_dict (papp->developer_names, priv->developer_names, overwrite);
- as_app_subsume_dict (papp->descriptions, priv->descriptions, overwrite);
- as_app_subsume_dict (papp->metadata, priv->metadata, overwrite);
- as_app_subsume_dict (papp->urls, priv->urls, overwrite);
- as_app_subsume_keywords (app, donor, overwrite);
-
- /* project_group */
- if (priv->project_group != NULL)
- as_app_set_project_group (app, priv->project_group);
-}
-
-static void
-as_app_subsume_private (AsApp *app, AsApp *donor, AsAppSubsumeFlags flags)
-{
- AsAppPrivate *priv = GET_PRIVATE (donor);
- AsAppPrivate *papp = GET_PRIVATE (app);
- AsBundle *bundle;
- const gchar *tmp;
- const gchar *key;
- guint i;
- gint percentage;
- GList *l;
- g_autoptr(GList) keys = NULL;
-
- /* stop us shooting ourselves in the foot */
- papp->trust_flags |= AS_APP_TRUST_FLAG_CHECK_DUPLICATES;
-
- /* safe things that can be done from merge components */
- as_app_subsume_merge (app, donor, flags);
- if (flags & AS_APP_SUBSUME_FLAG_ONLY_MERGE)
- return;
-
- /* id-kind */
- if (papp->kind == AS_APP_KIND_UNKNOWN)
- as_app_set_kind (app, priv->kind);
-
- /* AppData or AppStream can overwrite the id-kind of desktop files */
- if ((priv->source_kind == AS_APP_SOURCE_KIND_APPDATA ||
- priv->source_kind == AS_APP_SOURCE_KIND_APPSTREAM) &&
- papp->source_kind == AS_APP_SOURCE_KIND_DESKTOP)
- as_app_set_kind (app, priv->kind);
-
- /* state */
- if (papp->state == AS_APP_STATE_UNKNOWN)
- as_app_set_state (app, priv->state);
-
- /* pkgnames */
- for (i = 0; i < priv->pkgnames->len; i++) {
- tmp = g_ptr_array_index (priv->pkgnames, i);
- as_app_add_pkgname (app, tmp);
- }
-
- /* bundles */
- for (i = 0; i < priv->bundles->len; i++) {
- bundle = g_ptr_array_index (priv->bundles, i);
- as_app_add_bundle (app, bundle);
+ if (flags & AS_APP_SUBSUME_FLAG_VETOS) {
+ for (i = 0; i < priv->vetos->len; i++) {
+ tmp = g_ptr_array_index (priv->vetos, i);
+ as_app_add_veto (app, "%s", tmp);
+ }
}
- /* do not subsume all properties */
- if ((flags & AS_APP_SUBSUME_FLAG_PARTIAL) > 0)
- return;
-
/* languages */
- keys = g_hash_table_get_keys (priv->languages);
- for (l = keys; l != NULL; l = l->next) {
- key = l->data;
- if (flags & AS_APP_SUBSUME_FLAG_NO_OVERWRITE) {
- percentage = as_app_get_language (app, key);
- if (percentage >= 0)
- continue;
+ if (flags & AS_APP_SUBSUME_FLAG_LANGUAGES) {
+ GList *l;
+ g_autoptr(GList) keys = g_hash_table_get_keys (priv->languages);
+ for (l = keys; l != NULL; l = l->next) {
+ gint percentage;
+ key = l->data;
+ if (flags & AS_APP_SUBSUME_FLAG_NO_OVERWRITE) {
+ percentage = as_app_get_language (app, key);
+ if (percentage >= 0)
+ continue;
+ }
+ percentage = GPOINTER_TO_INT (g_hash_table_lookup (priv->languages, key));
+ as_app_add_language (app, percentage, key);
}
- percentage = GPOINTER_TO_INT (g_hash_table_lookup (priv->languages, key));
- as_app_add_language (app, percentage, key);
}
+ /* dictionaries */
+ if (flags & AS_APP_SUBSUME_FLAG_NAME)
+ as_app_subsume_dict (papp->names, priv->names, overwrite);
+ if (flags & AS_APP_SUBSUME_FLAG_COMMENT)
+ as_app_subsume_dict (papp->comments, priv->comments, overwrite);
+ if (flags & AS_APP_SUBSUME_FLAG_DEVELOPER_NAME)
+ as_app_subsume_dict (papp->developer_names, priv->developer_names, overwrite);
+ if (flags & AS_APP_SUBSUME_FLAG_DESCRIPTION)
+ as_app_subsume_dict (papp->descriptions, priv->descriptions, overwrite);
+ if (flags & AS_APP_SUBSUME_FLAG_METADATA)
+ as_app_subsume_dict (papp->metadata, priv->metadata, overwrite);
+ if (flags & AS_APP_SUBSUME_FLAG_URL)
+ as_app_subsume_dict (papp->urls, priv->urls, overwrite);
+ if (flags & AS_APP_SUBSUME_FLAG_KEYWORDS)
+ as_app_subsume_keywords (app, donor, overwrite);
+
/* source */
- if (priv->source_file != NULL)
- as_app_set_source_file (app, priv->source_file);
+ if (flags & AS_APP_SUBSUME_FLAG_SOURCE_FILE) {
+ if (priv->source_file != NULL)
+ as_app_set_source_file (app, priv->source_file);
+ }
/* branch */
- if (priv->branch != NULL)
- as_app_set_branch (app, priv->branch);
+ if (flags & AS_APP_SUBSUME_FLAG_BRANCH) {
+ if (priv->branch != NULL)
+ as_app_set_branch (app, priv->branch);
+ }
/* source_pkgname */
- if (priv->source_pkgname != NULL)
- as_app_set_source_pkgname (app, priv->source_pkgname);
+ if (flags & AS_APP_SUBSUME_FLAG_BUNDLES) {
+ if (priv->source_pkgname != NULL)
+ as_app_set_source_pkgname (app, priv->source_pkgname);
+ }
/* origin */
- if (priv->origin != NULL)
- as_app_set_origin (app, priv->origin);
+ if (flags & AS_APP_SUBSUME_FLAG_ORIGIN) {
+ if (priv->origin != NULL)
+ as_app_set_origin (app, priv->origin);
+ }
/* licenses */
- if (priv->project_license != NULL)
- as_app_set_project_license (app, priv->project_license);
- if (priv->metadata_license != NULL)
- as_app_set_metadata_license (app, priv->metadata_license);
+ if (flags & AS_APP_SUBSUME_FLAG_PROJECT_LICENSE) {
+ if (priv->project_license != NULL)
+ as_app_set_project_license (app, priv->project_license);
+ }
+ if (flags & AS_APP_SUBSUME_FLAG_METADATA_LICENSE) {
+ if (priv->metadata_license != NULL)
+ as_app_set_metadata_license (app, priv->metadata_license);
+ }
+
+ /* project_group */
+ if (flags & AS_APP_SUBSUME_FLAG_PROJECT_GROUP) {
+ if (priv->project_group != NULL)
+ as_app_set_project_group (app, priv->project_group);
+ }
}
/**
@@ -3511,6 +3555,12 @@ as_app_subsume_full (AsApp *app, AsApp *donor, AsAppSubsumeFlags flags)
{
g_assert (app != donor);
+ /* legacy value */
+ if (flags & AS_APP_SUBSUME_FLAG_PARTIAL) {
+ g_warning ("using AS_APP_SUBSUME_FLAG_PARTIAL fallback");
+ flags |= AS_APP_SUBSUME_FLAG_MERGE;
+ }
+
/* two way sync implies no overwriting */
if ((flags & AS_APP_SUBSUME_FLAG_BOTH_WAYS) > 0)
flags |= AS_APP_SUBSUME_FLAG_NO_OVERWRITE;
@@ -3535,7 +3585,7 @@ as_app_subsume_full (AsApp *app, AsApp *donor, AsAppSubsumeFlags flags)
void
as_app_subsume (AsApp *app, AsApp *donor)
{
- as_app_subsume_full (app, donor, AS_APP_SUBSUME_FLAG_NONE);
+ as_app_subsume_full (app, donor, AS_APP_SUBSUME_FLAG_DEDUPE);
}
static gint
diff --git a/libappstream-glib/as-app.h b/libappstream-glib/as-app.h
index d0b3ba3..88a74d5 100644
--- a/libappstream-glib/as-app.h
+++ b/libappstream-glib/as-app.h
@@ -88,21 +88,119 @@ typedef enum {
* @AS_APP_SUBSUME_FLAG_NONE: No special actions to use
* @AS_APP_SUBSUME_FLAG_NO_OVERWRITE: Do not overwrite already set properties
* @AS_APP_SUBSUME_FLAG_BOTH_WAYS: Copy unset properties both ways
- * @AS_APP_SUBSUME_FLAG_PARTIAL: Only subsume a safe subset
- * @AS_APP_SUBSUME_FLAG_ONLY_MERGE: Only copy properties allowed in merge components
+ * @AS_APP_SUBSUME_FLAG_PARTIAL: Only subsume a safe subset (obsolete)
+ * @AS_APP_SUBSUME_FLAG_KIND: Copy the kind
+ * @AS_APP_SUBSUME_FLAG_STATE: Copy the state
+ * @AS_APP_SUBSUME_FLAG_BUNDLES: Copy the bundles
+ * @AS_APP_SUBSUME_FLAG_TRANSLATIONS Copy the translations
+ * @AS_APP_SUBSUME_FLAG_RELEASES: Copy the releases
+ * @AS_APP_SUBSUME_FLAG_KUDOS: Copy the kudos
+ * @AS_APP_SUBSUME_FLAG_CATEGORIES: Copy the categories
+ * @AS_APP_SUBSUME_FLAG_PERMISSIONS: Copy the permissions
+ * @AS_APP_SUBSUME_FLAG_EXTENDS: Copy the extends
+ * @AS_APP_SUBSUME_FLAG_COMPULSORY: Copy the compulsory-for-desktop
+ * @AS_APP_SUBSUME_FLAG_SCREENSHOTS: Copy the screenshots
+ * @AS_APP_SUBSUME_FLAG_REVIEWS: Copy the reviews
+ * @AS_APP_SUBSUME_FLAG_CONTENT_RATINGS Copy the content ratings
+ * @AS_APP_SUBSUME_FLAG_PROVIDES: Copy the provides
+ * @AS_APP_SUBSUME_FLAG_ICONS: Copy the icons
+ * @AS_APP_SUBSUME_FLAG_MIMETYPES: Copy the mimetypes
+ * @AS_APP_SUBSUME_FLAG_VETOS: Copy the vetos
+ * @AS_APP_SUBSUME_FLAG_LANGUAGES: Copy the languages
+ * @AS_APP_SUBSUME_FLAG_NAME: Copy the name
+ * @AS_APP_SUBSUME_FLAG_COMMENT: Copy the comment
+ * @AS_APP_SUBSUME_FLAG_DEVELOPER_NAME Copy the developer name
+ * @AS_APP_SUBSUME_FLAG_DESCRIPTION: Copy the description
+ * @AS_APP_SUBSUME_FLAG_METADATA: Copy the metadata
+ * @AS_APP_SUBSUME_FLAG_URL: Copy the urls
+ * @AS_APP_SUBSUME_FLAG_KEYWORDS: Copy the keywords
+ * @AS_APP_SUBSUME_FLAG_SOURCE_FILE: Copy the source file
+ * @AS_APP_SUBSUME_FLAG_BRANCH: Copy the branch
+ * @AS_APP_SUBSUME_FLAG_ORIGIN: Copy the origin
+ * @AS_APP_SUBSUME_FLAG_METADATA_LICENSE: Copy the metadata license
+ * @AS_APP_SUBSUME_FLAG_PROJECT_LICENSE Copy the project license
+ * @AS_APP_SUBSUME_FLAG_PROJECT_GROUP Copy the project group
+ * @AS_APP_SUBSUME_FLAG_SOURCE_KIND: Copy the source kind
*
* The flags to use when subsuming applications.
**/
typedef enum {
AS_APP_SUBSUME_FLAG_NONE = 0,
- AS_APP_SUBSUME_FLAG_NO_OVERWRITE = 1 << 0, /* Since: 0.1.4 */
- AS_APP_SUBSUME_FLAG_BOTH_WAYS = 1 << 1, /* Since: 0.1.4 */
- AS_APP_SUBSUME_FLAG_PARTIAL = 1 << 2, /* Since: 0.2.2 */
- AS_APP_SUBSUME_FLAG_ONLY_MERGE = 1 << 3, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_NO_OVERWRITE = 1lu << 0, /* Since: 0.1.4 */
+ AS_APP_SUBSUME_FLAG_BOTH_WAYS = 1lu << 1, /* Since: 0.1.4 */
+ AS_APP_SUBSUME_FLAG_PARTIAL = 1lu << 2, /* Since: 0.2.2 */
+ AS_APP_SUBSUME_FLAG_KIND = 1lu << 3, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_STATE = 1lu << 4, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_BUNDLES = 1lu << 5, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_TRANSLATIONS = 1lu << 6, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_RELEASES = 1lu << 7, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_KUDOS = 1lu << 8, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_CATEGORIES = 1lu << 9, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_PERMISSIONS = 1lu << 10, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_EXTENDS = 1lu << 11, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_COMPULSORY = 1lu << 12, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_SCREENSHOTS = 1lu << 13, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_REVIEWS = 1lu << 14, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_CONTENT_RATINGS = 1lu << 15, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_PROVIDES = 1lu << 16, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_ICONS = 1lu << 17, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_MIMETYPES = 1lu << 18, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_VETOS = 1lu << 19, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_LANGUAGES = 1lu << 20, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_NAME = 1lu << 21, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_COMMENT = 1lu << 22, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_DEVELOPER_NAME = 1lu << 23, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_DESCRIPTION = 1lu << 24, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_METADATA = 1lu << 25, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_URL = 1lu << 26, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_KEYWORDS = 1lu << 27, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_SOURCE_FILE = 1lu << 28, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_BRANCH = 1lu << 29, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_ORIGIN = 1lu << 30, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_METADATA_LICENSE = 1lu << 31, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_PROJECT_LICENSE = 1lu << 32, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_PROJECT_GROUP = 1lu << 33, /* Since: 0.6.1 */
+ AS_APP_SUBSUME_FLAG_SOURCE_KIND = 1lu << 34, /* Since: 0.6.1 */
/*< private >*/
AS_APP_SUBSUME_FLAG_LAST,
} AsAppSubsumeFlags;
+/* safe to do from a merge <component> */
+#define AS_APP_SUBSUME_FLAG_MERGE (AS_APP_SUBSUME_FLAG_CATEGORIES | \
+ AS_APP_SUBSUME_FLAG_COMMENT | \
+ AS_APP_SUBSUME_FLAG_COMPULSORY | \
+ AS_APP_SUBSUME_FLAG_CONTENT_RATINGS | \
+ AS_APP_SUBSUME_FLAG_DESCRIPTION | \
+ AS_APP_SUBSUME_FLAG_DEVELOPER_NAME | \
+ AS_APP_SUBSUME_FLAG_EXTENDS | \
+ AS_APP_SUBSUME_FLAG_ICONS | \
+ AS_APP_SUBSUME_FLAG_KEYWORDS | \
+ AS_APP_SUBSUME_FLAG_KUDOS | \
+ AS_APP_SUBSUME_FLAG_LANGUAGES | \
+ AS_APP_SUBSUME_FLAG_MIMETYPES | \
+ AS_APP_SUBSUME_FLAG_NAME | \
+ AS_APP_SUBSUME_FLAG_PERMISSIONS | \
+ AS_APP_SUBSUME_FLAG_PROJECT_GROUP | \
+ AS_APP_SUBSUME_FLAG_PROVIDES | \
+ AS_APP_SUBSUME_FLAG_RELEASES | \
+ AS_APP_SUBSUME_FLAG_REVIEWS | \
+ AS_APP_SUBSUME_FLAG_SCREENSHOTS | \
+ AS_APP_SUBSUME_FLAG_TRANSLATIONS | \
+ AS_APP_SUBSUME_FLAG_URL)
+
+/* all properties */
+#define AS_APP_SUBSUME_FLAG_DEDUPE (AS_APP_SUBSUME_FLAG_BRANCH | \
+ AS_APP_SUBSUME_FLAG_BUNDLES | \
+ AS_APP_SUBSUME_FLAG_KIND | \
+ AS_APP_SUBSUME_FLAG_MERGE | \
+ AS_APP_SUBSUME_FLAG_METADATA | \
+ AS_APP_SUBSUME_FLAG_ORIGIN | \
+ AS_APP_SUBSUME_FLAG_PROJECT_LICENSE | \
+ AS_APP_SUBSUME_FLAG_SOURCE_FILE | \
+ AS_APP_SUBSUME_FLAG_SOURCE_KIND | \
+ AS_APP_SUBSUME_FLAG_STATE | \
+ AS_APP_SUBSUME_FLAG_VETOS)
+
/**
* AsAppError:
* @AS_APP_ERROR_FAILED: Generic failure
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index 172628d..02f215a 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -2646,7 +2646,9 @@ as_test_app_subsume_func (void)
app = as_app_new ();
as_app_add_metadata (app, "overwrite", "2222");
as_app_add_metadata (app, "recipient", "true");
- as_app_subsume_full (app, donor, AS_APP_SUBSUME_FLAG_NO_OVERWRITE);
+ as_app_subsume_full (app, donor,
+ AS_APP_SUBSUME_FLAG_NO_OVERWRITE |
+ AS_APP_SUBSUME_FLAG_DEDUPE);
as_app_add_screenshot (app, ss);
g_assert_cmpstr (as_app_get_metadata_item (app, "donor"), ==, "true");
@@ -2670,7 +2672,9 @@ as_test_app_subsume_func (void)
g_assert_cmpint (as_icon_get_height (ic), ==, 0);
/* test both ways */
- as_app_subsume_full (app, donor, AS_APP_SUBSUME_FLAG_BOTH_WAYS);
+ as_app_subsume_full (app, donor,
+ AS_APP_SUBSUME_FLAG_BOTH_WAYS |
+ AS_APP_SUBSUME_FLAG_METADATA);
g_assert_cmpstr (as_app_get_metadata_item (app, "donor"), ==, "true");
g_assert_cmpstr (as_app_get_metadata_item (app, "recipient"), ==, "true");
g_assert_cmpstr (as_app_get_metadata_item (donor, "donor"), ==, "true");
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index f11b197..dbdbd31 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -950,7 +950,7 @@ as_store_add_app (AsStore *store, AsApp *app)
id, as_app_get_unique_id (app_tmp));
as_app_subsume_full (app_tmp, app,
AS_APP_SUBSUME_FLAG_NO_OVERWRITE |
- AS_APP_SUBSUME_FLAG_ONLY_MERGE);
+ AS_APP_SUBSUME_FLAG_MERGE);
}
return;
}
@@ -965,7 +965,7 @@ as_store_add_app (AsStore *store, AsApp *app)
as_app_get_unique_id (app));
as_app_subsume_full (app, app_tmp,
AS_APP_SUBSUME_FLAG_NO_OVERWRITE |
- AS_APP_SUBSUME_FLAG_ONLY_MERGE);
+ AS_APP_SUBSUME_FLAG_MERGE);
}
}
@@ -1001,7 +1001,9 @@ as_store_add_app (AsStore *store, AsApp *app)
g_debug ("merging duplicate AppData:desktop entries: %s:%s",
as_app_get_unique_id (app),
as_app_get_unique_id (item));
- as_app_subsume_full (app, item, AS_APP_SUBSUME_FLAG_BOTH_WAYS);
+ as_app_subsume_full (app, item,
+ AS_APP_SUBSUME_FLAG_BOTH_WAYS |
+ AS_APP_SUBSUME_FLAG_DEDUPE);
/* promote the desktop source to AppData */
as_app_set_source_kind (item, AS_APP_SOURCE_KIND_APPDATA);
return;
@@ -1011,7 +1013,9 @@ as_store_add_app (AsStore *store, AsApp *app)
g_debug ("merging duplicate desktop:AppData entries: %s:%s",
as_app_get_unique_id (app),
as_app_get_unique_id (item));
- as_app_subsume_full (app, item, AS_APP_SUBSUME_FLAG_BOTH_WAYS);
+ as_app_subsume_full (app, item,
+ AS_APP_SUBSUME_FLAG_BOTH_WAYS |
+ AS_APP_SUBSUME_FLAG_DEDUPE);
return;
}
@@ -1053,7 +1057,8 @@ as_store_add_app (AsStore *store, AsApp *app)
as_app_get_unique_id (app),
as_app_get_unique_id (item));
as_app_subsume_full (app, item,
- AS_APP_SUBSUME_FLAG_BOTH_WAYS);
+ AS_APP_SUBSUME_FLAG_BOTH_WAYS |
+ AS_APP_SUBSUME_FLAG_DEDUPE);
/* promote the desktop source to AppData */
if (as_app_get_source_kind (item) == AS_APP_SOURCE_KIND_DESKTOP &&