[gnome-software] Add --prefer-local to prefer the local data to the distro AppStream metadata
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Add --prefer-local to prefer the local data to the distro AppStream metadata
- Date: Tue, 1 Jul 2014 08:46:15 +0000 (UTC)
commit b59375cd5bf75a3e5044647d4a74878f4315a800
Author: Richard Hughes <richard hughsie com>
Date: Tue Jul 1 09:36:43 2014 +0100
Add --prefer-local to prefer the local data to the distro AppStream metadata
Users can also use GNOME_SOFTWARE_PREFER_LOCAL=1 in the environment settings.
Resolves: https://bugzilla.gnome.org/show_bug.cgi?id=732466
src/gs-application.c | 7 +++++++
src/gs-cmd.c | 7 +++++++
src/plugins/gs-plugin-appstream.c | 4 ++++
3 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 0f6903b..69d521b 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -514,6 +514,7 @@ gs_application_local_command_line (GApplication *app, gchar ***args, gint *statu
gchar *local_filename = NULL;
gchar *id = NULL;
gboolean activate_ui = TRUE;
+ gboolean prefer_local = FALSE;
gboolean version = FALSE;
gboolean profile = FALSE;
gboolean verbose = FALSE;
@@ -534,6 +535,8 @@ gs_application_local_command_line (GApplication *app, gchar ***args, gint *statu
_("Set the specified debugging level"), _("ID") },
{ "profile", 0, 0, G_OPTION_ARG_NONE, &profile,
_("Show profiling information for the service"), NULL },
+ { "prefer-local", '\0', 0, G_OPTION_ARG_NONE, &prefer_local,
+ "Prefer local file sources to AppStream", NULL },
{ "version", 0, 0, G_OPTION_ARG_NONE, &version, NULL, NULL },
{ NULL}
};
@@ -553,6 +556,10 @@ gs_application_local_command_line (GApplication *app, gchar ***args, gint *statu
if (verbose)
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
+ /* prefer local sources */
+ if (prefer_local)
+ g_setenv ("GNOME_SOFTWARE_PREFER_LOCAL", "true", TRUE);
+
if (version) {
g_print ("gnome-software " VERSION "\n");
*status = 0;
diff --git a/src/gs-cmd.c b/src/gs-cmd.c
index c56f340..e9288fd 100644
--- a/src/gs-cmd.c
+++ b/src/gs-cmd.c
@@ -186,6 +186,7 @@ main (int argc, char **argv)
GsCategory *category = NULL;
GsPluginLoader *plugin_loader = NULL;
GsProfile *profile = NULL;
+ gboolean prefer_local = FALSE;
gboolean ret;
gboolean show_results = FALSE;
guint64 refine_flags = GS_PLUGIN_REFINE_FLAGS_DEFAULT;
@@ -201,6 +202,8 @@ main (int argc, char **argv)
"Set any refine flags required for the action", NULL },
{ "repeat", '\0', 0, G_OPTION_ARG_INT, &repeat,
"Repeat the action this number of times", NULL },
+ { "prefer-local", '\0', 0, G_OPTION_ARG_NONE, &prefer_local,
+ "Prefer local file sources to AppStream", NULL },
{ NULL}
};
@@ -224,6 +227,10 @@ main (int argc, char **argv)
goto out;
}
+ /* prefer local sources */
+ if (prefer_local)
+ g_setenv ("GNOME_SOFTWARE_PREFER_LOCAL", "true", TRUE);
+
/* parse any refine flags */
refine_flags = gs_cmd_parse_refine_flags (refine_flags_str, &error);
if (refine_flags == G_MAXUINT64) {
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 050daea..ae66a65 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -136,6 +136,10 @@ gs_plugin_startup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
/* Parse the XML */
gs_profile_start (plugin->profile, "appstream::startup");
+ if (g_getenv ("GNOME_SOFTWARE_PREFER_LOCAL") != NULL) {
+ as_store_set_add_flags (plugin->priv->store,
+ AS_STORE_ADD_FLAG_PREFER_LOCAL);
+ }
ret = as_store_load (plugin->priv->store,
AS_STORE_LOAD_FLAG_APP_INFO_SYSTEM |
AS_STORE_LOAD_FLAG_APP_INFO_USER |
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]