[gnome-software: 7/8] packagekit: Merge packagekit-upgrade plugin into packagekit
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 7/8] packagekit: Merge packagekit-upgrade plugin into packagekit
- Date: Thu, 10 Jun 2021 12:18:50 +0000 (UTC)
commit 74746085724f55a3869c7dd6dc83228fbe002a2f
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu May 20 18:04:19 2021 +0100
packagekit: Merge packagekit-upgrade plugin into packagekit
Signed-off-by: Philip Withnall <pwithnall endlessos org>
contrib/gnome-software.spec.in | 1 -
plugins/packagekit/gs-plugin-packagekit-upgrade.c | 90 -----------------------
plugins/packagekit/gs-plugin-packagekit.c | 57 ++++++++++++++
plugins/packagekit/meson.build | 17 -----
plugins/rpm-ostree/gs-plugin-rpm-ostree.c | 1 -
5 files changed, 57 insertions(+), 109 deletions(-)
---
diff --git a/contrib/gnome-software.spec.in b/contrib/gnome-software.spec.in
index 49beee6ea..c289d5948 100644
--- a/contrib/gnome-software.spec.in
+++ b/contrib/gnome-software.spec.in
@@ -165,7 +165,6 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop
%{gs_plugin_dir}/libgs_plugin_os-release.so
%{gs_plugin_dir}/libgs_plugin_packagekit-refine-repos.so
%{gs_plugin_dir}/libgs_plugin_packagekit-refresh.so
-%{gs_plugin_dir}/libgs_plugin_packagekit-upgrade.so
%{gs_plugin_dir}/libgs_plugin_packagekit.so
%{gs_plugin_dir}/libgs_plugin_provenance-license.so
%{gs_plugin_dir}/libgs_plugin_provenance.so
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index d86b585c0..8988db2f9 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -56,6 +56,9 @@ struct GsPluginData {
GSettings *settings_https;
GSettings *settings_ftp;
GSettings *settings_socks;
+
+ PkTask *task_upgrade;
+ GMutex task_mutex_upgrade;
};
static void gs_plugin_packagekit_updates_changed_cb (PkControl *control, GsPlugin *plugin);
@@ -126,6 +129,14 @@ gs_plugin_initialize (GsPlugin *plugin)
g_signal_connect (priv->settings_socks, "changed",
G_CALLBACK (gs_plugin_packagekit_proxy_changed_cb), plugin);
+ /* upgrade */
+ g_mutex_init (&priv->task_mutex_upgrade);
+ priv->task_upgrade = pk_task_new ();
+ pk_task_set_only_download (priv->task_upgrade, TRUE);
+ pk_client_set_background (PK_CLIENT (priv->task_upgrade), TRUE);
+ pk_client_set_cache_age (PK_CLIENT (priv->task_upgrade), 60 * 60 * 24);
+ pk_client_set_interactive (PK_CLIENT (priv->task_upgrade), gs_plugin_has_flags (plugin,
GS_PLUGIN_FLAGS_INTERACTIVE));
+
/* need pkgname and ID */
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "appstream");
}
@@ -163,6 +174,10 @@ gs_plugin_destroy (GsPlugin *plugin)
g_object_unref (priv->settings_https);
g_object_unref (priv->settings_ftp);
g_object_unref (priv->settings_socks);
+
+ /* upgrade */
+ g_mutex_clear (&priv->task_mutex_upgrade);
+ g_object_unref (priv->task_upgrade);
}
static gboolean
@@ -889,6 +904,8 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
gs_app_set_management_plugin (app, "packagekit");
gs_plugin_packagekit_set_packaging_format (plugin, app);
return;
+ } else if (gs_app_get_kind (app) == AS_COMPONENT_KIND_OPERATING_SYSTEM) {
+ gs_app_set_management_plugin (app, "packagekit");
}
}
@@ -2581,3 +2598,43 @@ gs_plugin_packagekit_proxy_changed_cb (GSettings *settings,
return;
reload_proxy_settings (plugin, NULL);
}
+
+gboolean
+gs_plugin_app_upgrade_download (GsPlugin *plugin,
+ GsApp *app,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GsPluginData *priv = gs_plugin_get_data (plugin);
+ g_autoptr(GsPackagekitHelper) helper = gs_packagekit_helper_new (plugin);
+ g_autoptr(PkResults) results = NULL;
+
+ /* only process this app if was created by this plugin */
+ if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
+ return TRUE;
+
+ /* check is distro-upgrade */
+ if (gs_app_get_kind (app) != AS_COMPONENT_KIND_OPERATING_SYSTEM)
+ return TRUE;
+
+ /* ask PK to download enough packages to upgrade the system */
+ gs_app_set_state (app, GS_APP_STATE_INSTALLING);
+ gs_packagekit_helper_set_progress_app (helper, app);
+ g_mutex_lock (&priv->task_mutex_upgrade);
+ pk_client_set_interactive (PK_CLIENT (priv->task_upgrade), gs_plugin_has_flags (plugin,
GS_PLUGIN_FLAGS_INTERACTIVE));
+ results = pk_task_upgrade_system_sync (priv->task_upgrade,
+ gs_app_get_version (app),
+ PK_UPGRADE_KIND_ENUM_COMPLETE,
+ cancellable,
+ gs_packagekit_helper_cb, helper,
+ error);
+ g_mutex_unlock (&priv->task_mutex_upgrade);
+ if (!gs_plugin_packagekit_results_valid (results, error)) {
+ gs_app_set_state_recover (app);
+ return FALSE;
+ }
+
+ /* state is known */
+ gs_app_set_state (app, GS_APP_STATE_UPDATABLE);
+ return TRUE;
+}
diff --git a/plugins/packagekit/meson.build b/plugins/packagekit/meson.build
index 9beac3afc..a7cfcd7d4 100644
--- a/plugins/packagekit/meson.build
+++ b/plugins/packagekit/meson.build
@@ -78,23 +78,6 @@ shared_module(
dependencies : [ plugin_libs, packagekit ],
)
-shared_module(
- 'gs_plugin_packagekit-upgrade',
- sources : [
- 'gs-plugin-packagekit-upgrade.c',
- 'gs-packagekit-helper.c',
- 'packagekit-common.c',
- ],
- include_directories : [
- include_directories('../..'),
- include_directories('../../lib'),
- ],
- install : true,
- install_dir: plugin_dir,
- c_args : cargs,
- dependencies : [ plugin_libs, packagekit ],
-)
-
if get_option('tests')
cargs += ['-DTESTDATADIR="' + join_paths(meson.current_source_dir(), 'tests') + '"']
e = executable(
diff --git a/plugins/rpm-ostree/gs-plugin-rpm-ostree.c b/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
index 5d9265dad..6b1a13519 100644
--- a/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
+++ b/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
@@ -70,7 +70,6 @@ gs_plugin_initialize (GsPlugin *plugin)
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_CONFLICTS, "packagekit");
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_CONFLICTS, "packagekit-refine-repos");
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_CONFLICTS, "packagekit-refresh");
- gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_CONFLICTS, "packagekit-upgrade");
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_CONFLICTS, "systemd-updates");
/* need pkgname */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]