diff options
-rw-r--r-- | app/xdg-app-builtins-add-remote.c | 14 | ||||
-rw-r--r-- | app/xdg-app-builtins-list-remotes.c | 9 | ||||
-rw-r--r-- | app/xdg-app-builtins-update.c | 3 | ||||
-rw-r--r-- | common/xdg-app-dir.c | 13 | ||||
-rw-r--r-- | common/xdg-app-dir.h | 2 | ||||
-rw-r--r-- | doc/xdg-app-remote-add.xml | 8 | ||||
-rw-r--r-- | doc/xdg-app-remote-list.xml | 8 | ||||
-rw-r--r-- | doc/xdg-app-remote-modify.xml | 16 | ||||
-rw-r--r-- | lib/xdg-app-remote.c | 16 | ||||
-rw-r--r-- | lib/xdg-app-remote.h | 1 |
10 files changed, 90 insertions, 0 deletions
diff --git a/app/xdg-app-builtins-add-remote.c b/app/xdg-app-builtins-add-remote.c index dc39dfd..27d990f 100644 --- a/app/xdg-app-builtins-add-remote.c +++ b/app/xdg-app-builtins-add-remote.c @@ -39,6 +39,8 @@ static gboolean opt_do_gpg_verify; static gboolean opt_do_enumerate; static gboolean opt_no_enumerate; static gboolean opt_if_not_exists; +static gboolean opt_enable; +static gboolean opt_disable; static int opt_prio = -1; static char *opt_title; static char *opt_url; @@ -54,6 +56,7 @@ static GOptionEntry modify_options[] = { { "gpg-verify", 0, 0, G_OPTION_ARG_NONE, &opt_do_gpg_verify, "Enable GPG verification", NULL }, { "enumerate", 0, 0, G_OPTION_ARG_NONE, &opt_do_enumerate, "Mark the remote as enumerate", NULL }, { "url", 0, 0, G_OPTION_ARG_STRING, &opt_url, "Set a new url", NULL }, + { "enable", 0, 0, G_OPTION_ARG_NONE, &opt_enable, "Enable the remote", }, { NULL } }; @@ -64,6 +67,7 @@ static GOptionEntry common_options[] = { { "title", 0, 0, G_OPTION_ARG_STRING, &opt_title, "A nice name to use for this remote", "TITLE" }, { "gpg-import", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_gpg_import, "Import GPG key from FILE (- for stdin)", "FILE" }, { "gpg-key", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_gpg_import, "Optionally only import the named key(s) from the keyring files", "KEY" }, + { "disable", 0, 0, G_OPTION_ARG_NONE, &opt_disable, "Disable the remote", }, { NULL } }; @@ -200,6 +204,11 @@ xdg_app_builtin_add_remote (int argc, char **argv, "xa.noenumerate", g_variant_new_variant (g_variant_new_boolean (TRUE))); + if (opt_disable) + g_variant_builder_add (optbuilder, "{s@v}", + "xa.disable", + g_variant_new_variant (g_variant_new_boolean (TRUE))); + if (opt_prio != -1) { prio_as_string = g_strdup_printf ("%d", opt_prio); @@ -310,6 +319,11 @@ xdg_app_builtin_modify_remote (int argc, char **argv, GCancellable *cancellable, if (opt_do_enumerate) g_key_file_set_boolean (config, group, "xa.noenumerate", FALSE); + if (opt_disable) + g_key_file_set_boolean (config, group, "xa.disable", TRUE); + else if (opt_enable) + g_key_file_set_boolean (config, group, "xa.disable", FALSE); + if (opt_prio != -1) { g_autofree char *prio_as_string = g_strdup_printf ("%d", opt_prio); diff --git a/app/xdg-app-builtins-list-remotes.c b/app/xdg-app-builtins-list-remotes.c index 6ddf1fe..a294e00 100644 --- a/app/xdg-app-builtins-list-remotes.c +++ b/app/xdg-app-builtins-list-remotes.c @@ -34,11 +34,13 @@ static gboolean opt_show_details; static gboolean opt_user; static gboolean opt_system; +static gboolean opt_show_disabled; static GOptionEntry options[] = { { "user", 0, 0, G_OPTION_ARG_NONE, &opt_user, "Show user installations", NULL }, { "system", 0, 0, G_OPTION_ARG_NONE, &opt_system, "Show system-wide installations", NULL }, { "show-details", 'd', 0, G_OPTION_ARG_NONE, &opt_show_details, "Show remote details", NULL }, + { "show-disabled", 0, 0, G_OPTION_ARG_NONE, &opt_show_disabled, "Show disabled remotes", NULL }, { NULL } }; @@ -88,6 +90,11 @@ xdg_app_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable, for (i = 0; remotes[i] != NULL; i++) { char *remote_name = remotes[i]; + gboolean disabled; + + disabled = xdg_app_dir_get_remote_disabled (dir, remote_name); + if (disabled && !opt_show_disabled) + continue; if (opt_show_details) { @@ -119,6 +126,8 @@ xdg_app_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable, &gpg_verify, NULL); if (!gpg_verify) xdg_app_table_printer_append_with_comma (printer, "no-gpg-verify"); + if (disabled) + xdg_app_table_printer_append_with_comma (printer, "disabled"); if (xdg_app_dir_get_remote_noenumerate (dir, remote_name)) xdg_app_table_printer_append_with_comma (printer, "no-enumerate"); diff --git a/app/xdg-app-builtins-update.c b/app/xdg-app-builtins-update.c index 70364cd..3d899e5 100644 --- a/app/xdg-app-builtins-update.c +++ b/app/xdg-app-builtins-update.c @@ -93,6 +93,9 @@ do_update (XdgAppDir* dir, if (repository == NULL) return FALSE; + if (xdg_app_dir_get_remote_disabled (dir, repository)) + g_print ("Not updating %s due to disabled remote %s\n", ref, repository); + subpaths = xdg_app_dir_get_subpaths (dir, ref, cancellable, error); if (subpaths == NULL) return FALSE; diff --git a/common/xdg-app-dir.c b/common/xdg-app-dir.c index 213063e..ca07f25 100644 --- a/common/xdg-app-dir.c +++ b/common/xdg-app-dir.c @@ -3635,6 +3635,19 @@ xdg_app_dir_get_remote_noenumerate (XdgAppDir *self, return TRUE; } +gboolean +xdg_app_dir_get_remote_disabled (XdgAppDir *self, + const char *remote_name) +{ + GKeyFile *config = ostree_repo_get_config (self->repo); + g_autofree char *group = get_group (remote_name); + + if (config) + return g_key_file_get_boolean (config, group, "xa.disable", NULL); + + return TRUE; +} + gint cmp_remote (gconstpointer a, gconstpointer b, diff --git a/common/xdg-app-dir.h b/common/xdg-app-dir.h index d467ca3..ccca522 100644 --- a/common/xdg-app-dir.h +++ b/common/xdg-app-dir.h @@ -326,6 +326,8 @@ int xdg_app_dir_get_remote_prio (XdgAppDir *self, const char *remote_name); gboolean xdg_app_dir_get_remote_noenumerate (XdgAppDir *self, const char *remote_name); +gboolean xdg_app_dir_get_remote_disabled (XdgAppDir *self, + const char *remote_name); gboolean xdg_app_dir_list_remote_refs (XdgAppDir *self, const char *remote, GHashTable **refs, diff --git a/doc/xdg-app-remote-add.xml b/doc/xdg-app-remote-add.xml index 3661816..4b4af25 100644 --- a/doc/xdg-app-remote-add.xml +++ b/doc/xdg-app-remote-add.xml @@ -119,6 +119,14 @@ </varlistentry> <varlistentry> + <term><option>--disable</option></term> + + <listitem><para> + Disable the added remote. + </para></listitem> + </varlistentry> + + <varlistentry> <term><option>--title=TITLE</option></term> <listitem><para> diff --git a/doc/xdg-app-remote-list.xml b/doc/xdg-app-remote-list.xml index 768861d..5babd57 100644 --- a/doc/xdg-app-remote-list.xml +++ b/doc/xdg-app-remote-list.xml @@ -89,6 +89,14 @@ </varlistentry> <varlistentry> + <term><option>--show-disabled</option></term> + + <listitem><para> + Show disabled repos. + </para></listitem> + </varlistentry> + + <varlistentry> <term><option>-v</option></term> <term><option>--verbose</option></term> diff --git a/doc/xdg-app-remote-modify.xml b/doc/xdg-app-remote-modify.xml index 77c4934..12f9e0b 100644 --- a/doc/xdg-app-remote-modify.xml +++ b/doc/xdg-app-remote-modify.xml @@ -117,6 +117,22 @@ </varlistentry> <varlistentry> + <term><option>--disable</option></term> + + <listitem><para> + Disable the remote. Disabled remotes will not be automatically updated from. + </para></listitem> + </varlistentry> + + <varlistentry> + <term><option>--enable</option></term> + + <listitem><para> + Enable the remote. + </para></listitem> + </varlistentry> + + <varlistentry> <term><option>--enumerate</option></term> <listitem><para> diff --git a/lib/xdg-app-remote.c b/lib/xdg-app-remote.c index 4a655dc..164bf40 100644 --- a/lib/xdg-app-remote.c +++ b/lib/xdg-app-remote.c @@ -260,6 +260,22 @@ xdg_app_remote_get_noenumerate (XdgAppRemote *self) } /** + * xdg_app_remote_get_disable: + * @self: a #XdgAppRemote + * + * Returns whether this remote is disabled. + * + * Returns: whether the remote is marked as "don't enumerate" + */ +gboolean +xdg_app_remote_get_disabled (XdgAppRemote *self) +{ + XdgAppRemotePrivate *priv = xdg_app_remote_get_instance_private (self); + + return xdg_app_dir_get_remote_disabled (priv->dir, priv->name); +} + +/** * xdg_app_remote_get_prio: * @self: a #XdgAppRemote * diff --git a/lib/xdg-app-remote.h b/lib/xdg-app-remote.h index fd66cb5..2040767 100644 --- a/lib/xdg-app-remote.h +++ b/lib/xdg-app-remote.h @@ -57,6 +57,7 @@ XDG_APP_EXTERN char * xdg_app_remote_get_url (XdgAppRemote *sel XDG_APP_EXTERN char * xdg_app_remote_get_title (XdgAppRemote *self); XDG_APP_EXTERN gboolean xdg_app_remote_get_gpg_verify (XdgAppRemote *self); XDG_APP_EXTERN gboolean xdg_app_remote_get_noenumerate (XdgAppRemote *self); +XDG_APP_EXTERN gboolean xdg_app_remote_get_disabled (XdgAppRemote *self); XDG_APP_EXTERN int xdg_app_remote_get_prio (XdgAppRemote *self); #endif /* __XDG_APP_REMOTE_H__ */ |