[gnome-software/wip/kalev/source_selection_drop_down: 2/2] Guess the packaging format and show it in the source selection drop down
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/kalev/source_selection_drop_down: 2/2] Guess the packaging format and show it in the source selection drop down
- Date: Wed, 26 Sep 2018 20:59:51 +0000 (UTC)
commit 2a715b088f360a55e5ed25c0b871fe178f9a2041
Author: Kalev Lember <klember redhat com>
Date: Wed Sep 26 22:15:02 2018 +0200
Guess the packaging format and show it in the source selection drop down
Add heuristics to the packagekit plugin to guess the packaging format
(RPM/deb) based on the distro. This is used in the newly added source
selection drop down on the details page.
plugins/packagekit/gs-plugin-packagekit-history.c | 3 +++
plugins/packagekit/gs-plugin-packagekit-local.c | 1 +
plugins/packagekit/gs-plugin-packagekit-offline.c | 1 +
plugins/packagekit/gs-plugin-packagekit-refine.c | 1 +
plugins/packagekit/gs-plugin-packagekit-url-to-app.c | 1 +
plugins/packagekit/gs-plugin-packagekit.c | 1 +
plugins/packagekit/packagekit-common.c | 14 ++++++++++++++
plugins/packagekit/packagekit-common.h | 2 ++
src/gs-origin-popover-row.c | 15 +++++++++++----
9 files changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit-history.c
b/plugins/packagekit/gs-plugin-packagekit-history.c
index 2c5fbdf0..dd7f5334 100644
--- a/plugins/packagekit/gs-plugin-packagekit-history.c
+++ b/plugins/packagekit/gs-plugin-packagekit-history.c
@@ -26,6 +26,8 @@
#include <gnome-software.h>
+#include "packagekit-common.h"
+
#define GS_PLUGIN_PACKAGEKIT_HISTORY_TIMEOUT 5000 /* ms */
/*
@@ -207,6 +209,7 @@ gs_plugin_packagekit_refine (GsPlugin *plugin,
if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED) {
g_autoptr(GsApp) app_dummy = NULL;
app_dummy = gs_app_new (gs_app_get_id (app));
+ gs_plugin_packagekit_set_packaging_format (plugin, app);
gs_app_set_metadata (app_dummy, "GnomeSoftware::Creator",
gs_plugin_get_name (plugin));
gs_app_set_install_date (app_dummy, GS_APP_INSTALL_DATE_UNKNOWN);
diff --git a/plugins/packagekit/gs-plugin-packagekit-local.c b/plugins/packagekit/gs-plugin-packagekit-local.c
index 50359b30..497f116a 100644
--- a/plugins/packagekit/gs-plugin-packagekit-local.c
+++ b/plugins/packagekit/gs-plugin-packagekit-local.c
@@ -191,6 +191,7 @@ gs_plugin_file_to_app (GsPlugin *plugin,
/* create application */
item = g_ptr_array_index (array, 0);
app = gs_app_new (NULL);
+ gs_plugin_packagekit_set_packaging_format (plugin, app);
gs_app_set_metadata (app, "GnomeSoftware::Creator",
gs_plugin_get_name (plugin));
package_id = pk_details_get_package_id (item);
diff --git a/plugins/packagekit/gs-plugin-packagekit-offline.c
b/plugins/packagekit/gs-plugin-packagekit-offline.c
index 28334196..9d482a3e 100644
--- a/plugins/packagekit/gs-plugin-packagekit-offline.c
+++ b/plugins/packagekit/gs-plugin-packagekit-offline.c
@@ -175,6 +175,7 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
app = gs_app_new (NULL);
package_id = pk_package_get_id (pkg);
split = g_strsplit (package_id, ";", 4);
+ gs_plugin_packagekit_set_packaging_format (plugin, app);
gs_app_add_source (app, split[0]);
gs_app_set_update_version (app, split[1]);
gs_app_set_management_plugin (app, "packagekit");
diff --git a/plugins/packagekit/gs-plugin-packagekit-refine.c
b/plugins/packagekit/gs-plugin-packagekit-refine.c
index 5c0695a6..c4281137 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refine.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refine.c
@@ -81,6 +81,7 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
if (gs_app_get_bundle_kind (app) == AS_BUNDLE_KIND_PACKAGE &&
gs_app_get_scope (app) == AS_APP_SCOPE_SYSTEM) {
gs_app_set_management_plugin (app, "packagekit");
+ gs_plugin_packagekit_set_packaging_format (plugin, app);
return;
}
}
diff --git a/plugins/packagekit/gs-plugin-packagekit-url-to-app.c
b/plugins/packagekit/gs-plugin-packagekit-url-to-app.c
index 969740b4..7afb082b 100644
--- a/plugins/packagekit/gs-plugin-packagekit-url-to-app.c
+++ b/plugins/packagekit/gs-plugin-packagekit-url-to-app.c
@@ -88,6 +88,7 @@ gs_plugin_url_to_app (GsPlugin *plugin,
}
app = gs_app_new (NULL);
+ gs_plugin_packagekit_set_packaging_format (plugin, app);
gs_app_add_source (app, path);
gs_app_set_kind (app, AS_APP_KIND_GENERIC);
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index 8d7eb551..57ae426c 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -540,6 +540,7 @@ gs_plugin_packagekit_build_update_app (GsPlugin *plugin, PkPackage *package)
if (app != NULL)
return app;
app = gs_app_new (NULL);
+ gs_plugin_packagekit_set_packaging_format (plugin, app);
gs_app_add_source (app, pk_package_get_name (package));
gs_app_add_source_id (app, pk_package_get_id (package));
gs_app_set_name (app, GS_APP_QUALITY_LOWEST,
diff --git a/plugins/packagekit/packagekit-common.c b/plugins/packagekit/packagekit-common.c
index b55063ca..64c2a599 100644
--- a/plugins/packagekit/packagekit-common.c
+++ b/plugins/packagekit/packagekit-common.c
@@ -256,6 +256,7 @@ gs_plugin_packagekit_add_results (GsPlugin *plugin,
app = gs_plugin_cache_lookup (plugin, pk_package_get_id (package));
if (app == NULL) {
app = gs_app_new (NULL);
+ gs_plugin_packagekit_set_packaging_format (plugin, app);
gs_app_add_source (app, pk_package_get_name (package));
gs_app_add_source_id (app, pk_package_get_id (package));
gs_plugin_cache_add (plugin, pk_package_get_id (package), app);
@@ -368,6 +369,7 @@ gs_plugin_packagekit_set_metadata_from_package (GsPlugin *plugin,
{
const gchar *data;
+ gs_plugin_packagekit_set_packaging_format (plugin, app);
gs_app_set_management_plugin (app, "packagekit");
gs_app_add_source (app, pk_package_get_name (package));
gs_app_add_source_id (app, pk_package_get_id (package));
@@ -491,3 +493,15 @@ gs_plugin_packagekit_refine_details_app (GsPlugin *plugin,
gs_app_set_size_download (app, size);
}
}
+
+void
+gs_plugin_packagekit_set_packaging_format (GsPlugin *plugin, GsApp *app)
+{
+ if (gs_plugin_check_distro_id (plugin, "fedora") ||
+ gs_plugin_check_distro_id (plugin, "rhel")) {
+ gs_app_set_metadata (app, "GnomeSoftware::PackagingFormat", "RPM");
+ } else if (gs_plugin_check_distro_id (plugin, "debian") ||
+ gs_plugin_check_distro_id (plugin, "ubuntu")) {
+ gs_app_set_metadata (app, "GnomeSoftware::PackagingFormat", "deb");
+ }
+}
diff --git a/plugins/packagekit/packagekit-common.h b/plugins/packagekit/packagekit-common.h
index d00c2b81..1684c9fc 100644
--- a/plugins/packagekit/packagekit-common.h
+++ b/plugins/packagekit/packagekit-common.h
@@ -47,6 +47,8 @@ void gs_plugin_packagekit_set_metadata_from_package (GsPlugin *plugin,
void gs_plugin_packagekit_refine_details_app (GsPlugin *plugin,
GPtrArray *array,
GsApp *app);
+void gs_plugin_packagekit_set_packaging_format (GsPlugin *plugin,
+ GsApp *app);
G_END_DECLS
diff --git a/src/gs-origin-popover-row.c b/src/gs-origin-popover-row.c
index d30b78d9..3d9d5537 100644
--- a/src/gs-origin-popover-row.c
+++ b/src/gs-origin-popover-row.c
@@ -44,7 +44,7 @@ refresh_ui (GsOriginPopoverRow *row)
GsOriginPopoverRowPrivate *priv = gs_origin_popover_row_get_instance_private (row);
const gchar *origin_ui = NULL;
const gchar *url;
- AsBundleKind bundle_kind;
+ const gchar *packaging_format;
g_autoptr(GsOsRelease) os_release = NULL;
g_assert (GS_IS_ORIGIN_POPOVER_ROW (row));
@@ -76,9 +76,16 @@ refresh_ui (GsOriginPopoverRow *row)
gtk_widget_hide (priv->url_box);
}
- bundle_kind = gs_app_get_bundle_kind (priv->app);
- if (bundle_kind != AS_BUNDLE_KIND_UNKNOWN) {
- gtk_label_set_text (GTK_LABEL (priv->format_label), as_bundle_kind_to_string (bundle_kind));
+ packaging_format = gs_app_get_metadata_item (priv->app, "GnomeSoftware::PackagingFormat");
+ if (packaging_format == NULL) {
+ AsBundleKind bundle_kind;
+ bundle_kind = gs_app_get_bundle_kind (priv->app);
+ if (bundle_kind != AS_BUNDLE_KIND_UNKNOWN)
+ packaging_format = as_bundle_kind_to_string (bundle_kind);
+ }
+
+ if (packaging_format != NULL) {
+ gtk_label_set_text (GTK_LABEL (priv->format_label), packaging_format);
gtk_widget_show (priv->format_box);
} else {
gtk_widget_hide (priv->format_box);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]