1
0

Accepting request 1158299 from GNOME:Next

GNOME 46

OBS-URL: https://build.opensuse.org/request/show/1158299
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/gnome-software?expand=0&rev=273
This commit is contained in:
Dominique Leuenberger 2024-03-19 13:29:45 +00:00 committed by Git OBS Bridge
parent a26fc3856b
commit e91030be21
8 changed files with 83 additions and 1219 deletions

19
_service Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<services>
<service name="obs_scm" mode="manual">
<param name="scm">git</param>
<param name="url">https://gitlab.gnome.org/GNOME/gnome-software.git</param>
<param name="revision">46.0</param>
<param name="versionformat">@PARENT_TAG@+@TAG_OFFSET@</param>
<param name="versionrewrite-pattern">(.*)\+0</param>
<param name="versionrewrite-replacement">\1</param>
<!-- <param name="changesgenerate">enable</param> -->
</service>
<service name="tar" mode="buildtime"/>
<service name="recompress" mode="buildtime">
<param name="file">*.tar</param>
<param name="compression">zst</param>
</service>
<service name="set_version" mode="manual" />
</services>

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0bdd8fc0caecd6eb013c6010dbca93077397118a6ef5eaf264e2a820a292f5b7
size 2475796

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:92117bf4ebd23b8bc215644d061ebf48b36d22128e223442263fedc4458210e4
size 19801613

View File

