summaryrefslogtreecommitdiff
path: root/app/flatpak-builtins-delete-remote.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2016-05-06 18:03:47 +0200
committerAlexander Larsson <alexl@redhat.com>2016-05-09 09:00:20 +0200
commitc24528d3697c62cad8ff746a56992a59f31d333d (patch)
tree2dbb32e15c57cc4061f7b37d6db29a7b97228c15 /app/flatpak-builtins-delete-remote.c
parent6a613d1fabce5e93656cfbcb6815cc9bc98f437b (diff)
downloadxdg-app-c24528d3697c62cad8ff746a56992a59f31d333d.tar.gz
Rename source files to flatpak
Diffstat (limited to 'app/flatpak-builtins-delete-remote.c')
-rw-r--r--app/flatpak-builtins-delete-remote.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/app/flatpak-builtins-delete-remote.c b/app/flatpak-builtins-delete-remote.c
new file mode 100644
index 0000000..48330cd
--- /dev/null
+++ b/app/flatpak-builtins-delete-remote.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2014 Red Hat, Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Alexander Larsson <alexl@redhat.com>
+ */
+
+#include "config.h"
+
+#include <locale.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "libgsystem.h"
+#include "libglnx/libglnx.h"
+
+#include "flatpak-builtins.h"
+
+gboolean
+flatpak_builtin_delete_remote (int argc, char **argv, GCancellable *cancellable, GError **error)
+{
+ g_autoptr(GOptionContext) context = NULL;
+ g_autoptr(FlatpakDir) dir = NULL;
+ const char *remote_name;
+
+ context = g_option_context_new ("NAME - Delete a remote repository");
+
+ if (!flatpak_option_context_parse (context, NULL, &argc, &argv, 0, &dir, cancellable, error))
+ return FALSE;
+
+ if (argc < 2)
+ return usage_error (context, "NAME must be specified", error);
+
+ remote_name = argv[1];
+
+ if (!flatpak_dir_remove_all_refs (dir, remote_name,
+ cancellable, error))
+ return FALSE;
+
+ if (!flatpak_dir_remove_appstream (dir, remote_name,
+ cancellable, error))
+ return FALSE;
+
+ if (!ostree_repo_remote_change (flatpak_dir_get_repo (dir), NULL,
+ OSTREE_REPO_REMOTE_CHANGE_DELETE,
+ remote_name, NULL,
+ NULL,
+ cancellable, error))
+ return FALSE;
+
+ if (!flatpak_dir_mark_changed (dir, error))
+ return FALSE;
+
+ return TRUE;
+}