@ -1,697 +0,0 @@
From 98ba5798c34db0f683312a5424489efa40fea426 Mon Sep 17 00:00:00 2001
From: Jonathan Kang <jonathankang@gnome.org>
Date: Tue, 22 Nov 2022 09:21:19 +0800
Subject: [PATCH] plugins: add opensuse-distro-upgrade plugin
---
plugins/meson.build | 1 +
.../gs-plugin-opensuse-distro-upgrade.c | 616 ++++++++++++++++++
.../gs-plugin-opensuse-distro-upgrade.h | 19 +
plugins/opensuse-distro-upgrade/meson.build | 14 +
4 files changed, 650 insertions(+)
create mode 100644 plugins/opensuse-distro-upgrade/gs-plugin-opensuse-distro-upgrade.c
create mode 100644 plugins/opensuse-distro-upgrade/gs-plugin-opensuse-distro-upgrade.h
create mode 100644 plugins/opensuse-distro-upgrade/meson.build
diff --git a/plugins/meson.build b/plugins/meson.build
index 711b488e2..16c1eb753 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -12,6 +12,7 @@ subdir('dpkg')
subdir('dummy')
subdir('fedora-langpacks')
subdir('fedora-pkgdb-collections')
+subdir('opensuse-distro-upgrade')
if get_option('eos_updater')
subdir('eos-updater')
diff --git a/plugins/opensuse-distro-upgrade/gs-plugin-opensuse-distro-upgrade.c b/plugins/opensuse-distro-upgrade/gs-plugin-opensuse-distro-upgrade.c
new file mode 100644
index 000000000..46de82d02
--- /dev/null
+++ b/plugins/opensuse-distro-upgrade/gs-plugin-opensuse-distro-upgrade.c
@@ -0,0 +1,616 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2020 Jonathan Kang <jonathankang@gnome.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <json-glib/json-glib.h>
+#include <gnome-software.h>
+
+#include "gs-plugin-opensuse-distro-upgrade.h"
+
+#define OPENSUSE_DISTRO_UPGRADE_API_URI "https://get.opensuse.org/api/v0/distributions.json"
+
+struct _GsPluginOpensuseDistroUpgrade {
+ GsPlugin Parent;
+
+ gchar *os_name;
+ gchar *os_version;
+ guint64 upgrade_weight;
+
+ gchar *cachefn;
+ GFileMonitor *cachefn_monitor;
+ GsApp *cached_origin;
+ gboolean is_valid;
+ GPtrArray *distros;
+};
+
+typedef enum {
+ DISTRO_UPGRADE_ITEM_STATE_ALPHA,
+ DISTRO_UPGRADE_ITEM_STATE_BETA,
+ DISTRO_UPGRADE_ITEM_STATE_STABLE,
+ DISTRO_UPGRADE_ITEM_STATE_EOL,
+ DISTRO_UPGRADE_ITEM_STATE_LAST,
+} DistroUpgradeItemState;
+
+typedef struct {
+ gchar *name;
+ gchar *version;
+ DistroUpgradeItemState state;
+ guint upgrade_weight;
+} DistroUpgradeItem;
+
+G_DEFINE_TYPE (GsPluginOpensuseDistroUpgrade, gs_plugin_opensuse_distro_upgrade, GS_TYPE_PLUGIN)
+
+static gboolean
+_is_valid_upgrade (GsPluginOpensuseDistroUpgrade *self,
+ DistroUpgradeItem *item)
+{
+ guint diff;
+
+ if (item->state != DISTRO_UPGRADE_ITEM_STATE_STABLE)
+ return FALSE;
+
+ diff = item->upgrade_weight - self->upgrade_weight;
+ if (diff == 1)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+static GsApp *
+_create_upgrade_app (GsPluginOpensuseDistroUpgrade *self,
+ DistroUpgradeItem *item)
+{
+ GsApp *app;
+ g_autofree gchar *app_id = NULL;
+ g_autofree gchar *app_version = NULL;
+ g_autofree gchar *background = NULL;
+ g_autofree gchar *cache_key = NULL;
+ g_autofree gchar *css = NULL;
+ g_autofree gchar *url = NULL;
+ g_autoptr(GFile) icon_file = NULL;
+ g_autoptr(GIcon) ic = NULL;
+
+ cache_key = g_strdup_printf ("leap-%s", item->version);
+ app = gs_plugin_cache_lookup (GS_PLUGIN (self), cache_key);
+
+ app_id = g_strdup_printf ("org.openSUSE.Leap-%s", item->version);
+ app_version = g_strdup (item->version);
+
+ /* icon from disk */
+ icon_file = g_file_new_for_path ("/usr/share/pixmaps/distribution-logos/square-symbolic.svg");
+ ic = g_file_icon_new (icon_file);
+
+ app = gs_app_new (app_id);
+ gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
+ gs_app_set_kind (app, AS_COMPONENT_KIND_OPERATING_SYSTEM);
+ gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
+ gs_app_set_name (app, GS_APP_QUALITY_LOWEST, item->name);
+ gs_app_set_summary (app, GS_APP_QUALITY_NORMAL,
+ _("Upgrade for the latest features, performance and stability improvements."));
+ gs_app_set_version (app, app_version);
+ gs_app_set_size_installed (app, GS_SIZE_TYPE_UNKNOWABLE, 0);
+ gs_app_set_size_download (app, GS_SIZE_TYPE_UNKNOWABLE, 0);
+ gs_app_set_license (app, GS_APP_QUALITY_LOWEST, "LicenseRef-free");
+ gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
+ gs_app_add_quirk (app, GS_APP_QUIRK_PROVENANCE);
+ gs_app_add_quirk (app, GS_APP_QUIRK_NOT_REVIEWABLE);
+ gs_app_add_icon (app, ic);
+
+ /* Save it in the cache. */
+ gs_plugin_cache_add (GS_PLUGIN (self), cache_key, app);
+
+ return app;
+}
+
+static void
+_distro_upgrade_item_destroy (DistroUpgradeItem *item)
+{
+ g_free (item->name);
+ g_free (item->version);
+ g_slice_free (DistroUpgradeItem, item);
+}
+
+static GPtrArray *
+load_json (GsPluginOpensuseDistroUpgrade *self,
+ GError **error)
+{
+ JsonArray *distros;
+ JsonNode *root_node;
+ JsonObject *root = NULL;
+ g_autoptr(JsonParser) parser = NULL;
+ g_autoptr(GPtrArray) new_distros = NULL;
+
+ new_distros = g_ptr_array_new_with_free_func ((GDestroyNotify) _distro_upgrade_item_destroy);
+ parser = json_parser_new_immutable ();
+
+ if (!json_parser_load_from_mapped_file (parser, self->cachefn, error))
+ return NULL;
+
+ root_node = json_parser_get_root (parser);
+ if (root_node != NULL && JSON_NODE_HOLDS_OBJECT (root_node))
+ root = json_node_get_object (root_node);
+ if (root == NULL) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_INVALID_FORMAT,
+ "no root object");
+ return NULL;
+ }
+
+ distros = json_object_get_array_member (root, "Leap");
+ if (distros == NULL) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_INVALID_FORMAT,
+ "No array member named \"Leap\".");
+ return NULL;
+ }
+
+ for (guint i = 0; i < json_array_get_length (distros); i++) {
+ DistroUpgradeItem *item;
+ DistroUpgradeItemState state;
+ JsonObject *distro;
+ const gchar *name;
+ const gchar *version;
+ const gchar *state_str;
+ guint upgrade_weight;
+
+ distro = json_array_get_object_element (distros, i);
+ if (distro == NULL)
+ continue;
+
+ name = json_object_get_string_member (distro, "name");
+ if (name == NULL)
+ continue;
+
+ version = json_object_get_string_member (distro, "version");
+ if (version == NULL)
+ continue;
+
+ state_str = json_object_get_string_member (distro, "state");
+ if (state_str == NULL)
+ continue;
+ if (g_strcmp0 (state_str, "Alpha") == 0)
+ state = DISTRO_UPGRADE_ITEM_STATE_ALPHA;
+ else if (g_strcmp0 (state_str, "Beta") == 0)
+ state = DISTRO_UPGRADE_ITEM_STATE_BETA;
+ else if (g_strcmp0 (state_str, "Stable") == 0)
+ state = DISTRO_UPGRADE_ITEM_STATE_STABLE;
+ else if (g_strcmp0 (state_str, "EOL") == 0)
+ state = DISTRO_UPGRADE_ITEM_STATE_EOL;
+ else
+ continue;
+
+ upgrade_weight = json_object_get_int_member (distro, "upgrade-weight");
+
+ /* Set upgrade weight for current OS. */
+ if (g_strcmp0 (self->os_version, version) == 0)
+ self->upgrade_weight = upgrade_weight;
+
+ /* add item */
+ item = g_slice_new0 (DistroUpgradeItem);
+ item->name = g_strdup (name);
+ item->version = g_strdup (version);
+ item->state = state;
+ item->upgrade_weight = upgrade_weight;
+ g_ptr_array_add (self->distros, item);
+ }
+
+ /* success */
+ g_clear_pointer (&self->distros, g_ptr_array_unref);
+ self->distros = g_ptr_array_ref (new_distros);
+ self->is_valid = TRUE;
+
+ return g_steal_pointer (&new_distros);
+}
+
+static void
+download_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ SoupSession *soup_session = SOUP_SESSION (source_object);
+ g_autoptr(GTask) task = g_steal_pointer (&user_data);
+ GsPluginOpensuseDistroUpgrade *self = g_task_get_source_object (task);
+ g_autoptr(GError) local_error = NULL;
+
+ if (!gs_download_file_finish (soup_session, result, &local_error) &&
+ !g_error_matches (local_error, GS_DOWNLOAD_ERROR, GS_DOWNLOAD_ERROR_NOT_MODIFIED)) {
+ g_autoptr(GError) wrapped_error = NULL;
+
+ /* Wrap in a GsPluginError. */
+ g_set_error_literal (&wrapped_error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_DOWNLOAD_FAILED,
+ local_error->message);
+
+ gs_utils_error_add_origin_id (&wrapped_error, self->cached_origin);
+ g_task_return_error (task, g_steal_pointer (&wrapped_error));
+ return;
+ }
+
+ /* success */
+ self->is_valid = FALSE;
+
+ g_task_return_boolean (task, TRUE);
+}
+
+static void
+_refresh_cache_async (GsPluginOpensuseDistroUpgrade *self,
+ guint64 cache_age_secs,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GsPlugin *plugin = GS_PLUGIN (self);
+ g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
+ g_autoptr(GTask) task = NULL;
+ g_autoptr(GFile) output_file = g_file_new_for_path (self->cachefn);
+ g_autoptr(SoupSession) soup_session = NULL;
+
+ task = g_task_new (self, cancellable, callback, user_data);
+ g_task_set_source_tag (task, _refresh_cache_async);
+
+ /* check cache age */
+ if (cache_age_secs > 0) {
+ guint64 tmp = gs_utils_get_file_age (output_file);
+ if (tmp < cache_age_secs) {
+ g_debug ("%s is only %" G_GUINT64_FORMAT " seconds old",
+ self->cachefn, tmp);
+ g_task_return_boolean (task, TRUE);
+ return;
+ }
+ }
+
+ /* download new file */
+ gs_app_set_summary_missing (app_dl,
+ /* TRANSLATORS: status text when downloading */
+ _("Downloading upgrade information…"));
+
+ soup_session = gs_build_soup_session ();
+
+ gs_download_file_async (soup_session,
+ OPENSUSE_DISTRO_UPGRADE_API_URI,
+ output_file,
+ G_PRIORITY_LOW,
+ NULL, NULL, /* FIXME: progress reporting */
+ cancellable,
+ download_cb,
+ g_steal_pointer (&task));
+}
+
+static gboolean
+_refresh_cache_finish (GsPluginOpensuseDistroUpgrade *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_boolean (G_TASK (result), error);
+}
+
+static void
+ensure_refresh_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GsPluginOpensuseDistroUpgrade *self = GS_PLUGIN_OPENSUSE_DISTRO_UPGRADE (source_object);
+ g_autoptr(GTask) task = g_steal_pointer (&user_data);
+ g_autoptr(GPtrArray) distros = NULL;
+ g_autoptr(GError) local_error = NULL;
+
+ if (!_refresh_cache_finish (self, result, &local_error)) {
+ g_task_return_error (task, g_steal_pointer (&local_error));
+ return;
+ }
+
+ distros = load_json (self, &local_error);
+ if (distros == NULL) {
+ g_autoptr(GFile) cache_file = g_file_new_for_path (self->cachefn);
+
+ g_debug ("Failed to load cache file %s, deleting it", self->cachefn);
+ g_file_delete (cache_file, NULL, NULL);
+
+ g_task_return_error (task, g_steal_pointer (&local_error));
+ return;
+ }
+
+ g_task_return_pointer (task, g_steal_pointer (&distros), (GDestroyNotify) g_ptr_array_unref);
+}
+
+/* This will return a strong reference to the latest distros
+ * #GPtrArray. The caller should use this in their computation. */
+static void
+_ensure_cache_async (GsPluginOpensuseDistroUpgrade *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_autoptr(GTask) task = NULL;
+
+ task = g_task_new (self, cancellable, callback, user_data);
+ g_task_set_source_tag (task, _ensure_cache_async);
+
+ /* already done */
+ if (self->is_valid) {
+ g_task_return_pointer (task, g_ptr_array_ref (self->distros), (GDestroyNotify) g_ptr_array_unref);
+ return;
+ }
+
+ /* Ensure there is any data, no matter how old. This can download from
+ * the network if needed. */
+ _refresh_cache_async (self, G_MAXUINT, cancellable,
+ ensure_refresh_cb, g_steal_pointer (&task));
+}
+
+static GPtrArray *
+_ensure_cache_finish (GsPluginOpensuseDistroUpgrade *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_pointer (G_TASK (result), error);
+}
+
+static void
+list_distro_upgrades_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GsPluginOpensuseDistroUpgrade *self = GS_PLUGIN_OPENSUSE_DISTRO_UPGRADE (source_object);
+ g_autoptr(GTask) task = g_steal_pointer (&user_data);
+ g_autoptr(GPtrArray) distros = NULL;
+ g_autoptr(GsAppList) list = NULL;
+ g_autoptr(GError) local_error = NULL;
+
+ distros = _ensure_cache_finish (self, result, &local_error);
+ if (distros == NULL) {
+ g_task_return_error (task, g_steal_pointer (&local_error));
+ return;
+ }
+
+ /* are any distros upgradable */
+ list = gs_app_list_new ();
+
+ for (guint i = 0; i < distros->len; i++) {
+ DistroUpgradeItem *item;
+
+ item = g_ptr_array_index (self->distros, i);
+ if (_is_valid_upgrade (self, item)) {
+ g_autoptr(GsApp) app = NULL;
+
+ app = _create_upgrade_app (self, item);
+ gs_app_list_add (list, app);
+
+ break;
+ }
+ }
+
+ g_task_return_pointer (task, g_steal_pointer (&list), g_object_unref);
+}
+
+static void
+gs_plugin_opensuse_distro_upgrade_list_distro_upgrades_async (GsPlugin *plugin,
+ GsPluginListDistroUpgradesFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_autoptr(GTask) task = NULL;
+ g_autoptr(GsAppList) list = gs_app_list_new ();
+ GsPluginOpensuseDistroUpgrade *self = GS_PLUGIN_OPENSUSE_DISTRO_UPGRADE (plugin);
+
+ task = g_task_new (plugin, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gs_plugin_opensuse_distro_upgrade_list_distro_upgrades_async);
+
+ /* Ensure valid data is loaded. */
+ _ensure_cache_async (self, cancellable, list_distro_upgrades_cb, g_steal_pointer (&task));
+
+ g_task_return_pointer (task, g_steal_pointer (&list), g_object_unref);
+}
+
+static GsAppList *
+gs_plugin_opensuse_distro_upgrade_list_distro_upgrades_finish (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_pointer (G_TASK (result), error);
+}
+
+static void
+gs_plugin_opensuse_distro_upgrade_dispose (GObject *object)
+{
+ GsPluginOpensuseDistroUpgrade *self = GS_PLUGIN_OPENSUSE_DISTRO_UPGRADE (object);
+
+ g_clear_object (&self->cachefn_monitor);
+ g_clear_object (&self->cached_origin);
+
+ G_OBJECT_CLASS (gs_plugin_opensuse_distro_upgrade_parent_class)->dispose (object);
+}
+
+static void
+gs_plugin_opensuse_distro_upgrade_finalize (GObject *object)
+{
+ GsPluginOpensuseDistroUpgrade *self = GS_PLUGIN_OPENSUSE_DISTRO_UPGRADE (object);
+
+ g_clear_pointer (&self->distros, g_ptr_array_unref);
+ g_clear_pointer (&self->os_name, g_free);
+ g_clear_pointer (&self->os_version, g_free);
+ g_clear_pointer (&self->cachefn, g_free);
+
+ G_OBJECT_CLASS (gs_plugin_opensuse_distro_upgrade_parent_class)->finalize (object);
+}
+
+static void
+_file_changed_cb (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ gpointer user_data)
+{
+ GsPluginOpensuseDistroUpgrade *self = GS_PLUGIN_OPENSUSE_DISTRO_UPGRADE (user_data);
+
+ g_debug ("cache file changed, so reloading upgrades list");
+ gs_plugin_updates_changed (GS_PLUGIN (self));
+
+ self->is_valid = FALSE;
+}
+
+static void
+gs_plugin_opensuse_distro_upgrade_setup_async (GsPlugin *plugin,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GsPluginOpensuseDistroUpgrade *self = GS_PLUGIN_OPENSUSE_DISTRO_UPGRADE (plugin);
+ g_autoptr(GFile) file = NULL;
+ g_autoptr(GsOsRelease) os_release = NULL;
+ g_autoptr(GTask) task = NULL;
+ g_autoptr(GError) local_error = NULL;
+
+ task = g_task_new (plugin, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gs_plugin_opensuse_distro_upgrade_setup_async);
+
+ /* get the file to cache */
+ self->cachefn = gs_utils_get_cache_filename ("opensuse-distro-upgrade",
+ "distributions.json",
+ GS_UTILS_CACHE_FLAG_WRITEABLE |
+ GS_UTILS_CACHE_FLAG_CREATE_DIRECTORY,
+ &local_error);
+ if (self->cachefn == NULL) {
+ g_task_return_error (task, g_steal_pointer (&local_error));
+ return;
+ }
+
+ /* watch this in case it is changed by the user */
+ file = g_file_new_for_path (self->cachefn);
+ self->cachefn_monitor = g_file_monitor (file,
+ G_FILE_MONITOR_NONE,
+ cancellable,
+ &local_error);
+ if (self->cachefn_monitor == NULL) {
+ g_task_return_error (task, g_steal_pointer (&local_error));
+ return;
+ }
+
+ g_signal_connect (self->cachefn_monitor, "changed",
+ G_CALLBACK (_file_changed_cb), plugin);
+
+ /* read os-release for the current versions */
+ os_release = gs_os_release_new (&local_error);
+ if (os_release == NULL) {
+ g_task_return_error (task, g_steal_pointer (&local_error));
+ return;
+ }
+
+ self->os_name = g_strdup (gs_os_release_get_name (os_release));
+ if (self->os_name == NULL) {
+ g_task_return_new_error (task, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_INVALID_FORMAT,
+ "OS release had no name");
+ return;
+ }
+ self->os_version = g_strdup (gs_os_release_get_version_id (os_release));
+ if (self->os_version == NULL) {
+ g_task_return_new_error (task, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_INVALID_FORMAT,
+ "OS release had no version ID");
+ return;
+ }
+
+ /* add source */
+ self->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
+ gs_app_set_kind (self->cached_origin, AS_COMPONENT_KIND_REPOSITORY);
+ gs_app_set_origin_hostname (self->cached_origin,
+ OPENSUSE_DISTRO_UPGRADE_API_URI);
+ gs_app_set_management_plugin (self->cached_origin, plugin);
+
+ /* add the source to the plugin cache which allows us to match the
+ * unique ID to a GsApp when creating an event */
+ gs_plugin_cache_add (plugin,
+ gs_app_get_unique_id (self->cached_origin),
+ self->cached_origin);
+
+ /* success */
+ g_task_return_boolean (task, TRUE);
+}
+
+static gboolean
+gs_plugin_opensuse_distro_upgrade_setup_finish (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_boolean (G_TASK (result), error);
+}
+
+static void
+gs_plugin_opensuse_distro_upgrade_refresh_metadata_async (GsPlugin *plugin,
+ guint64 cache_age_secs,
+ GsPluginRefreshMetadataFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GsPluginOpensuseDistroUpgrade *self = GS_PLUGIN_OPENSUSE_DISTRO_UPGRADE (plugin);
+ _refresh_cache_async (self, cache_age_secs, cancellable, callback, user_data);
+}
+
+static gboolean
+gs_plugin_opensuse_distro_upgrade_refresh_metadata_finish (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ return _refresh_cache_finish (GS_PLUGIN_OPENSUSE_DISTRO_UPGRADE (plugin),
+ result,
+ error);
+}
+
+static void
+gs_plugin_opensuse_distro_upgrade_init (GsPluginOpensuseDistroUpgrade *self)
+{
+ GsPlugin *plugin = GS_PLUGIN (self);
+
+ /* We don't need distribution upgrade banner for Tumbleweed. */
+ if (gs_plugin_check_distro_id (plugin, "opensuse-tumbleweed")) {
+ gs_plugin_set_enabled (plugin, FALSE);
+ g_debug ("Disabeling '%s' as this is not needed in Tumbleweed.", gs_plugin_get_name (plugin));
+ return;
+ }
+
+ /* Check if we are running openSUSE Leap. */
+ if (!gs_plugin_check_distro_id (plugin, "opensuse-leap")) {
+ gs_plugin_set_enabled (plugin, FALSE);
+ g_debug ("Disabling '%s' as it's only supported in openSUSE Leap", gs_plugin_get_name (plugin));
+ return;
+ }
+
+ self->distros = g_ptr_array_new_with_free_func ((GDestroyNotify) _distro_upgrade_item_destroy);
+
+ /* require the GnomeSoftware::CpeName metadata */
+ gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "os-release");
+}
+
+static void
+gs_plugin_opensuse_distro_upgrade_class_init (GsPluginOpensuseDistroUpgradeClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GsPluginClass *plugin_class = GS_PLUGIN_CLASS (klass);
+
+ object_class->dispose = gs_plugin_opensuse_distro_upgrade_dispose;
+ object_class->finalize = gs_plugin_opensuse_distro_upgrade_finalize;
+
+ plugin_class->setup_async = gs_plugin_opensuse_distro_upgrade_setup_async;
+ plugin_class->setup_finish = gs_plugin_opensuse_distro_upgrade_setup_finish;
+ plugin_class->refresh_metadata_async = gs_plugin_opensuse_distro_upgrade_refresh_metadata_async;
+ plugin_class->refresh_metadata_finish = gs_plugin_opensuse_distro_upgrade_refresh_metadata_finish;
+ plugin_class->list_distro_upgrades_async = gs_plugin_opensuse_distro_upgrade_list_distro_upgrades_async;
+ plugin_class->list_distro_upgrades_finish = gs_plugin_opensuse_distro_upgrade_list_distro_upgrades_finish;
+}
+
+GType
+gs_plugin_query_type (void)
+{
+ return GS_TYPE_PLUGIN_OPENSUSE_DISTRO_UPGRADE;
+}
diff --git a/plugins/opensuse-distro-upgrade/gs-plugin-opensuse-distro-upgrade.h b/plugins/opensuse-distro-upgrade/gs-plugin-opensuse-distro-upgrade.h
new file mode 100644
index 000000000..5b1763c05
--- /dev/null
+++ b/plugins/opensuse-distro-upgrade/gs-plugin-opensuse-distro-upgrade.h
@@ -0,0 +1,19 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2020 Jonathan Kang <jonathankang@gnome.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#pragma once
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GS_TYPE_PLUGIN_OPENSUSE_DISTRO_UPGRADE (gs_plugin_opensuse_distro_upgrade_get_type ())
+
+G_DECLARE_FINAL_TYPE (GsPluginOpensuseDistroUpgrade, gs_plugin_opensuse_distro_upgrade, GS, PLUGIN_OPENSUSE_DISTRO_UPGRADE, GsPlugin)
+
+G_END_DECLS
diff --git a/plugins/opensuse-distro-upgrade/meson.build b/plugins/opensuse-distro-upgrade/meson.build
new file mode 100644
index 000000000..bc09af9b4
--- /dev/null
+++ b/plugins/opensuse-distro-upgrade/meson.build
@@ -0,0 +1,14 @@
+cargs = ['-DG_LOG_DOMAIN="GsPluginOpensuseDistroUpgrade"']
+
+shared_module(
+ 'gs_plugin_opensuse-distro-upgrade',
+ sources : 'gs-plugin-opensuse-distro-upgrade.c',
+ include_directories : [
+ include_directories('../..'),
+ include_directories('../../lib')
+ ],
+ install : true,
+ install_dir : plugin_dir,
+ c_args : cargs,
+ dependencies : plugin_libs,
+)
--
2.37.3

View File

@ -1,511 +0,0 @@
Support building with appstream 0.16 and 1.0
Origin: https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/1810
https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/1830
---
lib/gs-app.c | 4 ++
lib/gs-appstream.c | 63 +++++++++++++++++++-----
lib/gs-utils.c | 8 +--
meson.build | 22 +--------
plugins/core/gs-plugin-appstream.c | 8 ---
plugins/fwupd/gs-fwupd-app.c | 8 +++
plugins/fwupd/gs-plugin-fwupd.c | 4 ++
src/gs-hardware-support-context-dialog.c | 6 +++
src/gs-repos-dialog.c | 4 ++
src/gs-screenshot-carousel.c | 4 +-
src/gs-screenshot-image.c | 41 +++++++++++----
src/gs-screenshot-image.h | 7 +++
subprojects/appstream.wrap | 2 +-
13 files changed, 122 insertions(+), 59 deletions(-)
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 048a061..e269405 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -609,7 +609,11 @@ gs_app_to_string_append (GsApp *app, GString *str)
AsScreenshot *ss = g_ptr_array_index (priv->screenshots, i);
g_autofree gchar *key = NULL;
tmp = as_screenshot_get_caption (ss);
+#if AS_CHECK_VERSION(1, 0, 0)
+ im = as_screenshot_get_image (ss, 0, 0, 1);
+#else
im = as_screenshot_get_image (ss, 0, 0);
+#endif
if (im == NULL)
continue;
key = g_strdup_printf ("screenshot-%02u", i);
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index deca176..4fd7f53 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -587,8 +587,6 @@ gs_appstream_refine_add_provides (GsApp *app, XbNode *component, GError **error)
kind = AS_PROVIDED_KIND_FIRMWARE_RUNTIME;
else if (g_strcmp0 (fw_type, "flashed") == 0)
kind = AS_PROVIDED_KIND_FIRMWARE_FLASHED;
- } else if (g_strcmp0 (element_name, "python2") == 0) {
- kind = AS_PROVIDED_KIND_PYTHON_2;
} else if (g_strcmp0 (element_name, "python3") == 0) {
kind = AS_PROVIDED_KIND_PYTHON;
} else if (g_strcmp0 (element_name, "dbus") == 0) {
@@ -1011,8 +1009,11 @@ gs_appstream_refine_app_relation (GsApp *app,
as_relation_set_item_kind (relation, AS_RELATION_ITEM_KIND_CONTROL);
as_relation_set_value_control_kind (relation, as_control_kind_from_string (xb_node_get_text (child)));
} else if (g_str_equal (item_kind, "display_length")) {
- AsDisplayLengthKind display_length_kind;
const gchar *compare;
+ const gchar *side;
+#if !AS_CHECK_VERSION(1, 0, 0)
+ AsDisplayLengthKind display_length_kind;
+#endif
/* https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-relations-display_length */
as_relation_set_item_kind (relation, AS_RELATION_ITEM_KIND_DISPLAY_LENGTH);
@@ -1020,15 +1021,21 @@ gs_appstream_refine_app_relation (GsApp *app,
compare = xb_node_get_attr (child, "compare");
as_relation_set_compare (relation, (compare != NULL) ? as_relation_compare_from_string (compare) : AS_RELATION_COMPARE_GE);
+#if AS_CHECK_VERSION(1, 0, 0)
+ side = xb_node_get_attr (child, "side");
+ as_relation_set_display_side_kind (relation, (side != NULL) ? as_display_side_kind_from_string (side) : AS_DISPLAY_SIDE_KIND_SHORTEST);
+ as_relation_set_value_px (relation, xb_node_get_text_as_uint (child));
+#else
display_length_kind = as_display_length_kind_from_string (xb_node_get_text (child));
if (display_length_kind != AS_DISPLAY_LENGTH_KIND_UNKNOWN) {
/* Ignore the `side` attribute */
as_relation_set_value_display_length_kind (relation, display_length_kind);
} else {
- const gchar *side = xb_node_get_attr (child, "side");
+ side = xb_node_get_attr (child, "side");
as_relation_set_display_side_kind (relation, (side != NULL) ? as_display_side_kind_from_string (side) : AS_DISPLAY_SIDE_KIND_SHORTEST);
as_relation_set_value_px (relation, xb_node_get_text_as_uint (child));
}
+#endif
} else {
g_debug ("Relation type %s not currently supported for %s; ignoring",
item_kind, gs_app_get_id (app));
@@ -1472,7 +1479,7 @@ gs_appstream_refine_app (GsPlugin *plugin,
}
typedef struct {
- AsSearchTokenMatch match_value;
+ guint16 match_value;
XbQuery *query;
} GsAppstreamSearchHelper;
@@ -1522,7 +1529,7 @@ gs_appstream_silo_search_component (GPtrArray *array, XbNode *component, const g
}
typedef struct {
- AsSearchTokenMatch match_value;
+ guint16 match_value;
const gchar *xpath;
} Query;
@@ -1539,6 +1546,11 @@ gs_appstream_do_search (GsPlugin *plugin,
g_autoptr(GPtrArray) array = g_ptr_array_new_with_free_func ((GDestroyNotify) gs_appstream_search_helper_free);
g_autoptr(GPtrArray) components = NULL;
g_autoptr(GTimer) timer = g_timer_new ();
+#if AS_CHECK_VERSION(1, 0, 0)
+ const guint16 component_id_weight = as_utils_get_tag_search_weight ("id");
+#else
+ const guint16 component_id_weight = AS_SEARCH_TOKEN_MATCH_ID;
+#endif
g_return_val_if_fail (GS_IS_PLUGIN (plugin), FALSE);
g_return_val_if_fail (XB_IS_SILO (silo), FALSE);
@@ -1585,7 +1597,7 @@ gs_appstream_do_search (GsPlugin *plugin,
* Drop the ID token from it as its the highest
* numeric value but isnt visible to the user in the
* UI, which leads to confusing results ordering. */
- gs_app_set_match_value (app, match_value & (~AS_SEARCH_TOKEN_MATCH_ID));
+ gs_app_set_match_value (app, match_value & (~component_id_weight));
gs_app_list_add (list, app);
if (gs_app_get_kind (app) == AS_COMPONENT_KIND_ADDON) {
@@ -1624,18 +1636,32 @@ gs_appstream_search (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
+#if AS_CHECK_VERSION(1, 0, 0)
+ guint16 pkgname_weight = as_utils_get_tag_search_weight ("pkgname");
+ guint16 name_weight = as_utils_get_tag_search_weight ("name");
+ guint16 id_weight = as_utils_get_tag_search_weight ("id");
const Query queries[] = {
- #ifdef HAVE_AS_SEARCH_TOKEN_MATCH_MEDIATYPE
- { AS_SEARCH_TOKEN_MATCH_MEDIATYPE, "mimetypes/mimetype[text()~=stem(?)]" },
- #else
- { AS_SEARCH_TOKEN_MATCH_MIMETYPE, "mimetypes/mimetype[text()~=stem(?)]" },
- #endif
+ { as_utils_get_tag_search_weight ("mediatype"), "provides/mediatype[text()~=stem(?)]" },
/* Search once with a tokenize-and-casefold operator (`~=`) to support casefolded
* full-text search, then again using substring matching (`contains()`), to
* support prefix matching. Only do the prefix matches on a few fields, and at a
* lower priority, otherwise things will get confusing.
- *
+ *
* See https://gitlab.gnome.org/GNOME/gnome-software/-/issues/2277 */
+ { pkgname_weight, "pkgname[text()~=stem(?)]" },
+ { pkgname_weight / 2, "pkgname[contains(text(),stem(?))]" },
+ { as_utils_get_tag_search_weight ("summary"), "summary[text()~=stem(?)]" },
+ { name_weight, "name[text()~=stem(?)]" },
+ { name_weight / 2, "name[contains(text(),stem(?))]" },
+ { as_utils_get_tag_search_weight ("keyword"), "keywords/keyword[text()~=stem(?)]" },
+ { id_weight, "id[text()~=stem(?)]" },
+ { id_weight, "launchable[text()~=stem(?)]" },
+ { as_utils_get_tag_search_weight ("origin"), "../components[@origin~=stem(?)]" },
+ { 0, NULL }
+ };
+#else
+ const Query queries[] = {
+ { AS_SEARCH_TOKEN_MATCH_MEDIATYPE, "mimetypes/mimetype[text()~=stem(?)]" },
{ AS_SEARCH_TOKEN_MATCH_PKGNAME, "pkgname[text()~=stem(?)]" },
{ AS_SEARCH_TOKEN_MATCH_PKGNAME / 2, "pkgname[contains(text(),stem(?))]" },
{ AS_SEARCH_TOKEN_MATCH_SUMMARY, "summary[text()~=stem(?)]" },
@@ -1647,6 +1673,7 @@ gs_appstream_search (GsPlugin *plugin,
{ AS_SEARCH_TOKEN_MATCH_ORIGIN, "../components[@origin~=stem(?)]" },
{ AS_SEARCH_TOKEN_MATCH_NONE, NULL }
};
+#endif
return gs_appstream_do_search (plugin, silo, values, queries, list, cancellable, error);
}
@@ -1659,11 +1686,21 @@ gs_appstream_search_developer_apps (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
+#if AS_CHECK_VERSION(1, 0, 0)
+ const Query queries[] = {
+ { as_utils_get_tag_search_weight ("pkgname"), "developer/name[text()~=stem(?)]" },
+ { as_utils_get_tag_search_weight ("summary"), "project_group[text()~=stem(?)]" },
+ /* for legacy support */
+ { as_utils_get_tag_search_weight ("pkgname"), "developer_name[text()~=stem(?)]" },
+ { 0, NULL }
+ };
+#else
const Query queries[] = {
{ AS_SEARCH_TOKEN_MATCH_PKGNAME, "developer_name[text()~=stem(?)]" },
{ AS_SEARCH_TOKEN_MATCH_SUMMARY, "project_group[text()~=stem(?)]" },
{ AS_SEARCH_TOKEN_MATCH_NONE, NULL }
};
+#endif
return gs_appstream_do_search (plugin, silo, values, queries, list, cancellable, error);
}
diff --git a/lib/gs-utils.c b/lib/gs-utils.c
index cf90730..19e6ebd 100644
--- a/lib/gs-utils.c
+++ b/lib/gs-utils.c
@@ -1694,9 +1694,9 @@ gs_utils_gstring_replace (GString *str,
const gchar *find,
const gchar *replace)
{
- #ifdef HAVE_AS_GSTRING_REPLACE_WITH_FOUR_ARGS
+#if AS_CHECK_VERSION(1, 0, 0)
as_gstring_replace (str, find, replace, 0);
- #else
- as_gstring_replace (str, find, replace);
- #endif
+#else
+ as_gstring_replace2 (str, find, replace, 0);
+#endif
}
diff --git a/meson.build b/meson.build
index da9e7ac..2cab9d6 100644
--- a/meson.build
+++ b/meson.build
@@ -113,7 +113,7 @@ add_project_arguments('-D_GNU_SOURCE', language : 'c')
conf.set('HAVE_LINUX_UNISTD_H', cc.has_header('linux/unistd.h'))
appstream = dependency('appstream',
- version : '>= 0.14.0',
+ version : '>= 0.16.4',
fallback : ['appstream', 'appstream_dep'],
default_options : [
'docs=false',
@@ -121,26 +121,6 @@ appstream = dependency('appstream',
'install-docs=false'
]
)
-if appstream.type_name() == 'internal'
-else
- if meson.get_compiler('c').has_header_symbol('appstream.h', 'AS_SEARCH_TOKEN_MATCH_MEDIATYPE', dependencies: appstream)
- conf.set('HAVE_AS_SEARCH_TOKEN_MATCH_MEDIATYPE', '1')
- endif
- if meson.get_compiler('c').has_header_symbol('appstream.h', 'AS_FORMAT_STYLE_CATALOG', dependencies: appstream)
- conf.set('HAVE_AS_FORMAT_STYLE_CATALOG', '1')
- endif
- if meson.get_compiler('c').has_function('as_metadata_components_to_catalog', prefix: '#include <appstream.h>', dependencies: appstream)
- conf.set('HAVE_AS_METADATA_COMPONENTS_TO_CATALOG', '1')
- endif
- if meson.get_compiler('c').links('''#include <appstream.h>
- int main (void)
- {
- as_gstring_replace (NULL, "a", "b", 0);
- return 0;
- }''', name: 'as_gstring_replace() has four arguments', dependencies: appstream)
- conf.set('HAVE_AS_GSTRING_REPLACE_WITH_FOUR_ARGS', '1')
- endif
-endif
gdk_pixbuf = dependency('gdk-pixbuf-2.0', version : '>= 2.32.0')
libxmlb = dependency('xmlb', version : '>= 0.1.7', fallback : ['libxmlb', 'libxmlb_dep'])
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index cf9f302..ef3226a 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -414,11 +414,7 @@ gs_plugin_appstream_load_dep11_cb (XbBuilderSource *self,
if (bytes == NULL)
return NULL;
- #ifdef HAVE_AS_FORMAT_STYLE_CATALOG
as_metadata_set_format_style (mdata, AS_FORMAT_STYLE_CATALOG);
- #else
- as_metadata_set_format_style (mdata, AS_FORMAT_STYLE_COLLECTION);
- #endif
as_metadata_parse_bytes (mdata,
bytes,
AS_FORMAT_KIND_YAML,
@@ -428,11 +424,7 @@ gs_plugin_appstream_load_dep11_cb (XbBuilderSource *self,
return NULL;
}
- #ifdef HAVE_AS_METADATA_COMPONENTS_TO_CATALOG
xml = as_metadata_components_to_catalog (mdata, AS_FORMAT_KIND_XML, &tmp_error);
- #else
- xml = as_metadata_components_to_collection (mdata, AS_FORMAT_KIND_XML, &tmp_error);
- #endif
if (xml == NULL) {
// This API currently returns NULL if there is nothing to serialize, so we
// have to test if this is an error or not.
diff --git a/plugins/fwupd/gs-fwupd-app.c b/plugins/fwupd/gs-fwupd-app.c
index 6dcda6e..5d3254d 100644
--- a/plugins/fwupd/gs-fwupd-app.c
+++ b/plugins/fwupd/gs-fwupd-app.c
@@ -164,7 +164,11 @@ gs_fwupd_app_set_from_device (GsApp *app,
gs_app_set_install_date (app, fwupd_device_get_created (dev));
if (fwupd_device_get_description (dev) != NULL) {
g_autofree gchar *tmp = NULL;
+#if AS_CHECK_VERSION(1, 0, 0)
+ tmp = as_markup_convert (fwupd_device_get_description (dev), AS_MARKUP_KIND_TEXT, NULL);
+#else
tmp = as_markup_convert_simple (fwupd_device_get_description (dev), NULL);
+#endif
if (tmp != NULL)
gs_app_set_description (app, GS_APP_QUALITY_NORMAL, tmp);
}
@@ -402,7 +406,11 @@ gs_fwupd_app_set_from_release (GsApp *app, FwupdRelease *rel)
}
if (fwupd_release_get_description (rel) != NULL) {
g_autofree gchar *tmp = NULL;
+#if AS_CHECK_VERSION(1, 0, 0)
+ tmp = as_markup_convert (fwupd_release_get_description (rel), AS_MARKUP_KIND_TEXT, NULL);
+#else
tmp = as_markup_convert_simple (fwupd_release_get_description (rel), NULL);
+#endif
if (tmp != NULL)
gs_app_set_update_details_text (app, tmp);
}
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index e931b2b..0747d6e 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -726,7 +726,11 @@ gs_plugin_add_updates (GsPlugin *plugin,
g_autofree gchar *desc = NULL;
if (fwupd_release_get_description (rel) == NULL)
continue;
+#if AS_CHECK_VERSION(1, 0, 0)
+ desc = as_markup_convert (fwupd_release_get_description (rel), AS_MARKUP_KIND_TEXT, NULL);
+#else
desc = as_markup_convert_simple (fwupd_release_get_description (rel), NULL);
+#endif
if (desc == NULL)
continue;
g_string_append_printf (update_desc,
diff --git a/src/gs-hardware-support-context-dialog.c b/src/gs-hardware-support-context-dialog.c
index 0e48c8c..1465340 100644
--- a/src/gs-hardware-support-context-dialog.c
+++ b/src/gs-hardware-support-context-dialog.c
@@ -461,6 +461,7 @@ gs_hardware_support_context_dialog_get_display_support (GdkMonitor *monitor,
AsRelationCompare comparator = as_relation_get_compare (relation);
Range current_display_comparand, relation_comparand;
+#if !AS_CHECK_VERSION(1, 0, 0)
/* From https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-requires-recommends-display_length */
Range display_lengths[] = {
[AS_DISPLAY_LENGTH_KIND_XSMALL] = { 0, 360 },
@@ -469,6 +470,7 @@ gs_hardware_support_context_dialog_get_display_support (GdkMonitor *monitor,
[AS_DISPLAY_LENGTH_KIND_LARGE] = { 1024, 3840 },
[AS_DISPLAY_LENGTH_KIND_XLARGE] = { 3840, G_MAXUINT },
};
+#endif
any_display_relations_set = TRUE;
@@ -485,11 +487,14 @@ gs_hardware_support_context_dialog_get_display_support (GdkMonitor *monitor,
case AS_DISPLAY_SIDE_KIND_LAST:
default:
current_display_comparand.min = current_display_comparand.max = MAX (current_screen_size.width, current_screen_size.height);
+#if !AS_CHECK_VERSION(1, 0, 0)
relation_comparand.min = display_lengths[as_relation_get_value_display_length_kind (relation)].min;
relation_comparand.max = display_lengths[as_relation_get_value_display_length_kind (relation)].max;
+#endif
break;
}
+#if !AS_CHECK_VERSION(1, 0, 0)
if (evaluate_display_comparison (display_lengths[AS_DISPLAY_LENGTH_KIND_SMALL], comparator, relation_comparand)) {
*mobile_relation_kind_out = max_relation_kind (*mobile_relation_kind_out, as_relation_get_kind (relation));
*mobile_match_out = TRUE;
@@ -499,6 +504,7 @@ gs_hardware_support_context_dialog_get_display_support (GdkMonitor *monitor,
*desktop_relation_kind_out = max_relation_kind (*desktop_relation_kind_out, as_relation_get_kind (relation));
*desktop_match_out = TRUE;
}
+#endif
if (evaluate_display_comparison (current_display_comparand, comparator, relation_comparand)) {
*current_relation_kind_out = max_relation_kind (*current_relation_kind_out, as_relation_get_kind (relation));
diff --git a/src/gs-repos-dialog.c b/src/gs-repos-dialog.c
index c41c494..7dac041 100644
--- a/src/gs-repos-dialog.c
+++ b/src/gs-repos-dialog.c
@@ -154,7 +154,11 @@ enable_repo (GsReposDialog *dialog,
g_autoptr(GError) error = NULL;
/* convert from AppStream markup */
+#if AS_CHECK_VERSION(1, 0, 0)
+ message = as_markup_convert (gs_app_get_agreement (repo), AS_MARKUP_KIND_TEXT, &error);
+#else
message = as_markup_convert_simple (gs_app_get_agreement (repo), &error);
+#endif
if (message == NULL) {
/* failed, so just try and show the original markup */
message = g_strdup (gs_app_get_agreement (repo));
diff --git a/src/gs-screenshot-carousel.c b/src/gs-screenshot-carousel.c
index 04bbf86..d269af6 100644
--- a/src/gs-screenshot-carousel.c
+++ b/src/gs-screenshot-carousel.c
@@ -141,8 +141,8 @@ gs_screenshot_carousel_load_screenshots (GsScreenshotCarousel *self, GsApp *app,
gtk_widget_set_can_focus (gtk_widget_get_first_child (ssimg), FALSE);
gs_screenshot_image_set_screenshot (GS_SCREENSHOT_IMAGE (ssimg), ss);
gs_screenshot_image_set_size (GS_SCREENSHOT_IMAGE (ssimg),
- AS_IMAGE_NORMAL_WIDTH,
- AS_IMAGE_NORMAL_HEIGHT);
+ GS_IMAGE_NORMAL_WIDTH,
+ GS_IMAGE_NORMAL_HEIGHT);
gtk_widget_add_css_class (ssimg, "screenshot-image-main");
gs_screenshot_image_load_async (GS_SCREENSHOT_IMAGE (ssimg), cancellable);
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index c313a25..b24083b 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -284,13 +284,13 @@ gs_screenshot_image_save_downloaded_img (GsScreenshotImage *ssimg,
if (images->len > 1)
return TRUE;
- if (width == AS_IMAGE_THUMBNAIL_WIDTH &&
- height == AS_IMAGE_THUMBNAIL_HEIGHT) {
- width = AS_IMAGE_NORMAL_WIDTH;
- height = AS_IMAGE_NORMAL_HEIGHT;
+ if (width == GS_IMAGE_THUMBNAIL_WIDTH &&
+ height == GS_IMAGE_THUMBNAIL_HEIGHT) {
+ width = GS_IMAGE_NORMAL_WIDTH;
+ height = GS_IMAGE_NORMAL_HEIGHT;
} else {
- width = AS_IMAGE_THUMBNAIL_WIDTH;
- height = AS_IMAGE_THUMBNAIL_HEIGHT;
+ width = GS_IMAGE_THUMBNAIL_WIDTH;
+ height = GS_IMAGE_THUMBNAIL_HEIGHT;
}
width *= ssimg->scale;
@@ -582,16 +582,30 @@ gs_screenshot_image_get_url (GsScreenshotImage *ssimg)
} else if (as_screenshot_get_media_kind (ssimg->screenshot) == AS_SCREENSHOT_MEDIA_KIND_IMAGE) {
AsImage *im;
+#if AS_CHECK_VERSION(1, 0, 0)
+ im = as_screenshot_get_image (ssimg->screenshot,
+ ssimg->width,
+ ssimg->height,
+ ssimg->scale);
+#else
im = as_screenshot_get_image (ssimg->screenshot,
ssimg->width * ssimg->scale,
ssimg->height * ssimg->scale);
+#endif
/* if we've failed to load a HiDPI image, fallback to LoDPI */
if (im == NULL && ssimg->scale > 1) {
ssimg->scale = 1;
+#if AS_CHECK_VERSION(1, 0, 0)
+ im = as_screenshot_get_image (ssimg->screenshot,
+ ssimg->width,
+ ssimg->height,
+ 1);
+#else
im = as_screenshot_get_image (ssimg->screenshot,
ssimg->width,
ssimg->height);
+#endif
}
if (im)
@@ -698,15 +712,22 @@ gs_screenshot_image_load_async (GsScreenshotImage *ssimg,
* smaller version of it straight away */
if (!ssimg->showing_image &&
as_screenshot_get_media_kind (ssimg->screenshot) == AS_SCREENSHOT_MEDIA_KIND_IMAGE &&
- ssimg->width > AS_IMAGE_THUMBNAIL_WIDTH &&
- ssimg->height > AS_IMAGE_THUMBNAIL_HEIGHT) {
+ ssimg->width > GS_IMAGE_THUMBNAIL_WIDTH &&
+ ssimg->height > GS_IMAGE_THUMBNAIL_HEIGHT) {
const gchar *url_thumb;
g_autofree gchar *basename_thumb = NULL;
g_autofree gchar *cache_kind_thumb = NULL;
AsImage *im;
+#if AS_CHECK_VERSION(1, 0, 0)
im = as_screenshot_get_image (ssimg->screenshot,
- AS_IMAGE_THUMBNAIL_WIDTH * ssimg->scale,
- AS_IMAGE_THUMBNAIL_HEIGHT * ssimg->scale);
+ GS_IMAGE_THUMBNAIL_WIDTH,
+ GS_IMAGE_THUMBNAIL_HEIGHT,
+ ssimg->scale);
+#else
+ im = as_screenshot_get_image (ssimg->screenshot,
+ GS_IMAGE_THUMBNAIL_WIDTH * ssimg->scale,
+ GS_IMAGE_THUMBNAIL_HEIGHT * ssimg->scale);
+#endif
url_thumb = as_image_get_url (im);
basename_thumb = gs_screenshot_get_cachefn_for_url (url_thumb);
cache_kind_thumb = g_build_filename ("screenshots", "112x63", NULL);
diff --git a/src/gs-screenshot-image.h b/src/gs-screenshot-image.h
index 1f6cf81..6e45f5d 100644
--- a/src/gs-screenshot-image.h
+++ b/src/gs-screenshot-image.h
@@ -21,6 +21,13 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GsScreenshotImage, gs_screenshot_image, GS, SCREENSHOT_IMAGE, GtkWidget)
+#define GS_IMAGE_LARGE_HEIGHT 423
+#define GS_IMAGE_LARGE_WIDTH 752
+#define GS_IMAGE_NORMAL_HEIGHT 351
+#define GS_IMAGE_NORMAL_WIDTH 624
+#define GS_IMAGE_THUMBNAIL_HEIGHT 63
+#define GS_IMAGE_THUMBNAIL_WIDTH 112
+
GtkWidget *gs_screenshot_image_new (SoupSession *session);
AsScreenshot *gs_screenshot_image_get_screenshot (GsScreenshotImage *ssimg);
diff --git a/subprojects/appstream.wrap b/subprojects/appstream.wrap
index 6f0beb0..b9a9c7d 100644
--- a/subprojects/appstream.wrap
+++ b/subprojects/appstream.wrap
@@ -1,5 +1,5 @@
[wrap-git]
directory = appstream
url = https://github.com/ximion/appstream.git
-revision = v0.14.1
+revision = v0.16.4
depth = 1
--
2.43.0

View File

@ -1,3 +1,54 @@
-------------------------------------------------------------------
Fri Mar 15 20:58:09 UTC 2024 - Dominique Leuenberger <dimstar@opensuse.org>
- Update to version 46.0:
+ Improvements for screen readers.
+ Stop loading updates in a loop on Debian.
+ Updated translations.
-------------------------------------------------------------------
Fri Mar 1 14:09:54 UTC 2024 - Dominique Leuenberger <dimstar@opensuse.org>
- Update to version 46.rc:
+ Various UI text improvements.
+ Fix launch of some apps.
+ Fix invalid app state after it's uninstalled.
+ Fix read of app description text.
+ Do not ask to reboot after failed firmware update.
+ Updated translations.
-------------------------------------------------------------------
Mon Feb 12 15:10:04 UTC 2024 - Dominique Leuenberger <dimstar@opensuse.org>
- Update to version 46.beta:
+ Show feedback for all conditions that pause automatic updates.
+ Various UI improvements and move to new libadwaita widgets.
+ Fix loading OS AppStream catalog data if it is available as
YAML.
+ Add openSUSE Leap distro upgrade plugin.
- Pass -D opensuse-distro-upgrade=true to meson: we are openSUSE,
so we want the plugin.
- Drop gnome-software-plugin-opensuse-distro-upgrade.patch: fixed
upstream.
-------------------------------------------------------------------
Tue Jan 16 13:19:59 UTC 2024 - Dominique Leuenberger <dimstar@opensuse.org>
- Update to version 46.alpha:
+ Recognize links in package update descriptions.
+ Expose package names discreetly in the UI.
+ Increase speed of load of the category pages.
+ Improve search match with multiple words.
+ Recognize verified apps by Flathub.
+ Correct message when installing firmware updates.
+ Improve application safety checks.
+ Improve update preferences dialog.
+ Fix deadlock when cancelling app update.
+ Support user installation of local flatpak files.
* Fix apps appearing unsorted and without tiles in category page.
- Convert to source service for easier updating.
- Drop gnome-software-support-appstream-1_0.patch: fixed upstream.
-------------------------------------------------------------------
Thu Dec 28 02:27:35 UTC 2023 - Yifan Jiang <yfjiang@suse.com>
@ -13,7 +64,7 @@ Fri Dec 15 09:33:16 UTC 2023 - Christophe Marin <christophe@krop.fr>
Fri Dec 1 10:46:39 UTC 2023 - Dominique Leuenberger <dimstar@opensuse.org>
- Update to version 45.2:
+ Updated translations.
+ Updated translations.
-------------------------------------------------------------------
Fri Oct 27 05:40:09 UTC 2023 - Jonathan Kang <jonathankang@gnome.org>

4
gnome-software.obsinfo Normal file
View File

@ -0,0 +1,4 @@
name: gnome-software
version: 46.0
mtime: 1710515704
commit: 9dec134914268d135a6f5251ddd624fef2de3c10

View File

@ -20,23 +20,19 @@
%bcond_with profiling
Name: gnome-software
Version: 45.2
Version: 46.0
Release: 0
Summary: GNOME Software Store
License: GPL-2.0-or-later
Group: System/GUI/GNOME
URL: https://wiki.gnome.org/Apps/Software
Source0: https://download.gnome.org/sources/gnome-software/45/%{name}-%{version}.tar.xz
Source0: %{name}-%{version}.tar.zst
%if 0%{?sle_version}
# PATCH-FIX-OPENSUSE gnome-software-launch-gpk-update-viewer-for-updates.patch bsc#1077332 boo#1090042 sckang@suse.com -- Don't launch gnome-software when clicking the updates notification. Launch gpk-update-viewer instead.
Patch0: gnome-software-launch-gpk-update-viewer-for-updates.patch
# PATCH-FIX-OPENSUSE gnome-software-disable-offline-update.patch bsc#944832 sckang@suse.com -- Disable offline update in SLE and openSUSE Leap
Patch1: gnome-software-disable-offline-update.patch
%endif
# PATCH-FIX-UPSTREAM gnome-software-plugin-opensuse-distro-upgrade.patch glgo#GNOME/gnome-software!1557 sckang@suse.com -- plugins: add opensuse-distro-upgrade plugin
Patch2: gnome-software-plugin-opensuse-distro-upgrade.patch
# PATCH-FIX-UPSTREAM gnome-software-support-appstream-1_0.patch boo#1217047 -- Apply upstream changes to support appstream 1.0
Patch3: gnome-software-support-appstream-1_0.patch
BuildRequires: gtk-doc
BuildRequires: meson >= 0.58.0
BuildRequires: pkgconfig
@ -57,7 +53,7 @@ BuildRequires: pkgconfig(libadwaita-1)
BuildRequires: pkgconfig(libhandy-1) >= 1.2.0
BuildRequires: pkgconfig(libsecret-1)
BuildRequires: pkgconfig(libsoup-3.0)
BuildRequires: pkgconfig(malcontent-0) >= 0.3.0
BuildRequires: pkgconfig(malcontent-0) >= 0.5.0
BuildRequires: pkgconfig(ostree-1)
BuildRequires: pkgconfig(packagekit-glib2) >= 1.1.0
BuildRequires: pkgconfig(polkit-gobject-1)
@ -110,6 +106,7 @@ the GNOME software store.
-D malcontent=true \
-D soup2=false \
-D sysprof=%{?with_profiling:enabled}%{!?with_profiling:disabled} \
-D opensuse-distro-upgrade=true \
%{nil}
%meson_build
@ -142,6 +139,7 @@ FOE
%{_datadir}/applications/gnome-software-local-file-fwupd.desktop
%{_datadir}/applications/gnome-software-local-file-packagekit.desktop
%{_datadir}/applications/org.gnome.Software.desktop
%{_datadir}/bash-completion/completions/gnome-software
%{_datadir}/dbus-1/services/org.gnome.Software.service
%{_datadir}/dbus-1/services/org.freedesktop.PackageKit.service
%{_datadir}/glib-2.0/schemas/org.gnome.software.gschema.xml