summaryrefslogtreecommitdiff
path: root/src/ostree
diff options
context:
space:
mode:
Diffstat (limited to 'src/ostree')
-rw-r--r--src/ostree/main.c102
-rw-r--r--src/ostree/ostree-trivial-httpd.c337
-rw-r--r--src/ostree/ot-admin-builtin-boot-complete.c21
-rw-r--r--src/ostree/ot-admin-builtin-cleanup.c19
-rw-r--r--src/ostree/ot-admin-builtin-deploy.c114
-rw-r--r--src/ostree/ot-admin-builtin-diff.c49
-rw-r--r--src/ostree/ot-admin-builtin-finalize-staged.c35
-rw-r--r--src/ostree/ot-admin-builtin-init-fs.c36
-rw-r--r--src/ostree/ot-admin-builtin-instutil.c32
-rw-r--r--src/ostree/ot-admin-builtin-kargs.c16
-rw-r--r--src/ostree/ot-admin-builtin-os-init.c16
-rw-r--r--src/ostree/ot-admin-builtin-pin.c39
-rw-r--r--src/ostree/ot-admin-builtin-set-origin.c68
-rw-r--r--src/ostree/ot-admin-builtin-status.c110
-rw-r--r--src/ostree/ot-admin-builtin-switch.c62
-rw-r--r--src/ostree/ot-admin-builtin-undeploy.c28
-rw-r--r--src/ostree/ot-admin-builtin-unlock.c31
-rw-r--r--src/ostree/ot-admin-builtin-upgrade.c60
-rw-r--r--src/ostree/ot-admin-builtins.h42
-rw-r--r--src/ostree/ot-admin-functions.c41
-rw-r--r--src/ostree/ot-admin-functions.h32
-rw-r--r--src/ostree/ot-admin-instutil-builtin-grub2-generate.c34
-rw-r--r--src/ostree/ot-admin-instutil-builtin-selinux-ensure-labeled.c111
-rw-r--r--src/ostree/ot-admin-instutil-builtin-set-kargs.c54
-rw-r--r--src/ostree/ot-admin-instutil-builtins.h13
-rw-r--r--src/ostree/ot-admin-kargs-builtin-edit-in-place.c30
-rw-r--r--src/ostree/ot-admin-kargs-builtins.h9
-rw-r--r--src/ostree/ot-builtin-admin.c72
-rw-r--r--src/ostree/ot-builtin-cat.c32
-rw-r--r--src/ostree/ot-builtin-checkout.c175
-rw-r--r--src/ostree/ot-builtin-checksum.c49
-rw-r--r--src/ostree/ot-builtin-commit.c412
-rw-r--r--src/ostree/ot-builtin-config.c72
-rw-r--r--src/ostree/ot-builtin-create-usb.c95
-rw-r--r--src/ostree/ot-builtin-diff.c81
-rw-r--r--src/ostree/ot-builtin-export.c58
-rw-r--r--src/ostree/ot-builtin-find-remotes.c164
-rw-r--r--src/ostree/ot-builtin-fsck.c189
-rw-r--r--src/ostree/ot-builtin-gpg-sign.c73
-rw-r--r--src/ostree/ot-builtin-init.c30
-rw-r--r--src/ostree/ot-builtin-log.c38
-rw-r--r--src/ostree/ot-builtin-ls.c104
-rw-r--r--src/ostree/ot-builtin-prune.c165
-rw-r--r--src/ostree/ot-builtin-pull-local.c118
-rw-r--r--src/ostree/ot-builtin-pull.c213
-rw-r--r--src/ostree/ot-builtin-refs.c105
-rw-r--r--src/ostree/ot-builtin-remote.c53
-rw-r--r--src/ostree/ot-builtin-reset.c26
-rw-r--r--src/ostree/ot-builtin-rev-parse.c27
-rw-r--r--src/ostree/ot-builtin-show.c201
-rw-r--r--src/ostree/ot-builtin-sign.c85
-rw-r--r--src/ostree/ot-builtin-static-delta.c317
-rw-r--r--src/ostree/ot-builtin-summary.c91
-rw-r--r--src/ostree/ot-builtin-trivial-httpd.c11
-rw-r--r--src/ostree/ot-builtins.h60
-rw-r--r--src/ostree/ot-dump.c171
-rw-r--r--src/ostree/ot-dump.h21
-rw-r--r--src/ostree/ot-editor.c26
-rw-r--r--src/ostree/ot-editor.h4
-rw-r--r--src/ostree/ot-main.c220
-rw-r--r--src/ostree/ot-main.h71
-rw-r--r--src/ostree/ot-remote-builtin-add-cookie.c23
-rw-r--r--src/ostree/ot-remote-builtin-add.c142
-rw-r--r--src/ostree/ot-remote-builtin-delete-cookie.c20
-rw-r--r--src/ostree/ot-remote-builtin-delete.c37
-rw-r--r--src/ostree/ot-remote-builtin-gpg-import.c53
-rw-r--r--src/ostree/ot-remote-builtin-gpg-list-keys.c26
-rw-r--r--src/ostree/ot-remote-builtin-list-cookies.c17
-rw-r--r--src/ostree/ot-remote-builtin-list.c20
-rw-r--r--src/ostree/ot-remote-builtin-refs.c28
-rw-r--r--src/ostree/ot-remote-builtin-show-url.c17
-rw-r--r--src/ostree/ot-remote-builtin-summary.c54
-rw-r--r--src/ostree/ot-remote-builtins.h28
-rw-r--r--src/ostree/ot-remote-cookie-util.c91
-rw-r--r--src/ostree/ot-remote-cookie-util.h17
75 files changed, 2757 insertions, 2986 deletions
diff --git a/src/ostree/main.c b/src/ostree/main.c
index 0b886c1f..edb8a7a0 100644
--- a/src/ostree/main.c
+++ b/src/ostree/main.c
@@ -35,99 +35,55 @@ static OstreeCommand commands[] = {
* admin command may have their own
* admin flag
*/
- { "admin", OSTREE_BUILTIN_FLAG_NO_REPO,
- ostree_builtin_admin,
+ { "admin", OSTREE_BUILTIN_FLAG_NO_REPO, ostree_builtin_admin,
"Commands for managing a host system booted with ostree" },
- { "cat", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_cat,
- "Concatenate contents of files"},
- { "checkout", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_checkout,
+ { "cat", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_cat, "Concatenate contents of files" },
+ { "checkout", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_checkout,
"Check out a commit into a filesystem tree" },
- { "checksum", OSTREE_BUILTIN_FLAG_NO_REPO,
- ostree_builtin_checksum,
+ { "checksum", OSTREE_BUILTIN_FLAG_NO_REPO, ostree_builtin_checksum,
"Checksum a file or directory" },
- { "commit", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_commit,
- "Commit a new revision" },
- { "config", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_config,
+ { "commit", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_commit, "Commit a new revision" },
+ { "config", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_config,
"Change repo configuration settings" },
- { "diff", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_diff,
- "Compare directory TARGETDIR against revision REV"},
- { "export", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_export,
+ { "diff", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_diff,
+ "Compare directory TARGETDIR against revision REV" },
+ { "export", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_export,
"Stream COMMIT to stdout in tar format" },
- { "find-remotes", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_find_remotes,
+ { "find-remotes", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_find_remotes,
"Find remotes to serve the given refs" },
- { "create-usb", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_create_usb,
+ { "create-usb", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_create_usb,
"Copy the refs to a USB stick" },
- { "fsck", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_fsck,
- "Check the repository for consistency" },
+ { "fsck", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_fsck, "Check the repository for consistency" },
#ifndef OSTREE_DISABLE_GPGME
- { "gpg-sign", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_gpg_sign,
- "Sign a commit" },
+ { "gpg-sign", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_gpg_sign, "Sign a commit" },
#endif /* OSTREE_DISABLE_GPGME */
- { "init", OSTREE_BUILTIN_FLAG_NO_CHECK,
- ostree_builtin_init,
+ { "init", OSTREE_BUILTIN_FLAG_NO_CHECK, ostree_builtin_init,
"Initialize a new empty repository" },
- { "log", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_log,
- "Show log starting at commit or ref" },
- { "ls", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_ls,
- "List file paths" },
- { "prune", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_prune,
- "Search for unreachable objects" },
- { "pull-local", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_pull_local,
- "Copy data from SRC_REPO" },
+ { "log", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_log, "Show log starting at commit or ref" },
+ { "ls", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_ls, "List file paths" },
+ { "prune", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_prune, "Search for unreachable objects" },
+ { "pull-local", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_pull_local, "Copy data from SRC_REPO" },
#ifdef HAVE_LIBCURL_OR_LIBSOUP
- { "pull", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_pull,
- "Download data from remote repository" },
+ { "pull", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_pull, "Download data from remote repository" },
#endif
- { "refs", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_refs,
- "List refs" },
- { "remote", OSTREE_BUILTIN_FLAG_NO_REPO,
- ostree_builtin_remote,
+ { "refs", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_refs, "List refs" },
+ { "remote", OSTREE_BUILTIN_FLAG_NO_REPO, ostree_builtin_remote,
"Remote commands that may involve internet access" },
- { "reset", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_reset,
- "Reset a REF to a previous COMMIT" },
- { "rev-parse", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_rev_parse,
- "Output the target of a rev" },
- { "sign", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_sign,
- "Sign a commit" },
- { "show", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_show,
- "Output a metadata object" },
- { "static-delta", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_static_delta,
+ { "reset", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_reset, "Reset a REF to a previous COMMIT" },
+ { "rev-parse", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_rev_parse, "Output the target of a rev" },
+ { "sign", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_sign, "Sign a commit" },
+ { "show", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_show, "Output a metadata object" },
+ { "static-delta", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_static_delta,
"Static delta related commands" },
- { "summary", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_summary,
- "Manage summary metadata" },
+ { "summary", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_summary, "Manage summary metadata" },
#if defined(HAVE_LIBSOUP_OR_LIBSOUP3) && defined(BUILDOPT_ENABLE_TRIVIAL_HTTPD_CMDLINE)
- { "trivial-httpd", OSTREE_BUILTIN_FLAG_NONE,
- ostree_builtin_trivial_httpd,
- NULL },
+ { "trivial-httpd", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_trivial_httpd, NULL },
#endif
{ NULL }
};
int
-main (int argc,
- char **argv)
+main (int argc, char **argv)
{
g_assert (argc > 0);
diff --git a/src/ostree/ostree-trivial-httpd.c b/src/ostree/ostree-trivial-httpd.c
index 855d2cea..facc1527 100644
--- a/src/ostree/ostree-trivial-httpd.c
+++ b/src/ostree/ostree-trivial-httpd.c
@@ -23,28 +23,31 @@
#include <gio/gunixoutputstream.h>
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
-#include <locale.h>
#include <err.h>
-#include <sys/socket.h>
-#include <sys/prctl.h>
+#include <locale.h>
#include <signal.h>
+#include <sys/prctl.h>
+#include <sys/socket.h>
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
-# define SoupServerMessage SoupMessage
-# define soup_server_message_get_method(msg) ((msg)->method)
-# define soup_server_message_get_request_headers(msg) ((msg)->request_headers)
-# define soup_server_message_get_response_headers(msg) ((msg)->response_headers)
-# define soup_server_message_get_response_body(msg) ((msg)->response_body)
-# define soup_server_message_set_status(msg, status) soup_message_set_status(msg, status)
-# define soup_server_message_set_redirect(msg, status, uri) soup_message_set_redirect(msg, status, uri)
-# define soup_server_message_set_response(msg, ct, ru, rb, rl) soup_message_set_response(msg, ct, ru, rb, rl)
+#if !SOUP_CHECK_VERSION(3, 0, 0)
+#define SoupServerMessage SoupMessage
+#define soup_server_message_get_method(msg) ((msg)->method)
+#define soup_server_message_get_request_headers(msg) ((msg)->request_headers)
+#define soup_server_message_get_response_headers(msg) ((msg)->response_headers)
+#define soup_server_message_get_response_body(msg) ((msg)->response_body)
+#define soup_server_message_set_status(msg, status) soup_message_set_status (msg, status)
+#define soup_server_message_set_redirect(msg, status, uri) \
+ soup_message_set_redirect (msg, status, uri)
+#define soup_server_message_set_response(msg, ct, ru, rb, rl) \
+ soup_message_set_response (msg, ct, ru, rb, rl)
#else
-# define soup_server_message_set_status(msg, status) soup_server_message_set_status(msg, status, NULL)
+#define soup_server_message_set_status(msg, status) \
+ soup_server_message_set_status (msg, status, NULL)
#endif
static char *opt_port_file = NULL;
@@ -66,7 +69,8 @@ static gboolean opt_require_basic_auth;
static guint emitted_random_500s_count = 0;
static guint emitted_random_408s_count = 0;
-typedef struct {
+typedef struct
+{
int root_dfd;
gboolean running;
GOutputStream *log;
@@ -77,30 +81,41 @@ typedef struct {
* man page (man/ostree-trivial-httpd.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "daemonize", 'd', 0, G_OPTION_ARG_NONE, &opt_daemonize, "Fork into background when ready", NULL },
- { "autoexit", 0, 0, G_OPTION_ARG_NONE, &opt_autoexit, "Automatically exit when directory is deleted", NULL },
- { "port", 'P', 0, G_OPTION_ARG_INT, &opt_port, "Use the specified TCP port", "PORT" },
- { "port-file", 'p', 0, G_OPTION_ARG_FILENAME, &opt_port_file, "Write port number to PATH (- for standard output)", "PATH" },
- { "force-range-requests", 0, 0, G_OPTION_ARG_NONE, &opt_force_ranges, "Force range requests by only serving half of files", NULL },
- { "require-basic-auth", 0, 0, G_OPTION_ARG_NONE, &opt_require_basic_auth, "Require username foouser, password barpw", NULL },
- { "random-500s", 0, 0, G_OPTION_ARG_INT, &opt_random_500s_percentage, "Generate random HTTP 500 errors approximately for PERCENTAGE requests", "PERCENTAGE" },
- { "random-500s-max", 0, 0, G_OPTION_ARG_INT, &opt_random_500s_max, "Limit HTTP 500 errors to MAX (default 100)", "MAX" },
- { "random-408s", 0, 0, G_OPTION_ARG_INT, &opt_random_408s_percentage, "Generate random HTTP 408 errors approximately for PERCENTAGE requests", "PERCENTAGE" },
- { "random-408s-max", 0, 0, G_OPTION_ARG_INT, &opt_random_408s_max, "Limit HTTP 408 errors to MAX (default 100)", "MAX" },
- { "log-file", 0, 0, G_OPTION_ARG_FILENAME, &opt_log, "Put logs here (use - for stdout)", "PATH" },
- { "expected-cookies", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_expected_cookies, "Expect given cookies in the http request", "KEY=VALUE" },
- { "expected-header", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_expected_headers, "Expect given headers in the http request", "KEY=VALUE" },
- { NULL }
-};
-
-static void
-httpd_log (OtTrivialHttpd *httpd, const gchar *format, ...) __attribute__ ((format(printf, 2, 3)));
+static GOptionEntry options[]
+ = { { "daemonize", 'd', 0, G_OPTION_ARG_NONE, &opt_daemonize, "Fork into background when ready",
+ NULL },
+ { "autoexit", 0, 0, G_OPTION_ARG_NONE, &opt_autoexit,
+ "Automatically exit when directory is deleted", NULL },
+ { "port", 'P', 0, G_OPTION_ARG_INT, &opt_port, "Use the specified TCP port", "PORT" },
+ { "port-file", 'p', 0, G_OPTION_ARG_FILENAME, &opt_port_file,
+ "Write port number to PATH (- for standard output)", "PATH" },
+ { "force-range-requests", 0, 0, G_OPTION_ARG_NONE, &opt_force_ranges,
+ "Force range requests by only serving half of files", NULL },
+ { "require-basic-auth", 0, 0, G_OPTION_ARG_NONE, &opt_require_basic_auth,
+ "Require username foouser, password barpw", NULL },
+ { "random-500s", 0, 0, G_OPTION_ARG_INT, &opt_random_500s_percentage,
+ "Generate random HTTP 500 errors approximately for PERCENTAGE requests", "PERCENTAGE" },
+ { "random-500s-max", 0, 0, G_OPTION_ARG_INT, &opt_random_500s_max,
+ "Limit HTTP 500 errors to MAX (default 100)", "MAX" },
+ { "random-408s", 0, 0, G_OPTION_ARG_INT, &opt_random_408s_percentage,
+ "Generate random HTTP 408 errors approximately for PERCENTAGE requests", "PERCENTAGE" },
+ { "random-408s-max", 0, 0, G_OPTION_ARG_INT, &opt_random_408s_max,
+ "Limit HTTP 408 errors to MAX (default 100)", "MAX" },
+ { "log-file", 0, 0, G_OPTION_ARG_FILENAME, &opt_log, "Put logs here (use - for stdout)",
+ "PATH" },
+ { "expected-cookies", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_expected_cookies,
+ "Expect given cookies in the http request", "KEY=VALUE" },
+ { "expected-header", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_expected_headers,
+ "Expect given headers in the http request", "KEY=VALUE" },
+ { NULL } };
+
+static void httpd_log (OtTrivialHttpd *httpd, const gchar *format, ...)
+ __attribute__ ((format (printf, 2, 3)));
static void
httpd_log (OtTrivialHttpd *httpd, const gchar *format, ...)
{
- g_autoptr(GString) str = NULL;
+ g_autoptr (GString) str = NULL;
va_list args;
gsize written;
@@ -108,7 +123,7 @@ httpd_log (OtTrivialHttpd *httpd, const gchar *format, ...)
return;
{
- g_autoptr(GDateTime) now = g_date_time_new_now_local ();
+ g_autoptr (GDateTime) now = g_date_time_new_now_local ();
g_autofree char *timestamp = g_date_time_format (now, "%F %T");
str = g_string_new (timestamp);
g_string_append_printf (str, ".%06d - ", g_date_time_get_microsecond (now));
@@ -131,12 +146,13 @@ compare_strings (gconstpointer a, gconstpointer b)
}
static GString *
-get_directory_listing (int dfd,
- const char *path)
+get_directory_listing (int dfd, const char *path)
{
- g_autoptr(GPtrArray) entries = g_ptr_array_new_with_free_func (g_free);
- g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
- g_autoptr(GError) local_error = NULL;
+ g_autoptr (GPtrArray) entries = g_ptr_array_new_with_free_func (g_free);
+ g_auto (GLnxDirFdIterator) dfd_iter = {
+ 0,
+ };
+ g_autoptr (GError) local_error = NULL;
GError **error = &local_error;
guint i;
char *escaped;
@@ -169,13 +185,12 @@ get_directory_listing (int dfd,
g_free (escaped);
for (i = 0; i < entries->len; i++)
{
- g_string_append_printf (listing, "<a href=\"%s\">%s</a><br>\r\n",
- (char *)entries->pdata[i],
+ g_string_append_printf (listing, "<a href=\"%s\">%s</a><br>\r\n", (char *)entries->pdata[i],
(char *)entries->pdata[i]);
g_free (g_steal_pointer (&entries->pdata[i]));
}
g_string_append (listing, "</body>\r\n</html>\r\n");
- out:
+out:
if (local_error)
g_printerr ("%s\n", local_error->message);
return listing;
@@ -218,7 +233,7 @@ close_socket (SoupServerMessage *msg, gpointer user_data)
static gchar *
calculate_etag (GMappedFile *mapping)
{
- g_autoptr(GBytes) bytes = g_mapped_file_get_bytes (mapping);
+ g_autoptr (GBytes) bytes = g_mapped_file_get_bytes (mapping);
g_autofree gchar *checksum = g_compute_checksum_for_bytes (G_CHECKSUM_SHA256, bytes);
return g_strconcat ("\"", checksum, "\"", NULL);
}
@@ -234,12 +249,11 @@ _server_cookies_from_request (SoupServerMessage *msg)
const char *header;
const char *host;
- header = soup_message_headers_get_one (soup_server_message_get_request_headers (msg),
- "Cookie");
+ header = soup_message_headers_get_one (soup_server_message_get_request_headers (msg), "Cookie");
if (!header)
return NULL;
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
+#if !SOUP_CHECK_VERSION(3, 0, 0)
host = soup_uri_get_host (soup_message_get_uri (msg));
#else
host = g_uri_get_host (soup_server_message_get_uri (msg));
@@ -249,7 +263,8 @@ _server_cookies_from_request (SoupServerMessage *msg)
while (g_hash_table_iter_next (&iter, &name, &value))
{
- if (!name || !value) continue;
+ if (!name || !value)
+ continue;
cookie = soup_cookie_new (name, value, host, NULL, 0);
cookies = g_slist_prepend (cookies, cookie);
}
@@ -260,17 +275,11 @@ _server_cookies_from_request (SoupServerMessage *msg)
}
static void
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
-do_get (OtTrivialHttpd *self,
- SoupServer *server,
- SoupServerMessage *msg,
- const char *path,
+#if !SOUP_CHECK_VERSION(3, 0, 0)
+do_get (OtTrivialHttpd *self, SoupServer *server, SoupServerMessage *msg, const char *path,
SoupClientContext *context)
#else
-do_get (OtTrivialHttpd *self,
- SoupServer *server,
- SoupServerMessage *msg,
- const char *path)
+do_get (OtTrivialHttpd *self, SoupServer *server, SoupServerMessage *msg, const char *path)
#endif
{
char *slash;
@@ -285,18 +294,18 @@ do_get (OtTrivialHttpd *self,
GSList *l;
int i;
- for (i = 0 ; opt_expected_cookies[i] != NULL; i++)
+ for (i = 0; opt_expected_cookies[i] != NULL; i++)
{
gboolean found = FALSE;
gchar *k = opt_expected_cookies[i];
gchar *v = strchr (k, '=') + 1;
- for (l = cookies; l != NULL ; l = g_slist_next (l))
+ for (l = cookies; l != NULL; l = g_slist_next (l))
{
SoupCookie *c = l->data;
- if (!strncmp (k, soup_cookie_get_name (c), v - k - 1) &&
- !strcmp (v, soup_cookie_get_value (c)))
+ if (!strncmp (k, soup_cookie_get_name (c), v - k - 1)
+ && !strcmp (v, soup_cookie_get_value (c)))
{
found = TRUE;
break;
@@ -316,7 +325,7 @@ do_get (OtTrivialHttpd *self,
if (opt_expected_headers)
{
- for (int i = 0 ; opt_expected_headers[i] != NULL; i++)
+ for (int i = 0; opt_expected_headers[i] != NULL; i++)
{
const gchar *kv = opt_expected_headers[i];
const gchar *eq = strchr (kv, '=');
@@ -326,7 +335,8 @@ do_get (OtTrivialHttpd *self,
{
g_autofree char *k = g_strndup (kv, eq - kv);
const gchar *expected_v = eq + 1;
- const gchar *found_v = soup_message_headers_get_one (soup_server_message_get_request_headers (msg), k);
+ const gchar *found_v
+ = soup_message_headers_get_one (soup_server_message_get_request_headers (msg), k);
if (!found_v)
{
@@ -350,17 +360,15 @@ do_get (OtTrivialHttpd *self,
goto out;
}
- if (opt_random_500s_percentage > 0 &&
- emitted_random_500s_count < opt_random_500s_max &&
- g_random_int_range (0, 100) < opt_random_500s_percentage)
+ if (opt_random_500s_percentage > 0 && emitted_random_500s_count < opt_random_500s_max
+ && g_random_int_range (0, 100) < opt_random_500s_percentage)
{
emitted_random_500s_count++;
soup_server_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
goto out;
}
- else if (opt_random_408s_percentage > 0 &&
- emitted_random_408s_count < opt_random_408s_max &&
- g_random_int_range (0, 100) < opt_random_408s_percentage)
+ else if (opt_random_408s_percentage > 0 && emitted_random_408s_count < opt_random_408s_max
+ && g_random_int_range (0, 100) < opt_random_408s_percentage)
{
emitted_random_408s_count++;
soup_server_message_set_status (msg, SOUP_STATUS_REQUEST_TIMEOUT);
@@ -397,13 +405,12 @@ do_get (OtTrivialHttpd *self,
{
g_autofree char *redir_uri = NULL;
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
+#if !SOUP_CHECK_VERSION(3, 0, 0)
redir_uri = g_strdup_printf ("%s/", soup_uri_get_path (soup_message_get_uri (msg)));
#else
redir_uri = g_strdup_printf ("%s/", g_uri_get_path (soup_server_message_get_uri (msg)));
#endif
- soup_server_message_set_redirect (msg, SOUP_STATUS_MOVED_PERMANENTLY,
- redir_uri);
+ soup_server_message_set_redirect (msg, SOUP_STATUS_MOVED_PERMANENTLY, redir_uri);
}
else
{
@@ -411,7 +418,7 @@ do_get (OtTrivialHttpd *self,
if (fstatat (self->root_dfd, index_realpath, &stbuf, 0) != -1)
{
g_autofree char *index_path = g_strconcat (path, "/index.html", NULL);
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
+#if !SOUP_CHECK_VERSION(3, 0, 0)
do_get (self, server, msg, index_path, context);
#else
do_get (self, server, msg, index_path);
@@ -420,9 +427,8 @@ do_get (OtTrivialHttpd *self,
else
{
GString *listing = get_directory_listing (self->root_dfd, path);
- soup_server_message_set_response (msg, "text/html",
- SOUP_MEMORY_TAKE,
- listing->str, listing->len);
+ soup_server_message_set_response (msg, "text/html", SOUP_MEMORY_TAKE, listing->str,
+ listing->len);
soup_server_message_set_status (msg, SOUP_STATUS_OK);
g_string_free (listing, FALSE);
}
@@ -443,20 +449,23 @@ do_get (OtTrivialHttpd *self,
goto out;
}
- g_autoptr(GMappedFile) mapping = g_mapped_file_new_from_fd (fd, FALSE, NULL);
+ g_autoptr (GMappedFile) mapping = g_mapped_file_new_from_fd (fd, FALSE, NULL);
if (!mapping)
{
soup_server_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
goto out;
}
- (void) close (fd); fd = -1;
+ (void)close (fd);
+ fd = -1;
/* Send caching headers */
- g_autoptr(GDateTime) last_modified = g_date_time_new_from_unix_utc (stbuf.st_mtim.tv_sec);
+ g_autoptr (GDateTime) last_modified = g_date_time_new_from_unix_utc (stbuf.st_mtim.tv_sec);
if (last_modified != NULL)
{
- g_autofree gchar *formatted = g_date_time_format (last_modified, "%a, %d %b %Y %H:%M:%S GMT");
- soup_message_headers_append (soup_server_message_get_response_headers (msg), "Last-Modified", formatted);
+ g_autofree gchar *formatted
+ = g_date_time_format (last_modified, "%a, %d %b %Y %H:%M:%S GMT");
+ soup_message_headers_append (soup_server_message_get_response_headers (msg),
+ "Last-Modified", formatted);
}
g_autofree gchar *etag = calculate_etag (mapping);
@@ -471,12 +480,14 @@ do_get (OtTrivialHttpd *self,
gboolean have_ranges;
file_size = g_mapped_file_get_length (mapping);
- have_ranges = soup_message_headers_get_ranges(soup_server_message_get_request_headers (msg), file_size, &ranges, &ranges_length);
+ have_ranges = soup_message_headers_get_ranges (
+ soup_server_message_get_request_headers (msg), file_size, &ranges, &ranges_length);
if (opt_force_ranges && !have_ranges && g_strrstr (path, "/objects") != NULL)
{
GSocket *sock;
- buffer_length = file_size/2;
- soup_message_headers_set_content_length (soup_server_message_get_response_headers (msg), file_size);
+ buffer_length = file_size / 2;
+ soup_message_headers_set_content_length (
+ soup_server_message_get_response_headers (msg), file_size);
soup_message_headers_append (soup_server_message_get_response_headers (msg),
"Connection", "close");
@@ -485,7 +496,7 @@ do_get (OtTrivialHttpd *self,
* the declared Content-Length. Instead, we
* forcibly close the socket at that point.
*/
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
+#if !SOUP_CHECK_VERSION(3, 0, 0)
sock = soup_client_context_get_gsocket (context);
#else
sock = soup_server_message_get_socket (msg);
@@ -500,19 +511,20 @@ do_get (OtTrivialHttpd *self,
if (ranges_length > 0 && ranges[0].start >= file_size)
{
soup_server_message_set_status (msg, SOUP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE);
- soup_message_headers_free_ranges (soup_server_message_get_request_headers (msg), ranges);
+ soup_message_headers_free_ranges (soup_server_message_get_request_headers (msg),
+ ranges);
goto out;
}
- soup_message_headers_free_ranges (soup_server_message_get_request_headers (msg), ranges);
+ soup_message_headers_free_ranges (soup_server_message_get_request_headers (msg),
+ ranges);
}
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
+#if !SOUP_CHECK_VERSION(3, 0, 0)
if (buffer_length > 0)
{
SoupBuffer *buffer;
buffer = soup_buffer_new_with_owner (g_mapped_file_get_contents (mapping),
- buffer_length,
- g_mapped_file_ref (mapping),
+ buffer_length, g_mapped_file_ref (mapping),
(GDestroyNotify)g_mapped_file_unref);
soup_message_body_append_buffer (msg->response_body, buffer);
soup_buffer_free (buffer);
@@ -546,10 +558,10 @@ do_get (OtTrivialHttpd *self,
}
/* Check client’s caching headers. */
- const gchar *if_modified_since = soup_message_headers_get_one (soup_server_message_get_request_headers (msg),
- "If-Modified-Since");
- const gchar *if_none_match = soup_message_headers_get_one (soup_server_message_get_request_headers (msg),
- "If-None-Match");
+ const gchar *if_modified_since = soup_message_headers_get_one (
+ soup_server_message_get_request_headers (msg), "If-Modified-Since");
+ const gchar *if_none_match = soup_message_headers_get_one (
+ soup_server_message_get_request_headers (msg), "If-None-Match");
if (if_none_match != NULL && etag != NULL)
{
@@ -565,18 +577,19 @@ do_get (OtTrivialHttpd *self,
}
else if (if_modified_since != NULL && last_modified != NULL)
{
- g_autoptr(GDateTime) if_modified_since_dt = NULL;
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
+ g_autoptr (GDateTime) if_modified_since_dt = NULL;
+#if !SOUP_CHECK_VERSION(3, 0, 0)
SoupDate *if_modified_since_sd = soup_date_new_from_string (if_modified_since);
if (if_modified_since_sd != NULL)
- if_modified_since_dt = g_date_time_new_from_unix_utc (soup_date_to_time_t (if_modified_since_sd));
+ if_modified_since_dt
+ = g_date_time_new_from_unix_utc (soup_date_to_time_t (if_modified_since_sd));
#else
if_modified_since_dt = soup_date_time_new_from_http_string (if_modified_since);
#endif
- if (if_modified_since_dt != NULL &&
- g_date_time_compare (last_modified, if_modified_since_dt) <= 0)
+ if (if_modified_since_dt != NULL
+ && g_date_time_compare (last_modified, if_modified_since_dt) <= 0)
{
soup_server_message_set_status (msg, SOUP_STATUS_NOT_MODIFIED);
soup_message_body_truncate (soup_server_message_get_response_body (msg));
@@ -591,16 +604,13 @@ do_get (OtTrivialHttpd *self,
soup_server_message_set_status (msg, SOUP_STATUS_OK);
}
}
- out:
+out:
{
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
+#if !SOUP_CHECK_VERSION(3, 0, 0)
guint status = 0;
g_autofree gchar *reason = NULL;
- g_object_get (msg,
- "status-code", &status,
- "reason-phrase", &reason,
- NULL);
+ g_object_get (msg, "status-code", &status, "reason-phrase", &reason, NULL);
#else
guint status = soup_server_message_get_status (msg);
const char *reason = soup_server_message_get_reason_phrase (msg);
@@ -612,20 +622,19 @@ do_get (OtTrivialHttpd *self,
}
static void
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
-httpd_callback (SoupServer *server, SoupServerMessage *msg,
- const char *path, GHashTable *query,
+#if !SOUP_CHECK_VERSION(3, 0, 0)
+httpd_callback (SoupServer *server, SoupServerMessage *msg, const char *path, GHashTable *query,
SoupClientContext *context, gpointer data)
#else
-httpd_callback (SoupServer *server, SoupServerMessage *msg,
- const char *path, GHashTable *query, gpointer data)
+httpd_callback (SoupServer *server, SoupServerMessage *msg, const char *path, GHashTable *query,
+ gpointer data)
#endif
{
OtTrivialHttpd *self = data;
const char *meth = soup_server_message_get_method (msg);
- if (!strcmp (meth, "GET") || !strcmp(meth, "HEAD"))
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
+ if (!strcmp (meth, "GET") || !strcmp (meth, "HEAD"))
+#if !SOUP_CHECK_VERSION(3, 0, 0)
do_get (self, server, msg, path, context);
#else
do_get (self, server, msg, path);
@@ -635,17 +644,14 @@ httpd_callback (SoupServer *server, SoupServerMessage *msg,
}
static gboolean
-basic_auth_callback (SoupAuthDomain *auth_domain, SoupServerMessage *msg,
- const char *username, const char *password, gpointer data)
+basic_auth_callback (SoupAuthDomain *auth_domain, SoupServerMessage *msg, const char *username,
+ const char *password, gpointer data)
{
- return g_str_equal (username, "foouser") && g_str_equal (password, "barpw");
+ return g_str_equal (username, "foouser") && g_str_equal (password, "barpw");
}
static void
-on_dir_changed (GFileMonitor *mon,
- GFile *file,
- GFile *other,
- GFileMonitorEvent event,
+on_dir_changed (GFileMonitor *mon, GFile *file, GFile *other, GFileMonitorEvent event,
gpointer user_data)
{
OtTrivialHttpd *self = user_data;
@@ -662,13 +668,15 @@ static gboolean
run (int argc, char **argv, GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
- g_autoptr(GOptionContext) context = NULL;
+ g_autoptr (GOptionContext) context = NULL;
const char *dirpath;
- OtTrivialHttpd appstruct = { 0, };
+ OtTrivialHttpd appstruct = {
+ 0,
+ };
OtTrivialHttpd *app = &appstruct;
int pipefd[2] = { -1, -1 };
glnx_unref_object SoupServer *server = NULL;
- g_autoptr(GFileMonitor) dirmon = NULL;
+ g_autoptr (GFileMonitor) dirmon = NULL;
context = g_option_context_new ("[DIR] - Simple webserver");
g_option_context_add_main_entries (context, options, NULL);
@@ -688,21 +696,22 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
if (!(opt_random_500s_percentage >= 0 && opt_random_500s_percentage <= 99))
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid --random-500s=%u", opt_random_500s_percentage);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Invalid --random-500s=%u",
+ opt_random_500s_percentage);
goto out;
}
if (!(opt_random_408s_percentage >= 0 && opt_random_408s_percentage <= 99))
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid --random-408s=%u", opt_random_408s_percentage);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Invalid --random-408s=%u",
+ opt_random_408s_percentage);
goto out;
}
if (opt_daemonize && (g_strcmp0 (opt_log, "-") == 0))
{
- ot_util_usage_error (context, "Cannot use --log-file=- and --daemonize at the same time", error);
+ ot_util_usage_error (context, "Cannot use --log-file=- and --daemonize at the same time",
+ error);
goto out;
}
@@ -719,7 +728,7 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
goto out;
}
- pid_t pid = fork();
+ pid_t pid = fork ();
if (pid == -1)
{
glnx_set_error_from_errno (error);
@@ -784,14 +793,11 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
}
else
{
- g_autoptr(GFile) log_file = NULL;
- GFileOutputStream* log_stream;
+ g_autoptr (GFile) log_file = NULL;
+ GFileOutputStream *log_stream;
log_file = g_file_new_for_path (opt_log);
- log_stream = g_file_create (log_file,
- G_FILE_CREATE_PRIVATE,
- cancellable,
- error);
+ log_stream = g_file_create (log_file, G_FILE_CREATE_PRIVATE, cancellable, error);
if (!log_stream)
goto out;
stream = G_OUTPUT_STREAM (log_stream);
@@ -805,22 +811,19 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
if (!soup_server_listen_all (server, opt_port, 0, error))
goto out;
#else
- server = soup_server_new (SOUP_SERVER_PORT, opt_port,
- SOUP_SERVER_SERVER_HEADER, "ostree-httpd ",
+ server = soup_server_new (SOUP_SERVER_PORT, opt_port, SOUP_SERVER_SERVER_HEADER, "ostree-httpd ",
NULL);
#endif
if (opt_require_basic_auth)
{
-#if ! SOUP_CHECK_VERSION (3, 0, 0)
- glnx_unref_object SoupAuthDomain *auth_domain =
- soup_auth_domain_basic_new (SOUP_AUTH_DOMAIN_REALM, "auth-test",
- SOUP_AUTH_DOMAIN_ADD_PATH, "/",
- SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, basic_auth_callback,
- NULL);
+#if !SOUP_CHECK_VERSION(3, 0, 0)
+ glnx_unref_object SoupAuthDomain *auth_domain = soup_auth_domain_basic_new (
+ SOUP_AUTH_DOMAIN_REALM, "auth-test", SOUP_AUTH_DOMAIN_ADD_PATH, "/",
+ SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, basic_auth_callback, NULL);
#else
- glnx_unref_object SoupAuthDomain *auth_domain =
- soup_auth_domain_basic_new ("realm", "auth-test", NULL);
+ glnx_unref_object SoupAuthDomain *auth_domain
+ = soup_auth_domain_basic_new ("realm", "auth-test", NULL);
soup_auth_domain_add_path (auth_domain, "/");
soup_auth_domain_basic_set_auth_callback (auth_domain, basic_auth_callback, NULL, NULL);
#endif
@@ -833,8 +836,8 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
g_autofree char *portstr = NULL;
#if SOUP_CHECK_VERSION(2, 48, 0)
GSList *listeners = soup_server_get_listeners (server);
- g_autoptr(GSocket) listener = NULL;
- g_autoptr(GSocketAddress) addr = NULL;
+ g_autoptr (GSocket) listener = NULL;
+ g_autoptr (GSocketAddress) addr = NULL;
g_assert (listeners);
listener = g_object_ref (listeners->data);
@@ -846,7 +849,8 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
g_assert (G_IS_INET_SOCKET_ADDRESS (addr));
- portstr = g_strdup_printf ("%u\n", g_inet_socket_address_get_port ((GInetSocketAddress*)addr));
+ portstr
+ = g_strdup_printf ("%u\n", g_inet_socket_address_get_port ((GInetSocketAddress *)addr));
#else
portstr = g_strdup_printf ("%u\n", soup_server_get_port (server));
#endif
@@ -881,17 +885,17 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
goto out;
}
/* Daemonising: close stdout/stderr so $() et al work on us */
- if (freopen("/dev/null", "r", stdin) == NULL)
+ if (freopen ("/dev/null", "r", stdin) == NULL)
{
glnx_set_prefix_error_from_errno (error, "%s", "freopen: ");
goto out;
}
- if (freopen("/dev/null", "w", stdout) == NULL)
+ if (freopen ("/dev/null", "w", stdout) == NULL)
{
glnx_set_prefix_error_from_errno (error, "%s", "freopen: ");
goto out;
}
- if (freopen("/dev/null", "w", stderr) == NULL)
+ if (freopen ("/dev/null", "w", stderr) == NULL)
{
glnx_set_prefix_error_from_errno (error, "%s", "freopen: ");
goto out;
@@ -902,14 +906,12 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
if (opt_autoexit)
{
gboolean is_symlink = FALSE;
- g_autoptr(GFile) root = NULL;
- g_autoptr(GFileInfo) info = NULL;
+ g_autoptr (GFile) root = NULL;
+ g_autoptr (GFileInfo) info = NULL;
root = g_file_new_for_path (dirpath);
- info = g_file_query_info (root,
- G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- cancellable, error);
+ info = g_file_query_info (root, G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error);
if (!info)
goto out;
@@ -929,7 +931,7 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
g_main_context_iteration (NULL, TRUE);
ret = TRUE;
- out:
+out:
if (pipefd[0] >= 0)
{
/* Read end in the parent. This should only be open on errors. */
@@ -942,21 +944,20 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
g_assert_false (ret);
guint8 buf = 1;
g_debug ("Writing %u to parent", buf);
- (void) TEMP_FAILURE_RETRY (write (pipefd[1], &buf, 1));
+ (void)TEMP_FAILURE_RETRY (write (pipefd[1], &buf, 1));
glnx_close_fd (&pipefd[1]);
}
if (app->root_dfd != -1)
- (void) close (app->root_dfd);
+ (void)close (app->root_dfd);
g_clear_object (&app->log);
return ret;
}
int
-main (int argc,
- char **argv)
+main (int argc, char **argv)
{
- g_autoptr(GError) error = NULL;
- g_autoptr(GCancellable) cancellable = NULL;
+ g_autoptr (GError) error = NULL;
+ g_autoptr (GCancellable) cancellable = NULL;
setlocale (LC_ALL, "");
@@ -964,10 +965,8 @@ main (int argc,
if (!run (argc, argv, cancellable, &error))
{
- g_printerr ("%s%serror:%s%s %s\n",
- ot_get_red_start (), ot_get_bold_start (),
- ot_get_bold_end (), ot_get_red_end (),
- error->message);
+ g_printerr ("%s%serror:%s%s %s\n", ot_get_red_start (), ot_get_bold_start (),
+ ot_get_bold_end (), ot_get_red_end (), error->message);
return 1;
}
diff --git a/src/ostree/ot-admin-builtin-boot-complete.c b/src/ostree/ot-admin-builtin-boot-complete.c
index 5d50c028..4599606c 100644
--- a/src/ostree/ot-admin-builtin-boot-complete.c
+++ b/src/ostree/ot-admin-builtin-boot-complete.c
@@ -21,20 +21,19 @@
#include <stdlib.h>
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
#include "ostree-cmd-private.h"
-static GOptionEntry options[] = {
- { NULL }
-};
+static GOptionEntry options[] = { { NULL } };
gboolean
-ot_admin_builtin_boot_complete (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_boot_complete (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
/* Just a sanity check; we shouldn't be called outside of the service though.
*/
@@ -44,14 +43,14 @@ ot_admin_builtin_boot_complete (int argc, char **argv, OstreeCommandInvocation *
// We must have been invoked via systemd which should have set up a mount namespace.
g_assert (getenv ("INVOCATION_ID"));
- g_autoptr(GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, invocation, &sysroot,
+ cancellable, error))
return FALSE;
- if (!ostree_cmd__private__()->ostree_boot_complete (sysroot, cancellable, error))
+ if (!ostree_cmd__private__ ()->ostree_boot_complete (sysroot, cancellable, error))
return FALSE;
return TRUE;
diff --git a/src/ostree/ot-admin-builtin-cleanup.c b/src/ostree/ot-admin-builtin-cleanup.c
index 94d3224c..b2d34231 100644
--- a/src/ostree/ot-admin-builtin-cleanup.c
+++ b/src/ostree/ot-admin-builtin-cleanup.c
@@ -21,26 +21,25 @@
#include "config.h"
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-main.h"
#include <glib/gi18n.h>
-static GOptionEntry options[] = {
- { NULL }
-};
+static GOptionEntry options[] = { { NULL } };
gboolean
-ot_admin_builtin_cleanup (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_cleanup (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("");
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, invocation, &sysroot,
+ cancellable, error))
return FALSE;
if (!ostree_sysroot_cleanup (sysroot, cancellable, error))
diff --git a/src/ostree/ot-admin-builtin-deploy.c b/src/ostree/ot-admin-builtin-deploy.c
index 28a5d9e8..00204ffd 100644
--- a/src/ostree/ot-admin-builtin-deploy.c
+++ b/src/ostree/ot-admin-builtin-deploy.c
@@ -23,10 +23,10 @@
#include "ostree-sysroot-private.h"
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
#include <glib/gi18n.h>
@@ -49,35 +49,51 @@ static gboolean opt_kernel_arg_none;
static char **opt_overlay_initrds;
static GOptionEntry options[] = {
- { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Use a different operating system root than the current one", "OSNAME" },
- { "origin-file", 0, 0, G_OPTION_ARG_FILENAME, &opt_origin_path, "Specify origin file", "FILENAME" },
- { "no-prune", 0, 0, G_OPTION_ARG_NONE, &opt_no_prune, "Don't prune the repo when done", NULL},
- { "no-merge", 0, 0, G_OPTION_ARG_NONE, &opt_no_merge, "Do not apply configuration (/etc and kernel arguments) from booted deployment", NULL},
+ { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname,
+ "Use a different operating system root than the current one", "OSNAME" },
+ { "origin-file", 0, 0, G_OPTION_ARG_FILENAME, &opt_origin_path, "Specify origin file",
+ "FILENAME" },
+ { "no-prune", 0, 0, G_OPTION_ARG_NONE, &opt_no_prune, "Don't prune the repo when done", NULL },
+ { "no-merge", 0, 0, G_OPTION_ARG_NONE, &opt_no_merge,
+ "Do not apply configuration (/etc and kernel arguments) from booted deployment", NULL },
{ "retain", 0, 0, G_OPTION_ARG_NONE, &opt_retain, "Do not delete previous deployments", NULL },
{ "stage", 0, 0, G_OPTION_ARG_NONE, &opt_stage, "Complete deployment at OS shutdown", NULL },
- { "lock-finalization", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_lock_finalization, "Prevent automatic deployment finalization on shutdown", NULL },
- { "retain-pending", 0, 0, G_OPTION_ARG_NONE, &opt_retain_pending, "Do not delete pending deployments", NULL },
- { "retain-rollback", 0, 0, G_OPTION_ARG_NONE, &opt_retain_rollback, "Do not delete rollback deployments", NULL },
- { "not-as-default", 0, 0, G_OPTION_ARG_NONE, &opt_not_as_default, "Append rather than prepend new deployment", NULL },
- { "karg-proc-cmdline", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_proc_cmdline, "Import current /proc/cmdline", NULL },
- { "karg", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv, "Set kernel argument, like root=/dev/sda1; this overrides any earlier argument with the same name", "NAME=VALUE" },
- { "karg-append", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv_append, "Append kernel argument; useful with e.g. console= that can be used multiple times", "NAME=VALUE" },
- { "karg-none", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_arg_none, "Do not import kernel arguments", NULL },
- { "karg-delete", 0, 0, G_OPTION_ARG_STRING, &opt_kernel_argv_delete, "Delete kernel argument if exists", "NAME=VALUE" },
- { "overlay-initrd", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_overlay_initrds, "Overlay iniramfs file", "FILE" },
+ { "lock-finalization", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_lock_finalization,
+ "Prevent automatic deployment finalization on shutdown", NULL },
+ { "retain-pending", 0, 0, G_OPTION_ARG_NONE, &opt_retain_pending,
+ "Do not delete pending deployments", NULL },
+ { "retain-rollback", 0, 0, G_OPTION_ARG_NONE, &opt_retain_rollback,
+ "Do not delete rollback deployments", NULL },
+ { "not-as-default", 0, 0, G_OPTION_ARG_NONE, &opt_not_as_default,
+ "Append rather than prepend new deployment", NULL },
+ { "karg-proc-cmdline", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_proc_cmdline,
+ "Import current /proc/cmdline", NULL },
+ { "karg", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv,
+ "Set kernel argument, like root=/dev/sda1; this overrides any earlier argument with the same "
+ "name",
+ "NAME=VALUE" },
+ { "karg-append", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv_append,
+ "Append kernel argument; useful with e.g. console= that can be used multiple times",
+ "NAME=VALUE" },
+ { "karg-none", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_arg_none, "Do not import kernel arguments",
+ NULL },
+ { "karg-delete", 0, 0, G_OPTION_ARG_STRING, &opt_kernel_argv_delete,
+ "Delete kernel argument if exists", "NAME=VALUE" },
+ { "overlay-initrd", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_overlay_initrds,
+ "Overlay iniramfs file", "FILE" },
{ NULL }
};
gboolean
-ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context =
- g_option_context_new ("REFSPEC");
+ g_autoptr (GOptionContext) context = g_option_context_new ("REFSPEC");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, invocation, &sysroot,
+ cancellable, error))
return FALSE;
if (argc < 2)
@@ -88,7 +104,8 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
if (opt_kernel_proc_cmdline && opt_kernel_arg_none)
{
- ot_util_usage_error (context, "Can't specify both --karg-proc-cmdline and --karg-none", error);
+ ot_util_usage_error (context, "Can't specify both --karg-proc-cmdline and --karg-none",
+ error);
return FALSE;
}
@@ -111,11 +128,10 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
/* Find the currently booted deployment, if any; we will ensure it
* is present in the new deployment list.
*/
- if (!ot_admin_require_booted_deployment_or_osname (sysroot, opt_osname,
- cancellable, error))
+ if (!ot_admin_require_booted_deployment_or_osname (sysroot, opt_osname, cancellable, error))
return glnx_prefix_error (error, "Looking for booted deployment");
- g_autoptr(GKeyFile) origin = NULL;
+ g_autoptr (GKeyFile) origin = NULL;
if (opt_origin_path)
{
origin = g_key_file_new ();
@@ -132,8 +148,8 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
if (!ostree_repo_resolve_rev (repo, refspec, FALSE, &revision, error))
return FALSE;
- g_autoptr(OstreeDeployment) merge_deployment =
- opt_no_merge ? NULL : ostree_sysroot_get_merge_deployment (sysroot, opt_osname);
+ g_autoptr (OstreeDeployment) merge_deployment
+ = opt_no_merge ? NULL : ostree_sysroot_get_merge_deployment (sysroot, opt_osname);
/* Here we perform cleanup of any leftover data from previous
* partial failures. This avoids having to call
@@ -148,7 +164,7 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
/* Initial set of kernel arguments; the default is to use the merge
* deployment, unless --karg-none or --karg-proc-cmdline are specified.
*/
- g_autoptr(OstreeKernelArgs) kargs = NULL;
+ g_autoptr (OstreeKernelArgs) kargs = NULL;
if (opt_kernel_arg_none)
{
kargs = ostree_kernel_args_new ();
@@ -159,10 +175,12 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
if (!ostree_kernel_args_append_proc_cmdline (kargs, cancellable, error))
return FALSE;
}
- else if (merge_deployment && (opt_kernel_argv || opt_kernel_argv_append || opt_kernel_argv_delete))
+ else if (merge_deployment
+ && (opt_kernel_argv || opt_kernel_argv_append || opt_kernel_argv_delete))
{
OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (merge_deployment);
- g_auto(GStrv) previous_args = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1);
+ g_auto (GStrv) previous_args
+ = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1);
kargs = ostree_kernel_args_new ();
ostree_kernel_args_append_argv (kargs, previous_args);
}
@@ -191,7 +209,7 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
return FALSE;
}
- g_autoptr(GPtrArray) overlay_initrd_chksums = NULL;
+ g_autoptr (GPtrArray) overlay_initrd_chksums = NULL;
for (char **it = opt_overlay_initrds; it && *it; it++)
{
const char *path = *it;
@@ -212,14 +230,14 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
if (overlay_initrd_chksums)
g_ptr_array_add (overlay_initrd_chksums, NULL);
- g_auto(GStrv) kargs_strv = kargs ? ostree_kernel_args_to_strv (kargs) : NULL;
+ g_auto (GStrv) kargs_strv = kargs ? ostree_kernel_args_to_strv (kargs) : NULL;
OstreeSysrootDeployTreeOpts opts = {
.override_kernel_argv = kargs_strv,
- .overlay_initrds = overlay_initrd_chksums ? (char**)overlay_initrd_chksums->pdata : NULL,
+ .overlay_initrds = overlay_initrd_chksums ? (char **)overlay_initrd_chksums->pdata : NULL,
};
- g_autoptr(OstreeDeployment) new_deployment = NULL;
+ g_autoptr (OstreeDeployment) new_deployment = NULL;
if (opt_stage)
{
if (opt_retain_pending || opt_retain_rollback)
@@ -243,16 +261,15 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
/* use old API if we can to exercise it in CI */
if (!overlay_initrd_chksums)
{
- if (!ostree_sysroot_stage_tree (sysroot, opt_osname, revision, origin,
- merge_deployment, kargs_strv, &new_deployment,
- cancellable, error))
+ if (!ostree_sysroot_stage_tree (sysroot, opt_osname, revision, origin, merge_deployment,
+ kargs_strv, &new_deployment, cancellable, error))
return FALSE;
}
else
{
- if (!ostree_sysroot_stage_tree_with_options (sysroot, opt_osname, revision,
- origin, merge_deployment, &opts,
- &new_deployment, cancellable, error))
+ if (!ostree_sysroot_stage_tree_with_options (sysroot, opt_osname, revision, origin,
+ merge_deployment, &opts, &new_deployment,
+ cancellable, error))
return FALSE;
}
g_assert (new_deployment);
@@ -262,22 +279,21 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
/* use old API if we can to exercise it in CI */
if (!overlay_initrd_chksums)
{
- if (!ostree_sysroot_deploy_tree (sysroot, opt_osname, revision, origin,
- merge_deployment, kargs_strv, &new_deployment,
- cancellable, error))
+ if (!ostree_sysroot_deploy_tree (sysroot, opt_osname, revision, origin, merge_deployment,
+ kargs_strv, &new_deployment, cancellable, error))
return FALSE;
}
else
{
- if (!ostree_sysroot_deploy_tree_with_options (sysroot, opt_osname, revision,
- origin, merge_deployment, &opts,
- &new_deployment, cancellable,
- error))
+ if (!ostree_sysroot_deploy_tree_with_options (sysroot, opt_osname, revision, origin,
+ merge_deployment, &opts, &new_deployment,
+ cancellable, error))
return FALSE;
}
g_assert (new_deployment);
- OstreeSysrootSimpleWriteDeploymentFlags flags = OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN;
+ OstreeSysrootSimpleWriteDeploymentFlags flags
+ = OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN;
if (opt_retain)
flags |= OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN;
else
diff --git a/src/ostree/ot-admin-builtin-diff.c b/src/ostree/ot-admin-builtin-diff.c
index 73e49d4e..8a123a22 100644
--- a/src/ostree/ot-admin-builtin-diff.c
+++ b/src/ostree/ot-admin-builtin-diff.c
@@ -21,58 +21,59 @@
#include "config.h"
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-main.h"
#include <glib/gi18n.h>
static char *opt_osname;
-static GOptionEntry options[] = {
- { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Use a different operating system root than the current one", "OSNAME" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname,
+ "Use a different operating system root than the current one", "OSNAME" },
+ { NULL } };
gboolean
-ot_admin_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("");
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER
+ | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
invocation, &sysroot, cancellable, error))
return FALSE;
- if (!ot_admin_require_booted_deployment_or_osname (sysroot, opt_osname,
- cancellable, error))
+ if (!ot_admin_require_booted_deployment_or_osname (sysroot, opt_osname, cancellable, error))
return FALSE;
- g_autoptr(OstreeDeployment) deployment = NULL;
+ g_autoptr (OstreeDeployment) deployment = NULL;
if (opt_osname != NULL)
{
deployment = ostree_sysroot_get_merge_deployment (sysroot, opt_osname);
if (deployment == NULL)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
- "No deployment for OS '%s'", opt_osname);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "No deployment for OS '%s'",
+ opt_osname);
return FALSE;
}
}
else
deployment = g_object_ref (ostree_sysroot_get_booted_deployment (sysroot));
- g_autoptr(GFile) deployment_dir = ostree_sysroot_get_deployment_directory (sysroot, deployment);
- g_autoptr(GFile) orig_etc_path = g_file_resolve_relative_path (deployment_dir, "usr/etc");
- g_autoptr(GFile) new_etc_path = g_file_resolve_relative_path (deployment_dir, "etc");
- g_autoptr(GPtrArray) modified = g_ptr_array_new_with_free_func ((GDestroyNotify) ostree_diff_item_unref);
- g_autoptr(GPtrArray) removed = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- g_autoptr(GPtrArray) added = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- if (!ostree_diff_dirs (OSTREE_DIFF_FLAGS_IGNORE_XATTRS,
- orig_etc_path, new_etc_path, modified, removed, added,
- cancellable, error))
+ g_autoptr (GFile) deployment_dir = ostree_sysroot_get_deployment_directory (sysroot, deployment);
+ g_autoptr (GFile) orig_etc_path = g_file_resolve_relative_path (deployment_dir, "usr/etc");
+ g_autoptr (GFile) new_etc_path = g_file_resolve_relative_path (deployment_dir, "etc");
+ g_autoptr (GPtrArray) modified
+ = g_ptr_array_new_with_free_func ((GDestroyNotify)ostree_diff_item_unref);
+ g_autoptr (GPtrArray) removed = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
+ g_autoptr (GPtrArray) added = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
+ if (!ostree_diff_dirs (OSTREE_DIFF_FLAGS_IGNORE_XATTRS, orig_etc_path, new_etc_path, modified,
+ removed, added, cancellable, error))
return FALSE;
ostree_diff_print (orig_etc_path, new_etc_path, modified, removed, added);
diff --git a/src/ostree/ot-admin-builtin-finalize-staged.c b/src/ostree/ot-admin-builtin-finalize-staged.c
index e408f447..a60f4687 100644
--- a/src/ostree/ot-admin-builtin-finalize-staged.c
+++ b/src/ostree/ot-admin-builtin-finalize-staged.c
@@ -25,10 +25,10 @@
#include <signal.h>
#include <stdlib.h>
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
#include "ostree-cmd-private.h"
@@ -36,16 +36,16 @@
static gboolean opt_hold;
-static GOptionEntry options[] = {
- { "hold", 0, 0, G_OPTION_ARG_NONE, &opt_hold, "Hold /boot open during finalization", NULL },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "hold", 0, 0, G_OPTION_ARG_NONE, &opt_hold, "Hold /boot open during finalization", NULL },
+ { NULL } };
/* Called by ostree-finalize-staged.service, and in turn
* invokes a cmdprivate function inside the shared library.
*/
gboolean
-ot_admin_builtin_finalize_staged (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_finalize_staged (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
/* Just a sanity check; we shouldn't be called outside of the service though.
*/
@@ -53,23 +53,23 @@ ot_admin_builtin_finalize_staged (int argc, char **argv, OstreeCommandInvocation
if (fstatat (AT_FDCWD, OSTREE_PATH_BOOTED, &stbuf, 0) < 0)
return TRUE;
- g_autoptr(GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
+ g_autoptr (OstreeSysroot) sysroot = NULL;
/* First parse the args without loading the sysroot to see what options are
* set. */
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_NO_LOAD,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_NO_LOAD, invocation, &sysroot,
+ cancellable, error))
return FALSE;
if (opt_hold)
{
/* Load the sysroot unlocked so that a separate namespace isn't
* created. */
- if (!ostree_admin_sysroot_load (sysroot,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
- cancellable, error))
+ if (!ostree_admin_sysroot_load (
+ sysroot, OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
+ cancellable, error))
return FALSE;
/* In case it's an automount, open /boot so that the automount doesn't
@@ -93,12 +93,11 @@ ot_admin_builtin_finalize_staged (int argc, char **argv, OstreeCommandInvocation
{
/* Load the sysroot with the normal flags and actually finalize the
* deployment. */
- if (!ostree_admin_sysroot_load (sysroot,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
- cancellable, error))
+ if (!ostree_admin_sysroot_load (sysroot, OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, cancellable,
+ error))
return FALSE;
- if (!ostree_cmd__private__()->ostree_finalize_staged (sysroot, cancellable, error))
+ if (!ostree_cmd__private__ ()->ostree_finalize_staged (sysroot, cancellable, error))
return FALSE;
}
diff --git a/src/ostree/ot-admin-builtin-init-fs.c b/src/ostree/ot-admin-builtin-init-fs.c
index 87f46cb9..bf00f19e 100644
--- a/src/ostree/ot-admin-builtin-init-fs.c
+++ b/src/ostree/ot-admin-builtin-init-fs.c
@@ -21,29 +21,29 @@
#include "config.h"
-#include "ot-main.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
+#include "ot-main.h"
#include "otutil.h"
#include <glib/gi18n.h>
static gboolean opt_modern;
-static GOptionEntry options[] = {
- { "modern", 0, 0, G_OPTION_ARG_NONE, &opt_modern, "Only create /boot and /ostree", NULL },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "modern", 0, 0, G_OPTION_ARG_NONE, &opt_modern, "Only create /boot and /ostree", NULL },
+ { NULL } };
gboolean
-ot_admin_builtin_init_fs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_init_fs (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("PATH");
+ g_autoptr (GOptionContext) context = g_option_context_new ("PATH");
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER |
- OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED |
- OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER
+ | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED
+ | OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
invocation, NULL, cancellable, error))
return FALSE;
@@ -70,20 +70,18 @@ ot_admin_builtin_init_fs (int argc, char **argv, OstreeCommandInvocation *invoca
*/
if (!opt_modern)
{
- const char *traditional_toplevels[] = {"boot", "dev", "home", "proc", "run", "sys"};
+ const char *traditional_toplevels[] = { "boot", "dev", "home", "proc", "run", "sys" };
for (guint i = 0; i < G_N_ELEMENTS (traditional_toplevels); i++)
{
- if (!glnx_shutil_mkdir_p_at (root_dfd, traditional_toplevels[i], 0755,
- cancellable, error))
+ if (!glnx_shutil_mkdir_p_at (root_dfd, traditional_toplevels[i], 0755, cancellable,
+ error))
return FALSE;
}
- if (!glnx_shutil_mkdir_p_at (root_dfd, "root", 0700,
- cancellable, error))
+ if (!glnx_shutil_mkdir_p_at (root_dfd, "root", 0700, cancellable, error))
return FALSE;
- if (!glnx_shutil_mkdir_p_at (root_dfd, "tmp", 01777,
- cancellable, error))
+ if (!glnx_shutil_mkdir_p_at (root_dfd, "tmp", 01777, cancellable, error))
return FALSE;
if (fchmodat (root_dfd, "tmp", 01777, 0) == -1)
{
@@ -92,8 +90,8 @@ ot_admin_builtin_init_fs (int argc, char **argv, OstreeCommandInvocation *invoca
}
}
- g_autoptr(GFile) dir = g_file_new_for_path (sysroot_path);
- g_autoptr(OstreeSysroot) sysroot = ostree_sysroot_new (dir);
+ g_autoptr (GFile) dir = g_file_new_for_path (sysroot_path);
+ g_autoptr (OstreeSysroot) sysroot = ostree_sysroot_new (dir);
if (!ostree_sysroot_ensure_initialized (sysroot, cancellable, error))
return FALSE;
diff --git a/src/ostree/ot-admin-builtin-instutil.c b/src/ostree/ot-admin-builtin-instutil.c
index b946a96b..d697cb00 100644
--- a/src/ostree/ot-admin-builtin-instutil.c
+++ b/src/ostree/ot-admin-builtin-instutil.c
@@ -19,26 +19,23 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
-#include "ot-admin-instutil-builtins.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-admin-instutil-builtins.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include <glib/gi18n.h>
static OstreeCommand admin_instutil_subcommands[] = {
#ifdef HAVE_SELINUX
{ "selinux-ensure-labeled", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_instutil_builtin_selinux_ensure_labeled,
- "Relabel all or part of a deployment" },
+ ot_admin_instutil_builtin_selinux_ensure_labeled, "Relabel all or part of a deployment" },
#endif
- { "set-kargs", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_instutil_builtin_set_kargs,
- "Set new kernel command line arguments(Not stable)" },
- { "grub2-generate", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_instutil_builtin_grub2_generate,
+ { "set-kargs", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_instutil_builtin_set_kargs,
+ "Set new kernel command line arguments(Not stable)" },
+ { "grub2-generate", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_instutil_builtin_grub2_generate,
"Generate GRUB2 configuration from given BLS entries" },
{ NULL, 0, NULL, NULL }
};
@@ -49,7 +46,7 @@ ostree_admin_instutil_option_context_new_with_commands (void)
OstreeCommand *command = admin_instutil_subcommands;
GOptionContext *context = g_option_context_new ("COMMAND");
- g_autoptr(GString) summary = g_string_new ("Builtin \"admin instutil\" Commands:");
+ g_autoptr (GString) summary = g_string_new ("Builtin \"admin instutil\" Commands:");
while (command->name != NULL)
{
@@ -69,7 +66,8 @@ ostree_admin_instutil_option_context_new_with_commands (void)
}
gboolean
-ot_admin_builtin_instutil (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_instutil (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
const char *subcommand_name = NULL;
int in, out;
@@ -107,13 +105,13 @@ ot_admin_builtin_instutil (int argc, char **argv, OstreeCommandInvocation *invoc
if (!subcommand->name)
{
- g_autoptr(GOptionContext) context =
- ostree_admin_instutil_option_context_new_with_commands ();
+ g_autoptr (GOptionContext) context
+ = ostree_admin_instutil_option_context_new_with_commands ();
/* This will not return for some options (e.g. --version). */
if (ostree_admin_option_context_parse (context, NULL, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
- invocation, NULL, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT, invocation, NULL,
+ cancellable, error))
{
if (subcommand_name == NULL)
{
diff --git a/src/ostree/ot-admin-builtin-kargs.c b/src/ostree/ot-admin-builtin-kargs.c
index 4afef294..c4d440bd 100644
--- a/src/ostree/ot-admin-builtin-kargs.c
+++ b/src/ostree/ot-admin-builtin-kargs.c
@@ -20,10 +20,10 @@
#include "config.h"
-#include "ot-main.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
#include "ot-admin-kargs-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
#include <glib/gi18n.h>
@@ -31,7 +31,7 @@
static OstreeCommand admin_kargs_subcommands[] = {
{ "edit-in-place", OSTREE_BUILTIN_FLAG_NO_REPO | OSTREE_BUILTIN_FLAG_HIDDEN,
ot_admin_kargs_builtin_edit_in_place,
- "Set new kernel command line arguments in place (applies to all deployments by default)" },
+ "Set new kernel command line arguments in place (applies to all deployments by default)" },
{ NULL, 0, NULL, NULL }
};
@@ -41,7 +41,7 @@ ostree_admin_kargs_option_context_new_with_commands (void)
OstreeCommand *command = admin_kargs_subcommands;
GOptionContext *context = g_option_context_new ("COMMAND");
- g_autoptr(GString) summary = g_string_new ("Builtin \"admin kargs\" Commands:");
+ g_autoptr (GString) summary = g_string_new ("Builtin \"admin kargs\" Commands:");
while (command->name != NULL)
{
@@ -61,7 +61,8 @@ ostree_admin_kargs_option_context_new_with_commands (void)
}
gboolean
-ot_admin_builtin_kargs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_kargs (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
const char *subcommand_name = NULL;
int in, out;
@@ -98,13 +99,12 @@ ot_admin_builtin_kargs (int argc, char **argv, OstreeCommandInvocation *invocati
if (!subcommand->name)
{
- g_autoptr(GOptionContext) context =
- ostree_admin_kargs_option_context_new_with_commands ();
+ g_autoptr (GOptionContext) context = ostree_admin_kargs_option_context_new_with_commands ();
/* This will not return for some options (e.g. --version). */
if (ostree_admin_option_context_parse (context, NULL, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
- invocation, NULL, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT, invocation, NULL,
+ cancellable, error))
{
if (subcommand_name == NULL)
{
diff --git a/src/ostree/ot-admin-builtin-os-init.c b/src/ostree/ot-admin-builtin-os-init.c
index 05311532..8588138f 100644
--- a/src/ostree/ot-admin-builtin-os-init.c
+++ b/src/ostree/ot-admin-builtin-os-init.c
@@ -21,25 +21,25 @@
#include "config.h"
-#include "ot-main.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
+#include "ot-main.h"
#include "otutil.h"
#include <glib/gi18n.h>
-static GOptionEntry options[] = {
- { NULL }
-};
+static GOptionEntry options[] = { { NULL } };
gboolean
-ot_admin_builtin_os_init (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_os_init (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("OSNAME");
+ g_autoptr (GOptionContext) context = g_option_context_new ("OSNAME");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER
+ | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
invocation, &sysroot, cancellable, error))
return FALSE;
diff --git a/src/ostree/ot-admin-builtin-pin.c b/src/ostree/ot-admin-builtin-pin.c
index 301e1aab..362df44c 100644
--- a/src/ostree/ot-admin-builtin-pin.c
+++ b/src/ostree/ot-admin-builtin-pin.c
@@ -21,27 +21,26 @@
#include <stdlib.h>
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
static gboolean opt_unpin;
-static GOptionEntry options[] = {
- { "unpin", 'u', 0, G_OPTION_ARG_NONE, &opt_unpin, "Unset pin", NULL },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "unpin", 'u', 0, G_OPTION_ARG_NONE, &opt_unpin, "Unset pin", NULL }, { NULL } };
gboolean
-ot_admin_builtin_pin (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_pin (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("INDEX");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (GOptionContext) context = g_option_context_new ("INDEX");
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, invocation, &sysroot,
+ cancellable, error))
return FALSE;
if (argc < 2)
@@ -62,7 +61,8 @@ ot_admin_builtin_pin (int argc, char **argv, OstreeCommandInvocation *invocation
if (errno == ERANGE)
return glnx_throw (error, "Index too large: %s", deploy_index_str);
- g_autoptr(OstreeDeployment) target_deployment = ot_admin_get_indexed_deployment (sysroot, deploy_index, error);
+ g_autoptr (OstreeDeployment) target_deployment
+ = ot_admin_get_indexed_deployment (sysroot, deploy_index, error);
if (!target_deployment)
return FALSE;
@@ -70,14 +70,17 @@ ot_admin_builtin_pin (int argc, char **argv, OstreeCommandInvocation *invocation
const gboolean desired_pin = !opt_unpin;
if (current_pin == desired_pin)
{
- g_print ("Deployment %s is already %s\n", deploy_index_str, current_pin ? "pinned" : "unpinned");
+ g_print ("Deployment %s is already %s\n", deploy_index_str,
+ current_pin ? "pinned" : "unpinned");
}
else
- {
- if (!ostree_sysroot_deployment_set_pinned (sysroot, target_deployment, desired_pin, error))
- return FALSE;
- g_print ("Deployment %s is now %s\n", deploy_index_str, desired_pin ? "pinned" : "unpinned");
- }
+ {
+ if (!ostree_sysroot_deployment_set_pinned (sysroot, target_deployment, desired_pin,
+ error))
+ return FALSE;
+ g_print ("Deployment %s is now %s\n", deploy_index_str,
+ desired_pin ? "pinned" : "unpinned");
+ }
}
return TRUE;
diff --git a/src/ostree/ot-admin-builtin-set-origin.c b/src/ostree/ot-admin-builtin-set-origin.c
index 91184cd6..84772cce 100644
--- a/src/ostree/ot-admin-builtin-set-origin.c
+++ b/src/ostree/ot-admin-builtin-set-origin.c
@@ -19,42 +19,44 @@
#include "config.h"
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
-#include <unistd.h>
-#include <stdlib.h>
#include <glib/gi18n.h>
+#include <stdlib.h>
+#include <unistd.h>
static int opt_index = -1;
static char **opt_set;
-static GOptionEntry options[] = {
- { "set", 's', 0, G_OPTION_ARG_STRING_ARRAY, &opt_set, "Set config option KEY=VALUE for remote", "KEY=VALUE" },
- { "index", 0, 0, G_OPTION_ARG_INT, &opt_index, "Operate on the deployment INDEX, starting from zero", "INDEX" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "set", 's', 0, G_OPTION_ARG_STRING_ARRAY, &opt_set,
+ "Set config option KEY=VALUE for remote", "KEY=VALUE" },
+ { "index", 0, 0, G_OPTION_ARG_INT, &opt_index,
+ "Operate on the deployment INDEX, starting from zero", "INDEX" },
+ { NULL } };
gboolean
-ot_admin_builtin_set_origin (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_set_origin (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
- g_autoptr(GOptionContext) context = NULL;
+ g_autoptr (GOptionContext) context = NULL;
const char *remotename = NULL;
const char *url = NULL;
const char *branch = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
- g_autoptr(OstreeSysroot) sysroot = NULL;
- g_autoptr(OstreeDeployment) target_deployment = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeDeployment) target_deployment = NULL;
context = g_option_context_new ("REMOTENAME URL [BRANCH]");
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, invocation, &sysroot,
+ cancellable, error))
goto out;
if (argc < 3)
@@ -86,10 +88,10 @@ ot_admin_builtin_set_origin (int argc, char **argv, OstreeCommandInvocation *inv
goto out;
}
- { char **iter;
- g_autoptr(GVariantBuilder) optbuilder =
- g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
- g_autoptr(GVariant) remote_options = NULL;
+ {
+ char **iter;
+ g_autoptr (GVariantBuilder) optbuilder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
+ g_autoptr (GVariant) remote_options = NULL;
for (iter = opt_set; iter && *iter; iter++)
{
@@ -100,21 +102,19 @@ ot_admin_builtin_set_origin (int argc, char **argv, OstreeCommandInvocation *inv
if (!ot_parse_keyvalue (keyvalue, &subkey, &subvalue, error))
goto out;
- g_variant_builder_add (optbuilder, "{s@v}",
- subkey, g_variant_new_variant (g_variant_new_string (subvalue)));
+ g_variant_builder_add (optbuilder, "{s@v}", subkey,
+ g_variant_new_variant (g_variant_new_string (subvalue)));
}
remote_options = g_variant_ref_sink (g_variant_builder_end (optbuilder));
- if (!ostree_repo_remote_change (repo, NULL,
- OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS,
- remotename, url,
- remote_options,
- cancellable, error))
+ if (!ostree_repo_remote_change (repo, NULL, OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS,
+ remotename, url, remote_options, cancellable, error))
goto out;
}
- { GKeyFile *old_origin = ostree_deployment_get_origin (target_deployment);
+ {
+ GKeyFile *old_origin = ostree_deployment_get_origin (target_deployment);
g_autofree char *origin_refspec = g_key_file_get_string (old_origin, "origin", "refspec", NULL);
g_autofree char *origin_remote = NULL;
g_autofree char *origin_ref = NULL;
@@ -122,18 +122,20 @@ ot_admin_builtin_set_origin (int argc, char **argv, OstreeCommandInvocation *inv
if (!ostree_parse_refspec (origin_refspec, &origin_remote, &origin_ref, error))
goto out;
- { g_autofree char *new_refspec = g_strconcat (remotename, ":", branch ? branch : origin_ref, NULL);
- g_autoptr(GKeyFile) new_origin = NULL;
+ {
+ g_autofree char *new_refspec
+ = g_strconcat (remotename, ":", branch ? branch : origin_ref, NULL);
+ g_autoptr (GKeyFile) new_origin = NULL;
new_origin = ostree_sysroot_origin_new_from_refspec (sysroot, new_refspec);
- if (!ostree_sysroot_write_origin_file (sysroot, target_deployment, new_origin,
- cancellable, error))
+ if (!ostree_sysroot_write_origin_file (sysroot, target_deployment, new_origin, cancellable,
+ error))
goto out;
}
}
ret = TRUE;
- out:
+out:
return ret;
}
diff --git a/src/ostree/ot-admin-builtin-status.c b/src/ostree/ot-admin-builtin-status.c
index 672882bd..3addfd16 100644
--- a/src/ostree/ot-admin-builtin-status.c
+++ b/src/ostree/ot-admin-builtin-status.c
@@ -21,25 +21,23 @@
#include "config.h"
-#include "ot-main.h"
+#include "libglnx.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
-#include "libglnx.h"
+#include "ot-main.h"
#include <glib/gi18n.h>
static gboolean opt_verify;
-static GOptionEntry options[] = {
- { "verify", 'V', 0, G_OPTION_ARG_NONE, &opt_verify, "Print the commit verification status", NULL },
- { NULL }
-};
+static GOptionEntry options[] = { { "verify", 'V', 0, G_OPTION_ARG_NONE, &opt_verify,
+ "Print the commit verification status", NULL },
+ { NULL } };
#ifndef OSTREE_DISABLE_GPGME
static gboolean
-deployment_get_gpg_verify (OstreeDeployment *deployment,
- OstreeRepo *repo)
+deployment_get_gpg_verify (OstreeDeployment *deployment, OstreeRepo *repo)
{
/* XXX Something like this could be added to the OstreeDeployment
* API in libostree if the OstreeRepo parameter is acceptable. */
@@ -59,38 +57,32 @@ deployment_get_gpg_verify (OstreeDeployment *deployment,
gboolean gpg_verify = FALSE;
if (remote)
- (void) ostree_repo_remote_get_gpg_verify (repo, remote, &gpg_verify, NULL);
+ (void)ostree_repo_remote_get_gpg_verify (repo, remote, &gpg_verify, NULL);
return gpg_verify;
}
#endif /* OSTREE_DISABLE_GPGME */
-
static gboolean
-deployment_print_status (OstreeSysroot *sysroot,
- OstreeRepo *repo,
- OstreeDeployment *deployment,
- gboolean is_booted,
- gboolean is_pending,
- gboolean is_rollback,
- GCancellable *cancellable,
- GError **error)
+deployment_print_status (OstreeSysroot *sysroot, OstreeRepo *repo, OstreeDeployment *deployment,
+ gboolean is_booted, gboolean is_pending, gboolean is_rollback,
+ GCancellable *cancellable, GError **error)
{
const char *ref = ostree_deployment_get_csum (deployment);
/* Load the backing commit; shouldn't normally fail, but if it does,
* we stumble on.
*/
- g_autoptr(GVariant) commit = NULL;
- (void)ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, ref,
- &commit, NULL);
- g_autoptr(GVariant) commit_metadata = NULL;
+ g_autoptr (GVariant) commit = NULL;
+ (void)ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, ref, &commit, NULL);
+ g_autoptr (GVariant) commit_metadata = NULL;
if (commit)
commit_metadata = g_variant_get_child_value (commit, 0);
- g_autoptr(GVariant) commit_detached_metadata = NULL;
+ g_autoptr (GVariant) commit_detached_metadata = NULL;
if (commit)
{
- if (!ostree_repo_read_commit_detached_metadata (repo, ref, &commit_detached_metadata, cancellable, error))
+ if (!ostree_repo_read_commit_detached_metadata (repo, ref, &commit_detached_metadata,
+ cancellable, error))
return FALSE;
}
@@ -98,8 +90,9 @@ deployment_print_status (OstreeSysroot *sysroot,
const char *source_title = NULL;
if (commit_metadata)
{
- (void) g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_VERSION, "&s", &version);
- (void) g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_SOURCE_TITLE, "&s", &source_title);
+ (void)g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_VERSION, "&s", &version);
+ (void)g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_SOURCE_TITLE, "&s",
+ &source_title);
}
GKeyFile *origin = ostree_deployment_get_origin (deployment);
@@ -111,11 +104,8 @@ deployment_print_status (OstreeSysroot *sysroot,
deployment_status = " (pending)";
else if (is_rollback)
deployment_status = " (rollback)";
- g_print ("%c %s %s.%d%s\n",
- is_booted ? '*' : ' ',
- ostree_deployment_get_osname (deployment),
- ostree_deployment_get_csum (deployment),
- ostree_deployment_get_deployserial (deployment),
+ g_print ("%c %s %s.%d%s\n", is_booted ? '*' : ' ', ostree_deployment_get_osname (deployment),
+ ostree_deployment_get_csum (deployment), ostree_deployment_get_deployserial (deployment),
deployment_status);
if (version)
g_print (" Version: %s\n", version);
@@ -127,8 +117,8 @@ deployment_print_status (OstreeSysroot *sysroot,
break;
default:
g_print (" %s%sUnlocked: %s%s%s\n", ot_get_red_start (), ot_get_bold_start (),
- ostree_deployment_unlocked_state_to_string (unlocked),
- ot_get_bold_end (), ot_get_red_end ());
+ ostree_deployment_unlocked_state_to_string (unlocked), ot_get_bold_end (),
+ ot_get_red_end ());
}
if (ostree_deployment_is_pinned (deployment))
g_print (" Pinned: yes\n");
@@ -148,14 +138,13 @@ deployment_print_status (OstreeSysroot *sysroot,
#ifndef OSTREE_DISABLE_GPGME
if (!opt_verify && deployment_get_gpg_verify (deployment, repo))
{
- g_autoptr(GString) output_buffer = g_string_sized_new (256);
+ g_autoptr (GString) output_buffer = g_string_sized_new (256);
/* Print any digital signatures on this commit. */
const char *osname = ostree_deployment_get_osname (deployment);
- g_autoptr(GError) local_error = NULL;
- g_autoptr(OstreeGpgVerifyResult) result =
- ostree_repo_verify_commit_for_remote (repo, ref, osname,
- cancellable, &local_error);
+ g_autoptr (GError) local_error = NULL;
+ g_autoptr (OstreeGpgVerifyResult) result
+ = ostree_repo_verify_commit_for_remote (repo, ref, osname, cancellable, &local_error);
/* G_IO_ERROR_NOT_FOUND just means the commit is not signed. */
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
@@ -172,8 +161,8 @@ deployment_print_status (OstreeSysroot *sysroot,
const guint n_signatures = ostree_gpg_verify_result_count_all (result);
for (guint jj = 0; jj < n_signatures; jj++)
{
- ostree_gpg_verify_result_describe (result, jj, output_buffer, " GPG: ",
- OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT);
+ ostree_gpg_verify_result_describe (result, jj, output_buffer,
+ " GPG: ", OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT);
}
g_print ("%s", output_buffer->str);
@@ -196,11 +185,13 @@ deployment_print_status (OstreeSysroot *sysroot,
if (remote == NULL)
return glnx_throw (error, "Cannot verify deployment without remote");
- g_autoptr(GBytes) commit_data = g_variant_get_data_as_bytes (commit);
- g_autoptr(GBytes) commit_detached_metadata_bytes =
- commit_detached_metadata ? g_variant_get_data_as_bytes (commit_detached_metadata) : NULL;
+ g_autoptr (GBytes) commit_data = g_variant_get_data_as_bytes (commit);
+ g_autoptr (GBytes) commit_detached_metadata_bytes
+ = commit_detached_metadata ? g_variant_get_data_as_bytes (commit_detached_metadata)
+ : NULL;
g_autofree char *verify_text = NULL;
- if (!ostree_repo_signature_verify_commit_data (repo, remote, commit_data, commit_detached_metadata_bytes, 0, &verify_text, error))
+ if (!ostree_repo_signature_verify_commit_data (
+ repo, remote, commit_data, commit_detached_metadata_bytes, 0, &verify_text, error))
return FALSE;
g_print ("%s\n", verify_text);
}
@@ -209,28 +200,28 @@ deployment_print_status (OstreeSysroot *sysroot,
}
gboolean
-ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("");
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED, invocation, &sysroot,
+ cancellable, error))
return FALSE;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
if (!ostree_sysroot_get_repo (sysroot, &repo, cancellable, error))
return FALSE;
- g_autoptr(GPtrArray) deployments = ostree_sysroot_get_deployments (sysroot);
+ g_autoptr (GPtrArray) deployments = ostree_sysroot_get_deployments (sysroot);
OstreeDeployment *booted_deployment = ostree_sysroot_get_booted_deployment (sysroot);
- g_autoptr(OstreeDeployment) pending_deployment = NULL;
- g_autoptr(OstreeDeployment) rollback_deployment = NULL;
+ g_autoptr (OstreeDeployment) pending_deployment = NULL;
+ g_autoptr (OstreeDeployment) rollback_deployment = NULL;
if (booted_deployment)
- ostree_sysroot_query_deployments_for (sysroot, NULL, &pending_deployment,
- &rollback_deployment);
+ ostree_sysroot_query_deployments_for (sysroot, NULL, &pending_deployment, &rollback_deployment);
if (deployments->len == 0)
{
@@ -241,12 +232,9 @@ ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocat
for (guint i = 0; i < deployments->len; i++)
{
OstreeDeployment *deployment = deployments->pdata[i];
- if (!deployment_print_status (sysroot, repo, deployment,
- deployment == booted_deployment,
+ if (!deployment_print_status (sysroot, repo, deployment, deployment == booted_deployment,
deployment == pending_deployment,
- deployment == rollback_deployment,
- cancellable,
- error))
+ deployment == rollback_deployment, cancellable, error))
return FALSE;
}
}
diff --git a/src/ostree/ot-admin-builtin-switch.c b/src/ostree/ot-admin-builtin-switch.c
index d29e7039..cb41cac5 100644
--- a/src/ostree/ot-admin-builtin-switch.c
+++ b/src/ostree/ot-admin-builtin-switch.c
@@ -19,34 +19,34 @@
#include "config.h"
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
-#include <unistd.h>
-#include <stdlib.h>
#include <glib/gi18n.h>
+#include <stdlib.h>
+#include <unistd.h>
static gboolean opt_reboot;
static char *opt_osname;
-static GOptionEntry options[] = {
- { "reboot", 'r', 0, G_OPTION_ARG_NONE, &opt_reboot, "Reboot after switching trees", NULL },
- { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Use a different operating system root than the current one", "OSNAME" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "reboot", 'r', 0, G_OPTION_ARG_NONE, &opt_reboot, "Reboot after switching trees", NULL },
+ { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname,
+ "Use a different operating system root than the current one", "OSNAME" },
+ { NULL } };
gboolean
-ot_admin_builtin_switch (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_switch (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context =
- g_option_context_new ("REFSPEC");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (GOptionContext) context = g_option_context_new ("REFSPEC");
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, invocation, &sysroot,
+ cancellable, error))
return FALSE;
if (argc < 2)
@@ -57,10 +57,8 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeCommandInvocation *invocat
const char *new_provided_refspec = argv[1];
- g_autoptr(OstreeSysrootUpgrader) upgrader =
- ostree_sysroot_upgrader_new_for_os_with_flags (sysroot, opt_osname,
- OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED,
- cancellable, error);
+ g_autoptr (OstreeSysrootUpgrader) upgrader = ostree_sysroot_upgrader_new_for_os_with_flags (
+ sysroot, opt_osname, OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED, cancellable, error);
if (!upgrader)
return FALSE;
@@ -77,7 +75,7 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeCommandInvocation *invocat
if (g_str_has_suffix (new_provided_refspec, ":"))
{
new_remote = g_strdup (new_provided_refspec);
- new_remote[strlen(new_remote)-1] = '\0';
+ new_remote[strlen (new_remote) - 1] = '\0';
new_ref = g_strdup (origin_ref);
}
else
@@ -86,7 +84,7 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeCommandInvocation *invocat
return FALSE;
}
- const char* remote = new_remote ?: origin_remote;
+ const char *remote = new_remote ?: origin_remote;
g_autofree char *new_refspec = NULL;
if (remote)
new_refspec = g_strconcat (remote, ":", new_ref, NULL);
@@ -95,30 +93,32 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeCommandInvocation *invocat
if (strcmp (origin_refspec, new_refspec) == 0)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Old and new refs are equal: %s", new_refspec);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Old and new refs are equal: %s",
+ new_refspec);
return FALSE;
}
- g_autoptr(GKeyFile) new_origin = ostree_sysroot_origin_new_from_refspec (sysroot, new_refspec);
+ g_autoptr (GKeyFile) new_origin = ostree_sysroot_origin_new_from_refspec (sysroot, new_refspec);
if (!ostree_sysroot_upgrader_set_origin (upgrader, new_origin, cancellable, error))
return FALSE;
- { g_auto(GLnxConsoleRef) console = { 0, };
+ {
+ g_auto (GLnxConsoleRef) console = {
+ 0,
+ };
glnx_console_lock (&console);
- g_autoptr(OstreeAsyncProgress) progress = NULL;
+ g_autoptr (OstreeAsyncProgress) progress = NULL;
if (console.is_tty)
- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
+ progress = ostree_async_progress_new_and_connect (
+ ostree_repo_pull_default_console_progress_changed, &console);
/* Always allow older...there's not going to be a chronological
* relationship necessarily.
*/
gboolean changed;
- if (!ostree_sysroot_upgrader_pull (upgrader, 0,
- OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_ALLOW_OLDER,
- progress, &changed,
- cancellable, error))
+ if (!ostree_sysroot_upgrader_pull (upgrader, 0, OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_ALLOW_OLDER,
+ progress, &changed, cancellable, error))
return FALSE;
if (progress)
diff --git a/src/ostree/ot-admin-builtin-undeploy.c b/src/ostree/ot-admin-builtin-undeploy.c
index c079c83f..ab028d41 100644
--- a/src/ostree/ot-admin-builtin-undeploy.c
+++ b/src/ostree/ot-admin-builtin-undeploy.c
@@ -21,25 +21,24 @@
#include <stdlib.h>
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
-static GOptionEntry options[] = {
- { NULL }
-};
+static GOptionEntry options[] = { { NULL } };
gboolean
-ot_admin_builtin_undeploy (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_undeploy (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("INDEX");
+ g_autoptr (GOptionContext) context = g_option_context_new ("INDEX");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, invocation, &sysroot,
+ cancellable, error))
return FALSE;
if (argc < 2)
@@ -48,13 +47,13 @@ ot_admin_builtin_undeploy (int argc, char **argv, OstreeCommandInvocation *invoc
return FALSE;
}
- g_autoptr(GPtrArray) current_deployments = ostree_sysroot_get_deployments (sysroot);
+ g_autoptr (GPtrArray) current_deployments = ostree_sysroot_get_deployments (sysroot);
const char *deploy_index_str = argv[1];
int deploy_index = atoi (deploy_index_str);
- g_autoptr(OstreeDeployment) target_deployment =
- ot_admin_get_indexed_deployment (sysroot, deploy_index, error);
+ g_autoptr (OstreeDeployment) target_deployment
+ = ot_admin_get_indexed_deployment (sysroot, deploy_index, error);
if (!target_deployment)
return FALSE;
@@ -67,8 +66,7 @@ ot_admin_builtin_undeploy (int argc, char **argv, OstreeCommandInvocation *invoc
g_ptr_array_remove_index (current_deployments, deploy_index);
- if (!ostree_sysroot_write_deployments (sysroot, current_deployments,
- cancellable, error))
+ if (!ostree_sysroot_write_deployments (sysroot, current_deployments, cancellable, error))
return FALSE;
g_print ("Deleted deployment %s.%d\n", ostree_deployment_get_csum (target_deployment),
diff --git a/src/ostree/ot-admin-builtin-unlock.c b/src/ostree/ot-admin-builtin-unlock.c
index 393d6be3..d0c41453 100644
--- a/src/ostree/ot-admin-builtin-unlock.c
+++ b/src/ostree/ot-admin-builtin-unlock.c
@@ -19,33 +19,34 @@
#include "config.h"
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
-#include <glib/gi18n.h>
#include <err.h>
+#include <glib/gi18n.h>
static gboolean opt_hotfix;
static gboolean opt_transient;
-static GOptionEntry options[] = {
- { "hotfix", 0, 0, G_OPTION_ARG_NONE, &opt_hotfix, "Retain changes across reboots", NULL },
- { "transient", 0, 0, G_OPTION_ARG_NONE, &opt_transient, "Mount overlayfs read-only by default", NULL },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "hotfix", 0, 0, G_OPTION_ARG_NONE, &opt_hotfix, "Retain changes across reboots", NULL },
+ { "transient", 0, 0, G_OPTION_ARG_NONE, &opt_transient,
+ "Mount overlayfs read-only by default", NULL },
+ { NULL } };
gboolean
-ot_admin_builtin_unlock (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_unlock (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("");
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, invocation, &sysroot,
+ cancellable, error))
return FALSE;
if (argc > 1)
@@ -70,8 +71,8 @@ ot_admin_builtin_unlock (int argc, char **argv, OstreeCommandInvocation *invocat
else
target_state = OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT;
- if (!ostree_sysroot_deployment_unlock (sysroot, booted_deployment,
- target_state, cancellable, error))
+ if (!ostree_sysroot_deployment_unlock (sysroot, booted_deployment, target_state, cancellable,
+ error))
return FALSE;
switch (target_state)
diff --git a/src/ostree/ot-admin-builtin-upgrade.c b/src/ostree/ot-admin-builtin-upgrade.c
index 3ed71efb..11710429 100644
--- a/src/ostree/ot-admin-builtin-upgrade.c
+++ b/src/ostree/ot-admin-builtin-upgrade.c
@@ -21,15 +21,15 @@
#include "config.h"
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
-#include <unistd.h>
-#include <stdlib.h>
#include <glib/gi18n.h>
+#include <stdlib.h>
+#include <unistd.h>
static gboolean opt_reboot;
static gboolean opt_allow_downgrade;
@@ -40,25 +40,31 @@ static char *opt_osname;
static char *opt_override_commit;
static GOptionEntry options[] = {
- { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Use a different operating system root than the current one", "OSNAME" },
+ { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname,
+ "Use a different operating system root than the current one", "OSNAME" },
{ "reboot", 'r', 0, G_OPTION_ARG_NONE, &opt_reboot, "Reboot after a successful upgrade", NULL },
- { "allow-downgrade", 0, 0, G_OPTION_ARG_NONE, &opt_allow_downgrade, "Permit deployment of chronologically older trees", NULL },
- { "override-commit", 0, 0, G_OPTION_ARG_STRING, &opt_override_commit, "Deploy CHECKSUM instead of the latest tree", "CHECKSUM" },
- { "pull-only", 0, 0, G_OPTION_ARG_NONE, &opt_pull_only, "Do not create a deployment, just download", NULL },
+ { "allow-downgrade", 0, 0, G_OPTION_ARG_NONE, &opt_allow_downgrade,
+ "Permit deployment of chronologically older trees", NULL },
+ { "override-commit", 0, 0, G_OPTION_ARG_STRING, &opt_override_commit,
+ "Deploy CHECKSUM instead of the latest tree", "CHECKSUM" },
+ { "pull-only", 0, 0, G_OPTION_ARG_NONE, &opt_pull_only,
+ "Do not create a deployment, just download", NULL },
{ "deploy-only", 0, 0, G_OPTION_ARG_NONE, &opt_deploy_only, "Do not pull, only deploy", NULL },
- { "stage", 0, 0, G_OPTION_ARG_NONE, &opt_stage, "Enable staging (finalization at reboot time)", NULL },
+ { "stage", 0, 0, G_OPTION_ARG_NONE, &opt_stage, "Enable staging (finalization at reboot time)",
+ NULL },
{ NULL }
};
gboolean
-ot_admin_builtin_upgrade (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_upgrade (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("");
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, invocation, &sysroot,
+ cancellable, error))
return FALSE;
if (opt_pull_only && opt_deploy_only)
@@ -78,13 +84,12 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeCommandInvocation *invoca
if (opt_stage)
flags |= OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE;
- g_autoptr(OstreeSysrootUpgrader) upgrader =
- ostree_sysroot_upgrader_new_for_os_with_flags (sysroot, opt_osname, flags,
- cancellable, error);
+ g_autoptr (OstreeSysrootUpgrader) upgrader = ostree_sysroot_upgrader_new_for_os_with_flags (
+ sysroot, opt_osname, flags, cancellable, error);
if (!upgrader)
return FALSE;
- g_autoptr(GKeyFile) origin = ostree_sysroot_upgrader_dup_origin (upgrader);
+ g_autoptr (GKeyFile) origin = ostree_sysroot_upgrader_dup_origin (upgrader);
if (origin != NULL)
{
/* Should we consider requiring --discard-hotfix here? */
@@ -92,9 +97,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeCommandInvocation *invoca
if (opt_override_commit != NULL)
{
/* Override the commit to pull and deploy. */
- g_key_file_set_string (origin, "origin",
- "override-commit",
- opt_override_commit);
+ g_key_file_set_string (origin, "origin", "override-commit", opt_override_commit);
}
if (!ostree_sysroot_upgrader_set_origin (upgrader, origin, NULL, error))
@@ -106,18 +109,21 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeCommandInvocation *invoca
if (opt_deploy_only)
upgraderpullflags |= OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_SYNTHETIC;
- { g_auto(GLnxConsoleRef) console = { 0, };
+ {
+ g_auto (GLnxConsoleRef) console = {
+ 0,
+ };
glnx_console_lock (&console);
- g_autoptr(OstreeAsyncProgress) progress = NULL;
+ g_autoptr (OstreeAsyncProgress) progress = NULL;
if (console.is_tty)
- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
+ progress = ostree_async_progress_new_and_connect (
+ ostree_repo_pull_default_console_progress_changed, &console);
if (opt_allow_downgrade)
upgraderpullflags |= OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_ALLOW_OLDER;
- if (!ostree_sysroot_upgrader_pull (upgrader, 0, upgraderpullflags,
- progress, &changed,
+ if (!ostree_sysroot_upgrader_pull (upgrader, 0, upgraderpullflags, progress, &changed,
cancellable, error))
{
/* In the pull-only case, we do a cleanup here to ensure that if
@@ -129,7 +135,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeCommandInvocation *invoca
* isn't directly referenced.
*/
if (opt_pull_only)
- (void) ostree_sysroot_cleanup (sysroot, NULL, NULL);
+ (void)ostree_sysroot_cleanup (sysroot, NULL, NULL);
return FALSE;
}
diff --git a/src/ostree/ot-admin-builtins.h b/src/ostree/ot-admin-builtins.h
index 10af1ec2..d2ad836c 100644
--- a/src/ostree/ot-admin-builtins.h
+++ b/src/ostree/ot-admin-builtins.h
@@ -25,28 +25,28 @@
G_BEGIN_DECLS
-#define BUILTINPROTO(name) gboolean ot_admin_builtin_ ## name (int argc, char **argv, \
- OstreeCommandInvocation *invocation, \
- GCancellable *cancellable, GError **error)
+#define BUILTINPROTO(name) \
+ gboolean ot_admin_builtin_##name (int argc, char **argv, OstreeCommandInvocation *invocation, \
+ GCancellable *cancellable, GError **error)
-BUILTINPROTO(selinux_ensure_labeled);
-BUILTINPROTO(os_init);
-BUILTINPROTO(install);
-BUILTINPROTO(instutil);
-BUILTINPROTO(init_fs);
-BUILTINPROTO(undeploy);
-BUILTINPROTO(deploy);
-BUILTINPROTO(cleanup);
-BUILTINPROTO(pin);
-BUILTINPROTO(finalize_staged);
-BUILTINPROTO(boot_complete);
-BUILTINPROTO(unlock);
-BUILTINPROTO(status);
-BUILTINPROTO(set_origin);
-BUILTINPROTO(diff);
-BUILTINPROTO(switch);
-BUILTINPROTO(upgrade);
-BUILTINPROTO(kargs);
+BUILTINPROTO (selinux_ensure_labeled);
+BUILTINPROTO (os_init);
+BUILTINPROTO (install);
+BUILTINPROTO (instutil);
+BUILTINPROTO (init_fs);
+BUILTINPROTO (undeploy);
+BUILTINPROTO (deploy);
+BUILTINPROTO (cleanup);
+BUILTINPROTO (pin);
+BUILTINPROTO (finalize_staged);
+BUILTINPROTO (boot_complete);
+BUILTINPROTO (unlock);
+BUILTINPROTO (status);
+BUILTINPROTO (set_origin);
+BUILTINPROTO (diff);
+BUILTINPROTO (switch);
+BUILTINPROTO (upgrade);
+BUILTINPROTO (kargs);
#undef BUILTINPROTO
diff --git a/src/ostree/ot-admin-functions.c b/src/ostree/ot-admin-functions.c
index 8c7cd135..e54fe8d9 100644
--- a/src/ostree/ot-admin-functions.c
+++ b/src/ostree/ot-admin-functions.c
@@ -22,20 +22,18 @@
#include "config.h"
#include "libglnx.h"
+#include "ostree.h"
#include "ot-admin-functions.h"
#include "otutil.h"
-#include "ostree.h"
gboolean
-ot_admin_require_booted_deployment_or_osname (OstreeSysroot *sysroot,
- const char *osname,
- GCancellable *cancellable,
- GError **error)
+ot_admin_require_booted_deployment_or_osname (OstreeSysroot *sysroot, const char *osname,
+ GCancellable *cancellable, GError **error)
{
- OstreeDeployment *booted_deployment =
- ostree_sysroot_get_booted_deployment (sysroot);
+ OstreeDeployment *booted_deployment = ostree_sysroot_get_booted_deployment (sysroot);
if (booted_deployment == NULL && osname == NULL)
- return glnx_throw (error, "Not currently booted into an OSTree system and no --os= argument given");
+ return glnx_throw (error,
+ "Not currently booted into an OSTree system and no --os= argument given");
return TRUE;
}
@@ -51,7 +49,7 @@ ot_admin_require_booted_deployment_or_osname (OstreeSysroot *sysroot,
char *
ot_admin_checksum_version (GVariant *checksum)
{
- g_autoptr(GVariant) metadata = NULL;
+ g_autoptr (GVariant) metadata = NULL;
const char *ret = NULL;
metadata = g_variant_get_child_value (checksum, 0);
@@ -63,18 +61,14 @@ ot_admin_checksum_version (GVariant *checksum)
}
OstreeDeployment *
-ot_admin_get_indexed_deployment (OstreeSysroot *sysroot,
- int index,
- GError **error)
+ot_admin_get_indexed_deployment (OstreeSysroot *sysroot, int index, GError **error)
{
- g_autoptr(GPtrArray) current_deployments =
- ostree_sysroot_get_deployments (sysroot);
+ g_autoptr (GPtrArray) current_deployments = ostree_sysroot_get_deployments (sysroot);
if (index < 0)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
- "Invalid index %d", index);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Invalid index %d", index);
return NULL;
}
if (index >= current_deployments->len)
@@ -88,7 +82,8 @@ ot_admin_get_indexed_deployment (OstreeSysroot *sysroot,
return g_object_ref (current_deployments->pdata[index]);
}
-struct ContextState {
+struct ContextState
+{
GMainContext *mainctx;
gboolean running;
};
@@ -101,17 +96,14 @@ on_sysroot_lock_timeout (gpointer user_data)
}
static void
-on_sysroot_lock_acquired (OstreeSysroot *sysroot,
- GAsyncResult *result,
- struct ContextState *state)
+on_sysroot_lock_acquired (OstreeSysroot *sysroot, GAsyncResult *result, struct ContextState *state)
{
state->running = FALSE;
g_main_context_wakeup (state->mainctx);
}
gboolean
-ot_admin_sysroot_lock (OstreeSysroot *sysroot,
- GError **error)
+ot_admin_sysroot_lock (OstreeSysroot *sysroot, GError **error)
{
gboolean ret = FALSE;
gboolean acquired;
@@ -134,14 +126,15 @@ ot_admin_sysroot_lock (OstreeSysroot *sysroot,
on_sysroot_lock_timeout (&state);
- ostree_sysroot_lock_async (sysroot, NULL, (GAsyncReadyCallback)on_sysroot_lock_acquired, &state);
+ ostree_sysroot_lock_async (sysroot, NULL, (GAsyncReadyCallback)on_sysroot_lock_acquired,
+ &state);
while (state.running)
g_main_context_iteration (state.mainctx, TRUE);
}
ret = TRUE;
- out:
+out:
g_main_context_pop_thread_default (state.mainctx);
g_main_context_unref (state.mainctx);
return ret;
diff --git a/src/ostree/ot-admin-functions.h b/src/ostree/ot-admin-functions.h
index f2cbc0be..50aef161 100644
--- a/src/ostree/ot-admin-functions.h
+++ b/src/ostree/ot-admin-functions.h
@@ -26,26 +26,16 @@
G_BEGIN_DECLS
-gboolean
-ot_admin_require_booted_deployment_or_osname (OstreeSysroot *sysroot,
- const char *osname,
- GCancellable *cancellable,
- GError **error);
-
-char *
-ot_admin_checksum_version (GVariant *checksum);
-
-OstreeDeployment *
-ot_admin_get_indexed_deployment (OstreeSysroot *sysroot,
- int index,
- GError **error);
-
-gboolean
-ot_admin_sysroot_lock (OstreeSysroot *sysroot,
- GError **error);
-
-gboolean
-ot_admin_execve_reboot (OstreeSysroot *sysroot,
- GError **error);
+gboolean ot_admin_require_booted_deployment_or_osname (OstreeSysroot *sysroot, const char *osname,
+ GCancellable *cancellable, GError **error);
+
+char *ot_admin_checksum_version (GVariant *checksum);
+
+OstreeDeployment *ot_admin_get_indexed_deployment (OstreeSysroot *sysroot, int index,
+ GError **error);
+
+gboolean ot_admin_sysroot_lock (OstreeSysroot *sysroot, GError **error);
+
+gboolean ot_admin_execve_reboot (OstreeSysroot *sysroot, GError **error);
G_END_DECLS
diff --git a/src/ostree/ot-admin-instutil-builtin-grub2-generate.c b/src/ostree/ot-admin-instutil-builtin-grub2-generate.c
index 0f259bee..0f8a8636 100644
--- a/src/ostree/ot-admin-instutil-builtin-grub2-generate.c
+++ b/src/ostree/ot-admin-instutil-builtin-grub2-generate.c
@@ -17,42 +17,43 @@
#include "config.h"
-#include <string.h>
#include <glib-unix.h>
+#include <string.h>
-#include "ot-main.h"
-#include "ot-admin-instutil-builtins.h"
#include "ostree-cmd-private.h"
+#include "ot-admin-instutil-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
-static GOptionEntry options[] = {
- { NULL }
-};
+static GOptionEntry options[] = { { NULL } };
gboolean
-ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_instutil_builtin_grub2_generate (int argc, char **argv,
+ OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
guint bootversion;
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
context = g_option_context_new ("[BOOTVERSION]");
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER
+ | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
invocation, &sysroot, cancellable, error))
goto out;
if (argc >= 2)
{
- bootversion = (guint) g_ascii_strtoull (argv[1], NULL, 10);
+ bootversion = (guint)g_ascii_strtoull (argv[1], NULL, 10);
if (!(bootversion == 0 || bootversion == 1))
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid bootversion: %u", bootversion);
- goto out;
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Invalid bootversion: %u",
+ bootversion);
+ goto out;
}
}
else
@@ -65,10 +66,11 @@ ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, OstreeCommandIn
g_assert (bootversion == 0 || bootversion == 1);
}
- if (!ostree_cmd__private__()->ostree_generate_grub2_config (sysroot, bootversion, 1, cancellable, error))
+ if (!ostree_cmd__private__ ()->ostree_generate_grub2_config (sysroot, bootversion, 1, cancellable,
+ error))
goto out;
ret = TRUE;
- out:
+out:
return ret;
}
diff --git a/src/ostree/ot-admin-instutil-builtin-selinux-ensure-labeled.c b/src/ostree/ot-admin-instutil-builtin-selinux-ensure-labeled.c
index e324da9e..bc226fb7 100644
--- a/src/ostree/ot-admin-instutil-builtin-selinux-ensure-labeled.c
+++ b/src/ostree/ot-admin-instutil-builtin-selinux-ensure-labeled.c
@@ -17,16 +17,16 @@
#include "config.h"
-#include <string.h>
#include <glib-unix.h>
+#include <string.h>
-#include "ot-main.h"
#include "ot-admin-instutil-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
static char *
-ptrarray_path_join (GPtrArray *path)
+ptrarray_path_join (GPtrArray *path)
{
GString *path_buf;
@@ -50,58 +50,44 @@ ptrarray_path_join (GPtrArray *path)
}
static gboolean
-relabel_one_path (OstreeSePolicy *sepolicy,
- GFile *path,
- GFileInfo *info,
- GPtrArray *path_parts,
- GCancellable *cancellable,
- GError **error)
+relabel_one_path (OstreeSePolicy *sepolicy, GFile *path, GFileInfo *info, GPtrArray *path_parts,
+ GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
g_autofree char *relpath = NULL;
g_autofree char *new_label = NULL;
relpath = ptrarray_path_join (path_parts);
- if (!ostree_sepolicy_restorecon (sepolicy, relpath,
- info, path,
- OSTREE_SEPOLICY_RESTORECON_FLAGS_ALLOW_NOLABEL |
- OSTREE_SEPOLICY_RESTORECON_FLAGS_KEEP_EXISTING,
- &new_label,
- cancellable, error))
+ if (!ostree_sepolicy_restorecon (sepolicy, relpath, info, path,
+ OSTREE_SEPOLICY_RESTORECON_FLAGS_ALLOW_NOLABEL
+ | OSTREE_SEPOLICY_RESTORECON_FLAGS_KEEP_EXISTING,
+ &new_label, cancellable, error))
{
g_prefix_error (error, "Setting context of %s: ", gs_file_get_path_cached (path));
goto out;
}
if (new_label)
- g_print ("Set label of '%s' (as '%s') to '%s'\n",
- gs_file_get_path_cached (path),
- relpath,
+ g_print ("Set label of '%s' (as '%s') to '%s'\n", gs_file_get_path_cached (path), relpath,
new_label);
ret = TRUE;
- out:
+out:
return ret;
}
static gboolean
-relabel_recursively (OstreeSePolicy *sepolicy,
- GFile *dir,
- GFileInfo *dir_info,
- GPtrArray *path_parts,
- GCancellable *cancellable,
- GError **error)
+relabel_recursively (OstreeSePolicy *sepolicy, GFile *dir, GFileInfo *dir_info,
+ GPtrArray *path_parts, GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
- g_autoptr(GFileEnumerator) direnum = NULL;
+ g_autoptr (GFileEnumerator) direnum = NULL;
- if (!relabel_one_path (sepolicy, dir, dir_info, path_parts,
- cancellable, error))
+ if (!relabel_one_path (sepolicy, dir, dir_info, path_parts, cancellable, error))
goto out;
direnum = g_file_enumerate_children (dir, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- cancellable, error);
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error);
if (!direnum)
goto out;
@@ -111,25 +97,22 @@ relabel_recursively (OstreeSePolicy *sepolicy,
GFile *child;
GFileType ftype;
- if (!g_file_enumerator_iterate (direnum, &file_info, &child,
- cancellable, error))
+ if (!g_file_enumerator_iterate (direnum, &file_info, &child, cancellable, error))
goto out;
if (file_info == NULL)
break;
- g_ptr_array_add (path_parts, (char*)g_file_info_get_name (file_info));
+ g_ptr_array_add (path_parts, (char *)g_file_info_get_name (file_info));
ftype = g_file_info_get_file_type (file_info);
if (ftype == G_FILE_TYPE_DIRECTORY)
{
- if (!relabel_recursively (sepolicy, child, file_info, path_parts,
- cancellable, error))
+ if (!relabel_recursively (sepolicy, child, file_info, path_parts, cancellable, error))
goto out;
}
else
{
- if (!relabel_one_path (sepolicy, child, file_info, path_parts,
- cancellable, error))
+ if (!relabel_one_path (sepolicy, child, file_info, path_parts, cancellable, error))
goto out;
}
@@ -137,70 +120,65 @@ relabel_recursively (OstreeSePolicy *sepolicy,
}
ret = TRUE;
- out:
+out:
return ret;
}
static gboolean
-selinux_relabel_dir (OstreeSePolicy *sepolicy,
- GFile *dir,
- const char *prefix,
- GCancellable *cancellable,
- GError **error)
+selinux_relabel_dir (OstreeSePolicy *sepolicy, GFile *dir, const char *prefix,
+ GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
- g_autoptr(GPtrArray) path_parts = g_ptr_array_new ();
- g_autoptr(GFileInfo) root_info = NULL;
+ g_autoptr (GPtrArray) path_parts = g_ptr_array_new ();
+ g_autoptr (GFileInfo) root_info = NULL;
root_info = g_file_query_info (dir, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- cancellable, error);
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error);
if (!root_info)
goto out;
- g_ptr_array_add (path_parts, (char*)prefix);
- if (!relabel_recursively (sepolicy, dir, root_info, path_parts,
- cancellable, error))
+ g_ptr_array_add (path_parts, (char *)prefix);
+ if (!relabel_recursively (sepolicy, dir, root_info, path_parts, cancellable, error))
{
g_prefix_error (error, "Relabeling /%s: ", prefix);
goto out;
}
ret = TRUE;
- out:
+out:
return ret;
}
-static GOptionEntry options[] = {
- { NULL }
-};
+static GOptionEntry options[] = { { NULL } };
gboolean
-ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv,
+ OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
const char *policy_name;
- g_autoptr(GFile) subpath = NULL;
+ g_autoptr (GFile) subpath = NULL;
const char *prefix = NULL;
- g_autoptr(OstreeSePolicy) sepolicy = NULL;
- g_autoptr(GPtrArray) deployments = NULL;
+ g_autoptr (OstreeSePolicy) sepolicy = NULL;
+ g_autoptr (GPtrArray) deployments = NULL;
OstreeDeployment *first_deployment;
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeSysroot) sysroot = NULL;
- g_autoptr(GFile) deployment_path = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
+ g_autoptr (GFile) deployment_path = NULL;
context = g_option_context_new ("[SUBPATH PREFIX]");
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER
+ | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
invocation, &sysroot, cancellable, error))
goto out;
deployments = ostree_sysroot_get_deployments (sysroot);
if (deployments->len == 0)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Unable to find a deployment in sysroot");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unable to find a deployment in sysroot");
goto out;
}
first_deployment = deployments->pdata[0];
@@ -225,8 +203,7 @@ ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeC
if (policy_name)
{
g_print ("Relabeling using policy '%s'\n", policy_name);
- if (!selinux_relabel_dir (sepolicy, subpath, prefix,
- cancellable, error))
+ if (!selinux_relabel_dir (sepolicy, subpath, prefix, cancellable, error))
goto out;
}
else
@@ -234,6 +211,6 @@ ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeC
gs_file_get_path_cached (deployment_path));
ret = TRUE;
- out:
+out:
return ret;
}
diff --git a/src/ostree/ot-admin-instutil-builtin-set-kargs.c b/src/ostree/ot-admin-instutil-builtin-set-kargs.c
index ff773c3b..90a69b42 100644
--- a/src/ostree/ot-admin-instutil-builtin-set-kargs.c
+++ b/src/ostree/ot-admin-instutil-builtin-set-kargs.c
@@ -17,51 +17,57 @@
#include "config.h"
-#include <string.h>
#include <glib-unix.h>
+#include <string.h>
-#include "ot-main.h"
#include "ot-admin-instutil-builtins.h"
+#include "ot-main.h"
-#include "otutil.h"
#include "ostree.h"
+#include "otutil.h"
static gboolean opt_proc_cmdline;
static gboolean opt_merge;
static char **opt_replace;
static char **opt_append;
-static GOptionEntry options[] = {
- { "import-proc-cmdline", 0, 0, G_OPTION_ARG_NONE, &opt_proc_cmdline, "Import current /proc/cmdline", NULL },
- { "merge", 0, 0, G_OPTION_ARG_NONE, &opt_merge, "Merge with previous command line", NULL },
- { "replace", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_replace, "Set kernel argument, like root=/dev/sda1; this overrides any earlier argument with the same name", "NAME=VALUE" },
- { "append", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_append, "Append kernel argument; useful with e.g. console= that can be used multiple times", "NAME=VALUE" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "import-proc-cmdline", 0, 0, G_OPTION_ARG_NONE, &opt_proc_cmdline,
+ "Import current /proc/cmdline", NULL },
+ { "merge", 0, 0, G_OPTION_ARG_NONE, &opt_merge, "Merge with previous command line", NULL },
+ { "replace", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_replace,
+ "Set kernel argument, like root=/dev/sda1; this overrides any earlier argument with the "
+ "same name",
+ "NAME=VALUE" },
+ { "append", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_append,
+ "Append kernel argument; useful with e.g. console= that can be used multiple times",
+ "NAME=VALUE" },
+ { NULL } };
gboolean
-ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
guint i;
- g_autoptr(GPtrArray) deployments = NULL;
+ g_autoptr (GPtrArray) deployments = NULL;
OstreeDeployment *first_deployment = NULL;
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeSysroot) sysroot = NULL;
- g_autoptr(OstreeKernelArgs) kargs = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeKernelArgs) kargs = NULL;
context = g_option_context_new ("ARGS");
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER
+ | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
invocation, &sysroot, cancellable, error))
goto out;
deployments = ostree_sysroot_get_deployments (sysroot);
if (deployments->len == 0)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Unable to find a deployment in sysroot");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unable to find a deployment in sysroot");
goto out;
}
first_deployment = deployments->pdata[0];
@@ -79,7 +85,8 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocat
else if (opt_merge)
{
OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (first_deployment);
- g_auto(GStrv) previous_args = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1);
+ g_auto (GStrv) previous_args
+ = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1);
ostree_kernel_args_append_argv (kargs, previous_args);
}
@@ -98,15 +105,14 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocat
ostree_kernel_args_append (kargs, argv[i]);
{
- g_auto(GStrv) kargs_strv = ostree_kernel_args_to_strv (kargs);
+ g_auto (GStrv) kargs_strv = ostree_kernel_args_to_strv (kargs);
- if (!ostree_sysroot_deployment_set_kargs (sysroot, first_deployment,
- kargs_strv,
- cancellable, error))
+ if (!ostree_sysroot_deployment_set_kargs (sysroot, first_deployment, kargs_strv, cancellable,
+ error))
goto out;
}
ret = TRUE;
- out:
+out:
return ret;
}
diff --git a/src/ostree/ot-admin-instutil-builtins.h b/src/ostree/ot-admin-instutil-builtins.h
index 832193db..746809e0 100644
--- a/src/ostree/ot-admin-instutil-builtins.h
+++ b/src/ostree/ot-admin-instutil-builtins.h
@@ -23,8 +23,15 @@
G_BEGIN_DECLS
-gboolean ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
-gboolean ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
-gboolean ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
+gboolean ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv,
+ OstreeCommandInvocation *invocation,
+ GCancellable *cancellable,
+ GError **error);
+gboolean ot_admin_instutil_builtin_set_kargs (int argc, char **argv,
+ OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error);
+gboolean ot_admin_instutil_builtin_grub2_generate (int argc, char **argv,
+ OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error);
G_END_DECLS
diff --git a/src/ostree/ot-admin-kargs-builtin-edit-in-place.c b/src/ostree/ot-admin-kargs-builtin-edit-in-place.c
index f7125e2c..cd434a7b 100644
--- a/src/ostree/ot-admin-kargs-builtin-edit-in-place.c
+++ b/src/ostree/ot-admin-kargs-builtin-edit-in-place.c
@@ -18,36 +18,36 @@
#include "config.h"
-#include "ot-main.h"
#include "ot-admin-kargs-builtins.h"
+#include "ot-main.h"
#include "ostree.h"
#include "otutil.h"
static char **opt_kargs_edit_in_place_append;
-static GOptionEntry options[] = {
- { "append-if-missing", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kargs_edit_in_place_append, "Append kernel arguments if they do not exist", "NAME=VALUE" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "append-if-missing", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kargs_edit_in_place_append,
+ "Append kernel arguments if they do not exist", "NAME=VALUE" },
+ { NULL } };
gboolean
-ot_admin_kargs_builtin_edit_in_place (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_kargs_builtin_edit_in_place (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
- g_autoptr(GOptionContext) context = g_option_context_new ("ARGS");
+ g_autoptr (GOptionContext) context = g_option_context_new ("ARGS");
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, invocation, &sysroot,
+ cancellable, error))
return FALSE;
- g_autoptr(GPtrArray) deployments = ostree_sysroot_get_deployments (sysroot);
+ g_autoptr (GPtrArray) deployments = ostree_sysroot_get_deployments (sysroot);
if (deployments->len == 0)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Unable to find a deployment in sysroot");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unable to find a deployment in sysroot");
return FALSE;
}
@@ -56,7 +56,8 @@ ot_admin_kargs_builtin_edit_in_place (int argc, char **argv, OstreeCommandInvoca
{
OstreeDeployment *deployment = deployments->pdata[i];
OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (deployment);
- g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_from_string (ostree_bootconfig_parser_get (bootconfig, "options"));
+ g_autoptr (OstreeKernelArgs) kargs
+ = ostree_kernel_args_from_string (ostree_bootconfig_parser_get (bootconfig, "options"));
if (opt_kargs_edit_in_place_append)
{
@@ -72,7 +73,6 @@ ot_admin_kargs_builtin_edit_in_place (int argc, char **argv, OstreeCommandInvoca
if (!ostree_sysroot_deployment_set_kargs_in_place (sysroot, deployment, new_options,
cancellable, error))
return FALSE;
-
}
return TRUE;
diff --git a/src/ostree/ot-admin-kargs-builtins.h b/src/ostree/ot-admin-kargs-builtins.h
index 5d345f2a..139e81d0 100644
--- a/src/ostree/ot-admin-kargs-builtins.h
+++ b/src/ostree/ot-admin-kargs-builtins.h
@@ -24,11 +24,12 @@
G_BEGIN_DECLS
-#define BUILTINPROTO(name) gboolean ot_admin_kargs_builtin_ ## name (int argc, char **argv, \
- OstreeCommandInvocation *invocation, \
- GCancellable *cancellable, GError **error)
+#define BUILTINPROTO(name) \
+ gboolean ot_admin_kargs_builtin_##name (int argc, char **argv, \
+ OstreeCommandInvocation *invocation, \
+ GCancellable *cancellable, GError **error)
-BUILTINPROTO(edit_in_place);
+BUILTINPROTO (edit_in_place);
#undef BUILTINPROTO
diff --git a/src/ostree/ot-builtin-admin.c b/src/ostree/ot-builtin-admin.c
index 73e18d15..4d3c3364 100644
--- a/src/ostree/ot-builtin-admin.c
+++ b/src/ostree/ot-builtin-admin.c
@@ -21,64 +21,45 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
+#include "ostree-repo-file.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
-#include "ostree-repo-file.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include <glib/gi18n.h>
static OstreeCommand admin_subcommands[] = {
- { "cleanup", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_cleanup,
+ { "cleanup", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_cleanup,
"Delete untagged deployments and repository objects" },
- { "config-diff", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_diff,
+ { "config-diff", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_diff,
"Diff current /etc configuration versus default" },
- { "deploy", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_deploy,
+ { "deploy", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_deploy,
"Checkout revision REFSPEC as the new default deployment" },
{ "finalize-staged", OSTREE_BUILTIN_FLAG_NO_REPO | OSTREE_BUILTIN_FLAG_HIDDEN,
- ot_admin_builtin_finalize_staged,
- "Internal command to run at shutdown time" },
+ ot_admin_builtin_finalize_staged, "Internal command to run at shutdown time" },
{ "boot-complete", OSTREE_BUILTIN_FLAG_NO_REPO | OSTREE_BUILTIN_FLAG_HIDDEN,
- ot_admin_builtin_boot_complete,
- "Internal command to run at boot after an update was applied" },
- { "init-fs", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_init_fs,
+ ot_admin_builtin_boot_complete, "Internal command to run at boot after an update was applied" },
+ { "init-fs", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_init_fs,
"Initialize a root filesystem" },
- { "instutil", OSTREE_BUILTIN_FLAG_NO_REPO | OSTREE_BUILTIN_FLAG_HIDDEN,
- ot_admin_builtin_instutil,
+ { "instutil", OSTREE_BUILTIN_FLAG_NO_REPO | OSTREE_BUILTIN_FLAG_HIDDEN, ot_admin_builtin_instutil,
"Deprecated commands intended for installer programs" },
- { "os-init", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_os_init,
+ { "os-init", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_os_init,
"Initialize empty state for given operating system" },
- { "pin", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_pin,
+ { "pin", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_pin,
"Change the \"pinning\" state of a deployment" },
- { "set-origin", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_set_origin,
+ { "set-origin", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_set_origin,
"Set Origin and create a new origin file" },
- { "status", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_status,
- "List deployments" },
- { "switch", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_switch,
+ { "status", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_status, "List deployments" },
+ { "switch", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_switch,
"Construct new tree from REFSPEC and deploy it" },
- { "undeploy", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_undeploy,
- "Delete deployment INDEX" },
- { "unlock", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_unlock,
+ { "undeploy", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_undeploy, "Delete deployment INDEX" },
+ { "unlock", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_unlock,
"Make the current deployment mutable (as a hotfix or development)" },
- { "upgrade", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_upgrade,
+ { "upgrade", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_upgrade,
"Construct new tree from current origin and deploy it, if it changed" },
- { "kargs", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_admin_builtin_kargs,
- "Change kernel arguments" },
+ { "kargs", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_kargs, "Change kernel arguments" },
{ NULL, 0, NULL, NULL }
};
@@ -88,7 +69,7 @@ ostree_admin_option_context_new_with_commands (void)
OstreeCommand *command = admin_subcommands;
GOptionContext *context = g_option_context_new ("--print-current-dir|COMMAND");
- g_autoptr(GString) summary = g_string_new ("Builtin \"admin\" Commands:");
+ g_autoptr (GString) summary = g_string_new ("Builtin \"admin\" Commands:");
while (command->name != NULL)
{
@@ -107,7 +88,8 @@ ostree_admin_option_context_new_with_commands (void)
}
gboolean
-ostree_builtin_admin (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_admin (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
const char *subcommand_name = NULL;
@@ -154,15 +136,15 @@ ostree_builtin_admin (int argc, char **argv, OstreeCommandInvocation *invocation
if (!subcommand->name)
{
- g_autoptr(GOptionContext) context = NULL;
+ g_autoptr (GOptionContext) context = NULL;
g_autofree char *help = NULL;
context = ostree_admin_option_context_new_with_commands ();
/* This will not return for some options (e.g. --version). */
if (ostree_admin_option_context_parse (context, NULL, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
- invocation, NULL, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT, invocation, NULL,
+ cancellable, error))
{
if (subcommand_name == NULL)
{
@@ -190,6 +172,6 @@ ostree_builtin_admin (int argc, char **argv, OstreeCommandInvocation *invocation
goto out;
ret = TRUE;
- out:
+out:
return ret;
}
diff --git a/src/ostree/ot-builtin-cat.c b/src/ostree/ot-builtin-cat.c
index 6d9736ea..58201b7c 100644
--- a/src/ostree/ot-builtin-cat.c
+++ b/src/ostree/ot-builtin-cat.c
@@ -21,9 +21,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
#include <gio/gunixoutputstream.h>
@@ -38,28 +38,28 @@ static GOptionEntry options[] = {
};
static gboolean
-cat_one_file (GFile *f,
- GOutputStream *stdout_stream,
- GCancellable *cancellable,
- GError **error)
+cat_one_file (GFile *f, GOutputStream *stdout_stream, GCancellable *cancellable, GError **error)
{
- g_autoptr(GInputStream) in = (GInputStream*)g_file_read (f, cancellable, error);
+ g_autoptr (GInputStream) in = (GInputStream *)g_file_read (f, cancellable, error);
if (!in)
return FALSE;
- if (g_output_stream_splice (stdout_stream, in, G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,
- cancellable, error) < 0)
+ if (g_output_stream_splice (stdout_stream, in, G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE, cancellable,
+ error)
+ < 0)
return FALSE;
return TRUE;
}
gboolean
-ostree_builtin_cat (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_cat (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("COMMIT PATH...");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (GOptionContext) context = g_option_context_new ("COMMIT PATH...");
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
if (argc <= 2)
@@ -69,15 +69,15 @@ ostree_builtin_cat (int argc, char **argv, OstreeCommandInvocation *invocation,
}
const char *rev = argv[1];
- g_autoptr(GFile) root = NULL;
+ g_autoptr (GFile) root = NULL;
if (!ostree_repo_read_commit (repo, rev, &root, NULL, NULL, error))
return FALSE;
- g_autoptr(GOutputStream) stdout_stream = g_unix_output_stream_new (1, FALSE);
+ g_autoptr (GOutputStream) stdout_stream = g_unix_output_stream_new (1, FALSE);
for (int i = 2; i < argc; i++)
{
- g_autoptr(GFile) f = g_file_resolve_relative_path (root, argv[i]);
+ g_autoptr (GFile) f = g_file_resolve_relative_path (root, argv[i]);
if (!cat_one_file (f, stdout_stream, cancellable, error))
return FALSE;
diff --git a/src/ostree/ot-builtin-checkout.c b/src/ostree/ot-builtin-checkout.c
index bfa43885..dfaec755 100644
--- a/src/ostree/ot-builtin-checkout.c
+++ b/src/ostree/ot-builtin-checkout.c
@@ -21,12 +21,12 @@
#include "config.h"
-#include <string.h>
#include <gio/gunixinputstream.h>
+#include <string.h>
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
static gboolean opt_user_mode;
@@ -50,10 +50,7 @@ static char *opt_selinux_policy;
static char *opt_selinux_prefix;
static gboolean
-parse_fsync_cb (const char *option_name,
- const char *value,
- gpointer data,
- GError **error)
+parse_fsync_cb (const char *option_name, const char *value, gpointer data, GError **error)
{
gboolean val;
@@ -71,32 +68,51 @@ parse_fsync_cb (const char *option_name,
*/
static GOptionEntry options[] = {
- { "user-mode", 'U', 0, G_OPTION_ARG_NONE, &opt_user_mode, "Do not change file ownership or initialize extended attributes", NULL },
- { "disable-cache", 0, 0, G_OPTION_ARG_NONE, &opt_disable_cache, "Do not update or use the internal repository uncompressed object cache", NULL },
+ { "user-mode", 'U', 0, G_OPTION_ARG_NONE, &opt_user_mode,
+ "Do not change file ownership or initialize extended attributes", NULL },
+ { "disable-cache", 0, 0, G_OPTION_ARG_NONE, &opt_disable_cache,
+ "Do not update or use the internal repository uncompressed object cache", NULL },
{ "subpath", 0, 0, G_OPTION_ARG_FILENAME, &opt_subpath, "Checkout sub-directory PATH", "PATH" },
- { "union", 0, 0, G_OPTION_ARG_NONE, &opt_union, "Keep existing directories, overwrite existing files", NULL },
- { "union-add", 0, 0, G_OPTION_ARG_NONE, &opt_union_add, "Keep existing files/directories, only add new", NULL },
- { "union-identical", 0, 0, G_OPTION_ARG_NONE, &opt_union_identical, "When layering checkouts, error out if a file would be replaced with a different version, but add new files and directories", NULL },
- { "whiteouts", 0, 0, G_OPTION_ARG_NONE, &opt_whiteouts, "Process 'whiteout' (Docker style) entries", NULL },
- { "process-passthrough-whiteouts", 0, 0, G_OPTION_ARG_NONE, &opt_process_passthrough_whiteouts, "Enable overlayfs whiteout extraction into char 0:0 devices", NULL },
- { "allow-noent", 0, 0, G_OPTION_ARG_NONE, &opt_allow_noent, "Do nothing if specified path does not exist", NULL },
- { "from-stdin", 0, 0, G_OPTION_ARG_NONE, &opt_from_stdin, "Process many checkouts from standard input", NULL },
- { "from-file", 0, 0, G_OPTION_ARG_STRING, &opt_from_file, "Process many checkouts from input file", "FILE" },
- { "fsync", 0, 0, G_OPTION_ARG_CALLBACK, parse_fsync_cb, "Specify how to invoke fsync()", "POLICY" },
- { "require-hardlinks", 'H', 0, G_OPTION_ARG_NONE, &opt_require_hardlinks, "Do not fall back to full copies if hardlinking fails", NULL },
- { "force-copy-zerosized", 'z', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_force_copy_zerosized, "Do not hardlink zero-sized files", NULL },
- { "force-copy", 'C', 0, G_OPTION_ARG_NONE, &opt_force_copy, "Never hardlink (but may reflink if available)", NULL },
- { "bareuseronly-dirs", 'M', 0, G_OPTION_ARG_NONE, &opt_bareuseronly_dirs, "Suppress mode bits outside of 0775 for directories (suid, world writable, etc.)", NULL },
- { "skip-list", 0, 0, G_OPTION_ARG_FILENAME, &opt_skiplist_file, "File containing list of files to skip", "FILE" },
- { "selinux-policy", 0, 0, G_OPTION_ARG_FILENAME, &opt_selinux_policy, "Set SELinux labels based on policy in root filesystem PATH (may be /); implies --force-copy", "PATH" },
- { "selinux-prefix", 0, 0, G_OPTION_ARG_STRING, &opt_selinux_prefix, "When setting SELinux labels, prefix all paths by PREFIX", "PREFIX" },
+ { "union", 0, 0, G_OPTION_ARG_NONE, &opt_union,
+ "Keep existing directories, overwrite existing files", NULL },
+ { "union-add", 0, 0, G_OPTION_ARG_NONE, &opt_union_add,
+ "Keep existing files/directories, only add new", NULL },
+ { "union-identical", 0, 0, G_OPTION_ARG_NONE, &opt_union_identical,
+ "When layering checkouts, error out if a file would be replaced with a different version, but "
+ "add new files and directories",
+ NULL },
+ { "whiteouts", 0, 0, G_OPTION_ARG_NONE, &opt_whiteouts,
+ "Process 'whiteout' (Docker style) entries", NULL },
+ { "process-passthrough-whiteouts", 0, 0, G_OPTION_ARG_NONE, &opt_process_passthrough_whiteouts,
+ "Enable overlayfs whiteout extraction into char 0:0 devices", NULL },
+ { "allow-noent", 0, 0, G_OPTION_ARG_NONE, &opt_allow_noent,
+ "Do nothing if specified path does not exist", NULL },
+ { "from-stdin", 0, 0, G_OPTION_ARG_NONE, &opt_from_stdin,
+ "Process many checkouts from standard input", NULL },
+ { "from-file", 0, 0, G_OPTION_ARG_STRING, &opt_from_file,
+ "Process many checkouts from input file", "FILE" },
+ { "fsync", 0, 0, G_OPTION_ARG_CALLBACK, parse_fsync_cb, "Specify how to invoke fsync()",
+ "POLICY" },
+ { "require-hardlinks", 'H', 0, G_OPTION_ARG_NONE, &opt_require_hardlinks,
+ "Do not fall back to full copies if hardlinking fails", NULL },
+ { "force-copy-zerosized", 'z', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_force_copy_zerosized,
+ "Do not hardlink zero-sized files", NULL },
+ { "force-copy", 'C', 0, G_OPTION_ARG_NONE, &opt_force_copy,
+ "Never hardlink (but may reflink if available)", NULL },
+ { "bareuseronly-dirs", 'M', 0, G_OPTION_ARG_NONE, &opt_bareuseronly_dirs,
+ "Suppress mode bits outside of 0775 for directories (suid, world writable, etc.)", NULL },
+ { "skip-list", 0, 0, G_OPTION_ARG_FILENAME, &opt_skiplist_file,
+ "File containing list of files to skip", "FILE" },
+ { "selinux-policy", 0, 0, G_OPTION_ARG_FILENAME, &opt_selinux_policy,
+ "Set SELinux labels based on policy in root filesystem PATH (may be /); implies --force-copy",
+ "PATH" },
+ { "selinux-prefix", 0, 0, G_OPTION_ARG_STRING, &opt_selinux_prefix,
+ "When setting SELinux labels, prefix all paths by PREFIX", "PREFIX" },
{ NULL }
};
static gboolean
-handle_skiplist_line (const char *line,
- void *data,
- GError **error)
+handle_skiplist_line (const char *line, void *data, GError **error)
{
GHashTable *files = data;
g_hash_table_add (files, g_strdup (line));
@@ -104,10 +120,7 @@ handle_skiplist_line (const char *line,
}
static OstreeRepoCheckoutFilterResult
-checkout_filter (OstreeRepo *self,
- const char *path,
- struct stat *st_buf,
- gpointer user_data)
+checkout_filter (OstreeRepo *self, const char *path, struct stat *st_buf, gpointer user_data)
{
GHashTable *skiplist = user_data;
if (g_hash_table_contains (skiplist, path))
@@ -116,25 +129,22 @@ checkout_filter (OstreeRepo *self,
}
static gboolean
-process_one_checkout (OstreeRepo *repo,
- const char *resolved_commit,
- const char *subpath,
- const char *destination,
- GCancellable *cancellable,
- GError **error)
+process_one_checkout (OstreeRepo *repo, const char *resolved_commit, const char *subpath,
+ const char *destination, GCancellable *cancellable, GError **error)
{
/* This strange code structure is to preserve testing
* coverage of both `ostree_repo_checkout_tree` and
* `ostree_repo_checkout_at` until such time as we have a more
* convenient infrastructure for testing C APIs with data.
*/
- if (opt_disable_cache || opt_whiteouts || opt_require_hardlinks ||
- opt_union_add || opt_force_copy || opt_force_copy_zerosized ||
- opt_bareuseronly_dirs || opt_union_identical ||
- opt_skiplist_file || opt_selinux_policy || opt_selinux_prefix ||
- opt_process_passthrough_whiteouts)
+ if (opt_disable_cache || opt_whiteouts || opt_require_hardlinks || opt_union_add || opt_force_copy
+ || opt_force_copy_zerosized || opt_bareuseronly_dirs || opt_union_identical
+ || opt_skiplist_file || opt_selinux_policy || opt_selinux_prefix
+ || opt_process_passthrough_whiteouts)
{
- OstreeRepoCheckoutAtOptions checkout_options = { 0, };
+ OstreeRepoCheckoutAtOptions checkout_options = {
+ 0,
+ };
/* do this early so option checking also catches force copy conflicts */
if (opt_selinux_policy)
@@ -170,7 +180,7 @@ process_one_checkout (OstreeRepo *repo,
if (subpath)
checkout_options.subpath = subpath;
- g_autoptr(OstreeSePolicy) policy = NULL;
+ g_autoptr (OstreeSePolicy) policy = NULL;
if (opt_selinux_policy)
{
glnx_autofd int rootfs_dfd = -1;
@@ -183,8 +193,8 @@ process_one_checkout (OstreeRepo *repo,
checkout_options.sepolicy_prefix = opt_selinux_prefix;
}
- g_autoptr(GHashTable) skip_list =
- g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ g_autoptr (GHashTable) skip_list
+ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
if (opt_skiplist_file)
{
if (!ot_parse_file_by_line (opt_skiplist_file, handle_skiplist_line, skip_list,
@@ -199,35 +209,31 @@ process_one_checkout (OstreeRepo *repo,
checkout_options.force_copy_zerosized = opt_force_copy_zerosized;
checkout_options.bareuseronly_dirs = opt_bareuseronly_dirs;
- if (!ostree_repo_checkout_at (repo, &checkout_options,
- AT_FDCWD, destination,
- resolved_commit,
+ if (!ostree_repo_checkout_at (repo, &checkout_options, AT_FDCWD, destination, resolved_commit,
cancellable, error))
return FALSE;
}
else
{
GError *tmp_error = NULL;
- g_autoptr(GFile) root = NULL;
- g_autoptr(GFile) destination_file = g_file_new_for_path (destination);
+ g_autoptr (GFile) root = NULL;
+ g_autoptr (GFile) destination_file = g_file_new_for_path (destination);
if (!ostree_repo_read_commit (repo, resolved_commit, &root, NULL, cancellable, error))
return FALSE;
- g_autoptr(GFile) subtree = NULL;
+ g_autoptr (GFile) subtree = NULL;
if (subpath)
subtree = g_file_resolve_relative_path (root, subpath);
else
subtree = g_object_ref (root);
- g_autoptr(GFileInfo) file_info
- = g_file_query_info (subtree, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- cancellable, &tmp_error);
+ g_autoptr (GFileInfo) file_info
+ = g_file_query_info (subtree, OSTREE_GIO_FAST_QUERYINFO,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, &tmp_error);
if (!file_info)
{
- if (opt_allow_noent
- && g_error_matches (tmp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ if (opt_allow_noent && g_error_matches (tmp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
g_clear_error (&tmp_error);
/* Note early return */
@@ -242,8 +248,7 @@ process_one_checkout (OstreeRepo *repo,
if (!ostree_repo_checkout_tree (repo, opt_user_mode ? OSTREE_REPO_CHECKOUT_MODE_USER : 0,
opt_union ? OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES : 0,
- destination_file,
- OSTREE_REPO_FILE (subtree), file_info,
+ destination_file, OSTREE_REPO_FILE (subtree), file_info,
cancellable, error))
return FALSE;
}
@@ -252,46 +257,44 @@ process_one_checkout (OstreeRepo *repo,
}
static gboolean
-process_many_checkouts (OstreeRepo *repo,
- const char *target,
- GCancellable *cancellable,
- GError **error)
+process_many_checkouts (OstreeRepo *repo, const char *target, GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
gsize len;
GError *temp_error = NULL;
- g_autoptr(GInputStream) instream = NULL;
- g_autoptr(GDataInputStream) datastream = NULL;
+ g_autoptr (GInputStream) instream = NULL;
+ g_autoptr (GDataInputStream) datastream = NULL;
g_autofree char *revision = NULL;
g_autofree char *subpath = NULL;
g_autofree char *resolved_commit = NULL;
if (opt_from_stdin)
{
- instream = (GInputStream*)g_unix_input_stream_new (0, FALSE);
+ instream = (GInputStream *)g_unix_input_stream_new (0, FALSE);
}
else
{
- g_autoptr(GFile) f = g_file_new_for_path (opt_from_file);
+ g_autoptr (GFile) f = g_file_new_for_path (opt_from_file);
- instream = (GInputStream*)g_file_read (f, cancellable, error);
+ instream = (GInputStream *)g_file_read (f, cancellable, error);
if (!instream)
goto out;
}
datastream = g_data_input_stream_new (instream);
- while ((revision = g_data_input_stream_read_upto (datastream, "", 1, &len,
- cancellable, &temp_error)) != NULL)
+ while (
+ (revision = g_data_input_stream_read_upto (datastream, "", 1, &len, cancellable, &temp_error))
+ != NULL)
{
if (revision[0] == '\0')
break;
/* Read the null byte */
- (void) g_data_input_stream_read_byte (datastream, cancellable, NULL);
+ (void)g_data_input_stream_read_byte (datastream, cancellable, NULL);
g_free (subpath);
- subpath = g_data_input_stream_read_upto (datastream, "", 1, &len,
- cancellable, &temp_error);
+ subpath = g_data_input_stream_read_upto (datastream, "", 1, &len, cancellable, &temp_error);
if (temp_error)
{
g_propagate_error (error, temp_error);
@@ -299,13 +302,12 @@ process_many_checkouts (OstreeRepo *repo,
}
/* Read the null byte */
- (void) g_data_input_stream_read_byte (datastream, cancellable, NULL);
+ (void)g_data_input_stream_read_byte (datastream, cancellable, NULL);
if (!ostree_repo_resolve_rev (repo, revision, FALSE, &resolved_commit, error))
goto out;
- if (!process_one_checkout (repo, resolved_commit, subpath, target,
- cancellable, error))
+ if (!process_one_checkout (repo, resolved_commit, subpath, target, cancellable, error))
{
g_prefix_error (error, "Processing tree %s: ", resolved_commit);
goto out;
@@ -320,16 +322,18 @@ process_many_checkouts (OstreeRepo *repo,
}
ret = TRUE;
- out:
+out:
return ret;
}
gboolean
-ostree_builtin_checkout (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_checkout (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("COMMIT [DESTINATION]");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (GOptionContext) context = g_option_context_new ("COMMIT [DESTINATION]");
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
if (opt_disable_fsync)
@@ -362,9 +366,8 @@ ostree_builtin_checkout (int argc, char **argv, OstreeCommandInvocation *invocat
if (!ostree_repo_resolve_rev (repo, commit, FALSE, &resolved_commit, error))
return FALSE;
- if (!process_one_checkout (repo, resolved_commit, opt_subpath,
- destination,
- cancellable, error))
+ if (!process_one_checkout (repo, resolved_commit, opt_subpath, destination, cancellable,
+ error))
return FALSE;
}
diff --git a/src/ostree/ot-builtin-checksum.c b/src/ostree/ot-builtin-checksum.c
index 576fbfde..b3b15c26 100644
--- a/src/ostree/ot-builtin-checksum.c
+++ b/src/ostree/ot-builtin-checksum.c
@@ -21,9 +21,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include <string.h>
@@ -34,30 +34,28 @@
static gboolean opt_ignore_xattrs;
-static GOptionEntry options[] = {
- { "ignore-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_ignore_xattrs, "Don't include xattrs in checksum", NULL },
- { NULL }
-};
+static GOptionEntry options[] = { { "ignore-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_ignore_xattrs,
+ "Don't include xattrs in checksum", NULL },
+ { NULL } };
-typedef struct {
+typedef struct
+{
GError **error;
gboolean success;
GMainLoop *loop;
} AsyncChecksumData;
static void
-on_checksum_received (GObject *obj,
- GAsyncResult *result,
- gpointer user_data)
+on_checksum_received (GObject *obj, GAsyncResult *result, gpointer user_data)
{
AsyncChecksumData *data = user_data;
g_autofree guchar *csum_bytes = NULL;
- data->success =
- ostree_checksum_file_async_finish ((GFile*)obj, result, &csum_bytes, data->error);
+ data->success
+ = ostree_checksum_file_async_finish ((GFile *)obj, result, &csum_bytes, data->error);
if (data->success)
{
- char csum[OSTREE_SHA256_STRING_LEN+1];
+ char csum[OSTREE_SHA256_STRING_LEN + 1];
ostree_checksum_inplace_from_bytes (csum_bytes, csum);
g_print ("%s\n", csum);
}
@@ -66,12 +64,12 @@ on_checksum_received (GObject *obj,
}
gboolean
-ostree_builtin_checksum (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_checksum (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context =
- g_option_context_new ("PATH");
- if (!ostree_option_context_parse (context, options, &argc, &argv,
- invocation, NULL, cancellable, error))
+ g_autoptr (GOptionContext) context = g_option_context_new ("PATH");
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, NULL, cancellable,
+ error))
return FALSE;
if (argc < 2)
@@ -81,23 +79,24 @@ ostree_builtin_checksum (int argc, char **argv, OstreeCommandInvocation *invocat
/* for test coverage, use the async API if no flags are needed */
if (!opt_ignore_xattrs)
{
- g_autoptr(GFile) f = g_file_new_for_path (path);
- g_autoptr(GMainLoop) loop = g_main_loop_new (NULL, FALSE);
+ g_autoptr (GFile) f = g_file_new_for_path (path);
+ g_autoptr (GMainLoop) loop = g_main_loop_new (NULL, FALSE);
- AsyncChecksumData data = { 0, };
+ AsyncChecksumData data = {
+ 0,
+ };
data.loop = loop;
data.error = error;
- ostree_checksum_file_async (f, OSTREE_OBJECT_TYPE_FILE, G_PRIORITY_DEFAULT,
- cancellable, on_checksum_received, &data);
+ ostree_checksum_file_async (f, OSTREE_OBJECT_TYPE_FILE, G_PRIORITY_DEFAULT, cancellable,
+ on_checksum_received, &data);
g_main_loop_run (data.loop);
return data.success;
}
g_autofree char *checksum = NULL;
if (!ostree_checksum_file_at (AT_FDCWD, path, NULL, OSTREE_OBJECT_TYPE_FILE,
- OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS, &checksum,
- cancellable, error))
+ OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS, &checksum, cancellable, error))
return FALSE;
g_print ("%s\n", checksum);
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index 1db2e2bc..8f56779f 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -21,15 +21,15 @@
#include "config.h"
-#include "ot-main.h"
+#include "ostree-libarchive-private.h"
+#include "ostree-repo-private.h"
+#include "ostree-sign.h"
+#include "ostree.h"
#include "ot-builtins.h"
#include "ot-editor.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
#include "parse-datetime.h"
-#include "ostree-repo-private.h"
-#include "ostree-libarchive-private.h"
-#include "ostree-sign.h"
static char *opt_subject;
static char *opt_body;
@@ -74,10 +74,7 @@ static gboolean opt_disable_fsync;
static char *opt_timestamp;
static gboolean
-parse_fsync_cb (const char *option_name,
- const char *value,
- gpointer data,
- GError **error)
+parse_fsync_cb (const char *option_name, const char *value, gpointer data, GError **error)
{
gboolean val;
if (!ot_parse_boolean (value, &val, error))
@@ -93,61 +90,95 @@ parse_fsync_cb (const char *option_name,
*/
static GOptionEntry options[] = {
- { "parent", 0, 0, G_OPTION_ARG_STRING, &opt_parent, "Parent commit checksum, or \"none\"", "COMMIT" },
+ { "parent", 0, 0, G_OPTION_ARG_STRING, &opt_parent, "Parent commit checksum, or \"none\"",
+ "COMMIT" },
{ "subject", 's', 0, G_OPTION_ARG_STRING, &opt_subject, "One line subject", "SUBJECT" },
{ "body", 'm', 0, G_OPTION_ARG_STRING, &opt_body, "Full description", "BODY" },
- { "body-file", 'F', 0, G_OPTION_ARG_FILENAME, &opt_body_file, "Commit message from FILE path", "FILE" },
- { "editor", 'e', 0, G_OPTION_ARG_NONE, &opt_editor, "Use an editor to write the commit message", NULL },
+ { "body-file", 'F', 0, G_OPTION_ARG_FILENAME, &opt_body_file, "Commit message from FILE path",
+ "FILE" },
+ { "editor", 'e', 0, G_OPTION_ARG_NONE, &opt_editor, "Use an editor to write the commit message",
+ NULL },
{ "branch", 'b', 0, G_OPTION_ARG_STRING, &opt_branch, "Branch", "BRANCH" },
{ "orphan", 0, 0, G_OPTION_ARG_NONE, &opt_orphan, "Create a commit without writing a ref", NULL },
- { "no-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_no_bindings, "Do not write any ref bindings", NULL },
- { "bind-ref", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_bind_refs, "Add a ref to ref binding commit metadata", "BRANCH" },
- { "base", 0, 0, G_OPTION_ARG_STRING, &opt_base, "Start from the given commit as a base (no modifiers apply)", "REV" },
- { "tree", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_trees, "Overlay the given argument as a tree", "dir=PATH or tar=TARFILE or ref=COMMIT" },
- { "add-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_strings, "Add a key/value pair to metadata", "KEY=VALUE" },
- { "add-metadata", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_variants, "Add a key/value pair to metadata, where the KEY is a string, and VALUE is in GVariant Text Format", "KEY=VALUE" },
- { "keep-metadata", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_keep, "Keep metadata KEY and its associated VALUE from parent", "KEY" },
- { "add-detached-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_detached_metadata_strings, "Add a key/value pair to detached metadata", "KEY=VALUE" },
+ { "no-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_no_bindings, "Do not write any ref bindings",
+ NULL },
+ { "bind-ref", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_bind_refs,
+ "Add a ref to ref binding commit metadata", "BRANCH" },
+ { "base", 0, 0, G_OPTION_ARG_STRING, &opt_base,
+ "Start from the given commit as a base (no modifiers apply)", "REV" },
+ { "tree", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_trees, "Overlay the given argument as a tree",
+ "dir=PATH or tar=TARFILE or ref=COMMIT" },
+ { "add-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_strings,
+ "Add a key/value pair to metadata", "KEY=VALUE" },
+ { "add-metadata", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_variants,
+ "Add a key/value pair to metadata, where the KEY is a string, and VALUE is in GVariant Text "
+ "Format",
+ "KEY=VALUE" },
+ { "keep-metadata", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_keep,
+ "Keep metadata KEY and its associated VALUE from parent", "KEY" },
+ { "add-detached-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_detached_metadata_strings,
+ "Add a key/value pair to detached metadata", "KEY=VALUE" },
{ "owner-uid", 0, 0, G_OPTION_ARG_INT, &opt_owner_uid, "Set file ownership user id", "UID" },
{ "owner-gid", 0, 0, G_OPTION_ARG_INT, &opt_owner_gid, "Set file ownership group id", "GID" },
- { "canonical-permissions", 0, 0, G_OPTION_ARG_NONE, &opt_canonical_permissions, "Canonicalize permissions in the same way bare-user does for hardlinked files", NULL },
- { "bootable", 0, 0, G_OPTION_ARG_NONE, &opt_bootable, "Flag this commit as a bootable OSTree (e.g. contains a Linux kernel)", NULL },
- { "mode-ro-executables", 0, 0, G_OPTION_ARG_NONE, &opt_ro_executables, "Ensure executable files are not writable", NULL },
- { "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Do not import extended attributes", NULL },
- { "selinux-policy", 0, 0, G_OPTION_ARG_FILENAME, &opt_selinux_policy, "Set SELinux labels based on policy in root filesystem PATH (may be /)", "PATH" },
- { "selinux-policy-from-base", 'P', 0, G_OPTION_ARG_NONE, &opt_selinux_policy_from_base, "Set SELinux labels based on first --tree argument", NULL },
- { "link-checkout-speedup", 0, 0, G_OPTION_ARG_NONE, &opt_link_checkout_speedup, "Optimize for commits of trees composed of hardlinks into the repository", NULL },
- { "devino-canonical", 'I', 0, G_OPTION_ARG_NONE, &opt_devino_canonical, "Assume hardlinked objects are unmodified. Implies --link-checkout-speedup", NULL },
- { "tar-autocreate-parents", 0, 0, G_OPTION_ARG_NONE, &opt_tar_autocreate_parents, "When loading tar archives, automatically create parent directories as needed", NULL },
- { "tar-pathname-filter", 0, 0, G_OPTION_ARG_STRING, &opt_tar_pathname_filter, "When loading tar archives, use REGEX,REPLACEMENT against path names", "REGEX,REPLACEMENT" },
- { "skip-if-unchanged", 0, 0, G_OPTION_ARG_NONE, &opt_skip_if_unchanged, "If the contents are unchanged from previous commit, do nothing", NULL },
- { "statoverride", 0, 0, G_OPTION_ARG_FILENAME, &opt_statoverride_file, "File containing list of modifications to make to permissions", "PATH" },
- { "skip-list", 0, 0, G_OPTION_ARG_FILENAME, &opt_skiplist_file, "File containing list of files to skip", "PATH" },
- { "consume", 0, 0, G_OPTION_ARG_NONE, &opt_consume, "Consume (delete) content after commit (for local directories)", NULL },
- { "table-output", 0, 0, G_OPTION_ARG_NONE, &opt_table_output, "Output more information in a KEY: VALUE format", NULL },
+ { "canonical-permissions", 0, 0, G_OPTION_ARG_NONE, &opt_canonical_permissions,
+ "Canonicalize permissions in the same way bare-user does for hardlinked files", NULL },
+ { "bootable", 0, 0, G_OPTION_ARG_NONE, &opt_bootable,
+ "Flag this commit as a bootable OSTree (e.g. contains a Linux kernel)", NULL },
+ { "mode-ro-executables", 0, 0, G_OPTION_ARG_NONE, &opt_ro_executables,
+ "Ensure executable files are not writable", NULL },
+ { "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Do not import extended attributes",
+ NULL },
+ { "selinux-policy", 0, 0, G_OPTION_ARG_FILENAME, &opt_selinux_policy,
+ "Set SELinux labels based on policy in root filesystem PATH (may be /)", "PATH" },
+ { "selinux-policy-from-base", 'P', 0, G_OPTION_ARG_NONE, &opt_selinux_policy_from_base,
+ "Set SELinux labels based on first --tree argument", NULL },
+ { "link-checkout-speedup", 0, 0, G_OPTION_ARG_NONE, &opt_link_checkout_speedup,
+ "Optimize for commits of trees composed of hardlinks into the repository", NULL },
+ { "devino-canonical", 'I', 0, G_OPTION_ARG_NONE, &opt_devino_canonical,
+ "Assume hardlinked objects are unmodified. Implies --link-checkout-speedup", NULL },
+ { "tar-autocreate-parents", 0, 0, G_OPTION_ARG_NONE, &opt_tar_autocreate_parents,
+ "When loading tar archives, automatically create parent directories as needed", NULL },
+ { "tar-pathname-filter", 0, 0, G_OPTION_ARG_STRING, &opt_tar_pathname_filter,
+ "When loading tar archives, use REGEX,REPLACEMENT against path names", "REGEX,REPLACEMENT" },
+ { "skip-if-unchanged", 0, 0, G_OPTION_ARG_NONE, &opt_skip_if_unchanged,
+ "If the contents are unchanged from previous commit, do nothing", NULL },
+ { "statoverride", 0, 0, G_OPTION_ARG_FILENAME, &opt_statoverride_file,
+ "File containing list of modifications to make to permissions", "PATH" },
+ { "skip-list", 0, 0, G_OPTION_ARG_FILENAME, &opt_skiplist_file,
+ "File containing list of files to skip", "PATH" },
+ { "consume", 0, 0, G_OPTION_ARG_NONE, &opt_consume,
+ "Consume (delete) content after commit (for local directories)", NULL },
+ { "table-output", 0, 0, G_OPTION_ARG_NONE, &opt_table_output,
+ "Output more information in a KEY: VALUE format", NULL },
#ifndef OSTREE_DISABLE_GPGME
- { "gpg-sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_gpg_key_ids, "GPG Key ID to sign the commit with", "KEY-ID"},
- { "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir, "GPG Homedir to use when looking for keyrings", "HOMEDIR"},
+ { "gpg-sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_gpg_key_ids,
+ "GPG Key ID to sign the commit with", "KEY-ID" },
+ { "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir,
+ "GPG Homedir to use when looking for keyrings", "HOMEDIR" },
#endif
- { "sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "Sign the commit with", "KEY_ID"},
- { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name, "Signature type to use (defaults to 'ed25519')", "NAME"},
- { "generate-sizes", 0, 0, G_OPTION_ARG_NONE, &opt_generate_sizes, "Generate size information along with commit metadata", NULL },
- { "disable-fsync", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
- { "fsync", 0, 0, G_OPTION_ARG_CALLBACK, parse_fsync_cb, "Specify how to invoke fsync()", "POLICY" },
- { "timestamp", 0, 0, G_OPTION_ARG_STRING, &opt_timestamp, "Override the timestamp of the commit", "TIMESTAMP" },
+ { "sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "Sign the commit with", "KEY_ID" },
+ { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name,
+ "Signature type to use (defaults to 'ed25519')", "NAME" },
+ { "generate-sizes", 0, 0, G_OPTION_ARG_NONE, &opt_generate_sizes,
+ "Generate size information along with commit metadata", NULL },
+ { "disable-fsync", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_disable_fsync,
+ "Do not invoke fsync()", NULL },
+ { "fsync", 0, 0, G_OPTION_ARG_CALLBACK, parse_fsync_cb, "Specify how to invoke fsync()",
+ "POLICY" },
+ { "timestamp", 0, 0, G_OPTION_ARG_STRING, &opt_timestamp, "Override the timestamp of the commit",
+ "TIMESTAMP" },
{ NULL }
};
-struct CommitFilterData {
+struct CommitFilterData
+{
GHashTable *mode_adds;
GHashTable *mode_overrides;
GHashTable *skip_list;
};
static gboolean
-handle_statoverride_line (const char *line,
- void *data,
- GError **error)
+handle_statoverride_line (const char *line, void *data, GError **error)
{
struct CommitFilterData *cf = data;
const char *spc = strchr (line, ' ');
@@ -157,23 +188,20 @@ handle_statoverride_line (const char *line,
if (g_str_has_prefix (line, "="))
{
- guint mode_override = (guint32)(gint32)g_ascii_strtod (line+1, NULL);
+ guint mode_override = (guint32)(gint32)g_ascii_strtod (line + 1, NULL);
g_hash_table_insert (cf->mode_overrides, g_strdup (fn),
- GUINT_TO_POINTER((gint32)mode_override));
+ GUINT_TO_POINTER ((gint32)mode_override));
}
else
{
guint mode_add = (guint32)(gint32)g_ascii_strtod (line, NULL);
- g_hash_table_insert (cf->mode_adds, g_strdup (fn),
- GUINT_TO_POINTER((gint32)mode_add));
+ g_hash_table_insert (cf->mode_adds, g_strdup (fn), GUINT_TO_POINTER ((gint32)mode_add));
}
return TRUE;
}
static gboolean
-handle_skiplist_line (const char *line,
- void *data,
- GError **error)
+handle_skiplist_line (const char *line, void *data, GError **error)
{
GHashTable *files = data;
g_hash_table_add (files, g_strdup (line));
@@ -181,10 +209,7 @@ handle_skiplist_line (const char *line,
}
static OstreeRepoCommitFilterResult
-commit_filter (OstreeRepo *self,
- const char *path,
- GFileInfo *file_info,
- gpointer user_data)
+commit_filter (OstreeRepo *self, const char *path, GFileInfo *file_info, gpointer user_data)
{
struct CommitFilterData *data = user_data;
GHashTable *mode_adds = data->mode_adds;
@@ -207,16 +232,14 @@ commit_filter (OstreeRepo *self,
if (mode_adds && g_hash_table_lookup_extended (mode_adds, path, NULL, &value))
{
guint mode_add = GPOINTER_TO_UINT (value);
- g_file_info_set_attribute_uint32 (file_info, "unix::mode",
- mode | mode_add);
+ g_file_info_set_attribute_uint32 (file_info, "unix::mode", mode | mode_add);
g_hash_table_remove (mode_adds, path);
}
else if (mode_overrides && g_hash_table_lookup_extended (mode_overrides, path, NULL, &value))
{
guint current_fmt = g_file_info_get_attribute_uint32 (file_info, "unix::mode") & S_IFMT;
guint mode_override = GPOINTER_TO_UINT (value);
- g_file_info_set_attribute_uint32 (file_info, "unix::mode",
- current_fmt | mode_override);
+ g_file_info_set_attribute_uint32 (file_info, "unix::mode", current_fmt | mode_override);
g_hash_table_remove (mode_adds, path);
}
@@ -230,23 +253,20 @@ commit_filter (OstreeRepo *self,
}
#ifdef HAVE_LIBARCHIVE
-typedef struct {
+typedef struct
+{
GRegex *regex;
const char *replacement;
} TranslatePathnameData;
/* Implement --tar-pathname-filter */
static char *
-handle_translate_pathname (OstreeRepo *repo,
- const struct stat *stbuf,
- const char *path,
+handle_translate_pathname (OstreeRepo *repo, const struct stat *stbuf, const char *path,
gpointer user_data)
{
TranslatePathnameData *tpdata = user_data;
- g_autoptr(GError) tmp_error = NULL;
- char *ret =
- g_regex_replace (tpdata->regex, path, -1, 0,
- tpdata->replacement, 0, &tmp_error);
+ g_autoptr (GError) tmp_error = NULL;
+ char *ret = g_regex_replace (tpdata->regex, path, -1, 0, tpdata->replacement, 0, &tmp_error);
g_assert_no_error (tmp_error);
g_assert (ret);
return ret;
@@ -254,22 +274,17 @@ handle_translate_pathname (OstreeRepo *repo,
#endif
static gboolean
-commit_editor (OstreeRepo *repo,
- const char *branch,
- char **subject,
- char **body,
- GCancellable *cancellable,
- GError **error)
+commit_editor (OstreeRepo *repo, const char *branch, char **subject, char **body,
+ GCancellable *cancellable, GError **error)
{
- g_autofree char *input = g_strdup_printf ("\n"
+ g_autofree char *input = g_strdup_printf (
+ "\n"
"# Please enter the commit message for your changes. The first line will\n"
"# become the subject, and the remainder the body. Lines starting\n"
"# with '#' will be ignored, and an empty message aborts the commit."
- "%s%s%s%s%s%s\n"
- , branch ? "\n#\n# Branch: " : "", branch ? branch : ""
- , *subject ? "\n" : "", *subject ? *subject : ""
- , *body ? "\n" : "", *body ? *body : ""
- );
+ "%s%s%s%s%s%s\n",
+ branch ? "\n#\n# Branch: " : "", branch ? branch : "", *subject ? "\n" : "",
+ *subject ? *subject : "", *body ? "\n" : "", *body ? *body : "");
*subject = NULL;
*body = NULL;
@@ -278,8 +293,8 @@ commit_editor (OstreeRepo *repo,
if (output == NULL)
return FALSE;
- g_auto(GStrv) lines = g_strsplit (output, "\n", -1);
- g_autoptr(GString) bodybuf = NULL;
+ g_auto (GStrv) lines = g_strsplit (output, "\n", -1);
+ g_autoptr (GString) bodybuf = NULL;
for (guint i = 0; lines[i] != NULL; i++)
{
g_strchomp (lines[i]);
@@ -323,12 +338,10 @@ commit_editor (OstreeRepo *repo,
}
static gboolean
-parse_keyvalue_strings (GVariantBuilder *builder,
- char **strings,
- gboolean is_gvariant_print,
- GError **error)
+parse_keyvalue_strings (GVariantBuilder *builder, char **strings, gboolean is_gvariant_print,
+ GError **error)
{
- for (char ** iter = strings; *iter; iter++)
+ for (char **iter = strings; *iter; iter++)
{
const char *s = *iter;
const char *eq = strchr (s, '=');
@@ -338,23 +351,21 @@ parse_keyvalue_strings (GVariantBuilder *builder,
const char *value = eq + 1;
if (is_gvariant_print)
{
- g_autoptr(GVariant) variant = g_variant_parse (NULL, value, NULL, NULL, error);
+ g_autoptr (GVariant) variant = g_variant_parse (NULL, value, NULL, NULL, error);
if (!variant)
return glnx_prefix_error (error, "Parsing %s", s);
g_variant_builder_add (builder, "{sv}", key, variant);
}
else
- g_variant_builder_add (builder, "{sv}", key,
- g_variant_new_string (value));
+ g_variant_builder_add (builder, "{sv}", key, g_variant_new_string (value));
}
return TRUE;
}
static void
-add_collection_binding (OstreeRepo *repo,
- GVariantBuilder *metadata_builder)
+add_collection_binding (OstreeRepo *repo, GVariantBuilder *metadata_builder)
{
const char *collection_id = ostree_repo_get_collection_id (repo);
@@ -379,67 +390,68 @@ add_ref_binding (GVariantBuilder *metadata_builder)
{
g_assert (opt_branch != NULL || opt_orphan);
- g_autoptr(GPtrArray) refs = g_ptr_array_new ();
+ g_autoptr (GPtrArray) refs = g_ptr_array_new ();
if (opt_branch != NULL)
g_ptr_array_add (refs, opt_branch);
for (char **iter = opt_bind_refs; iter != NULL && *iter != NULL; ++iter)
g_ptr_array_add (refs, *iter);
g_ptr_array_sort (refs, compare_strings);
- g_autoptr(GVariant) refs_v = g_variant_new_strv ((const char *const *)refs->pdata,
- refs->len);
+ g_autoptr (GVariant) refs_v = g_variant_new_strv ((const char *const *)refs->pdata, refs->len);
g_variant_builder_add (metadata_builder, "{s@v}", OSTREE_COMMIT_META_KEY_REF_BINDING,
g_variant_new_variant (g_steal_pointer (&refs_v)));
}
/* Note if you're using the API, you currently need to do this yourself */
static void
-fill_bindings (OstreeRepo *repo,
- GVariant *metadata,
- GVariant **out_metadata)
+fill_bindings (OstreeRepo *repo, GVariant *metadata, GVariant **out_metadata)
{
- g_autoptr(GVariantBuilder) metadata_builder =
- ot_util_variant_builder_from_variant (metadata, G_VARIANT_TYPE_VARDICT);
+ g_autoptr (GVariantBuilder) metadata_builder
+ = ot_util_variant_builder_from_variant (metadata, G_VARIANT_TYPE_VARDICT);
add_ref_binding (metadata_builder);
/* Allow the collection ID to be overridden using
* --add-metadata-string=ostree.collection-binding=blah */
- if (metadata == NULL ||
- !g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_COLLECTION_BINDING, "*", NULL))
+ if (metadata == NULL
+ || !g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_COLLECTION_BINDING, "*", NULL))
add_collection_binding (repo, metadata_builder);
*out_metadata = g_variant_ref_sink (g_variant_builder_end (metadata_builder));
}
gboolean
-ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
gboolean ret = FALSE;
gboolean skip_commit = FALSE;
- g_autoptr(GFile) object_to_commit = NULL;
+ g_autoptr (GFile) object_to_commit = NULL;
g_autofree char *parent = NULL;
g_autofree char *commit_checksum = NULL;
- g_autoptr(GFile) root = NULL;
- g_autoptr(GVariant) metadata = NULL;
- g_autoptr(GVariant) detached_metadata = NULL;
- g_autoptr(OstreeMutableTree) mtree = NULL;
+ g_autoptr (GFile) root = NULL;
+ g_autoptr (GVariant) metadata = NULL;
+ g_autoptr (GVariant) detached_metadata = NULL;
+ g_autoptr (OstreeMutableTree) mtree = NULL;
g_autofree char *tree_type = NULL;
- g_autoptr(GHashTable) mode_adds = NULL;
- g_autoptr(GHashTable) mode_overrides = NULL;
- g_autoptr(GHashTable) skip_list = NULL;
+ g_autoptr (GHashTable) mode_adds = NULL;
+ g_autoptr (GHashTable) mode_overrides = NULL;
+ g_autoptr (GHashTable) skip_list = NULL;
OstreeRepoCommitModifierFlags flags = 0;
- g_autoptr(OstreeSePolicy) policy = NULL;
- g_autoptr(OstreeRepoCommitModifier) modifier = NULL;
+ g_autoptr (OstreeSePolicy) policy = NULL;
+ g_autoptr (OstreeRepoCommitModifier) modifier = NULL;
OstreeRepoTransactionStats stats;
- struct CommitFilterData filter_data = { 0, };
+ struct CommitFilterData filter_data = {
+ 0,
+ };
g_autofree char *commit_body = NULL;
g_autoptr (OstreeSign) sign = NULL;
context = g_option_context_new ("[PATH]");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
@@ -447,18 +459,20 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_statoverride_file)
{
- filter_data.mode_adds = mode_adds = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- filter_data.mode_overrides = mode_overrides = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- if (!ot_parse_file_by_line (opt_statoverride_file, handle_statoverride_line,
- &filter_data, cancellable, error))
+ filter_data.mode_adds = mode_adds
+ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ filter_data.mode_overrides = mode_overrides
+ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ if (!ot_parse_file_by_line (opt_statoverride_file, handle_statoverride_line, &filter_data,
+ cancellable, error))
goto out;
}
if (opt_skiplist_file)
{
skip_list = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- if (!ot_parse_file_by_line (opt_skiplist_file, handle_skiplist_line,
- skip_list, cancellable, error))
+ if (!ot_parse_file_by_line (opt_skiplist_file, handle_skiplist_line, skip_list, cancellable,
+ error))
goto out;
}
@@ -487,10 +501,11 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY))
{
/* A folder exists with the specified ref name,
- * which is handled by _ostree_repo_write_ref */
+ * which is handled by _ostree_repo_write_ref */
g_clear_error (error);
}
- else goto out;
+ else
+ goto out;
}
}
@@ -504,31 +519,30 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_metadata_strings || opt_metadata_variants || opt_metadata_keep || opt_bootable)
{
- g_autoptr(GVariantBuilder) builder =
- g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
+ g_autoptr (GVariantBuilder) builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
- if (opt_metadata_strings &&
- !parse_keyvalue_strings (builder, opt_metadata_strings, FALSE, error))
- goto out;
+ if (opt_metadata_strings
+ && !parse_keyvalue_strings (builder, opt_metadata_strings, FALSE, error))
+ goto out;
- if (opt_metadata_variants &&
- !parse_keyvalue_strings (builder, opt_metadata_variants, TRUE, error))
+ if (opt_metadata_variants
+ && !parse_keyvalue_strings (builder, opt_metadata_variants, TRUE, error))
goto out;
if (opt_metadata_keep)
{
g_assert (parent);
- g_autoptr(GVariant) parent_commit = NULL;
+ g_autoptr (GVariant) parent_commit = NULL;
if (!ostree_repo_load_commit (repo, parent, &parent_commit, NULL, error))
goto out;
- g_auto(GVariantDict) dict;
+ g_auto (GVariantDict) dict;
g_variant_dict_init (&dict, g_variant_get_child_value (parent_commit, 0));
for (char **keyp = opt_metadata_keep; keyp && *keyp; keyp++)
{
const char *key = *keyp;
- g_autoptr(GVariant) val = g_variant_dict_lookup_value (&dict, key, NULL);
+ g_autoptr (GVariant) val = g_variant_dict_lookup_value (&dict, key, NULL);
if (!val)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -545,8 +559,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_detached_metadata_strings)
{
- g_autoptr(GVariantBuilder) builder =
- g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
+ g_autoptr (GVariantBuilder) builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
if (!parse_keyvalue_strings (builder, opt_detached_metadata_strings, FALSE, error))
goto out;
@@ -587,20 +600,13 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_disable_fsync)
ostree_repo_set_disable_fsync (repo, TRUE);
- if (flags != 0
- || opt_owner_uid >= 0
- || opt_owner_gid >= 0
- || opt_statoverride_file != NULL
- || opt_skiplist_file != NULL
- || opt_no_xattrs
- || opt_ro_executables
- || opt_selinux_policy
+ if (flags != 0 || opt_owner_uid >= 0 || opt_owner_gid >= 0 || opt_statoverride_file != NULL
+ || opt_skiplist_file != NULL || opt_no_xattrs || opt_ro_executables || opt_selinux_policy
|| opt_selinux_policy_from_base)
{
filter_data.mode_adds = mode_adds;
filter_data.skip_list = skip_list;
- modifier = ostree_repo_commit_modifier_new (flags, commit_filter,
- &filter_data, NULL);
+ modifier = ostree_repo_commit_modifier_new (flags, commit_filter, &filter_data, NULL);
if (opt_selinux_policy)
{
@@ -621,8 +627,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
}
else if (opt_body_file)
{
- commit_body = glnx_file_get_contents_utf8_at (AT_FDCWD, opt_body_file, NULL,
- cancellable, error);
+ commit_body
+ = glnx_file_get_contents_utf8_at (AT_FDCWD, opt_body_file, NULL, cancellable, error);
if (!commit_body)
goto out;
}
@@ -644,7 +650,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_selinux_policy_from_base)
{
g_assert (modifier);
- if (!ostree_repo_commit_modifier_set_sepolicy_from_commit (modifier, repo, opt_base, cancellable, error))
+ if (!ostree_repo_commit_modifier_set_sepolicy_from_commit (modifier, repo, opt_base,
+ cancellable, error))
goto out;
/* Don't try to handle it twice */
opt_selinux_policy_from_base = FALSE;
@@ -655,7 +662,6 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
mtree = ostree_mutable_tree_new ();
}
-
/* Convert implicit . or explicit path via argv into
* --tree=dir= so that we only have one primary code path below.
*/
@@ -670,20 +676,20 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
opt_trees[0] = g_strconcat ("dir=", path, NULL);
}
- const char *const*tree_iter;
+ const char *const *tree_iter;
const char *tree;
const char *eq;
g_assert (opt_trees && *opt_trees);
- for (tree_iter = (const char *const*)opt_trees; *tree_iter; tree_iter++)
+ for (tree_iter = (const char *const *)opt_trees; *tree_iter; tree_iter++)
{
- const gboolean first = (tree_iter == (const char *const*)opt_trees);
+ const gboolean first = (tree_iter == (const char *const *)opt_trees);
tree = *tree_iter;
eq = strchr (tree, '=');
if (!eq)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Missing type in tree specification '%s'", tree);
+ "Missing type in tree specification '%s'", tree);
goto out;
}
g_free (tree_type);
@@ -703,8 +709,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
goto out;
ostree_repo_commit_modifier_set_sepolicy (modifier, policy);
}
- if (!ostree_repo_write_dfd_to_mtree (repo, AT_FDCWD, tree, mtree, modifier,
- cancellable, error))
+ if (!ostree_repo_write_dfd_to_mtree (repo, AT_FDCWD, tree, mtree, modifier, cancellable,
+ error))
goto out;
}
else if (strcmp (tree_type, "tar") == 0)
@@ -718,9 +724,9 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
{
if (strcmp (tree, "-") == 0)
{
- if (!ostree_repo_write_archive_to_mtree_from_fd (repo, STDIN_FILENO, mtree, modifier,
- opt_tar_autocreate_parents,
- cancellable, error))
+ if (!ostree_repo_write_archive_to_mtree_from_fd (
+ repo, STDIN_FILENO, mtree, modifier, opt_tar_autocreate_parents,
+ cancellable, error))
goto out;
}
else
@@ -728,8 +734,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
object_to_commit = g_file_new_for_path (tree);
if (!ostree_repo_write_archive_to_mtree (repo, object_to_commit, mtree, modifier,
- opt_tar_autocreate_parents,
- cancellable, error))
+ opt_tar_autocreate_parents, cancellable,
+ error))
goto out;
}
}
@@ -740,16 +746,19 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (!comma)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Missing ',' in --tar-pathname-filter");
+ "Missing ',' in --tar-pathname-filter");
goto out;
}
const char *replacement = comma + 1;
- g_autofree char *regexp_text = g_strndup (opt_tar_pathname_filter, comma - opt_tar_pathname_filter);
+ g_autofree char *regexp_text
+ = g_strndup (opt_tar_pathname_filter, comma - opt_tar_pathname_filter);
/* Use new API if we have a pathname filter */
- OstreeRepoImportArchiveOptions opts = { 0, };
+ OstreeRepoImportArchiveOptions opts = {
+ 0,
+ };
opts.autocreate_parents = opt_tar_autocreate_parents;
opts.translate_pathname = handle_translate_pathname;
- g_autoptr(GRegex) regexp = g_regex_new (regexp_text, 0, 0, error);
+ g_autoptr (GRegex) regexp = g_regex_new (regexp_text, 0, 0, error);
TranslatePathnameData tpdata = { regexp, replacement };
if (!regexp)
{
@@ -758,7 +767,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
}
opts.translate_pathname_user_data = &tpdata;
- g_autoptr(OtAutoArchiveRead) archive;
+ g_autoptr (OtAutoArchiveRead) archive;
if (strcmp (tree, "-") == 0)
archive = ot_open_archive_read_fd (STDIN_FILENO, error);
else
@@ -766,12 +775,12 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (!archive)
goto out;
- if (!ostree_repo_import_archive_to_mtree (repo, &opts, archive, mtree,
- modifier, cancellable, error))
+ if (!ostree_repo_import_archive_to_mtree (repo, &opts, archive, mtree, modifier,
+ cancellable, error))
goto out;
#else
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- "This version of ostree is not compiled with libarchive support");
+ "This version of ostree is not compiled with libarchive support");
goto out;
#endif
}
@@ -781,20 +790,21 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (first && opt_selinux_policy_from_base)
{
g_assert (modifier);
- if (!ostree_repo_commit_modifier_set_sepolicy_from_commit (modifier, repo, tree, cancellable, error))
+ if (!ostree_repo_commit_modifier_set_sepolicy_from_commit (modifier, repo, tree,
+ cancellable, error))
goto out;
}
if (!ostree_repo_read_commit (repo, tree, &object_to_commit, NULL, cancellable, error))
goto out;
if (!ostree_repo_write_directory_to_mtree (repo, object_to_commit, mtree, modifier,
- cancellable, error))
+ cancellable, error))
goto out;
}
else
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid tree type specification '%s'", tree_type);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Invalid tree type specification '%s'",
+ tree_type);
goto out;
}
}
@@ -808,10 +818,9 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
while (g_hash_table_iter_next (&hash_iter, &key, &value))
{
- g_printerr ("Unmatched statoverride path: %s\n", (char*)key);
+ g_printerr ("Unmatched statoverride path: %s\n", (char *)key);
}
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Unmatched statoverride paths");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unmatched statoverride paths");
goto out;
}
@@ -824,10 +833,9 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
while (g_hash_table_iter_next (&hash_iter, &key, NULL))
{
- g_printerr ("Unmatched skip-list path: %s\n", (char*)key);
+ g_printerr ("Unmatched skip-list path: %s\n", (char *)key);
}
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Unmatched skip-list paths");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unmatched skip-list paths");
goto out;
}
@@ -836,7 +844,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_skip_if_unchanged && parent)
{
- g_autoptr(GFile) parent_root;
+ g_autoptr (GFile) parent_root;
if (!ostree_repo_read_commit (repo, parent, &parent_root, NULL, cancellable, error))
goto out;
@@ -849,14 +857,14 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
{
if (!opt_no_bindings)
{
- g_autoptr(GVariant) old_metadata = g_steal_pointer (&metadata);
+ g_autoptr (GVariant) old_metadata = g_steal_pointer (&metadata);
fill_bindings (repo, old_metadata, &metadata);
}
if (opt_bootable)
{
- g_autoptr(GVariant) old_metadata = g_steal_pointer (&metadata);
- g_auto(GVariantDict) bootmeta;
+ g_autoptr (GVariant) old_metadata = g_steal_pointer (&metadata);
+ g_auto (GVariantDict) bootmeta;
g_variant_dict_init (&bootmeta, old_metadata);
if (!ostree_commit_metadata_for_bootable (root, &bootmeta, cancellable, error))
goto out;
@@ -867,8 +875,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (!opt_timestamp)
{
if (!ostree_repo_write_commit (repo, parent, opt_subject, commit_body, metadata,
- OSTREE_REPO_FILE (root),
- &commit_checksum, cancellable, error))
+ OSTREE_REPO_FILE (root), &commit_checksum, cancellable,
+ error))
goto out;
}
else
@@ -876,23 +884,21 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
struct timespec ts;
if (!parse_datetime (&ts, opt_timestamp, NULL))
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Could not parse '%s'", opt_timestamp);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Could not parse '%s'",
+ opt_timestamp);
goto out;
}
guint64 timestamp = ts.tv_sec;
if (!ostree_repo_write_commit_with_time (repo, parent, opt_subject, commit_body, metadata,
- OSTREE_REPO_FILE (root),
- timestamp,
+ OSTREE_REPO_FILE (root), timestamp,
&commit_checksum, cancellable, error))
goto out;
}
if (detached_metadata)
{
- if (!ostree_repo_write_commit_detached_metadata (repo, commit_checksum,
- detached_metadata,
+ if (!ostree_repo_write_commit_detached_metadata (repo, commit_checksum, detached_metadata,
cancellable, error))
goto out;
}
@@ -915,13 +921,9 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
secret_key = g_variant_new_string (keyid);
if (!ostree_sign_set_sk (sign, secret_key, error))
- goto out;
+ goto out;
- if (!ostree_sign_commit (sign,
- repo,
- commit_checksum,
- cancellable,
- error))
+ if (!ostree_sign_commit (sign, repo, commit_checksum, cancellable, error))
goto out;
}
}
@@ -935,12 +937,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
{
const char *keyid = *iter;
- if (!ostree_repo_sign_commit (repo,
- commit_checksum,
- keyid,
- opt_gpg_homedir,
- cancellable,
- error))
+ if (!ostree_repo_sign_commit (repo, commit_checksum, keyid, opt_gpg_homedir,
+ cancellable, error))
goto out;
}
}
@@ -975,7 +973,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
}
ret = TRUE;
- out:
+out:
if (repo)
ostree_repo_abort_transaction (repo, cancellable, NULL);
return ret;
diff --git a/src/ostree/ot-builtin-config.c b/src/ostree/ot-builtin-config.c
index 5c1334a5..ad90b4b2 100644
--- a/src/ostree/ot-builtin-config.c
+++ b/src/ostree/ot-builtin-config.c
@@ -21,35 +21,29 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
-static char* opt_group;
+static char *opt_group;
/* ATTENTION:
* Please remember to update the bash-completion script (bash/ostree) and
* man page (man/ostree-config.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "group", 0, 0, G_OPTION_ARG_STRING, &opt_group , "Group name", NULL },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "group", 0, 0, G_OPTION_ARG_STRING, &opt_group, "Group name", NULL }, { NULL } };
static gboolean
-split_key_string (const char *k,
- char **out_section,
- char **out_value,
- GError **error)
+split_key_string (const char *k, char **out_section, char **out_value, GError **error)
{
const char *dot = strchr (k, '.');
if (!dot)
{
- return glnx_throw (error,
- "Key must be of the form \"sectionname.keyname\"");
+ return glnx_throw (error, "Key must be of the form \"sectionname.keyname\"");
}
*out_section = g_strndup (k, dot - k);
@@ -59,13 +53,15 @@ split_key_string (const char *k,
}
gboolean
-ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("(get KEY|set KEY VALUE|unset KEY)");
+ g_autoptr (GOptionContext) context = g_option_context_new ("(get KEY|set KEY VALUE|unset KEY)");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
if (argc < 2)
@@ -88,7 +84,7 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
g_autofree char *section = NULL;
g_autofree char *key = NULL;
- g_autoptr(GKeyFile) config = NULL;
+ g_autoptr (GKeyFile) config = NULL;
const char *section_key;
const char *value;
if (!strcmp (op, "set"))
@@ -97,25 +93,24 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
{
if (argc < 4)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "GROUP name, KEY and VALUE must be specified");
- return FALSE;
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "GROUP name, KEY and VALUE must be specified");
+ return FALSE;
}
- section = g_strdup(opt_group);
- key = g_strdup(argv[2]);
+ section = g_strdup (opt_group);
+ key = g_strdup (argv[2]);
value = argv[3];
}
else
{
if (argc < 4)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "KEY and VALUE must be specified");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "KEY and VALUE must be specified");
return FALSE;
}
section_key = argv[2];
value = argv[3];
- if(!split_key_string (section_key, &section, &key, error))
+ if (!split_key_string (section_key, &section, &key, error))
return FALSE;
}
@@ -137,15 +132,14 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
"Group name and key must be specified");
return FALSE;
}
- section = g_strdup(opt_group);
- key = g_strdup(argv[2]);
+ section = g_strdup (opt_group);
+ key = g_strdup (argv[2]);
}
else
{
- if(argc < 3)
+ if (argc < 3)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "KEY must be specified");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "KEY must be specified");
return FALSE;
}
section_key = argv[2];
@@ -162,7 +156,7 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
}
else if (!strcmp (op, "unset"))
{
- g_autoptr(GError) local_error = NULL;
+ g_autoptr (GError) local_error = NULL;
if (opt_group)
{
if (argc < 3)
@@ -171,15 +165,14 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
"Group name and key must be specified");
return FALSE;
}
- section = g_strdup(opt_group);
- key = g_strdup(argv[2]);
+ section = g_strdup (opt_group);
+ key = g_strdup (argv[2]);
}
else
{
if (argc < 3)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "KEY must be specified");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "KEY must be specified");
return FALSE;
}
section_key = argv[2];
@@ -190,8 +183,8 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
config = ostree_repo_copy_config (repo);
if (!g_key_file_remove_key (config, section, key, &local_error))
{
- if (!g_error_matches (local_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND) &&
- !g_error_matches (local_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND))
+ if (!g_error_matches (local_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND)
+ && !g_error_matches (local_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND))
{
g_propagate_error (error, g_steal_pointer (&local_error));
return FALSE;
@@ -203,8 +196,7 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
}
else
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Unknown operation %s", op);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown operation %s", op);
return FALSE;
}
diff --git a/src/ostree/ot-builtin-create-usb.c b/src/ostree/ot-builtin-create-usb.c
index 6bd5f2ad..0c48295c 100644
--- a/src/ostree/ot-builtin-create-usb.c
+++ b/src/ostree/ot-builtin-create-usb.c
@@ -22,9 +22,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
#include "ostree-remote-private.h"
@@ -33,31 +33,32 @@ static gboolean opt_disable_fsync = FALSE;
static char *opt_destination_repo = NULL;
static char *opt_commit = NULL;
-static GOptionEntry options[] =
- {
- { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
- { "destination-repo", 0, 0, G_OPTION_ARG_FILENAME, &opt_destination_repo, "Use custom repository directory within the mount", "DEST" },
- { "commit", 0, 0, G_OPTION_ARG_STRING, &opt_commit, "Pull a specific commit (only works when a single ref is specified)", "COMMIT" },
- { NULL }
- };
+static GOptionEntry options[]
+ = { { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()",
+ NULL },
+ { "destination-repo", 0, 0, G_OPTION_ARG_FILENAME, &opt_destination_repo,
+ "Use custom repository directory within the mount", "DEST" },
+ { "commit", 0, 0, G_OPTION_ARG_STRING, &opt_commit,
+ "Pull a specific commit (only works when a single ref is specified)", "COMMIT" },
+ { NULL } };
gboolean
-ostree_builtin_create_usb (int argc,
- char **argv,
- OstreeCommandInvocation *invocation,
- GCancellable *cancellable,
- GError **error)
+ostree_builtin_create_usb (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeAsyncProgress) progress = NULL;
- g_auto(GLnxConsoleRef) console = { 0, };
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeAsyncProgress) progress = NULL;
+ g_auto (GLnxConsoleRef) console = {
+ 0,
+ };
context = g_option_context_new ("MOUNT-PATH COLLECTION-ID REF [COLLECTION-ID REF...]");
/* Parse options. */
- g_autoptr(OstreeRepo) src_repo = NULL;
+ g_autoptr (OstreeRepo) src_repo = NULL;
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &src_repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &src_repo,
+ cancellable, error))
return FALSE;
if (argc < 2)
@@ -74,13 +75,17 @@ ostree_builtin_create_usb (int argc,
if (argc % 2 == 1)
{
- ot_util_usage_error (context, "Only complete COLLECTION-ID REF pairs may be specified", error);
+ ot_util_usage_error (context, "Only complete COLLECTION-ID REF pairs may be specified",
+ error);
return FALSE;
}
if (opt_commit && argc > 4)
{
- ot_util_usage_error (context, "The --commit option can only be used when a single COLLECTION-ID REF pair is specified", error);
+ ot_util_usage_error (
+ context,
+ "The --commit option can only be used when a single COLLECTION-ID REF pair is specified",
+ error);
return FALSE;
}
@@ -95,12 +100,13 @@ ostree_builtin_create_usb (int argc,
return FALSE;
/* Read in the refs to add to the USB stick. */
- g_autoptr(GPtrArray) refs = g_ptr_array_new_full (argc, (GDestroyNotify) ostree_collection_ref_free);
+ g_autoptr (GPtrArray) refs
+ = g_ptr_array_new_full (argc, (GDestroyNotify)ostree_collection_ref_free);
for (gsize i = 2; i < argc; i += 2)
{
- if (!ostree_validate_collection_id (argv[i], error) ||
- !ostree_validate_rev (argv[i + 1], error))
+ if (!ostree_validate_collection_id (argv[i], error)
+ || !ostree_validate_rev (argv[i + 1], error))
return FALSE;
g_ptr_array_add (refs, ostree_collection_ref_new (argv[i], argv[i + 1]));
@@ -109,7 +115,8 @@ ostree_builtin_create_usb (int argc,
/* Open the destination repository on the USB stick or create it if it doesn’t exist.
* Check it’s below @mount_root_path, and that it’s not the same as the source
* repository. */
- const char *dest_repo_path = (opt_destination_repo != NULL) ? opt_destination_repo : ".ostree/repo";
+ const char *dest_repo_path
+ = (opt_destination_repo != NULL) ? opt_destination_repo : ".ostree/repo";
if (!glnx_shutil_mkdir_p_at (mount_root_dfd, dest_repo_path, 0755, cancellable, error))
return FALSE;
@@ -122,8 +129,8 @@ ostree_builtin_create_usb (int argc,
g_debug ("%s: Creating repository in mode %u", G_STRFUNC, mode);
- g_autoptr(OstreeRepo) dest_repo = ostree_repo_create_at (mount_root_dfd, dest_repo_path,
- mode, NULL, cancellable, error);
+ g_autoptr (OstreeRepo) dest_repo
+ = ostree_repo_create_at (mount_root_dfd, dest_repo_path, mode, NULL, cancellable, error);
if (dest_repo == NULL)
return FALSE;
@@ -159,19 +166,20 @@ ostree_builtin_create_usb (int argc,
{
const OstreeCollectionRef *ref = g_ptr_array_index (refs, i);
- g_variant_builder_add (&refs_builder, "(sss)",
- ref->collection_id, ref->ref_name, opt_commit ?: "");
+ g_variant_builder_add (&refs_builder, "(sss)", ref->collection_id, ref->ref_name,
+ opt_commit ?: "");
}
{
GVariantBuilder builder;
- g_autoptr(GVariant) opts = NULL;
+ g_autoptr (GVariant) opts = NULL;
OstreeRepoPullFlags flags = OSTREE_REPO_PULL_FLAGS_MIRROR;
glnx_console_lock (&console);
if (console.is_tty)
- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
+ progress = ostree_async_progress_new_and_connect (
+ ostree_repo_pull_default_console_progress_changed, &console);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
@@ -185,10 +193,8 @@ ostree_builtin_create_usb (int argc,
g_autofree char *src_repo_uri = g_file_get_uri (ostree_repo_get_path (src_repo));
- if (!ostree_repo_pull_with_options (dest_repo, src_repo_uri,
- opts,
- progress,
- cancellable, error))
+ if (!ostree_repo_pull_with_options (dest_repo, src_repo_uri, opts, progress, cancellable,
+ error))
{
ostree_repo_abort_transaction (dest_repo, cancellable, NULL);
return FALSE;
@@ -208,8 +214,7 @@ ostree_builtin_create_usb (int argc,
/* Add the symlinks .ostree/repos.d/@symlink_name → @dest_repo_path, unless
* the @dest_repo_path is a well-known one like ostree/repo, in which case no
* symlink is necessary; #OstreeRepoFinderMount always looks there. */
- if (!g_str_equal (dest_repo_path, "ostree/repo") &&
- !g_str_equal (dest_repo_path, ".ostree/repo"))
+ if (!g_str_equal (dest_repo_path, "ostree/repo") && !g_str_equal (dest_repo_path, ".ostree/repo"))
{
if (!glnx_shutil_mkdir_p_at (mount_root_dfd, ".ostree/repos.d", 0755, cancellable, error))
return FALSE;
@@ -219,7 +224,8 @@ ostree_builtin_create_usb (int argc,
GLnxDirFdIterator repos_iter;
gboolean need_symlink = TRUE;
- if (!glnx_dirfd_iterator_init_at (mount_root_dfd, ".ostree/repos.d", TRUE, &repos_iter, error))
+ if (!glnx_dirfd_iterator_init_at (mount_root_dfd, ".ostree/repos.d", TRUE, &repos_iter,
+ error))
return FALSE;
while (TRUE)
@@ -246,7 +252,8 @@ ostree_builtin_create_usb (int argc,
if (need_symlink)
{
/* Relative to .ostree/repos.d. */
- g_autofree char *relative_dest_repo_path = g_build_filename ("..", "..", dest_repo_path, NULL);
+ g_autofree char *relative_dest_repo_path
+ = g_build_filename ("..", "..", dest_repo_path, NULL);
guint i;
const guint max_attempts = 100;
@@ -254,9 +261,11 @@ ostree_builtin_create_usb (int argc,
{
g_autofree char *symlink_path = g_strdup_printf (".ostree/repos.d/%02u-generated", i);
- int ret = TEMP_FAILURE_RETRY (symlinkat (relative_dest_repo_path, mount_root_dfd, symlink_path));
+ int ret = TEMP_FAILURE_RETRY (
+ symlinkat (relative_dest_repo_path, mount_root_dfd, symlink_path));
if (ret < 0 && errno != EEXIST)
- return glnx_throw_errno_prefix (error, "symlinkat(%s → %s)", symlink_path, relative_dest_repo_path);
+ return glnx_throw_errno_prefix (error, "symlinkat(%s → %s)", symlink_path,
+ relative_dest_repo_path);
else if (ret >= 0)
break;
}
@@ -269,8 +278,8 @@ ostree_builtin_create_usb (int argc,
/* Report success to the user. */
g_autofree char *src_repo_path = g_file_get_path (ostree_repo_get_path (src_repo));
- g_print ("Copied %u/%u refs successfully from ‘%s’ to ‘%s’ repository in ‘%s’.\n", refs->len, refs->len,
- src_repo_path, dest_repo_path, mount_root_path);
+ g_print ("Copied %u/%u refs successfully from ‘%s’ to ‘%s’ repository in ‘%s’.\n", refs->len,
+ refs->len, src_repo_path, dest_repo_path, mount_root_path);
return TRUE;
}
diff --git a/src/ostree/ot-builtin-diff.c b/src/ostree/ot-builtin-diff.c
index 9c918348..2060dc74 100644
--- a/src/ostree/ot-builtin-diff.c
+++ b/src/ostree/ot-builtin-diff.c
@@ -21,9 +21,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
static gboolean opt_stats;
@@ -37,27 +37,24 @@ static gint opt_owner_gid = -1;
* man page (man/ostree-diff.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "stats", 0, 0, G_OPTION_ARG_NONE, &opt_stats, "Print various statistics", NULL },
- { "fs-diff", 0, 0, G_OPTION_ARG_NONE, &opt_fs_diff, "Print filesystem diff", NULL },
- { "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Skip output of extended attributes", NULL },
- { "owner-uid", 0, 0, G_OPTION_ARG_INT, &opt_owner_uid, "Use file ownership user id for local files", "UID" },
- { "owner-gid", 0, 0, G_OPTION_ARG_INT, &opt_owner_gid, "Use file ownership group id for local files", "GID" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "stats", 0, 0, G_OPTION_ARG_NONE, &opt_stats, "Print various statistics", NULL },
+ { "fs-diff", 0, 0, G_OPTION_ARG_NONE, &opt_fs_diff, "Print filesystem diff", NULL },
+ { "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs,
+ "Skip output of extended attributes", NULL },
+ { "owner-uid", 0, 0, G_OPTION_ARG_INT, &opt_owner_uid,
+ "Use file ownership user id for local files", "UID" },
+ { "owner-gid", 0, 0, G_OPTION_ARG_INT, &opt_owner_gid,
+ "Use file ownership group id for local files", "GID" },
+ { NULL } };
static gboolean
-parse_file_or_commit (OstreeRepo *repo,
- const char *arg,
- GFile **out_file,
- GCancellable *cancellable,
- GError **error)
+parse_file_or_commit (OstreeRepo *repo, const char *arg, GFile **out_file,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GFile) ret_file = NULL;
+ g_autoptr (GFile) ret_file = NULL;
- if (g_str_has_prefix (arg, "/")
- || g_str_has_prefix (arg, "./")
- )
+ if (g_str_has_prefix (arg, "/") || g_str_has_prefix (arg, "./"))
{
ret_file = g_file_new_for_path (arg);
}
@@ -90,11 +87,8 @@ reachable_set_intersect (GHashTable *a, GHashTable *b)
}
static gboolean
-object_set_total_size (OstreeRepo *repo,
- GHashTable *reachable,
- guint64 *out_total,
- GCancellable *cancellable,
- GError **error)
+object_set_total_size (OstreeRepo *repo, GHashTable *reachable, guint64 *out_total,
+ GCancellable *cancellable, GError **error)
{
GHashTableIter hashiter;
gpointer key, value;
@@ -110,8 +104,7 @@ object_set_total_size (OstreeRepo *repo,
guint64 size;
ostree_object_name_deserialize (v, &csum, &objtype);
- if (!ostree_repo_query_object_storage_size (repo, objtype, csum, &size,
- cancellable, error))
+ if (!ostree_repo_query_object_storage_size (repo, objtype, csum, &size, cancellable, error))
return FALSE;
*out_total += size;
}
@@ -120,12 +113,14 @@ object_set_total_size (OstreeRepo *repo,
}
gboolean
-ostree_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("REV_OR_DIR REV_OR_DIR");
+ g_autoptr (GOptionContext) context = g_option_context_new ("REV_OR_DIR REV_OR_DIR");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
if (argc < 2)
@@ -133,8 +128,7 @@ ostree_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation,
gchar *help = g_option_context_get_help (context, TRUE, NULL);
g_printerr ("%s\n", help);
g_free (help);
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "REV must be specified");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "REV must be specified");
return FALSE;
}
@@ -156,11 +150,11 @@ ostree_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation,
if (!opt_stats && !opt_fs_diff)
opt_fs_diff = TRUE;
- g_autoptr(GFile) srcf = NULL;
- g_autoptr(GFile) targetf = NULL;
- g_autoptr(GPtrArray) modified = NULL;
- g_autoptr(GPtrArray) removed = NULL;
- g_autoptr(GPtrArray) added = NULL;
+ g_autoptr (GFile) srcf = NULL;
+ g_autoptr (GFile) targetf = NULL;
+ g_autoptr (GPtrArray) modified = NULL;
+ g_autoptr (GPtrArray) removed = NULL;
+ g_autoptr (GPtrArray) added = NULL;
if (opt_fs_diff)
{
@@ -179,8 +173,8 @@ ostree_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation,
added = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
OstreeDiffDirsOptions diff_opts = { opt_owner_uid, opt_owner_gid };
- if (!ostree_diff_dirs_with_options (diff_flags, srcf, targetf, modified, removed,
- added, &diff_opts, cancellable, error))
+ if (!ostree_diff_dirs_with_options (diff_flags, srcf, targetf, modified, removed, added,
+ &diff_opts, cancellable, error))
return FALSE;
ostree_diff_print (srcf, targetf, modified, removed, added);
@@ -188,9 +182,9 @@ ostree_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation,
if (opt_stats)
{
- g_autoptr(GHashTable) reachable_a = NULL;
- g_autoptr(GHashTable) reachable_b = NULL;
- g_autoptr(GHashTable) reachable_intersection = NULL;
+ g_autoptr (GHashTable) reachable_a = NULL;
+ g_autoptr (GHashTable) reachable_b = NULL;
+ g_autoptr (GHashTable) reachable_intersection = NULL;
g_autofree char *rev_a = NULL;
g_autofree char *rev_b = NULL;
g_autofree char *size = NULL;
@@ -217,8 +211,7 @@ ostree_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation,
g_print ("Common Object Count: %u\n", g_hash_table_size (reachable_intersection));
- if (!object_set_total_size (repo, reachable_intersection, &total_common,
- cancellable, error))
+ if (!object_set_total_size (repo, reachable_intersection, &total_common, cancellable, error))
return FALSE;
size = g_format_size_full (total_common, 0);
g_print ("Common Object Size: %s\n", size);
diff --git a/src/ostree/ot-builtin-export.c b/src/ostree/ot-builtin-export.c
index a8929ec1..00d77cc3 100644
--- a/src/ostree/ot-builtin-export.c
+++ b/src/ostree/ot-builtin-export.c
@@ -19,12 +19,12 @@
#include "config.h"
-#include "otutil.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree-libarchive-private.h"
-#include "ostree.h"
#include "ostree-repo-file.h"
+#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
+#include "otutil.h"
#ifdef HAVE_LIBARCHIVE
#include <archive.h>
@@ -41,45 +41,49 @@ static gboolean opt_no_xattrs;
* man page (man/ostree-export.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Skip output of extended attributes", NULL },
- { "subpath", 0, 0, G_OPTION_ARG_FILENAME, &opt_subpath, "Checkout sub-directory PATH", "PATH" },
- { "prefix", 0, 0, G_OPTION_ARG_FILENAME, &opt_prefix, "Add PATH as prefix to archive pathnames", "PATH" },
- { "output", 'o', 0, G_OPTION_ARG_FILENAME, &opt_output_path, "Output to PATH ", "PATH" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs,
+ "Skip output of extended attributes", NULL },
+ { "subpath", 0, 0, G_OPTION_ARG_FILENAME, &opt_subpath, "Checkout sub-directory PATH",
+ "PATH" },
+ { "prefix", 0, 0, G_OPTION_ARG_FILENAME, &opt_prefix,
+ "Add PATH as prefix to archive pathnames", "PATH" },
+ { "output", 'o', 0, G_OPTION_ARG_FILENAME, &opt_output_path, "Output to PATH ", "PATH" },
+ { NULL } };
#ifdef HAVE_LIBARCHIVE
static void
-propagate_libarchive_error (GError **error,
- struct archive *a)
+propagate_libarchive_error (GError **error, struct archive *a)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "%s", archive_error_string (a));
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "%s", archive_error_string (a));
}
#endif
gboolean
-ostree_builtin_export (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_export (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
gboolean ret = FALSE;
- g_autoptr(GFile) root = NULL;
- g_autoptr(GFile) subtree = NULL;
+ g_autoptr (GFile) root = NULL;
+ g_autoptr (GFile) subtree = NULL;
g_autofree char *commit = NULL;
- g_autoptr(GVariant) commit_data = NULL;
+ g_autoptr (GVariant) commit_data = NULL;
#ifdef HAVE_LIBARCHIVE
const char *rev;
- g_autoptr(OtAutoArchiveWrite) a = NULL;
- OstreeRepoExportArchiveOptions opts = { 0, };
+ g_autoptr (OtAutoArchiveWrite) a = NULL;
+ OstreeRepoExportArchiveOptions opts = {
+ 0,
+ };
#endif
context = g_option_context_new ("COMMIT");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
goto out;
#ifdef HAVE_LIBARCHIVE
@@ -143,8 +147,8 @@ ostree_builtin_export (int argc, char **argv, OstreeCommandInvocation *invocatio
opts.path_prefix = opt_prefix;
- if (!ostree_repo_export_tree_to_archive (repo, &opts, (OstreeRepoFile*)subtree, a,
- cancellable, error))
+ if (!ostree_repo_export_tree_to_archive (repo, &opts, (OstreeRepoFile *)subtree, a, cancellable,
+ error))
goto out;
if (archive_write_close (a) != ARCHIVE_OK)
@@ -160,6 +164,6 @@ ostree_builtin_export (int argc, char **argv, OstreeCommandInvocation *invocatio
#endif
ret = TRUE;
- out:
+out:
return ret;
}
diff --git a/src/ostree/ot-builtin-find-remotes.c b/src/ostree/ot-builtin-find-remotes.c
index 03ab1bef..b13ab4e4 100644
--- a/src/ostree/ot-builtin-find-remotes.c
+++ b/src/ostree/ot-builtin-find-remotes.c
@@ -22,9 +22,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
#include "ostree-remote-private.h"
@@ -35,20 +35,21 @@ static gboolean opt_disable_fsync = FALSE;
static gboolean opt_pull = FALSE;
static gboolean opt_mirror = FALSE;
-static GOptionEntry options[] =
- {
- { "cache-dir", 0, 0, G_OPTION_ARG_FILENAME, &opt_cache_dir, "Use custom cache dir", NULL },
- { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
- { "finders", 0, 0, G_OPTION_ARG_STRING, &opt_finders, "Use the specified comma separated list of finders (e.g. config,lan,mount)", "FINDERS" },
- { "pull", 0, 0, G_OPTION_ARG_NONE, &opt_pull, "Pull the updates after finding them", NULL },
- { "mirror", 0, 0, G_OPTION_ARG_NONE, &opt_mirror, "Do a mirror pull (see ostree pull --mirror)", NULL},
- { NULL }
- };
+static GOptionEntry options[]
+ = { { "cache-dir", 0, 0, G_OPTION_ARG_FILENAME, &opt_cache_dir, "Use custom cache dir", NULL },
+ { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()",
+ NULL },
+ { "finders", 0, 0, G_OPTION_ARG_STRING, &opt_finders,
+ "Use the specified comma separated list of finders (e.g. config,lan,mount)", "FINDERS" },
+ { "pull", 0, 0, G_OPTION_ARG_NONE, &opt_pull, "Pull the updates after finding them", NULL },
+ { "mirror", 0, 0, G_OPTION_ARG_NONE, &opt_mirror,
+ "Do a mirror pull (see ostree pull --mirror)", NULL },
+ { NULL } };
static gchar *
uint64_secs_to_iso8601 (guint64 secs)
{
- g_autoptr(GDateTime) dt = g_date_time_new_from_unix_utc (secs);
+ g_autoptr (GDateTime) dt = g_date_time_new_from_unix_utc (secs);
if (dt != NULL)
return g_date_time_format (dt, "%FT%TZ");
@@ -57,21 +58,20 @@ uint64_secs_to_iso8601 (guint64 secs)
}
static gchar *
-format_ref_to_checksum (GHashTable *ref_to_checksum /* (element-type OstreeCollectionRef utf8) */,
+format_ref_to_checksum (GHashTable *ref_to_checksum /* (element-type OstreeCollectionRef utf8) */,
const gchar *line_prefix)
{
GHashTableIter iter;
const OstreeCollectionRef *ref;
const gchar *checksum;
- g_autoptr(GString) out = NULL;
+ g_autoptr (GString) out = NULL;
g_hash_table_iter_init (&iter, ref_to_checksum);
out = g_string_new ("");
- while (g_hash_table_iter_next (&iter, (gpointer *) &ref, (gpointer *) &checksum))
- g_string_append_printf (out, "%s - (%s, %s) = %s\n",
- line_prefix, ref->collection_id, ref->ref_name,
- (checksum != NULL) ? checksum : "(not found)");
+ while (g_hash_table_iter_next (&iter, (gpointer *)&ref, (gpointer *)&checksum))
+ g_string_append_printf (out, "%s - (%s, %s) = %s\n", line_prefix, ref->collection_id,
+ ref->ref_name, (checksum != NULL) ? checksum : "(not found)");
return g_string_free (g_steal_pointer (&out), FALSE);
}
@@ -79,7 +79,7 @@ format_ref_to_checksum (GHashTable *ref_to_checksum /* (element-type OstreeCol
static gchar *
remote_get_uri (OstreeRemote *remote)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
g_autofree gchar *uri = NULL;
uri = g_key_file_get_string (remote->options, remote->group, "url", &error);
@@ -90,8 +90,7 @@ remote_get_uri (OstreeRemote *remote)
/* Add each key from @keys_input to @set iff its value is non-%NULL. */
static void
-add_keys_to_set_if_non_null (GHashTable *set,
- GHashTable *keys_input)
+add_keys_to_set_if_non_null (GHashTable *set, GHashTable *keys_input)
{
GHashTableIter iter;
gpointer key, value;
@@ -104,9 +103,7 @@ add_keys_to_set_if_non_null (GHashTable *set,
}
static void
-get_result_cb (GObject *obj,
- GAsyncResult *result,
- gpointer user_data)
+get_result_cb (GObject *obj, GAsyncResult *result, gpointer user_data)
{
GAsyncResult **result_out = user_data;
*result_out = g_object_ref (result);
@@ -121,19 +118,16 @@ collection_ref_free0 (OstreeCollectionRef *ref)
}
static gboolean
-validate_finders_list (const char **finders,
- GOptionContext *context,
- GError **error)
+validate_finders_list (const char **finders, GOptionContext *context, GError **error)
{
- typedef struct {
+ typedef struct
+ {
gchar *finder_name;
gboolean already_used;
} Finder;
- Finder valid_finders[] = {
- {.finder_name = "config", .already_used = FALSE},
- {.finder_name = "lan", .already_used = FALSE},
- {.finder_name = "mount", .already_used = FALSE}
- };
+ Finder valid_finders[] = { { .finder_name = "config", .already_used = FALSE },
+ { .finder_name = "lan", .already_used = FALSE },
+ { .finder_name = "mount", .already_used = FALSE } };
if (finders == NULL || *finders == NULL)
{
@@ -157,7 +151,8 @@ validate_finders_list (const char **finders,
if (!is_valid_finder)
{
g_autofree gchar *error_msg = NULL;
- error_msg = g_strdup_printf ("Unknown or duplicate finder type given in --finders option: ‘%s’", *iter);
+ error_msg = g_strdup_printf (
+ "Unknown or duplicate finder type given in --finders option: ‘%s’", *iter);
ot_util_usage_error (context, error_msg, error);
return FALSE;
}
@@ -167,33 +162,33 @@ validate_finders_list (const char **finders,
}
gboolean
-ostree_builtin_find_remotes (int argc,
- char **argv,
- OstreeCommandInvocation *invocation,
- GCancellable *cancellable,
- GError **error)
+ostree_builtin_find_remotes (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
- g_autoptr(GPtrArray) refs = NULL; /* (element-type OstreeCollectionRef) */
- g_autoptr(GPtrArray) finders = NULL; /* (element-type OstreeRepoFinder) */
- g_autoptr(OstreeRepoFinder) finder_config = NULL;
- g_autoptr(OstreeRepoFinder) finder_mount = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
+ g_autoptr (GPtrArray) refs = NULL; /* (element-type OstreeCollectionRef) */
+ g_autoptr (GPtrArray) finders = NULL; /* (element-type OstreeRepoFinder) */
+ g_autoptr (OstreeRepoFinder) finder_config = NULL;
+ g_autoptr (OstreeRepoFinder) finder_mount = NULL;
#ifdef HAVE_AVAHI
- g_autoptr(OstreeRepoFinder) finder_avahi = NULL;
-#endif /* HAVE_AVAHI */
- g_autoptr(OstreeAsyncProgress) progress = NULL;
+ g_autoptr (OstreeRepoFinder) finder_avahi = NULL;
+#endif /* HAVE_AVAHI */
+ g_autoptr (OstreeAsyncProgress) progress = NULL;
gsize i;
- g_autoptr(GAsyncResult) find_result = NULL, pull_result = NULL;
- g_auto(OstreeRepoFinderResultv) results = NULL;
- g_auto(GLnxConsoleRef) console = { 0, };
- g_autoptr(GHashTable) refs_found = NULL; /* set (element-type OstreeCollectionRef) */
- g_autoptr(GVariant) pull_options = NULL;
+ g_autoptr (GAsyncResult) find_result = NULL, pull_result = NULL;
+ g_auto (OstreeRepoFinderResultv) results = NULL;
+ g_auto (GLnxConsoleRef) console = {
+ 0,
+ };
+ g_autoptr (GHashTable) refs_found = NULL; /* set (element-type OstreeCollectionRef) */
+ g_autoptr (GVariant) pull_options = NULL;
context = g_option_context_new ("COLLECTION-ID REF [COLLECTION-ID REF...]");
/* Parse options. */
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
if (!ostree_ensure_repo_writable (repo, error))
@@ -207,7 +202,8 @@ ostree_builtin_find_remotes (int argc,
if (argc % 2 == 0)
{
- ot_util_usage_error (context, "Only complete COLLECTION-ID REF pairs may be specified", error);
+ ot_util_usage_error (context, "Only complete COLLECTION-ID REF pairs may be specified",
+ error);
return FALSE;
}
@@ -220,17 +216,17 @@ ostree_builtin_find_remotes (int argc,
if (opt_disable_fsync)
ostree_repo_set_disable_fsync (repo, TRUE);
- if (opt_cache_dir &&
- !ostree_repo_set_cache_dir (repo, AT_FDCWD, opt_cache_dir, cancellable, error))
+ if (opt_cache_dir
+ && !ostree_repo_set_cache_dir (repo, AT_FDCWD, opt_cache_dir, cancellable, error))
return FALSE;
/* Read in the refs to search for remotes for. */
- refs = g_ptr_array_new_full (argc, (GDestroyNotify) collection_ref_free0);
+ refs = g_ptr_array_new_full (argc, (GDestroyNotify)collection_ref_free0);
for (i = 1; i < argc; i += 2)
{
- if (!ostree_validate_collection_id (argv[i], error) ||
- !ostree_validate_rev (argv[i + 1], error))
+ if (!ostree_validate_collection_id (argv[i], error)
+ || !ostree_validate_rev (argv[i + 1], error))
return FALSE;
g_ptr_array_add (refs, ostree_collection_ref_new (argv[i], argv[i + 1]));
@@ -241,7 +237,7 @@ ostree_builtin_find_remotes (int argc,
/* Build the array of OstreeRepoFinder instances */
if (opt_finders != NULL)
{
- g_auto(GStrv) finders_strings = NULL;
+ g_auto (GStrv) finders_strings = NULL;
finders_strings = g_strsplit (opt_finders, ",", 0);
if (!validate_finders_list ((const char **)finders_strings, context, error))
@@ -264,10 +260,11 @@ ostree_builtin_find_remotes (int argc,
{
#ifdef HAVE_AVAHI
GMainContext *main_context = g_main_context_get_thread_default ();
- g_autoptr(GError) local_error = NULL;
+ g_autoptr (GError) local_error = NULL;
finder_avahi = OSTREE_REPO_FINDER (ostree_repo_finder_avahi_new (main_context));
- ostree_repo_finder_avahi_start (OSTREE_REPO_FINDER_AVAHI (finder_avahi), &local_error);
+ ostree_repo_finder_avahi_start (OSTREE_REPO_FINDER_AVAHI (finder_avahi),
+ &local_error);
if (local_error != NULL)
{
@@ -277,9 +274,11 @@ ostree_builtin_find_remotes (int argc,
else
g_ptr_array_add (finders, finder_avahi);
#else
- ot_util_usage_error (context, "LAN repo finder requested but ostree was compiled without Avahi support", error);
+ ot_util_usage_error (
+ context,
+ "LAN repo finder requested but ostree was compiled without Avahi support", error);
return FALSE;
-#endif /* HAVE_AVAHI */
+#endif /* HAVE_AVAHI */
}
else
g_assert_not_reached ();
@@ -291,14 +290,13 @@ ostree_builtin_find_remotes (int argc,
glnx_console_lock (&console);
if (console.is_tty)
- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
+ progress = ostree_async_progress_new_and_connect (
+ ostree_repo_pull_default_console_progress_changed, &console);
- ostree_repo_find_remotes_async (repo,
- (const OstreeCollectionRef * const *) refs->pdata,
- NULL /* no options */,
- finders != NULL ? (OstreeRepoFinder **) finders->pdata : NULL,
- progress, cancellable,
- get_result_cb, &find_result);
+ ostree_repo_find_remotes_async (repo, (const OstreeCollectionRef *const *)refs->pdata,
+ NULL /* no options */,
+ finders != NULL ? (OstreeRepoFinder **)finders->pdata : NULL,
+ progress, cancellable, get_result_cb, &find_result);
while (find_result == NULL)
g_main_context_iteration (NULL, TRUE);
@@ -312,8 +310,8 @@ ostree_builtin_find_remotes (int argc,
ostree_async_progress_finish (progress);
/* Print results and work out which refs were not found. */
- refs_found = g_hash_table_new_full (ostree_collection_ref_hash,
- ostree_collection_ref_equal, NULL, NULL);
+ refs_found
+ = g_hash_table_new_full (ostree_collection_ref_hash, ostree_collection_ref_equal, NULL, NULL);
for (i = 0; results[i] != NULL; i++)
{
@@ -350,7 +348,7 @@ ostree_builtin_find_remotes (int argc,
g_print ("%u/%u refs were found.\n", g_hash_table_size (refs_found), refs->len - 1);
/* Print out the refs which weren’t found. */
- if (g_hash_table_size (refs_found) != refs->len - 1 /* NULL terminator */)
+ if (g_hash_table_size (refs_found) != refs->len - 1 /* NULL terminator */)
{
g_print ("Refs not found in any remote:\n");
@@ -371,21 +369,21 @@ ostree_builtin_find_remotes (int argc,
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
if (opt_mirror)
- g_variant_builder_add (&builder, "{s@v}", "flags",
- g_variant_new_variant (g_variant_new_int32 (OSTREE_REPO_PULL_FLAGS_MIRROR)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "flags",
+ g_variant_new_variant (g_variant_new_int32 (OSTREE_REPO_PULL_FLAGS_MIRROR)));
pull_options = g_variant_ref_sink (g_variant_builder_end (&builder));
}
/* Run the pull operation. */
if (console.is_tty)
- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
+ progress = ostree_async_progress_new_and_connect (
+ ostree_repo_pull_default_console_progress_changed, &console);
- ostree_repo_pull_from_remotes_async (repo,
- (const OstreeRepoFinderResult * const *) results,
- pull_options,
- progress, cancellable,
- get_result_cb, &pull_result);
+ ostree_repo_pull_from_remotes_async (repo, (const OstreeRepoFinderResult *const *)results,
+ pull_options, progress, cancellable, get_result_cb,
+ &pull_result);
while (pull_result == NULL)
g_main_context_iteration (NULL, TRUE);
diff --git a/src/ostree/ot-builtin-fsck.c b/src/ostree/ot-builtin-fsck.c
index bb9e8563..cd3c7768 100644
--- a/src/ostree/ot-builtin-fsck.c
+++ b/src/ostree/ot-builtin-fsck.c
@@ -22,10 +22,10 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
-#include "ostree.h"
#include "ostree-cmd-private.h"
+#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
static gboolean opt_quiet;
@@ -40,31 +40,28 @@ static gboolean opt_verify_back_refs;
* man page (man/ostree-fsck.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "add-tombstones", 0, 0, G_OPTION_ARG_NONE, &opt_add_tombstones, "Add tombstones for missing commits", NULL },
- { "quiet", 'q', 0, G_OPTION_ARG_NONE, &opt_quiet, "Only print error messages", NULL },
- { "all", 'a', 0, G_OPTION_ARG_NONE, &opt_all, "Don't stop on first error", NULL },
- { "delete", 0, 0, G_OPTION_ARG_NONE, &opt_delete, "Remove corrupted objects", NULL },
- { "verify-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_verify_bindings, "Verify ref bindings", NULL },
- { "verify-back-refs", 0, 0, G_OPTION_ARG_NONE, &opt_verify_back_refs, "Verify back-references (implies --verify-bindings)", NULL },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "add-tombstones", 0, 0, G_OPTION_ARG_NONE, &opt_add_tombstones,
+ "Add tombstones for missing commits", NULL },
+ { "quiet", 'q', 0, G_OPTION_ARG_NONE, &opt_quiet, "Only print error messages", NULL },
+ { "all", 'a', 0, G_OPTION_ARG_NONE, &opt_all, "Don't stop on first error", NULL },
+ { "delete", 0, 0, G_OPTION_ARG_NONE, &opt_delete, "Remove corrupted objects", NULL },
+ { "verify-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_verify_bindings, "Verify ref bindings",
+ NULL },
+ { "verify-back-refs", 0, 0, G_OPTION_ARG_NONE, &opt_verify_back_refs,
+ "Verify back-references (implies --verify-bindings)", NULL },
+ { NULL } };
static gboolean
-fsck_one_object (OstreeRepo *repo,
- const char *checksum,
- OstreeObjectType objtype,
- GHashTable *object_parents,
- GVariant *key,
- gboolean *out_found_corruption,
- GCancellable *cancellable,
- GError **error)
+fsck_one_object (OstreeRepo *repo, const char *checksum, OstreeObjectType objtype,
+ GHashTable *object_parents, GVariant *key, gboolean *out_found_corruption,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GError) temp_error = NULL;
+ g_autoptr (GError) temp_error = NULL;
if (!ostree_repo_fsck_object (repo, objtype, checksum, cancellable, &temp_error))
{
gboolean object_missing = FALSE;
- g_auto(GStrv) parent_commits = NULL;
+ g_auto (GStrv) parent_commits = NULL;
g_autofree char *parent_commits_str = NULL;
if (object_parents)
@@ -92,7 +89,7 @@ fsck_one_object (OstreeRepo *repo,
if (opt_delete)
{
g_printerr ("%s\n", temp_error->message);
- (void) ostree_repo_delete_object (repo, objtype, checksum, cancellable, NULL);
+ (void)ostree_repo_delete_object (repo, objtype, checksum, cancellable, NULL);
object_missing = TRUE;
}
else if (opt_all)
@@ -120,13 +117,14 @@ fsck_one_object (OstreeRepo *repo,
{
const char *parent_commit = parent_commits[i];
OstreeRepoCommitState state;
- if (!ostree_repo_load_commit (repo, parent_commit, NULL,
- &state, error))
+ if (!ostree_repo_load_commit (repo, parent_commit, NULL, &state, error))
return FALSE;
if ((state & OSTREE_REPO_COMMIT_STATE_PARTIAL) == 0)
{
g_printerr ("Marking commit as partial: %s\n", parent_commit);
- if (!ostree_repo_mark_commit_partial_reason (repo, parent_commit, TRUE, OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL, error))
+ if (!ostree_repo_mark_commit_partial_reason (
+ repo, parent_commit, TRUE, OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL,
+ error))
return FALSE;
}
}
@@ -138,14 +136,12 @@ fsck_one_object (OstreeRepo *repo,
}
static gboolean
-fsck_reachable_objects_from_commits (OstreeRepo *repo,
- GHashTable *commits,
- gboolean *out_found_corruption,
- GCancellable *cancellable,
- GError **error)
+fsck_reachable_objects_from_commits (OstreeRepo *repo, GHashTable *commits,
+ gboolean *out_found_corruption, GCancellable *cancellable,
+ GError **error)
{
- g_autoptr(GHashTable) reachable_objects = ostree_repo_traverse_new_reachable ();
- g_autoptr(GHashTable) object_parents = ostree_repo_traverse_new_parents ();
+ g_autoptr (GHashTable) reachable_objects = ostree_repo_traverse_new_reachable ();
+ g_autoptr (GHashTable) object_parents = ostree_repo_traverse_new_parents ();
GHashTableIter hash_iter;
gpointer key, value;
@@ -160,12 +156,14 @@ fsck_reachable_objects_from_commits (OstreeRepo *repo,
g_assert (objtype == OSTREE_OBJECT_TYPE_COMMIT);
- if (!ostree_repo_traverse_commit_union_with_parents (repo, checksum, 0, reachable_objects, object_parents,
- cancellable, error))
+ if (!ostree_repo_traverse_commit_union_with_parents (repo, checksum, 0, reachable_objects,
+ object_parents, cancellable, error))
return FALSE;
}
- g_auto(GLnxConsoleRef) console = { 0, };
+ g_auto (GLnxConsoleRef) console = {
+ 0,
+ };
glnx_console_lock (&console);
const guint count = g_hash_table_size (reachable_objects);
@@ -179,8 +177,7 @@ fsck_reachable_objects_from_commits (OstreeRepo *repo,
ostree_object_name_deserialize (serialized_key, &checksum, &objtype);
- if (!fsck_one_object (repo, checksum, objtype,
- object_parents, serialized_key,
+ if (!fsck_one_object (repo, checksum, objtype, object_parents, serialized_key,
out_found_corruption, cancellable, error))
return FALSE;
@@ -194,27 +191,21 @@ fsck_reachable_objects_from_commits (OstreeRepo *repo,
/* Check that a given commit object is valid for the ref it was looked up via.
* @collection_id will be %NULL for normal refs, and non-%NULL for collection–refs. */
static gboolean
-fsck_commit_for_ref (OstreeRepo *repo,
- const char *checksum,
- const char *collection_id,
- const char *ref_name,
- gboolean *found_corruption,
- GCancellable *cancellable,
- GError **error)
+fsck_commit_for_ref (OstreeRepo *repo, const char *checksum, const char *collection_id,
+ const char *ref_name, gboolean *found_corruption, GCancellable *cancellable,
+ GError **error)
{
- if (!fsck_one_object (repo, checksum, OSTREE_OBJECT_TYPE_COMMIT,
- NULL, NULL, found_corruption,
+ if (!fsck_one_object (repo, checksum, OSTREE_OBJECT_TYPE_COMMIT, NULL, NULL, found_corruption,
cancellable, error))
return FALSE;
/* Check the commit exists. */
- g_autoptr(GVariant) commit = NULL;
- if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
- checksum, &commit, error))
+ g_autoptr (GVariant) commit = NULL;
+ if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, &commit, error))
{
if (collection_id != NULL)
- return glnx_prefix_error (error, "Loading commit for ref (%s, %s)",
- collection_id, ref_name);
+ return glnx_prefix_error (error, "Loading commit for ref (%s, %s)", collection_id,
+ ref_name);
else
return glnx_prefix_error (error, "Loading commit for ref %s", ref_name);
}
@@ -222,7 +213,8 @@ fsck_commit_for_ref (OstreeRepo *repo,
/* Check its bindings. */
if (opt_verify_bindings)
{
- if (!ostree_cmd__private__ ()->ostree_repo_verify_bindings (collection_id, ref_name, commit, error))
+ if (!ostree_cmd__private__ ()->ostree_repo_verify_bindings (collection_id, ref_name, commit,
+ error))
return glnx_prefix_error (error, "Commit %s", checksum);
}
@@ -237,60 +229,52 @@ fsck_one_commit (OstreeRepo *repo, const char *checksum, GVariant *commit, GPtrA
* for this commit resolve back to this commit. */
if (opt_verify_back_refs)
{
- g_autoptr(GVariant) metadata = g_variant_get_child_value (commit, 0);
+ g_autoptr (GVariant) metadata = g_variant_get_child_value (commit, 0);
const char *collection_id = NULL;
- if (!g_variant_lookup (metadata,
- OSTREE_COMMIT_META_KEY_COLLECTION_BINDING,
- "&s",
+ if (!g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_COLLECTION_BINDING, "&s",
&collection_id))
collection_id = NULL;
g_autofree const char **refs = NULL;
- if (g_variant_lookup (metadata,
- OSTREE_COMMIT_META_KEY_REF_BINDING,
- "^a&s",
- &refs))
+ if (g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_REF_BINDING, "^a&s", &refs))
{
for (const char **iter = refs; *iter != NULL; ++iter)
{
g_autofree char *checksum_for_ref = NULL;
if (collection_id != NULL)
{
- const OstreeCollectionRef collection_ref = { (char *) collection_id, (char *) *iter };
- if (!ostree_repo_resolve_collection_ref (repo, &collection_ref,
- TRUE,
+ const OstreeCollectionRef collection_ref
+ = { (char *)collection_id, (char *)*iter };
+ if (!ostree_repo_resolve_collection_ref (repo, &collection_ref, TRUE,
OSTREE_REPO_RESOLVE_REV_EXT_NONE,
- &checksum_for_ref,
- cancellable,
- error))
+ &checksum_for_ref, cancellable, error))
return FALSE;
}
else
{
- if (!ostree_repo_resolve_rev (repo, *iter, TRUE,
- &checksum_for_ref, error))
+ if (!ostree_repo_resolve_rev (repo, *iter, TRUE, &checksum_for_ref, error))
return FALSE;
}
if (checksum_for_ref == NULL)
{
if (collection_id != NULL)
- return glnx_throw (error,
- "Collection–ref (%s, %s) in bindings for commit %s does not exist",
- collection_id, *iter, checksum);
+ return glnx_throw (
+ error, "Collection–ref (%s, %s) in bindings for commit %s does not exist",
+ collection_id, *iter, checksum);
else
- return glnx_throw (error,
- "Ref ‘%s’ in bindings for commit %s does not exist",
+ return glnx_throw (error, "Ref ‘%s’ in bindings for commit %s does not exist",
*iter, checksum);
}
else if (g_strcmp0 (checksum_for_ref, checksum) != 0)
{
if (collection_id != NULL)
return glnx_throw (error,
- "Collection–ref (%s, %s) in bindings for commit %s does not resolve to that commit",
+ "Collection–ref (%s, %s) in bindings for commit %s does "
+ "not resolve to that commit",
collection_id, *iter, checksum);
else
- return glnx_throw (error,
- "Ref ‘%s’ in bindings for commit %s does not resolve to that commit",
- *iter, checksum);
+ return glnx_throw (
+ error, "Ref ‘%s’ in bindings for commit %s does not resolve to that commit",
+ *iter, checksum);
}
}
}
@@ -301,7 +285,7 @@ fsck_one_commit (OstreeRepo *repo, const char *checksum, GVariant *commit, GPtrA
g_autofree char *parent = ostree_commit_get_parent (commit);
if (parent)
{
- g_autoptr(GVariant) parent_commit = NULL;
+ g_autoptr (GVariant) parent_commit = NULL;
if (!ostree_repo_load_variant_if_exists (repo, OSTREE_OBJECT_TYPE_COMMIT, parent,
&parent_commit, error))
return FALSE;
@@ -314,22 +298,23 @@ fsck_one_commit (OstreeRepo *repo, const char *checksum, GVariant *commit, GPtrA
}
gboolean
-ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
gboolean found_corruption = FALSE;
- g_autoptr(GOptionContext) context = g_option_context_new ("");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
if (!opt_quiet)
g_print ("Validating refs...\n");
/* Validate that the commit for each ref is available */
- g_autoptr(GHashTable) all_refs = NULL;
- if (!ostree_repo_list_refs (repo, NULL, &all_refs,
- cancellable, error))
+ g_autoptr (GHashTable) all_refs = NULL;
+ if (!ostree_repo_list_refs (repo, NULL, &all_refs, cancellable, error))
return FALSE;
GHashTableIter hash_iter;
@@ -342,26 +327,26 @@ ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation,
g_autofree char *ref_name = NULL;
if (!ostree_parse_refspec (refspec, NULL, &ref_name, error))
return FALSE;
- if (!fsck_commit_for_ref (repo, checksum, NULL, ref_name,
- &found_corruption, cancellable, error))
+ if (!fsck_commit_for_ref (repo, checksum, NULL, ref_name, &found_corruption, cancellable,
+ error))
return FALSE;
}
if (!opt_quiet)
g_print ("Validating refs in collections...\n");
- g_autoptr(GHashTable) all_collection_refs = NULL; /* (element-type OstreeCollectionRef utf8) */
+ g_autoptr (GHashTable) all_collection_refs = NULL; /* (element-type OstreeCollectionRef utf8) */
if (!ostree_repo_list_collection_refs (repo, NULL, &all_collection_refs,
- OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES,
- cancellable, error))
+ OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES, cancellable,
+ error))
return FALSE;
g_hash_table_iter_init (&hash_iter, all_collection_refs);
while (g_hash_table_iter_next (&hash_iter, &key, &value))
{
const OstreeCollectionRef *ref = key;
- if (!fsck_commit_for_ref (repo, value, ref->collection_id, ref->ref_name,
- &found_corruption, cancellable, error))
+ if (!fsck_commit_for_ref (repo, value, ref->collection_id, ref->ref_name, &found_corruption,
+ cancellable, error))
return FALSE;
}
@@ -369,14 +354,14 @@ ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation,
g_print ("Enumerating commits...\n");
// Find all commit objects, including partial ones
- g_autoptr(GHashTable) all_commits = NULL;
+ g_autoptr (GHashTable) all_commits = NULL;
if (!ostree_repo_list_commit_objects_starting_with (repo, "", &all_commits, cancellable, error))
return FALSE;
// And gather a set of non-partial commits for further analysis
- g_autoptr(GHashTable) commits = g_hash_table_new_full (ostree_hash_object_name, g_variant_equal,
- (GDestroyNotify)g_variant_unref, NULL);
+ g_autoptr (GHashTable) commits = g_hash_table_new_full (ostree_hash_object_name, g_variant_equal,
+ (GDestroyNotify)g_variant_unref, NULL);
- g_autoptr(GPtrArray) tombstones = NULL;
+ g_autoptr (GPtrArray) tombstones = NULL;
if (opt_add_tombstones)
tombstones = g_ptr_array_new_with_free_func (g_free);
@@ -392,7 +377,7 @@ ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation,
const char *checksum;
OstreeObjectType objtype;
OstreeRepoCommitState commitstate = 0;
- g_autoptr(GVariant) commit = NULL;
+ g_autoptr (GVariant) commit = NULL;
ostree_object_name_deserialize (serialized_key, &checksum, &objtype);
@@ -412,7 +397,7 @@ ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation,
}
else
g_hash_table_add (commits, g_variant_ref (serialized_key));
- }
+ }
g_clear_pointer (&all_commits, g_hash_table_unref);
@@ -420,8 +405,7 @@ ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation,
g_print ("Verifying content integrity of %u commit objects...\n",
(guint)g_hash_table_size (commits));
- if (!fsck_reachable_objects_from_commits (repo, commits, &found_corruption,
- cancellable, error))
+ if (!fsck_reachable_objects_from_commits (repo, commits, &found_corruption, cancellable, error))
return FALSE;
if (opt_add_tombstones)
@@ -437,7 +421,8 @@ ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation,
{
const char *checksum = tombstones->pdata[i];
g_print ("Adding tombstone for commit %s\n", checksum);
- if (!ostree_repo_delete_object (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, cancellable, error))
+ if (!ostree_repo_delete_object (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, cancellable,
+ error))
return FALSE;
}
}
diff --git a/src/ostree/ot-builtin-gpg-sign.c b/src/ostree/ot-builtin-gpg-sign.c
index 48aa4699..a0ddf2af 100644
--- a/src/ostree/ot-builtin-gpg-sign.c
+++ b/src/ostree/ot-builtin-gpg-sign.c
@@ -21,11 +21,11 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
+#include "ostree-core-private.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
-#include "ostree-core-private.h"
static gboolean opt_delete;
static char *opt_gpg_homedir;
@@ -35,11 +35,11 @@ static char *opt_gpg_homedir;
* man page (man/ostree-gpg-sign.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "delete", 'd', 0, G_OPTION_ARG_NONE, &opt_delete, "Delete signatures having any of the GPG KEY-IDs" },
- { "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir, "GPG Homedir to use when looking for keyrings", "HOMEDIR" },
- { NULL }
-};
+static GOptionEntry options[] = { { "delete", 'd', 0, G_OPTION_ARG_NONE, &opt_delete,
+ "Delete signatures having any of the GPG KEY-IDs" },
+ { "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir,
+ "GPG Homedir to use when looking for keyrings", "HOMEDIR" },
+ { NULL } };
static void
usage_error (GOptionContext *context, const char *message, GError **error)
@@ -50,19 +50,14 @@ usage_error (GOptionContext *context, const char *message, GError **error)
}
static gboolean
-delete_signatures (OstreeRepo *repo,
- const char *commit_checksum,
- const char * const *key_ids,
- guint n_key_ids,
- guint *out_n_deleted,
- GCancellable *cancellable,
- GError **error)
+delete_signatures (OstreeRepo *repo, const char *commit_checksum, const char *const *key_ids,
+ guint n_key_ids, guint *out_n_deleted, GCancellable *cancellable, GError **error)
{
GVariantDict metadata_dict;
- g_autoptr(OstreeGpgVerifyResult) result = NULL;
- g_autoptr(GVariant) old_metadata = NULL;
- g_autoptr(GVariant) new_metadata = NULL;
- g_autoptr(GVariant) signature_data = NULL;
+ g_autoptr (OstreeGpgVerifyResult) result = NULL;
+ g_autoptr (GVariant) old_metadata = NULL;
+ g_autoptr (GVariant) new_metadata = NULL;
+ g_autoptr (GVariant) signature_data = NULL;
GVariantIter iter;
GVariant *child;
GQueue signatures = G_QUEUE_INIT;
@@ -80,17 +75,13 @@ delete_signatures (OstreeRepo *repo,
* OTOH, would this really be a useful addition to libostree?
*/
- if (!ostree_repo_read_commit_detached_metadata (repo,
- commit_checksum,
- &old_metadata,
- cancellable,
+ if (!ostree_repo_read_commit_detached_metadata (repo, commit_checksum, &old_metadata, cancellable,
error))
goto out;
g_variant_dict_init (&metadata_dict, old_metadata);
- signature_data = g_variant_dict_lookup_value (&metadata_dict,
- _OSTREE_METADATA_GPGSIGS_NAME,
+ signature_data = g_variant_dict_lookup_value (&metadata_dict, _OSTREE_METADATA_GPGSIGS_NAME,
G_VARIANT_TYPE ("aay"));
/* Taking the approach of deleting whatever matches we find for the
@@ -108,9 +99,8 @@ delete_signatures (OstreeRepo *repo,
* XXX Reading detached metadata from disk twice here. Another reason
* to move this into libostree?
*/
- result = ostree_repo_verify_commit_ext (repo, commit_checksum,
- NULL, NULL,
- cancellable, &local_error);
+ result = ostree_repo_verify_commit_ext (repo, commit_checksum, NULL, NULL, cancellable,
+ &local_error);
if (result == NULL)
{
g_variant_dict_clear (&metadata_dict);
@@ -169,21 +159,17 @@ delete_signatures (OstreeRepo *repo,
while (!g_queue_is_empty (&signatures))
{
- g_autoptr(GVariant) sigchild = g_queue_pop_head (&signatures);
+ g_autoptr (GVariant) sigchild = g_queue_pop_head (&signatures);
g_variant_builder_add_value (&signature_builder, sigchild);
}
- g_variant_dict_insert_value (&metadata_dict,
- _OSTREE_METADATA_GPGSIGS_NAME,
+ g_variant_dict_insert_value (&metadata_dict, _OSTREE_METADATA_GPGSIGS_NAME,
g_variant_builder_end (&signature_builder));
}
/* Commit the new metadata. */
new_metadata = g_variant_dict_end (&metadata_dict);
- if (!ostree_repo_write_commit_detached_metadata (repo,
- commit_checksum,
- new_metadata,
- cancellable,
+ if (!ostree_repo_write_commit_detached_metadata (repo, commit_checksum, new_metadata, cancellable,
error))
goto out;
@@ -199,13 +185,15 @@ out:
}
gboolean
-ostree_builtin_gpg_sign (int argc, char **argv,OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_gpg_sign (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("COMMIT KEY-ID...");
+ g_autoptr (GOptionContext) context = g_option_context_new ("COMMIT KEY-ID...");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
if (argc < 2)
@@ -232,8 +220,7 @@ ostree_builtin_gpg_sign (int argc, char **argv,OstreeCommandInvocation *invocati
{
guint n_deleted = 0;
- if (!delete_signatures (repo, resolved_commit,
- (const char * const *) key_ids, n_key_ids,
+ if (!delete_signatures (repo, resolved_commit, (const char *const *)key_ids, n_key_ids,
&n_deleted, cancellable, error))
return FALSE;
@@ -243,8 +230,8 @@ ostree_builtin_gpg_sign (int argc, char **argv,OstreeCommandInvocation *invocati
for (int ii = 0; ii < n_key_ids; ii++)
{
- if (!ostree_repo_sign_commit (repo, resolved_commit, key_ids[ii],
- opt_gpg_homedir, cancellable, error))
+ if (!ostree_repo_sign_commit (repo, resolved_commit, key_ids[ii], opt_gpg_homedir,
+ cancellable, error))
return FALSE;
}
diff --git a/src/ostree/ot-builtin-init.c b/src/ostree/ot-builtin-init.c
index a699a55a..379c2b98 100644
--- a/src/ostree/ot-builtin-init.c
+++ b/src/ostree/ot-builtin-init.c
@@ -21,9 +21,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
static char *opt_mode = "bare";
static char *opt_collection_id = NULL;
@@ -33,24 +33,28 @@ static char *opt_collection_id = NULL;
* man page (man/ostree-init.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "mode", 0, 0, G_OPTION_ARG_STRING, &opt_mode, "Initialize repository in given mode (bare, bare-user, bare-user-only, archive)", NULL },
- { "collection-id", 0, 0, G_OPTION_ARG_STRING, &opt_collection_id,
- "Globally unique ID for this repository as an collection of refs for redistribution to other repositories", "COLLECTION-ID" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "mode", 0, 0, G_OPTION_ARG_STRING, &opt_mode,
+ "Initialize repository in given mode (bare, bare-user, bare-user-only, archive)", NULL },
+ { "collection-id", 0, 0, G_OPTION_ARG_STRING, &opt_collection_id,
+ "Globally unique ID for this repository as an collection of refs for redistribution to "
+ "other repositories",
+ "COLLECTION-ID" },
+ { NULL } };
gboolean
-ostree_builtin_init (int argc, char **argv,OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_init (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
gboolean ret = FALSE;
OstreeRepoMode mode;
context = g_option_context_new ("");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
goto out;
if (!ostree_repo_mode_from_string (opt_mode, &mode, error))
@@ -62,6 +66,6 @@ ostree_builtin_init (int argc, char **argv,OstreeCommandInvocation *invocation,
goto out;
ret = TRUE;
- out:
+out:
return ret;
}
diff --git a/src/ostree/ot-builtin-log.c b/src/ostree/ot-builtin-log.c
index c75656df..0b59bf8a 100644
--- a/src/ostree/ot-builtin-log.c
+++ b/src/ostree/ot-builtin-log.c
@@ -21,10 +21,10 @@
#include "config.h"
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-builtins.h"
#include "ot-dump.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
static gboolean opt_raw;
@@ -34,25 +34,19 @@ static gboolean opt_raw;
* man page (man/ostree-log.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "raw", 0, 0, G_OPTION_ARG_NONE, &opt_raw, "Show raw variant data" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "raw", 0, 0, G_OPTION_ARG_NONE, &opt_raw, "Show raw variant data" }, { NULL } };
static gboolean
-log_commit (OstreeRepo *repo,
- const gchar *checksum,
- gboolean is_recurse,
- OstreeDumpFlags flags,
- GError **error)
+log_commit (OstreeRepo *repo, const gchar *checksum, gboolean is_recurse, OstreeDumpFlags flags,
+ GError **error)
{
- g_autoptr(GVariant) variant = NULL;
+ g_autoptr (GVariant) variant = NULL;
g_autofree char *parent = NULL;
gboolean ret = FALSE;
GError *local_error = NULL;
- if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum,
- &variant, &local_error))
+ if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, &variant, &local_error))
{
if (is_recurse && g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
@@ -80,14 +74,11 @@ out:
}
gboolean
-ostree_builtin_log (int argc,
- char **argv,
- OstreeCommandInvocation *invocation,
- GCancellable *cancellable,
- GError **error)
+ostree_builtin_log (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
gboolean ret = FALSE;
const char *rev;
g_autofree char *checksum = NULL;
@@ -95,7 +86,8 @@ ostree_builtin_log (int argc,
context = g_option_context_new ("REV");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
goto out;
if (opt_raw)
@@ -115,6 +107,6 @@ ostree_builtin_log (int argc,
goto out;
ret = TRUE;
- out:
+out:
return ret;
}
diff --git a/src/ostree/ot-builtin-ls.c b/src/ostree/ot-builtin-ls.c
index 2a7d1cdc..780bc016 100644
--- a/src/ostree/ot-builtin-ls.c
+++ b/src/ostree/ot-builtin-ls.c
@@ -21,10 +21,10 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
-#include "ostree.h"
#include "ostree-repo-file.h"
+#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
static gboolean opt_dironly;
@@ -38,27 +38,26 @@ static gboolean opt_nul_filenames_only;
* man page (man/ostree-ls.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "dironly", 'd', 0, G_OPTION_ARG_NONE, &opt_dironly, "Do not recurse into directory arguments", NULL },
- { "recursive", 'R', 0, G_OPTION_ARG_NONE, &opt_recursive, "Print directories recursively", NULL },
- { "checksum", 'C', 0, G_OPTION_ARG_NONE, &opt_checksum, "Print checksum", NULL },
- { "xattrs", 'X', 0, G_OPTION_ARG_NONE, &opt_xattrs, "Print extended attributes", NULL },
- { "nul-filenames-only", 0, 0, G_OPTION_ARG_NONE, &opt_nul_filenames_only, "Print only filenames, NUL separated", NULL },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "dironly", 'd', 0, G_OPTION_ARG_NONE, &opt_dironly,
+ "Do not recurse into directory arguments", NULL },
+ { "recursive", 'R', 0, G_OPTION_ARG_NONE, &opt_recursive, "Print directories recursively",
+ NULL },
+ { "checksum", 'C', 0, G_OPTION_ARG_NONE, &opt_checksum, "Print checksum", NULL },
+ { "xattrs", 'X', 0, G_OPTION_ARG_NONE, &opt_xattrs, "Print extended attributes", NULL },
+ { "nul-filenames-only", 0, 0, G_OPTION_ARG_NONE, &opt_nul_filenames_only,
+ "Print only filenames, NUL separated", NULL },
+ { NULL } };
static gboolean
-print_one_file_text (GFile *f,
- GFileInfo *file_info,
- GCancellable *cancellable,
- GError **error)
+print_one_file_text (GFile *f, GFileInfo *file_info, GCancellable *cancellable, GError **error)
{
- g_autoptr(GString) buf = g_string_new ("");
+ g_autoptr (GString) buf = g_string_new ("");
char type_c;
guint32 mode;
guint32 type;
- if (!ostree_repo_file_ensure_resolved ((OstreeRepoFile*)f, error))
+ if (!ostree_repo_file_ensure_resolved ((OstreeRepoFile *)f, error))
return FALSE;
type_c = '?';
@@ -76,9 +75,9 @@ print_one_file_text (GFile *f,
type_c = 'l';
break;
case G_FILE_TYPE_SPECIAL:
- if (S_ISCHR(mode))
+ if (S_ISCHR (mode))
type_c = 'c';
- else if (S_ISBLK(mode))
+ else if (S_ISBLK (mode))
type_c = 'b';
break;
case G_FILE_TYPE_UNKNOWN:
@@ -87,8 +86,7 @@ print_one_file_text (GFile *f,
return glnx_throw (error, "Invalid file type");
}
g_string_append_c (buf, type_c);
- g_string_append_printf (buf, "0%04o %u %u %6" G_GUINT64_FORMAT " ",
- mode & ~S_IFMT,
+ g_string_append_printf (buf, "0%04o %u %u %6" G_GUINT64_FORMAT " ", mode & ~S_IFMT,
g_file_info_get_attribute_uint32 (file_info, "unix::uid"),
g_file_info_get_attribute_uint32 (file_info, "unix::gid"),
g_file_info_get_attribute_uint64 (file_info, "standard::size"));
@@ -96,8 +94,9 @@ print_one_file_text (GFile *f,
if (opt_checksum)
{
if (type == G_FILE_TYPE_DIRECTORY)
- g_string_append_printf (buf, "%s ", ostree_repo_file_tree_get_contents_checksum ((OstreeRepoFile*)f));
- g_string_append_printf (buf, "%s ", ostree_repo_file_get_checksum ((OstreeRepoFile*)f));
+ g_string_append_printf (buf, "%s ",
+ ostree_repo_file_tree_get_contents_checksum ((OstreeRepoFile *)f));
+ g_string_append_printf (buf, "%s ", ostree_repo_file_get_checksum ((OstreeRepoFile *)f));
}
if (opt_xattrs)
@@ -105,7 +104,7 @@ print_one_file_text (GFile *f,
GVariant *xattrs;
char *formatted;
- if (!ostree_repo_file_get_xattrs ((OstreeRepoFile*)f, &xattrs, cancellable, error))
+ if (!ostree_repo_file_get_xattrs ((OstreeRepoFile *)f, &xattrs, cancellable, error))
return FALSE;
formatted = g_variant_print (xattrs, TRUE);
@@ -119,7 +118,9 @@ print_one_file_text (GFile *f,
g_string_append (buf, gs_file_get_path_cached (f));
if (type == G_FILE_TYPE_SYMBOLIC_LINK)
- g_string_append_printf (buf, " -> %s", g_file_info_get_attribute_byte_string (file_info, "standard::symlink-target"));
+ g_string_append_printf (
+ buf, " -> %s",
+ g_file_info_get_attribute_byte_string (file_info, "standard::symlink-target"));
g_print ("%s\n", buf->str);
@@ -127,14 +128,11 @@ print_one_file_text (GFile *f,
}
static gboolean
-print_one_file_binary (GFile *f,
- GFileInfo *file_info,
- GCancellable *cancellable,
- GError **error)
+print_one_file_binary (GFile *f, GFileInfo *file_info, GCancellable *cancellable, GError **error)
{
const char *path;
- if (!ostree_repo_file_ensure_resolved ((OstreeRepoFile*)f, error))
+ if (!ostree_repo_file_ensure_resolved ((OstreeRepoFile *)f, error))
return FALSE;
path = gs_file_get_path_cached (f);
@@ -146,10 +144,7 @@ print_one_file_binary (GFile *f,
}
static gboolean
-print_one_file (GFile *f,
- GFileInfo *file_info,
- GCancellable *cancellable,
- GError **error)
+print_one_file (GFile *f, GFileInfo *file_info, GCancellable *cancellable, GError **error)
{
if (opt_nul_filenames_only)
return print_one_file_binary (f, file_info, cancellable, error);
@@ -158,14 +153,11 @@ print_one_file (GFile *f,
}
static gboolean
-print_directory_recurse (GFile *f,
- int depth,
- GCancellable *cancellable,
- GError **error)
+print_directory_recurse (GFile *f, int depth, GCancellable *cancellable, GError **error)
{
- g_autoptr(GFileEnumerator) dir_enum = NULL;
- g_autoptr(GFile) child = NULL;
- g_autoptr(GFileInfo) child_info = NULL;
+ g_autoptr (GFileEnumerator) dir_enum = NULL;
+ g_autoptr (GFile) child = NULL;
+ g_autoptr (GFileInfo) child_info = NULL;
GError *temp_error = NULL;
if (depth > 0)
@@ -176,9 +168,7 @@ print_directory_recurse (GFile *f,
g_assert (depth == -1);
dir_enum = g_file_enumerate_children (f, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- NULL,
- error);
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, error);
if (dir_enum == NULL)
return FALSE;
@@ -208,22 +198,18 @@ print_directory_recurse (GFile *f,
}
static gboolean
-print_one_argument (OstreeRepo *repo,
- GFile *root,
- const char *arg,
- GCancellable *cancellable,
- GError **error)
+print_one_argument (OstreeRepo *repo, GFile *root, const char *arg, GCancellable *cancellable,
+ GError **error)
{
g_assert (root != NULL);
g_assert (arg != NULL);
- g_autoptr(GFile) f = g_file_resolve_relative_path (root, arg);
+ g_autoptr (GFile) f = g_file_resolve_relative_path (root, arg);
if (f == NULL)
return glnx_throw (error, "Failed to resolve path '%s'", arg);
- g_autoptr(GFileInfo) file_info = NULL;
- file_info = g_file_query_info (f, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ g_autoptr (GFileInfo) file_info = NULL;
+ file_info = g_file_query_info (f, OSTREE_GIO_FAST_QUERYINFO, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
cancellable, error);
if (file_info == NULL)
return FALSE;
@@ -249,17 +235,19 @@ print_one_argument (OstreeRepo *repo,
}
gboolean
-ostree_builtin_ls (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_ls (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
const char *rev;
int i;
- g_autoptr(GFile) root = NULL;
+ g_autoptr (GFile) root = NULL;
context = g_option_context_new ("COMMIT [PATH...]");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
if (argc <= 1)
diff --git a/src/ostree/ot-builtin-prune.c b/src/ostree/ot-builtin-prune.c
index e641c18b..1416ed84 100644
--- a/src/ostree/ot-builtin-prune.c
+++ b/src/ostree/ot-builtin-prune.c
@@ -22,9 +22,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
#include "parse-datetime.h"
@@ -44,29 +44,39 @@ static gboolean opt_commit_only;
*/
static GOptionEntry options[] = {
- { "no-prune", 0, 0, G_OPTION_ARG_NONE, &opt_no_prune, "Only display unreachable objects; don't delete", NULL },
- { "refs-only", 0, 0, G_OPTION_ARG_NONE, &opt_refs_only, "Only compute reachability via refs", NULL },
- { "depth", 0, 0, G_OPTION_ARG_INT, &opt_depth, "Only traverse DEPTH parents for each commit (default: -1=infinite)", "DEPTH" },
- { "delete-commit", 0, 0, G_OPTION_ARG_STRING, &opt_delete_commit, "Specify a commit to delete", "COMMIT" },
- { "keep-younger-than", 0, 0, G_OPTION_ARG_STRING, &opt_keep_younger_than, "Prune all commits older than the specified date", "DATE" },
- { "static-deltas-only", 0, 0, G_OPTION_ARG_NONE, &opt_static_deltas_only, "Change the behavior of delete-commit and keep-younger-than to prune only static deltas" },
- { "retain-branch-depth", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_retain_branch_depth, "Additionally retain BRANCH=DEPTH commits", "BRANCH=DEPTH" },
- { "only-branch", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_only_branches, "Only prune BRANCH (may be specified multiple times)", "BRANCH" },
- { "commit-only", 0, 0, G_OPTION_ARG_NONE, &opt_commit_only, "Only traverse and delete commit objects.", NULL },
+ { "no-prune", 0, 0, G_OPTION_ARG_NONE, &opt_no_prune,
+ "Only display unreachable objects; don't delete", NULL },
+ { "refs-only", 0, 0, G_OPTION_ARG_NONE, &opt_refs_only, "Only compute reachability via refs",
+ NULL },
+ { "depth", 0, 0, G_OPTION_ARG_INT, &opt_depth,
+ "Only traverse DEPTH parents for each commit (default: -1=infinite)", "DEPTH" },
+ { "delete-commit", 0, 0, G_OPTION_ARG_STRING, &opt_delete_commit, "Specify a commit to delete",
+ "COMMIT" },
+ { "keep-younger-than", 0, 0, G_OPTION_ARG_STRING, &opt_keep_younger_than,
+ "Prune all commits older than the specified date", "DATE" },
+ { "static-deltas-only", 0, 0, G_OPTION_ARG_NONE, &opt_static_deltas_only,
+ "Change the behavior of delete-commit and keep-younger-than to prune only static deltas" },
+ { "retain-branch-depth", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_retain_branch_depth,
+ "Additionally retain BRANCH=DEPTH commits", "BRANCH=DEPTH" },
+ { "only-branch", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_only_branches,
+ "Only prune BRANCH (may be specified multiple times)", "BRANCH" },
+ { "commit-only", 0, 0, G_OPTION_ARG_NONE, &opt_commit_only,
+ "Only traverse and delete commit objects.", NULL },
{ NULL }
};
static gboolean
-delete_commit (OstreeRepo *repo, const char *commit_to_delete, GCancellable *cancellable, GError **error)
+delete_commit (OstreeRepo *repo, const char *commit_to_delete, GCancellable *cancellable,
+ GError **error)
{
- g_autoptr(GHashTable) refs = NULL; /* (element-type utf8 utf8) */
- g_autoptr(GHashTable) collection_refs = NULL; /* (element-type OstreeCollectionRef utf8) */
+ g_autoptr (GHashTable) refs = NULL; /* (element-type utf8 utf8) */
+ g_autoptr (GHashTable) collection_refs = NULL; /* (element-type OstreeCollectionRef utf8) */
/* Check refs which are not in a collection. */
if (!ostree_repo_list_refs (repo, NULL, &refs, cancellable, error))
return FALSE;
- GLNX_HASH_TABLE_FOREACH_KV(refs, const char *, ref, const char *, commit)
+ GLNX_HASH_TABLE_FOREACH_KV (refs, const char *, ref, const char *, commit)
{
if (g_strcmp0 (commit_to_delete, commit) == 0)
return glnx_throw (error, "Commit '%s' is referenced by '%s'", commit_to_delete, ref);
@@ -74,32 +84,31 @@ delete_commit (OstreeRepo *repo, const char *commit_to_delete, GCancellable *can
/* And check refs which *are* in a collection. */
if (!ostree_repo_list_collection_refs (repo, NULL, &collection_refs,
- OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES,
- cancellable, error))
+ OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES, cancellable,
+ error))
return FALSE;
- GLNX_HASH_TABLE_FOREACH_KV (collection_refs, const OstreeCollectionRef*, ref,
- const char *, commit)
+ GLNX_HASH_TABLE_FOREACH_KV (collection_refs, const OstreeCollectionRef *, ref, const char *,
+ commit)
{
if (g_strcmp0 (commit_to_delete, commit) == 0)
- return glnx_throw (error, "Commit '%s' is referenced by (%s, %s)",
- commit_to_delete, ref->collection_id, ref->ref_name);
+ return glnx_throw (error, "Commit '%s' is referenced by (%s, %s)", commit_to_delete,
+ ref->collection_id, ref->ref_name);
}
if (!ot_enable_tombstone_commits (repo, error))
return FALSE;
- if (!ostree_repo_delete_object (repo, OSTREE_OBJECT_TYPE_COMMIT, commit_to_delete, cancellable, error))
+ if (!ostree_repo_delete_object (repo, OSTREE_OBJECT_TYPE_COMMIT, commit_to_delete, cancellable,
+ error))
return FALSE;
return TRUE;
}
static gboolean
-traverse_keep_younger_than (OstreeRepo *repo, const char *checksum,
- struct timespec *ts,
- GHashTable *reachable,
- GCancellable *cancellable, GError **error)
+traverse_keep_younger_than (OstreeRepo *repo, const char *checksum, struct timespec *ts,
+ GHashTable *reachable, GCancellable *cancellable, GError **error)
{
g_autofree char *next_checksum = g_strdup (checksum);
OstreeRepoCommitTraverseFlags traverse_flags = OSTREE_REPO_COMMIT_TRAVERSE_FLAG_NONE;
@@ -109,13 +118,13 @@ traverse_keep_younger_than (OstreeRepo *repo, const char *checksum,
/* This is the first commit in our loop, which has a ref pointing to it. We
* don't want to auto-prune it.
*/
- if (!ostree_repo_traverse_commit_with_flags (repo, traverse_flags, checksum, 0, reachable,
- NULL, cancellable, error))
+ if (!ostree_repo_traverse_commit_with_flags (repo, traverse_flags, checksum, 0, reachable, NULL,
+ cancellable, error))
return FALSE;
while (TRUE)
{
- g_autoptr(GVariant) commit = NULL;
+ g_autoptr (GVariant) commit = NULL;
if (!ostree_repo_load_variant_if_exists (repo, OSTREE_OBJECT_TYPE_COMMIT, next_checksum,
&commit, error))
return FALSE;
@@ -127,8 +136,8 @@ traverse_keep_younger_than (OstreeRepo *repo, const char *checksum,
if (commit_timestamp >= ts->tv_sec)
{
/* It's newer, traverse it */
- if (!ostree_repo_traverse_commit_with_flags (repo, traverse_flags, next_checksum, 0, reachable,
- NULL, cancellable, error))
+ if (!ostree_repo_traverse_commit_with_flags (repo, traverse_flags, next_checksum, 0,
+ reachable, NULL, cancellable, error))
return FALSE;
g_free (next_checksum);
@@ -146,11 +155,13 @@ traverse_keep_younger_than (OstreeRepo *repo, const char *checksum,
}
gboolean
-ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
if (!opt_no_prune && !ostree_ensure_repo_writable (repo, error))
@@ -163,16 +174,17 @@ ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation
{
if (opt_no_prune)
{
- ot_util_usage_error (context, "Cannot specify both --delete-commit and --no-prune", error);
+ ot_util_usage_error (context, "Cannot specify both --delete-commit and --no-prune",
+ error);
return FALSE;
}
- if (opt_static_deltas_only)
- {
- if(!ostree_repo_prune_static_deltas (repo, opt_delete_commit, cancellable, error))
- return FALSE;
- }
- else if (!delete_commit (repo, opt_delete_commit, cancellable, error))
- return FALSE;
+ if (opt_static_deltas_only)
+ {
+ if (!ostree_repo_prune_static_deltas (repo, opt_delete_commit, cancellable, error))
+ return FALSE;
+ }
+ else if (!delete_commit (repo, opt_delete_commit, cancellable, error))
+ return FALSE;
}
else
{
@@ -181,7 +193,8 @@ ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation
* https://github.com/ostreedev/ostree/issues/1479
*/
if (opt_static_deltas_only)
- return glnx_throw (error, "--static-deltas-only requires --delete-commit; see https://github.com/ostreedev/ostree/issues/1479");
+ return glnx_throw (error, "--static-deltas-only requires --delete-commit; see "
+ "https://github.com/ostreedev/ostree/issues/1479");
}
OstreeRepoPruneFlags pruneflags = 0;
@@ -201,9 +214,8 @@ ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation
guint64 objsize_total;
if (!(opt_retain_branch_depth || opt_keep_younger_than || opt_only_branches))
{
- if (!ostree_repo_prune (repo, pruneflags, opt_depth,
- &n_objects_total, &n_objects_pruned, &objsize_total,
- cancellable, error))
+ if (!ostree_repo_prune (repo, pruneflags, opt_depth, &n_objects_total, &n_objects_pruned,
+ &objsize_total, cancellable, error))
return FALSE;
}
else
@@ -212,15 +224,18 @@ ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation
* While we do this, we can't let new content in since it'll race with
* reachability calculations and we may immediately nuke it. So push an
* exclusive lock now. */
- g_autoptr(OstreeRepoAutoLock) lock =
- ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_EXCLUSIVE, cancellable, error);
+ g_autoptr (OstreeRepoAutoLock) lock
+ = ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_EXCLUSIVE, cancellable, error);
if (!lock)
return FALSE;
- g_autoptr(GHashTable) all_refs = NULL;
- g_autoptr(GHashTable) reachable = ostree_repo_traverse_new_reachable ();
- g_autoptr(GHashTable) retain_branch_depth = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- struct timespec keep_younger_than_ts = {0, };
+ g_autoptr (GHashTable) all_refs = NULL;
+ g_autoptr (GHashTable) reachable = ostree_repo_traverse_new_reachable ();
+ g_autoptr (GHashTable) retain_branch_depth
+ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ struct timespec keep_younger_than_ts = {
+ 0,
+ };
GHashTableIter hash_iter;
gpointer key, value;
@@ -259,8 +274,7 @@ ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation
/* We start from the refs */
/* FIXME: Do we also want to look at ostree_repo_list_collection_refs()? */
- if (!ostree_repo_list_refs (repo, NULL, &all_refs,
- cancellable, error))
+ if (!ostree_repo_list_refs (repo, NULL, &all_refs, cancellable, error))
return FALSE;
/* Process --only-branch. Note this combines with --retain-branch-depth; one
@@ -275,14 +289,14 @@ ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation
if (opt_only_branches)
{
/* Turn --only-branch into a set */
- g_autoptr(GHashTable) only_branches_set = g_hash_table_new (g_str_hash, g_str_equal);
+ g_autoptr (GHashTable) only_branches_set = g_hash_table_new (g_str_hash, g_str_equal);
for (char **iter = opt_only_branches; iter && *iter; iter++)
{
const char *ref = *iter;
/* Ensure the specified branch exists */
if (!ostree_repo_resolve_rev (repo, ref, FALSE, NULL, error))
return FALSE;
- g_hash_table_add (only_branches_set, (char*)ref);
+ g_hash_table_add (only_branches_set, (char *)ref);
}
/* Iterate over all refs, add equivalent of --retain-branch-depth=$ref=-1
@@ -291,10 +305,11 @@ ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation
*/
GLNX_HASH_TABLE_FOREACH (all_refs, const char *, ref)
{
- if (!g_hash_table_contains (only_branches_set, ref) &&
- !g_hash_table_contains (retain_branch_depth, ref))
+ if (!g_hash_table_contains (only_branches_set, ref)
+ && !g_hash_table_contains (retain_branch_depth, ref))
{
- g_hash_table_insert (retain_branch_depth, g_strdup (ref), GINT_TO_POINTER ((int)-1));
+ g_hash_table_insert (retain_branch_depth, g_strdup (ref),
+ GINT_TO_POINTER ((int)-1));
}
}
}
@@ -318,54 +333,48 @@ ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation
* --retain-branch-depth=myos/x86_64/dev=5
*/
if (depthp)
- depth = GPOINTER_TO_INT(depthp);
+ depth = GPOINTER_TO_INT (depthp);
else if (opt_keep_younger_than)
{
- if (!traverse_keep_younger_than (repo, checksum,
- &keep_younger_than_ts,
- reachable,
+ if (!traverse_keep_younger_than (repo, checksum, &keep_younger_than_ts, reachable,
cancellable, error))
return FALSE;
/* Okay, we handled the younger-than case; the other
* two fall through to plain depth-based handling below.
*/
- continue; /* Note again, we're skipping the below bit */
+ continue; /* Note again, we're skipping the below bit */
}
else
depth = opt_depth; /* No --retain-branch-depth for this branch, use
the global default */
g_debug ("Finding objects to keep for commit %s", checksum);
- if (!ostree_repo_traverse_commit_with_flags (repo, traverse_flags, checksum, depth, reachable,
- NULL, cancellable, error))
+ if (!ostree_repo_traverse_commit_with_flags (repo, traverse_flags, checksum, depth,
+ reachable, NULL, cancellable, error))
return FALSE;
}
/* We've gathered the reachable set; start the prune ✀ */
- { OstreeRepoPruneOptions opts = { pruneflags, reachable };
- if (!ostree_repo_prune_from_reachable (repo, &opts,
- &n_objects_total,
- &n_objects_pruned,
- &objsize_total,
- cancellable, error))
+ {
+ OstreeRepoPruneOptions opts = { pruneflags, reachable };
+ if (!ostree_repo_prune_from_reachable (repo, &opts, &n_objects_total, &n_objects_pruned,
+ &objsize_total, cancellable, error))
return FALSE;
}
}
g_autofree char *formatted_freed_size = g_format_size_full (objsize_total, 0);
if (opt_commit_only)
- g_print("Total (commit only) objects: %u\n", n_objects_total);
+ g_print ("Total (commit only) objects: %u\n", n_objects_total);
else
g_print ("Total objects: %u\n", n_objects_total);
if (n_objects_pruned == 0)
g_print ("No unreachable objects\n");
else if (pruneflags & OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE)
- g_print ("Would delete: %u objects, freeing %s\n",
- n_objects_pruned, formatted_freed_size);
+ g_print ("Would delete: %u objects, freeing %s\n", n_objects_pruned, formatted_freed_size);
else
- g_print ("Deleted %u objects, %s freed\n",
- n_objects_pruned, formatted_freed_size);
+ g_print ("Deleted %u objects, %s freed\n", n_objects_pruned, formatted_freed_size);
return TRUE;
}
diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c
index a49445da..6ea8da05 100644
--- a/src/ostree/ot-builtin-pull-local.c
+++ b/src/ostree/ot-builtin-pull-local.c
@@ -21,12 +21,12 @@
#include "config.h"
-#include <unistd.h>
#include <stdlib.h>
+#include <unistd.h>
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
static char *opt_remote;
@@ -46,45 +46,55 @@ static int opt_depth = 0;
* man page (man/ostree-pull-local.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "commit-metadata-only", 0, 0, G_OPTION_ARG_NONE, &opt_commit_only, "Fetch only the commit metadata", NULL },
- { "remote", 0, 0, G_OPTION_ARG_STRING, &opt_remote, "Add REMOTE to refspec", "REMOTE" },
- { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
- { "per-object-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_per_object_fsync, "Perform writes in such a way that avoids stalling concurrent processes", NULL },
- { "untrusted", 0, 0, G_OPTION_ARG_NONE, &opt_untrusted, "Verify checksums of local sources (always enabled for HTTP pulls)", NULL },
- { "bareuseronly-files", 0, 0, G_OPTION_ARG_NONE, &opt_bareuseronly_files, "Reject regular files with mode outside of 0775 (world writable, suid, etc.)", NULL },
- { "require-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_require_static_deltas, "Require static deltas", NULL },
- { "gpg-verify", 0, 0, G_OPTION_ARG_NONE, &opt_gpg_verify, "GPG verify commits (must specify --remote)", NULL },
- { "gpg-verify-summary", 0, 0, G_OPTION_ARG_NONE, &opt_gpg_verify_summary, "GPG verify summary (must specify --remote)", NULL },
- { "disable-verify-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_disable_verify_bindings, "Do not verify commit bindings", NULL },
- { "depth", 0, 0, G_OPTION_ARG_INT, &opt_depth, "Traverse DEPTH parents (-1=infinite) (default: 0)", "DEPTH" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "commit-metadata-only", 0, 0, G_OPTION_ARG_NONE, &opt_commit_only,
+ "Fetch only the commit metadata", NULL },
+ { "remote", 0, 0, G_OPTION_ARG_STRING, &opt_remote, "Add REMOTE to refspec", "REMOTE" },
+ { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()",
+ NULL },
+ { "per-object-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_per_object_fsync,
+ "Perform writes in such a way that avoids stalling concurrent processes", NULL },
+ { "untrusted", 0, 0, G_OPTION_ARG_NONE, &opt_untrusted,
+ "Verify checksums of local sources (always enabled for HTTP pulls)", NULL },
+ { "bareuseronly-files", 0, 0, G_OPTION_ARG_NONE, &opt_bareuseronly_files,
+ "Reject regular files with mode outside of 0775 (world writable, suid, etc.)", NULL },
+ { "require-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_require_static_deltas,
+ "Require static deltas", NULL },
+ { "gpg-verify", 0, 0, G_OPTION_ARG_NONE, &opt_gpg_verify,
+ "GPG verify commits (must specify --remote)", NULL },
+ { "gpg-verify-summary", 0, 0, G_OPTION_ARG_NONE, &opt_gpg_verify_summary,
+ "GPG verify summary (must specify --remote)", NULL },
+ { "disable-verify-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_disable_verify_bindings,
+ "Do not verify commit bindings", NULL },
+ { "depth", 0, 0, G_OPTION_ARG_INT, &opt_depth,
+ "Traverse DEPTH parents (-1=infinite) (default: 0)", "DEPTH" },
+ { NULL } };
/* See canonical version of this in ot-builtin-pull.c */
static void
-noninteractive_console_progress_changed (OstreeAsyncProgress *progress,
- gpointer user_data)
+noninteractive_console_progress_changed (OstreeAsyncProgress *progress, gpointer user_data)
{
/* We do nothing here - we just want the final status */
}
gboolean
-ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
int i;
const char *src_repo_arg;
g_autofree char *src_repo_uri = NULL;
- g_autoptr(OstreeAsyncProgress) progress = NULL;
- g_autoptr(GPtrArray) refs_to_fetch = NULL;
+ g_autoptr (OstreeAsyncProgress) progress = NULL;
+ g_autoptr (GPtrArray) refs_to_fetch = NULL;
OstreeRepoPullFlags pullflags = 0;
context = g_option_context_new ("SRC_REPO [REFS...]");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
@@ -95,8 +105,7 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
gchar *help = g_option_context_get_help (context, TRUE, NULL);
g_printerr ("%s\n", help);
g_free (help);
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "DESTINATION must be specified");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "DESTINATION must be specified");
goto out;
}
@@ -122,9 +131,9 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
if (argc == 2)
{
- g_autoptr(GFile) src_repo_path = g_file_new_for_path (src_repo_arg);
- g_autoptr(OstreeRepo) src_repo = ostree_repo_new (src_repo_path);
- g_autoptr(GHashTable) refs_to_clone = NULL;
+ g_autoptr (GFile) src_repo_path = g_file_new_for_path (src_repo_arg);
+ g_autoptr (OstreeRepo) src_repo = ostree_repo_new (src_repo_path);
+ g_autoptr (GHashTable) refs_to_clone = NULL;
refs_to_fetch = g_ptr_array_new_with_free_func (g_free);
@@ -133,11 +142,11 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
/* FIXME: This should grow support for pulling refs from refs/mirrors on
* a local repository, using ostree_repo_list_collection_refs(). */
- if (!ostree_repo_list_refs (src_repo, NULL, &refs_to_clone,
- cancellable, error))
+ if (!ostree_repo_list_refs (src_repo, NULL, &refs_to_clone, cancellable, error))
goto out;
- { GHashTableIter hashiter;
+ {
+ GHashTableIter hashiter;
gpointer hkey, hvalue;
g_hash_table_iter_init (&hashiter, refs_to_clone);
@@ -153,14 +162,17 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
{
const char *ref = argv[i];
- g_ptr_array_add (refs_to_fetch, (char*)ref);
+ g_ptr_array_add (refs_to_fetch, (char *)ref);
}
g_ptr_array_add (refs_to_fetch, NULL);
}
- { GVariantBuilder builder;
- g_autoptr(GVariant) opts = NULL;
- g_auto(GLnxConsoleRef) console = { 0, };
+ {
+ GVariantBuilder builder;
+ g_autoptr (GVariant) opts = NULL;
+ g_auto (GLnxConsoleRef) console = {
+ 0,
+ };
glnx_console_lock (&console);
@@ -168,21 +180,24 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
g_variant_builder_add (&builder, "{s@v}", "flags",
g_variant_new_variant (g_variant_new_int32 (pullflags)));
- g_variant_builder_add (&builder, "{s@v}", "refs",
- g_variant_new_variant (g_variant_new_strv ((const char *const*) refs_to_fetch->pdata, -1)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "refs",
+ g_variant_new_variant (g_variant_new_strv ((const char *const *)refs_to_fetch->pdata, -1)));
if (opt_remote)
g_variant_builder_add (&builder, "{s@v}", "override-remote-name",
g_variant_new_variant (g_variant_new_string (opt_remote)));
- g_variant_builder_add (&builder, "{s@v}", "require-static-deltas",
- g_variant_new_variant (g_variant_new_boolean (opt_require_static_deltas)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "require-static-deltas",
+ g_variant_new_variant (g_variant_new_boolean (opt_require_static_deltas)));
if (opt_gpg_verify)
g_variant_builder_add (&builder, "{s@v}", "gpg-verify",
g_variant_new_variant (g_variant_new_boolean (TRUE)));
if (opt_gpg_verify_summary)
g_variant_builder_add (&builder, "{s@v}", "gpg-verify-summary",
g_variant_new_variant (g_variant_new_boolean (TRUE)));
- g_variant_builder_add (&builder, "{s@v}", "disable-verify-bindings",
- g_variant_new_variant (g_variant_new_boolean (opt_disable_verify_bindings)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "disable-verify-bindings",
+ g_variant_new_variant (g_variant_new_boolean (opt_disable_verify_bindings)));
g_variant_builder_add (&builder, "{s@v}", "depth",
g_variant_new_variant (g_variant_new_int32 (opt_depth)));
/* local pulls always disable signapi verification. If you don't want this, use
@@ -193,19 +208,18 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
g_variant_builder_add (&builder, "{s@v}", "disable-sign-verify-summary",
g_variant_new_variant (g_variant_new_boolean (TRUE)));
if (opt_per_object_fsync)
- g_variant_builder_add (&builder, "{s@v}", "per-object-fsync",
- g_variant_new_variant (g_variant_new_boolean (TRUE)));
+ g_variant_builder_add (&builder, "{s@v}", "per-object-fsync",
+ g_variant_new_variant (g_variant_new_boolean (TRUE)));
if (console.is_tty)
- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
+ progress = ostree_async_progress_new_and_connect (
+ ostree_repo_pull_default_console_progress_changed, &console);
else
- progress = ostree_async_progress_new_and_connect (noninteractive_console_progress_changed, &console);
+ progress = ostree_async_progress_new_and_connect (noninteractive_console_progress_changed,
+ &console);
opts = g_variant_ref_sink (g_variant_builder_end (&builder));
- if (!ostree_repo_pull_with_options (repo, src_repo_uri,
- opts,
- progress,
- cancellable, error))
+ if (!ostree_repo_pull_with_options (repo, src_repo_uri, opts, progress, cancellable, error))
goto out;
if (!console.is_tty)
@@ -219,7 +233,7 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invoc
}
ret = TRUE;
- out:
+out:
if (repo)
ostree_repo_abort_transaction (repo, cancellable, NULL);
return ret;
diff --git a/src/ostree/ot-builtin-pull.c b/src/ostree/ot-builtin-pull.c
index 07671e54..bb4be037 100644
--- a/src/ostree/ot-builtin-pull.c
+++ b/src/ostree/ot-builtin-pull.c
@@ -21,9 +21,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
static gboolean opt_disable_fsync;
@@ -37,55 +37,73 @@ static gboolean opt_untrusted;
static gboolean opt_http_trusted;
static gboolean opt_timestamp_check;
static gboolean opt_disable_verify_bindings;
-static char* opt_timestamp_check_from_rev;
+static char *opt_timestamp_check_from_rev;
static gboolean opt_bareuseronly_files;
-static char** opt_subpaths;
-static char** opt_http_headers;
-static char* opt_cache_dir;
-static char* opt_append_user_agent;
+static char **opt_subpaths;
+static char **opt_http_headers;
+static char *opt_cache_dir;
+static char *opt_append_user_agent;
static int opt_depth = 0;
static int opt_frequency = 0;
static int opt_network_retries = -1;
-static char* opt_url;
-static char** opt_localcache_repos;
+static char *opt_url;
+static char **opt_localcache_repos;
/* ATTENTION:
* Please remember to update the bash-completion script (bash/ostree) and
* man page (man/ostree-pull.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "commit-metadata-only", 0, 0, G_OPTION_ARG_NONE, &opt_commit_only, "Fetch only the commit metadata", NULL },
- { "cache-dir", 0, 0, G_OPTION_ARG_FILENAME, &opt_cache_dir, "Use custom cache dir", NULL },
- { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
- { "per-object-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_per_object_fsync, "Perform writes in such a way that avoids stalling concurrent processes", NULL },
- { "disable-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_disable_static_deltas, "Do not use static deltas", NULL },
- { "require-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_require_static_deltas, "Require static deltas", NULL },
- { "mirror", 0, 0, G_OPTION_ARG_NONE, &opt_mirror, "Write refs suitable for a mirror and fetches all refs if none provided", NULL },
- { "subpath", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_subpaths, "Only pull the provided subpath(s)", NULL },
- { "untrusted", 0, 0, G_OPTION_ARG_NONE, &opt_untrusted, "Verify checksums of local sources (always enabled for HTTP pulls)", NULL },
- { "http-trusted", 0, 0, G_OPTION_ARG_NONE, &opt_http_trusted, "Do not verify checksums of HTTP sources (mostly useful when mirroring)", NULL },
- { "bareuseronly-files", 0, 0, G_OPTION_ARG_NONE, &opt_bareuseronly_files, "Reject regular files with mode outside of 0775 (world writable, suid, etc.)", NULL },
- { "dry-run", 0, 0, G_OPTION_ARG_NONE, &opt_dry_run, "Only print information on what will be downloaded (requires static deltas)", NULL },
- { "depth", 0, 0, G_OPTION_ARG_INT, &opt_depth, "Traverse DEPTH parents (-1=infinite) (default: 0)", "DEPTH" },
- { "url", 0, 0, G_OPTION_ARG_STRING, &opt_url, "Pull objects from this URL instead of the one from the remote config", "URL" },
- { "http-header", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_http_headers, "Add NAME=VALUE as HTTP header to all requests", "NAME=VALUE" },
- { "update-frequency", 0, 0, G_OPTION_ARG_INT, &opt_frequency, "Sets the update frequency, in milliseconds (0=1000ms) (default: 0)", "FREQUENCY" },
- { "network-retries", 0, 0, G_OPTION_ARG_INT, &opt_network_retries, "Specifies how many times each download should be retried upon error (default: 5)", "N"},
- { "localcache-repo", 'L', 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_localcache_repos, "Add REPO as local cache source for objects during this pull", "REPO" },
- { "timestamp-check", 'T', 0, G_OPTION_ARG_NONE, &opt_timestamp_check, "Require fetched commits to have newer timestamps", NULL },
- { "timestamp-check-from-rev", 0, 0, G_OPTION_ARG_STRING, &opt_timestamp_check_from_rev, "Require fetched commits to have newer timestamps than given rev", NULL },
- { "disable-verify-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_disable_verify_bindings, "Do not verify commit bindings", NULL },
- /* let's leave this hidden for now; we just need it for tests */
- { "append-user-agent", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &opt_append_user_agent, "Append string to user agent", NULL },
- { NULL }
- };
+static GOptionEntry options[]
+ = { { "commit-metadata-only", 0, 0, G_OPTION_ARG_NONE, &opt_commit_only,
+ "Fetch only the commit metadata", NULL },
+ { "cache-dir", 0, 0, G_OPTION_ARG_FILENAME, &opt_cache_dir, "Use custom cache dir", NULL },
+ { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()",
+ NULL },
+ { "per-object-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_per_object_fsync,
+ "Perform writes in such a way that avoids stalling concurrent processes", NULL },
+ { "disable-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_disable_static_deltas,
+ "Do not use static deltas", NULL },
+ { "require-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_require_static_deltas,
+ "Require static deltas", NULL },
+ { "mirror", 0, 0, G_OPTION_ARG_NONE, &opt_mirror,
+ "Write refs suitable for a mirror and fetches all refs if none provided", NULL },
+ { "subpath", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_subpaths,
+ "Only pull the provided subpath(s)", NULL },
+ { "untrusted", 0, 0, G_OPTION_ARG_NONE, &opt_untrusted,
+ "Verify checksums of local sources (always enabled for HTTP pulls)", NULL },
+ { "http-trusted", 0, 0, G_OPTION_ARG_NONE, &opt_http_trusted,
+ "Do not verify checksums of HTTP sources (mostly useful when mirroring)", NULL },
+ { "bareuseronly-files", 0, 0, G_OPTION_ARG_NONE, &opt_bareuseronly_files,
+ "Reject regular files with mode outside of 0775 (world writable, suid, etc.)", NULL },
+ { "dry-run", 0, 0, G_OPTION_ARG_NONE, &opt_dry_run,
+ "Only print information on what will be downloaded (requires static deltas)", NULL },
+ { "depth", 0, 0, G_OPTION_ARG_INT, &opt_depth,
+ "Traverse DEPTH parents (-1=infinite) (default: 0)", "DEPTH" },
+ { "url", 0, 0, G_OPTION_ARG_STRING, &opt_url,
+ "Pull objects from this URL instead of the one from the remote config", "URL" },
+ { "http-header", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_http_headers,
+ "Add NAME=VALUE as HTTP header to all requests", "NAME=VALUE" },
+ { "update-frequency", 0, 0, G_OPTION_ARG_INT, &opt_frequency,
+ "Sets the update frequency, in milliseconds (0=1000ms) (default: 0)", "FREQUENCY" },
+ { "network-retries", 0, 0, G_OPTION_ARG_INT, &opt_network_retries,
+ "Specifies how many times each download should be retried upon error (default: 5)", "N" },
+ { "localcache-repo", 'L', 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_localcache_repos,
+ "Add REPO as local cache source for objects during this pull", "REPO" },
+ { "timestamp-check", 'T', 0, G_OPTION_ARG_NONE, &opt_timestamp_check,
+ "Require fetched commits to have newer timestamps", NULL },
+ { "timestamp-check-from-rev", 0, 0, G_OPTION_ARG_STRING, &opt_timestamp_check_from_rev,
+ "Require fetched commits to have newer timestamps than given rev", NULL },
+ { "disable-verify-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_disable_verify_bindings,
+ "Do not verify commit bindings", NULL },
+ /* let's leave this hidden for now; we just need it for tests */
+ { "append-user-agent", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &opt_append_user_agent,
+ "Append string to user agent", NULL },
+ { NULL } };
#ifndef OSTREE_DISABLE_GPGME
static void
-gpg_verify_result_cb (OstreeRepo *repo,
- const char *checksum,
- OstreeGpgVerifyResult *result,
+gpg_verify_result_cb (OstreeRepo *repo, const char *checksum, OstreeGpgVerifyResult *result,
GLnxConsoleRef *console)
{
/* Temporarily place the tty back in normal mode before printing GPG
@@ -103,8 +121,7 @@ gpg_verify_result_cb (OstreeRepo *repo,
static gboolean printed_console_progress;
static void
-dry_run_console_progress_changed (OstreeAsyncProgress *progress,
- gpointer user_data)
+dry_run_console_progress_changed (OstreeAsyncProgress *progress, gpointer user_data)
{
guint fetched_delta_parts, total_delta_parts;
guint fetched_delta_part_fallbacks, total_delta_part_fallbacks;
@@ -113,17 +130,15 @@ dry_run_console_progress_changed (OstreeAsyncProgress *progress,
g_assert (!printed_console_progress);
printed_console_progress = TRUE;
- ostree_async_progress_get (progress,
- /* Number of parts */
- "fetched-delta-parts", "u", &fetched_delta_parts,
- "total-delta-parts", "u", &total_delta_parts,
- "fetched-delta-fallbacks", "u", &fetched_delta_part_fallbacks,
- "total-delta-fallbacks", "u", &total_delta_part_fallbacks,
- /* Size variables */
- "fetched-delta-part-size", "t", &fetched_delta_part_size,
- "total-delta-part-size", "t", &total_delta_part_size,
- "total-delta-part-usize", "t", &total_delta_part_usize,
- NULL);
+ ostree_async_progress_get (
+ progress,
+ /* Number of parts */
+ "fetched-delta-parts", "u", &fetched_delta_parts, "total-delta-parts", "u",
+ &total_delta_parts, "fetched-delta-fallbacks", "u", &fetched_delta_part_fallbacks,
+ "total-delta-fallbacks", "u", &total_delta_part_fallbacks,
+ /* Size variables */
+ "fetched-delta-part-size", "t", &fetched_delta_part_size, "total-delta-part-size", "t",
+ &total_delta_part_size, "total-delta-part-usize", "t", &total_delta_part_usize, NULL);
/* Fold the count of deltaparts + fallbacks for simplicity; if changing this,
* please change ostree_repo_pull_default_console_progress_changed() first.
@@ -131,46 +146,44 @@ dry_run_console_progress_changed (OstreeAsyncProgress *progress,
fetched_delta_parts += fetched_delta_part_fallbacks;
total_delta_parts += total_delta_part_fallbacks;
- g_autoptr(GString) buf = g_string_new ("");
+ g_autoptr (GString) buf = g_string_new ("");
- { g_autofree char *formatted_fetched =
- g_format_size (fetched_delta_part_size);
- g_autofree char *formatted_size =
- g_format_size (total_delta_part_size);
- g_autofree char *formatted_usize =
- g_format_size (total_delta_part_usize);
+ {
+ g_autofree char *formatted_fetched = g_format_size (fetched_delta_part_size);
+ g_autofree char *formatted_size = g_format_size (total_delta_part_size);
+ g_autofree char *formatted_usize = g_format_size (total_delta_part_usize);
g_string_append_printf (buf, "Delta update: %u/%u parts, %s/%s, %s total uncompressed",
- fetched_delta_parts, total_delta_parts,
- formatted_fetched, formatted_size,
- formatted_usize);
+ fetched_delta_parts, total_delta_parts, formatted_fetched,
+ formatted_size, formatted_usize);
}
g_print ("%s\n", buf->str);
}
static void
-noninteractive_console_progress_changed (OstreeAsyncProgress *progress,
- gpointer user_data)
+noninteractive_console_progress_changed (OstreeAsyncProgress *progress, gpointer user_data)
{
/* We do nothing here - we just want the final status */
}
gboolean
-ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
gboolean ret = FALSE;
g_autofree char *remote = NULL;
OstreeRepoPullFlags pullflags = 0;
- g_autoptr(GPtrArray) refs_to_fetch = NULL;
- g_autoptr(GPtrArray) override_commit_ids = NULL;
- g_autoptr(OstreeAsyncProgress) progress = NULL;
+ g_autoptr (GPtrArray) refs_to_fetch = NULL;
+ g_autoptr (GPtrArray) override_commit_ids = NULL;
+ g_autoptr (OstreeAsyncProgress) progress = NULL;
gulong signal_handler_id = 0;
context = g_option_context_new ("REMOTE [BRANCH...]");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
@@ -271,8 +284,10 @@ ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation,
{
GVariantBuilder builder;
- g_autoptr(GVariant) pull_options = NULL;
- g_auto(GLnxConsoleRef) console = { 0, };
+ g_autoptr (GVariant) pull_options = NULL;
+ g_auto (GLnxConsoleRef) console = {
+ 0,
+ };
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
glnx_console_lock (&console);
@@ -288,14 +303,16 @@ ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation,
g_variant_builder_add (&builder, "{s@v}", "subdir",
g_variant_new_variant (g_variant_new_string (opt_subpaths[0])));
else
- g_variant_builder_add (&builder, "{s@v}", "subdirs",
- g_variant_new_variant (g_variant_new_strv ((const char *const*) opt_subpaths, -1)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "subdirs",
+ g_variant_new_variant (g_variant_new_strv ((const char *const *)opt_subpaths, -1)));
}
g_variant_builder_add (&builder, "{s@v}", "flags",
g_variant_new_variant (g_variant_new_int32 (pullflags)));
if (refs_to_fetch)
g_variant_builder_add (&builder, "{s@v}", "refs",
- g_variant_new_variant (g_variant_new_strv ((const char *const*) refs_to_fetch->pdata, -1)));
+ g_variant_new_variant (g_variant_new_strv (
+ (const char *const *)refs_to_fetch->pdata, -1)));
g_variant_builder_add (&builder, "{s@v}", "depth",
g_variant_new_variant (g_variant_new_int32 (opt_depth)));
@@ -306,11 +323,13 @@ ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation,
g_variant_builder_add (&builder, "{s@v}", "n-network-retries",
g_variant_new_variant (g_variant_new_uint32 (opt_network_retries)));
- g_variant_builder_add (&builder, "{s@v}", "disable-static-deltas",
- g_variant_new_variant (g_variant_new_boolean (opt_disable_static_deltas)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "disable-static-deltas",
+ g_variant_new_variant (g_variant_new_boolean (opt_disable_static_deltas)));
- g_variant_builder_add (&builder, "{s@v}", "require-static-deltas",
- g_variant_new_variant (g_variant_new_boolean (opt_require_static_deltas)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "require-static-deltas",
+ g_variant_new_variant (g_variant_new_boolean (opt_require_static_deltas)));
g_variant_builder_add (&builder, "{s@v}", "dry-run",
g_variant_new_variant (g_variant_new_boolean (opt_dry_run)));
@@ -318,20 +337,25 @@ ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation,
g_variant_builder_add (&builder, "{s@v}", "timestamp-check",
g_variant_new_variant (g_variant_new_boolean (opt_timestamp_check)));
if (opt_timestamp_check_from_rev)
- g_variant_builder_add (&builder, "{s@v}", "timestamp-check-from-rev",
- g_variant_new_variant (g_variant_new_string (opt_timestamp_check_from_rev)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "timestamp-check-from-rev",
+ g_variant_new_variant (g_variant_new_string (opt_timestamp_check_from_rev)));
if (override_commit_ids)
- g_variant_builder_add (&builder, "{s@v}", "override-commit-ids",
- g_variant_new_variant (g_variant_new_strv ((const char*const*)override_commit_ids->pdata, override_commit_ids->len)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "override-commit-ids",
+ g_variant_new_variant (g_variant_new_strv (
+ (const char *const *)override_commit_ids->pdata, override_commit_ids->len)));
if (opt_localcache_repos)
g_variant_builder_add (&builder, "{s@v}", "localcache-repos",
- g_variant_new_variant (g_variant_new_strv ((const char*const*)opt_localcache_repos, -1)));
+ g_variant_new_variant (g_variant_new_strv (
+ (const char *const *)opt_localcache_repos, -1)));
if (opt_per_object_fsync)
g_variant_builder_add (&builder, "{s@v}", "per-object-fsync",
g_variant_new_variant (g_variant_new_boolean (TRUE)));
- g_variant_builder_add (&builder, "{s@v}", "disable-verify-bindings",
- g_variant_new_variant (g_variant_new_boolean (opt_disable_verify_bindings)));
+ g_variant_builder_add (
+ &builder, "{s@v}", "disable-verify-bindings",
+ g_variant_new_variant (g_variant_new_boolean (opt_disable_verify_bindings)));
if (opt_http_headers)
{
GVariantBuilder hdr_builder;
@@ -344,8 +368,7 @@ ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation,
g_autofree char *key = NULL;
if (!eq)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Missing '=' in --http-header");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Missing '=' in --http-header");
goto out;
}
key = g_strndup (kv, eq - kv);
@@ -362,9 +385,11 @@ ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation,
if (!opt_dry_run)
{
if (console.is_tty)
- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
+ progress = ostree_async_progress_new_and_connect (
+ ostree_repo_pull_default_console_progress_changed, &console);
else
- progress = ostree_async_progress_new_and_connect (noninteractive_console_progress_changed, &console);
+ progress = ostree_async_progress_new_and_connect (noninteractive_console_progress_changed,
+ &console);
}
else
{
@@ -375,15 +400,13 @@ ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation,
{
#ifndef OSTREE_DISABLE_GPGME
signal_handler_id = g_signal_connect (repo, "gpg-verify-result",
- G_CALLBACK (gpg_verify_result_cb),
- &console);
+ G_CALLBACK (gpg_verify_result_cb), &console);
#endif /* OSTREE_DISABLE_GPGME */
}
pull_options = g_variant_ref_sink (g_variant_builder_end (&builder));
- if (!ostree_repo_pull_with_options (repo, remote, pull_options,
- progress, cancellable, error))
+ if (!ostree_repo_pull_with_options (repo, remote, pull_options, progress, cancellable, error))
goto out;
if (!console.is_tty && !opt_dry_run)
@@ -401,7 +424,7 @@ ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation,
}
ret = TRUE;
- out:
+out:
if (signal_handler_id > 0)
g_signal_handler_disconnect (repo, signal_handler_id);
return ret;
diff --git a/src/ostree/ot-builtin-refs.c b/src/ostree/ot-builtin-refs.c
index c49d7507..ec345b5c 100644
--- a/src/ostree/ot-builtin-refs.c
+++ b/src/ostree/ot-builtin-refs.c
@@ -21,9 +21,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
static gboolean opt_delete;
static gboolean opt_list;
@@ -39,19 +39,22 @@ static gboolean opt_force;
*/
static GOptionEntry options[] = {
- { "delete", 0, 0, G_OPTION_ARG_NONE, &opt_delete, "Delete refs which match PREFIX, rather than listing them", NULL },
+ { "delete", 0, 0, G_OPTION_ARG_NONE, &opt_delete,
+ "Delete refs which match PREFIX, rather than listing them", NULL },
{ "list", 0, 0, G_OPTION_ARG_NONE, &opt_list, "Do not remove the prefix from the refs", NULL },
{ "revision", 'r', 0, G_OPTION_ARG_NONE, &opt_revision, "Show revisions in listing", NULL },
- { "alias", 'A', 0, G_OPTION_ARG_NONE, &opt_alias, "If used with --create, create an alias, otherwise just list aliases", NULL },
- { "create", 0, 0, G_OPTION_ARG_STRING, &opt_create, "Create a new ref for an existing commit", "NEWREF" },
- { "collections", 'c', 0, G_OPTION_ARG_NONE, &opt_collections, "Enable listing collection IDs for refs", NULL },
+ { "alias", 'A', 0, G_OPTION_ARG_NONE, &opt_alias,
+ "If used with --create, create an alias, otherwise just list aliases", NULL },
+ { "create", 0, 0, G_OPTION_ARG_STRING, &opt_create, "Create a new ref for an existing commit",
+ "NEWREF" },
+ { "collections", 'c', 0, G_OPTION_ARG_NONE, &opt_collections,
+ "Enable listing collection IDs for refs", NULL },
{ "force", 0, 0, G_OPTION_ARG_NONE, &opt_force, "Overwrite existing refs when creating", NULL },
{ NULL }
};
static int
-collection_ref_cmp (OstreeCollectionRef *a,
- OstreeCollectionRef *b)
+collection_ref_cmp (OstreeCollectionRef *a, OstreeCollectionRef *b)
{
int ret = g_strcmp0 (a->collection_id, b->collection_id);
if (ret == 0)
@@ -60,26 +63,22 @@ collection_ref_cmp (OstreeCollectionRef *a,
}
static gboolean
-do_ref_with_collections (OstreeRepo *repo,
- const char *refspec_prefix,
- GCancellable *cancellable,
- GError **error)
+do_ref_with_collections (OstreeRepo *repo, const char *refspec_prefix, GCancellable *cancellable,
+ GError **error)
{
- g_autoptr(GHashTable) refs = NULL; /* (element-type OstreeCollectionRef utf8) */
+ g_autoptr (GHashTable) refs = NULL; /* (element-type OstreeCollectionRef utf8) */
GHashTableIter hashiter;
gpointer hashkey, hashvalue;
gboolean ret = FALSE;
- if (!ostree_repo_list_collection_refs (repo,
- (!opt_create) ? refspec_prefix : NULL,
- &refs, OSTREE_REPO_LIST_REFS_EXT_NONE,
- cancellable, error))
+ if (!ostree_repo_list_collection_refs (repo, (!opt_create) ? refspec_prefix : NULL, &refs,
+ OSTREE_REPO_LIST_REFS_EXT_NONE, cancellable, error))
goto out;
if (!opt_delete && !opt_create)
{
- g_autoptr(GList) ordered_keys = g_hash_table_get_keys (refs);
- ordered_keys = g_list_sort (ordered_keys, (GCompareFunc) collection_ref_cmp);
+ g_autoptr (GList) ordered_keys = g_hash_table_get_keys (refs);
+ ordered_keys = g_list_sort (ordered_keys, (GCompareFunc)collection_ref_cmp);
for (GList *iter = ordered_keys; iter != NULL; iter = iter->next)
{
@@ -101,7 +100,8 @@ do_ref_with_collections (OstreeRepo *repo,
g_autofree char *checksum = NULL;
g_autofree char *checksum_existing = NULL;
- if (!ostree_repo_resolve_rev_ext (repo, opt_create, TRUE, OSTREE_REPO_RESOLVE_REV_EXT_NONE, &checksum_existing, error))
+ if (!ostree_repo_resolve_rev_ext (repo, opt_create, TRUE, OSTREE_REPO_RESOLVE_REV_EXT_NONE,
+ &checksum_existing, error))
{
if (g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY))
{
@@ -109,7 +109,8 @@ do_ref_with_collections (OstreeRepo *repo,
* which is handled by _ostree_repo_write_ref */
g_clear_error (error);
}
- else goto out;
+ else
+ goto out;
}
if (!opt_force && checksum_existing != NULL)
@@ -124,7 +125,7 @@ do_ref_with_collections (OstreeRepo *repo,
/* This is technically an abuse of the refspec syntax: collection IDs
* should not be treated like remote names. */
- g_auto(GStrv) parts = g_strsplit (opt_create, ":", 2);
+ g_auto (GStrv) parts = g_strsplit (opt_create, ":", 2);
const char *collection_id = parts[0];
const char *ref_name = parts[1];
if (!ostree_validate_collection_id (collection_id, error))
@@ -132,9 +133,8 @@ do_ref_with_collections (OstreeRepo *repo,
if (!ostree_validate_rev (ref_name, error))
goto out;
- const OstreeCollectionRef ref = { (gchar *) collection_id, (gchar *) ref_name };
- if (!ostree_repo_set_collection_ref_immediate (repo, &ref, checksum,
- cancellable, error))
+ const OstreeCollectionRef ref = { (gchar *)collection_id, (gchar *)ref_name };
+ if (!ostree_repo_set_collection_ref_immediate (repo, &ref, checksum, cancellable, error))
goto out;
}
else
@@ -145,20 +145,20 @@ do_ref_with_collections (OstreeRepo *repo,
{
const OstreeCollectionRef *ref = hashkey;
- if (!ostree_repo_set_collection_ref_immediate (repo, ref, NULL,
- cancellable, error))
+ if (!ostree_repo_set_collection_ref_immediate (repo, ref, NULL, cancellable, error))
goto out;
}
}
ret = TRUE;
- out:
+out:
return ret;
}
-static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellable *cancellable, GError **error)
+static gboolean
+do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellable *cancellable, GError **error)
{
- g_autoptr(GHashTable) refs = NULL;
- g_autoptr(GHashTable) ref_aliases = NULL;
+ g_autoptr (GHashTable) refs = NULL;
+ g_autoptr (GHashTable) ref_aliases = NULL;
GHashTableIter hashiter;
gpointer hashkey, hashvalue;
gboolean ret = FALSE;
@@ -174,8 +174,7 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
*/
if (opt_alias || opt_delete)
{
- if (!ostree_repo_list_refs_ext (repo, NULL, &ref_aliases,
- OSTREE_REPO_LIST_REFS_EXT_ALIASES,
+ if (!ostree_repo_list_refs_ext (repo, NULL, &ref_aliases, OSTREE_REPO_LIST_REFS_EXT_ALIASES,
cancellable, error))
goto out;
}
@@ -187,8 +186,7 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
OstreeRepoListRefsExtFlags flags = OSTREE_REPO_LIST_REFS_EXT_NONE;
if (opt_alias)
flags |= OSTREE_REPO_LIST_REFS_EXT_ALIASES;
- if (!ostree_repo_list_refs_ext (repo, refspec_prefix, &refs, flags,
- cancellable, error))
+ if (!ostree_repo_list_refs_ext (repo, refspec_prefix, &refs, flags, cancellable, error))
goto out;
}
else if (opt_create)
@@ -202,8 +200,8 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
if (is_list)
{
- g_autoptr(GList) ordered_keys = g_hash_table_get_keys (refs);
- ordered_keys = g_list_sort (ordered_keys, (GCompareFunc) g_strcmp0);
+ g_autoptr (GList) ordered_keys = g_hash_table_get_keys (refs);
+ ordered_keys = g_list_sort (ordered_keys, (GCompareFunc)g_strcmp0);
for (GList *iter = ordered_keys; iter != NULL; iter = iter->next)
{
@@ -232,7 +230,8 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
g_autofree char *remote = NULL;
g_autofree char *ref = NULL;
- if (!ostree_repo_resolve_rev_ext (repo, opt_create, TRUE, OSTREE_REPO_RESOLVE_REV_EXT_NONE, &checksum_existing, error))
+ if (!ostree_repo_resolve_rev_ext (repo, opt_create, TRUE, OSTREE_REPO_RESOLVE_REV_EXT_NONE,
+ &checksum_existing, error))
{
if (g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY))
{
@@ -240,7 +239,8 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
* which is handled by _ostree_repo_write_ref */
g_clear_error (error);
}
- else goto out;
+ else
+ goto out;
}
/* We want to allow replacing an existing alias or a normal ref when
@@ -264,8 +264,8 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
if (!g_hash_table_contains (refs, refspec_prefix))
return glnx_throw (error, "Cannot create alias to non-existent ref: %s",
refspec_prefix);
- if (!ostree_repo_set_alias_ref_immediate (repo, remote, ref, refspec_prefix,
- cancellable, error))
+ if (!ostree_repo_set_alias_ref_immediate (repo, remote, ref, refspec_prefix, cancellable,
+ error))
goto out;
}
else
@@ -273,8 +273,7 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
if (!ostree_repo_resolve_rev (repo, refspec_prefix, FALSE, &checksum, error))
goto out;
- if (!ostree_repo_set_ref_immediate (repo, remote, ref, checksum,
- cancellable, error))
+ if (!ostree_repo_set_ref_immediate (repo, remote, ref, checksum, cancellable, error))
goto out;
}
}
@@ -292,8 +291,7 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
goto out;
/* Look for alias if it exists for a ref we want to delete */
- GLNX_HASH_TABLE_FOREACH_KV (ref_aliases, const char *,
- ref_alias, const char *, value)
+ GLNX_HASH_TABLE_FOREACH_KV (ref_aliases, const char *, ref_alias, const char *, value)
{
if (!strcmp (ref, value))
{
@@ -302,27 +300,28 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
goto out;
}
}
- if (!ostree_repo_set_ref_immediate (repo, remote, ref, NULL,
- cancellable, error))
+ if (!ostree_repo_set_ref_immediate (repo, remote, ref, NULL, cancellable, error))
goto out;
}
}
ret = TRUE;
- out:
+out:
return ret;
}
gboolean
-ostree_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
int i;
context = g_option_context_new ("[PREFIX]");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
goto out;
if (argc >= 2)
@@ -358,7 +357,7 @@ ostree_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocation,
}
ret = TRUE;
- out:
+out:
if (repo)
ostree_repo_abort_transaction (repo, cancellable, NULL);
return ret;
diff --git a/src/ostree/ot-builtin-remote.c b/src/ostree/ot-builtin-remote.c
index 0e14bb16..f50e09b2 100644
--- a/src/ostree/ot-builtin-remote.c
+++ b/src/ostree/ot-builtin-remote.c
@@ -21,48 +21,31 @@
#include "config.h"
-#include "ot-main.h"
#include "ot-builtins.h"
+#include "ot-main.h"
#include "ot-remote-builtins.h"
static OstreeCommand remote_subcommands[] = {
- { "add", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_remote_builtin_add,
- "Add a remote repository" },
- { "delete", OSTREE_BUILTIN_FLAG_NO_REPO,
- ot_remote_builtin_delete,
- "Delete a remote repository" },
- { "show-url", OSTREE_BUILTIN_FLAG_NONE,
- ot_remote_builtin_show_url,
+ { "add", OSTREE_BUILTIN_FLAG_NO_REPO, ot_remote_builtin_add, "Add a remote repository" },
+ { "delete", OSTREE_BUILTIN_FLAG_NO_REPO, ot_remote_builtin_delete, "Delete a remote repository" },
+ { "show-url", OSTREE_BUILTIN_FLAG_NONE, ot_remote_builtin_show_url,
"Show remote repository URL" },
- { "list", OSTREE_BUILTIN_FLAG_NONE,
- ot_remote_builtin_list,
- "List remote repository names" },
+ { "list", OSTREE_BUILTIN_FLAG_NONE, ot_remote_builtin_list, "List remote repository names" },
#ifndef OSTREE_DISABLE_GPGME
- { "gpg-import", OSTREE_BUILTIN_FLAG_NONE,
- ot_remote_builtin_gpg_import,
- "Import GPG keys" },
- { "gpg-list-keys", OSTREE_BUILTIN_FLAG_NONE,
- ot_remote_builtin_list_gpg_keys,
+ { "gpg-import", OSTREE_BUILTIN_FLAG_NONE, ot_remote_builtin_gpg_import, "Import GPG keys" },
+ { "gpg-list-keys", OSTREE_BUILTIN_FLAG_NONE, ot_remote_builtin_list_gpg_keys,
"Show remote GPG keys" },
#endif /* OSTREE_DISABLE_GPGME */
#ifdef HAVE_LIBCURL_OR_LIBSOUP
- { "add-cookie", OSTREE_BUILTIN_FLAG_NONE,
- ot_remote_builtin_add_cookie,
+ { "add-cookie", OSTREE_BUILTIN_FLAG_NONE, ot_remote_builtin_add_cookie,
"Add a cookie to remote" },
- { "delete-cookie", OSTREE_BUILTIN_FLAG_NONE,
- ot_remote_builtin_delete_cookie,
+ { "delete-cookie", OSTREE_BUILTIN_FLAG_NONE, ot_remote_builtin_delete_cookie,
"Remove one cookie from remote" },
- { "list-cookies", OSTREE_BUILTIN_FLAG_NONE,
- ot_remote_builtin_list_cookies,
+ { "list-cookies", OSTREE_BUILTIN_FLAG_NONE, ot_remote_builtin_list_cookies,
"Show remote repository cookies" },
#endif
- { "refs", OSTREE_BUILTIN_FLAG_NONE,
- ot_remote_builtin_refs,
- "List remote refs" },
- { "summary", OSTREE_BUILTIN_FLAG_NONE,
- ot_remote_builtin_summary,
- "Show remote summary" },
+ { "refs", OSTREE_BUILTIN_FLAG_NONE, ot_remote_builtin_refs, "List remote refs" },
+ { "summary", OSTREE_BUILTIN_FLAG_NONE, ot_remote_builtin_summary, "Show remote summary" },
{ NULL, 0, NULL, NULL }
};
@@ -72,7 +55,7 @@ remote_option_context_new_with_commands (void)
OstreeCommand *subcommand = remote_subcommands;
GOptionContext *context = g_option_context_new ("COMMAND");
- g_autoptr(GString) summary = g_string_new ("Builtin \"remote\" Commands:");
+ g_autoptr (GString) summary = g_string_new ("Builtin \"remote\" Commands:");
while (subcommand->name != NULL)
{
@@ -91,10 +74,11 @@ remote_option_context_new_with_commands (void)
}
gboolean
-ostree_builtin_remote (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_remote (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
const char *subcommand_name = NULL;
- int in,out;
+ int in, out;
for (in = 1, out = 1; in < argc; in++, out++)
{
/* The non-option is the command, take it out of the arguments */
@@ -128,14 +112,13 @@ ostree_builtin_remote (int argc, char **argv, OstreeCommandInvocation *invocatio
if (!subcommand->name)
{
- g_autoptr(GOptionContext) context = NULL;
+ g_autoptr (GOptionContext) context = NULL;
g_autofree char *help = NULL;
context = remote_option_context_new_with_commands ();
/* This will not return for some options (e.g. --version). */
- if (ostree_option_context_parse (context, NULL, &argc, &argv,
- invocation, NULL, cancellable,
+ if (ostree_option_context_parse (context, NULL, &argc, &argv, invocation, NULL, cancellable,
error))
{
if (subcommand_name == NULL)
diff --git a/src/ostree/ot-builtin-reset.c b/src/ostree/ot-builtin-reset.c
index 591eed12..86c5d9cd 100644
--- a/src/ostree/ot-builtin-reset.c
+++ b/src/ostree/ot-builtin-reset.c
@@ -21,9 +21,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
/* ATTENTION:
@@ -31,20 +31,15 @@
* man page (man/ostree-reset.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { NULL }
-};
+static GOptionEntry options[] = { { NULL } };
gboolean
-ostree_builtin_reset (int argc,
- char **argv,
- OstreeCommandInvocation *invocation,
- GCancellable *cancellable,
- GError **error)
+ostree_builtin_reset (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
- g_autoptr(GHashTable) known_refs = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
+ g_autoptr (GHashTable) known_refs = NULL;
gboolean ret = FALSE;
const char *ref;
const char *target = NULL;
@@ -53,7 +48,8 @@ ostree_builtin_reset (int argc,
/* FIXME: Add support for collection–refs. */
context = g_option_context_new ("REF COMMIT");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
@@ -88,7 +84,7 @@ ostree_builtin_reset (int argc,
goto out;
ret = TRUE;
- out:
+out:
if (repo)
ostree_repo_abort_transaction (repo, cancellable, NULL);
return ret;
diff --git a/src/ostree/ot-builtin-rev-parse.c b/src/ostree/ot-builtin-rev-parse.c
index 7da0a01b..e94012dd 100644
--- a/src/ostree/ot-builtin-rev-parse.c
+++ b/src/ostree/ot-builtin-rev-parse.c
@@ -21,9 +21,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
#include <stdbool.h>
@@ -34,17 +34,20 @@
static gboolean opt_single;
-static GOptionEntry options[] = {
- { "single", 'S', 0, G_OPTION_ARG_NONE, &opt_single, "If the repository has exactly one commit, then print it; any other case will result in an error", NULL },
- { NULL }
-};
+static GOptionEntry options[] = { { "single", 'S', 0, G_OPTION_ARG_NONE, &opt_single,
+ "If the repository has exactly one commit, then print it; any "
+ "other case will result in an error",
+ NULL },
+ { NULL } };
gboolean
-ostree_builtin_rev_parse (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_rev_parse (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("REV");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (GOptionContext) context = g_option_context_new ("REV");
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
if (opt_single)
@@ -55,12 +58,12 @@ ostree_builtin_rev_parse (int argc, char **argv, OstreeCommandInvocation *invoca
return FALSE;
}
- g_autoptr(GHashTable) objects = NULL;
+ g_autoptr (GHashTable) objects = NULL;
if (!ostree_repo_list_commit_objects_starting_with (repo, "", &objects, cancellable, error))
return FALSE;
GVariant *found = NULL;
- GLNX_HASH_TABLE_FOREACH (objects, GVariant*, key)
+ GLNX_HASH_TABLE_FOREACH (objects, GVariant *, key)
{
if (found)
return glnx_throw (error, "Multiple commit objects found");
diff --git a/src/ostree/ot-builtin-show.c b/src/ostree/ot-builtin-show.c
index 9346a7b3..d59407f8 100644
--- a/src/ostree/ot-builtin-show.c
+++ b/src/ostree/ot-builtin-show.c
@@ -21,16 +21,16 @@
#include "config.h"
-#include "ot-main.h"
+#include "ostree.h"
#include "ot-builtins.h"
#include "ot-dump.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
static gboolean opt_print_related;
-static char* opt_print_variant_type;
-static char* opt_print_metadata_key;
-static char* opt_print_detached_metadata_key;
+static char *opt_print_variant_type;
+static char *opt_print_metadata_key;
+static char *opt_print_detached_metadata_key;
static gboolean opt_list_metadata_keys;
static gboolean opt_list_detached_metadata_keys;
static gboolean opt_print_sizes;
@@ -44,27 +44,34 @@ static char *opt_gpg_verify_remote;
* man page (man/ostree-show.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "print-related", 0, 0, G_OPTION_ARG_NONE, &opt_print_related, "Show the \"related\" commits", NULL },
- { "print-variant-type", 0, 0, G_OPTION_ARG_STRING, &opt_print_variant_type, "Memory map OBJECT (in this case a filename) to the GVariant type string", "TYPE" },
- { "list-metadata-keys", 0, 0, G_OPTION_ARG_NONE, &opt_list_metadata_keys, "List the available metadata keys", NULL },
- { "print-metadata-key", 0, 0, G_OPTION_ARG_STRING, &opt_print_metadata_key, "Print string value of metadata key", "KEY" },
- { "list-detached-metadata-keys", 0, 0, G_OPTION_ARG_NONE, &opt_list_detached_metadata_keys, "List the available detached metadata keys", NULL },
- { "print-detached-metadata-key", 0, 0, G_OPTION_ARG_STRING, &opt_print_detached_metadata_key, "Print string value of detached metadata key", "KEY" },
- { "print-sizes", 0, 0, G_OPTION_ARG_NONE, &opt_print_sizes, "Show the commit size metadata", NULL },
- { "raw", 0, 0, G_OPTION_ARG_NONE, &opt_raw, "Show raw variant data" },
- { "no-byteswap", 'B', 0, G_OPTION_ARG_NONE, &opt_no_byteswap, "Do not automatically convert variant data from big endian" },
- { "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir, "GPG Homedir to use when looking for keyrings", "HOMEDIR"},
- { "gpg-verify-remote", 0, 0, G_OPTION_ARG_STRING, &opt_gpg_verify_remote, "Use REMOTE name for GPG configuration", "REMOTE"},
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "print-related", 0, 0, G_OPTION_ARG_NONE, &opt_print_related,
+ "Show the \"related\" commits", NULL },
+ { "print-variant-type", 0, 0, G_OPTION_ARG_STRING, &opt_print_variant_type,
+ "Memory map OBJECT (in this case a filename) to the GVariant type string", "TYPE" },
+ { "list-metadata-keys", 0, 0, G_OPTION_ARG_NONE, &opt_list_metadata_keys,
+ "List the available metadata keys", NULL },
+ { "print-metadata-key", 0, 0, G_OPTION_ARG_STRING, &opt_print_metadata_key,
+ "Print string value of metadata key", "KEY" },
+ { "list-detached-metadata-keys", 0, 0, G_OPTION_ARG_NONE, &opt_list_detached_metadata_keys,
+ "List the available detached metadata keys", NULL },
+ { "print-detached-metadata-key", 0, 0, G_OPTION_ARG_STRING,
+ &opt_print_detached_metadata_key, "Print string value of detached metadata key", "KEY" },
+ { "print-sizes", 0, 0, G_OPTION_ARG_NONE, &opt_print_sizes, "Show the commit size metadata",
+ NULL },
+ { "raw", 0, 0, G_OPTION_ARG_NONE, &opt_raw, "Show raw variant data" },
+ { "no-byteswap", 'B', 0, G_OPTION_ARG_NONE, &opt_no_byteswap,
+ "Do not automatically convert variant data from big endian" },
+ { "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir,
+ "GPG Homedir to use when looking for keyrings", "HOMEDIR" },
+ { "gpg-verify-remote", 0, 0, G_OPTION_ARG_STRING, &opt_gpg_verify_remote,
+ "Use REMOTE name for GPG configuration", "REMOTE" },
+ { NULL } };
static gboolean
-do_print_variant_generic (const GVariantType *type,
- const char *filename,
- GError **error)
+do_print_variant_generic (const GVariantType *type, const char *filename, GError **error)
{
- g_autoptr(GVariant) variant = NULL;
+ g_autoptr (GVariant) variant = NULL;
glnx_autofd int fd = -1;
if (!glnx_openat_rdonly (AT_FDCWD, filename, TRUE, &fd, error))
@@ -77,22 +84,18 @@ do_print_variant_generic (const GVariantType *type,
}
static gboolean
-do_print_related (OstreeRepo *repo,
- const char *rev,
- const char *resolved_rev,
- GError **error)
+do_print_related (OstreeRepo *repo, const char *rev, const char *resolved_rev, GError **error)
{
- g_autoptr(GVariant) variant = NULL;
- if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
- resolved_rev, &variant, error))
+ g_autoptr (GVariant) variant = NULL;
+ if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, resolved_rev, &variant, error))
return FALSE;
/* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */
- g_autoptr(GVariant) related = g_variant_get_child_value (variant, 2);
- g_autoptr(GVariantIter) viter = g_variant_iter_new (related);
+ g_autoptr (GVariant) related = g_variant_get_child_value (variant, 2);
+ g_autoptr (GVariantIter) viter = g_variant_iter_new (related);
const char *name;
- GVariant* csum_v;
+ GVariant *csum_v;
while (g_variant_iter_loop (viter, "(&s@ay)", &name, &csum_v))
{
g_autofree char *checksum = ostree_checksum_from_bytes_v (csum_v);
@@ -102,29 +105,24 @@ do_print_related (OstreeRepo *repo,
}
static gboolean
-get_metadata (OstreeRepo *repo,
- const char *resolved_rev,
- gboolean detached,
- GVariant **out_metadata,
- GError **error)
+get_metadata (OstreeRepo *repo, const char *resolved_rev, gboolean detached,
+ GVariant **out_metadata, GError **error)
{
g_assert (out_metadata != NULL);
- g_autoptr(GVariant) commit = NULL;
- g_autoptr(GVariant) metadata = NULL;
+ g_autoptr (GVariant) commit = NULL;
+ g_autoptr (GVariant) metadata = NULL;
if (!detached)
{
- if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
- resolved_rev, &commit, error))
+ if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, resolved_rev, &commit, error))
return FALSE;
/* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */
metadata = g_variant_get_child_value (commit, 0);
}
else
{
- if (!ostree_repo_read_commit_detached_metadata (repo, resolved_rev, &metadata,
- NULL, error))
+ if (!ostree_repo_read_commit_detached_metadata (repo, resolved_rev, &metadata, NULL, error))
return FALSE;
if (metadata == NULL)
{
@@ -140,34 +138,31 @@ get_metadata (OstreeRepo *repo,
}
static gint
-strptr_cmp (gconstpointer a,
- gconstpointer b)
+strptr_cmp (gconstpointer a, gconstpointer b)
{
- const char *a_str = *((const char **) a);
- const char *b_str = *((const char **) b);
+ const char *a_str = *((const char **)a);
+ const char *b_str = *((const char **)b);
return g_strcmp0 (a_str, b_str);
}
static gboolean
-do_list_metadata_keys (OstreeRepo *repo,
- const char *resolved_rev,
- gboolean detached,
- GError **error)
+do_list_metadata_keys (OstreeRepo *repo, const char *resolved_rev, gboolean detached,
+ GError **error)
{
- g_autoptr(GVariant) metadata = NULL;
+ g_autoptr (GVariant) metadata = NULL;
if (!get_metadata (repo, resolved_rev, detached, &metadata, error))
return FALSE;
GVariantIter iter;
const char *key = NULL;
- g_autoptr(GPtrArray) keys = g_ptr_array_new ();
+ g_autoptr (GPtrArray) keys = g_ptr_array_new ();
g_variant_iter_init (&iter, metadata);
while (g_variant_iter_loop (&iter, "{&s@v}", &key, NULL))
- g_ptr_array_add (keys, (gpointer) key);
+ g_ptr_array_add (keys, (gpointer)key);
g_ptr_array_sort (keys, strptr_cmp);
- for (guint i = 0; i < keys-> len; i++)
+ for (guint i = 0; i < keys->len; i++)
{
key = keys->pdata[i];
g_print ("%s\n", key);
@@ -177,21 +172,17 @@ do_list_metadata_keys (OstreeRepo *repo,
}
static gboolean
-do_print_metadata_key (OstreeRepo *repo,
- const char *resolved_rev,
- gboolean detached,
- const char *key,
- GError **error)
+do_print_metadata_key (OstreeRepo *repo, const char *resolved_rev, gboolean detached,
+ const char *key, GError **error)
{
- g_autoptr(GVariant) metadata = NULL;
+ g_autoptr (GVariant) metadata = NULL;
if (!get_metadata (repo, resolved_rev, detached, &metadata, error))
return FALSE;
- g_autoptr(GVariant) value = g_variant_lookup_value (metadata, key, NULL);
+ g_autoptr (GVariant) value = g_variant_lookup_value (metadata, key, NULL);
if (!value)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
- "No such metadata key '%s'", key);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "No such metadata key '%s'", key);
return FALSE;
}
@@ -206,19 +197,16 @@ do_print_metadata_key (OstreeRepo *repo,
}
static gboolean
-do_print_sizes (OstreeRepo *repo,
- const char *rev,
- GError **error)
+do_print_sizes (OstreeRepo *repo, const char *rev, GError **error)
{
- g_autoptr(GVariant) commit = NULL;
- if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, rev,
- &commit, error))
+ g_autoptr (GVariant) commit = NULL;
+ if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, rev, &commit, error))
{
g_prefix_error (error, "Failed to read commit: ");
return FALSE;
}
- g_autoptr(GPtrArray) sizes = NULL;
+ g_autoptr (GPtrArray) sizes = NULL;
if (!ostree_commit_get_object_sizes (commit, &sizes, error))
return FALSE;
@@ -237,8 +225,7 @@ do_print_sizes (OstreeRepo *repo,
objects++;
gboolean exists;
- if (!ostree_repo_has_object (repo, entry->objtype, entry->checksum,
- &exists, NULL, error))
+ if (!ostree_repo_has_object (repo, entry->objtype, entry->checksum, &exists, NULL, error))
return FALSE;
if (!exists)
@@ -257,24 +244,18 @@ do_print_sizes (OstreeRepo *repo,
g_print ("Compressed size (needed/total): %s/%s\n"
"Unpacked size (needed/total): %s/%s\n"
"Number of objects (needed/total): %" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT "\n",
- new_archived_str, archived_str,
- new_unpacked_str, unpacked_str,
- new_objects, objects);
+ new_archived_str, archived_str, new_unpacked_str, unpacked_str, new_objects, objects);
return TRUE;
}
static gboolean
-print_object (OstreeRepo *repo,
- OstreeObjectType objtype,
- const char *checksum,
- GError **error)
+print_object (OstreeRepo *repo, OstreeObjectType objtype, const char *checksum, GError **error)
{
OstreeDumpFlags flags = OSTREE_DUMP_NONE;
- g_autoptr(GVariant) variant = NULL;
- if (!ostree_repo_load_variant (repo, objtype, checksum,
- &variant, error))
+ g_autoptr (GVariant) variant = NULL;
+ if (!ostree_repo_load_variant (repo, objtype, checksum, &variant, error))
return FALSE;
if (opt_raw)
flags |= OSTREE_DUMP_RAW;
@@ -285,9 +266,10 @@ print_object (OstreeRepo *repo,
#ifndef OSTREE_DISABLE_GPGME
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
{
- g_autoptr(OstreeGpgVerifyResult) result = NULL;
- g_autoptr(GError) local_error = NULL;
- g_autoptr(GFile) gpg_homedir = opt_gpg_homedir ? g_file_new_for_path (opt_gpg_homedir) : NULL;
+ g_autoptr (OstreeGpgVerifyResult) result = NULL;
+ g_autoptr (GError) local_error = NULL;
+ g_autoptr (GFile) gpg_homedir
+ = opt_gpg_homedir ? g_file_new_for_path (opt_gpg_homedir) : NULL;
if (opt_gpg_verify_remote)
{
@@ -296,8 +278,7 @@ print_object (OstreeRepo *repo,
}
else
{
- result = ostree_repo_verify_commit_ext (repo, checksum,
- gpg_homedir, NULL, NULL,
+ result = ostree_repo_verify_commit_ext (repo, checksum, gpg_homedir, NULL, NULL,
&local_error);
}
@@ -315,7 +296,7 @@ print_object (OstreeRepo *repo,
guint n_sigs = ostree_gpg_verify_result_count_all (result);
g_print ("Found %u signature%s:\n", n_sigs, n_sigs == 1 ? "" : "s");
- g_autoptr(GString) buffer = g_string_sized_new (256);
+ g_autoptr (GString) buffer = g_string_sized_new (256);
for (guint ii = 0; ii < n_sigs; ii++)
{
g_string_append_c (buffer, '\n');
@@ -332,20 +313,15 @@ print_object (OstreeRepo *repo,
}
static gboolean
-print_if_found (OstreeRepo *repo,
- OstreeObjectType objtype,
- const char *checksum,
- gboolean *inout_was_found,
- GCancellable *cancellable,
- GError **error)
+print_if_found (OstreeRepo *repo, OstreeObjectType objtype, const char *checksum,
+ gboolean *inout_was_found, GCancellable *cancellable, GError **error)
{
gboolean have_object = FALSE;
if (*inout_was_found)
return TRUE;
- if (!ostree_repo_has_object (repo, objtype, checksum, &have_object,
- cancellable, error))
+ if (!ostree_repo_has_object (repo, objtype, checksum, &have_object, cancellable, error))
return FALSE;
if (have_object)
{
@@ -358,12 +334,14 @@ print_if_found (OstreeRepo *repo,
}
gboolean
-ostree_builtin_show (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_show (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("OBJECT");
+ g_autoptr (GOptionContext) context = g_option_context_new ("OBJECT");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
if (argc <= 1)
@@ -423,25 +401,22 @@ ostree_builtin_show (int argc, char **argv, OstreeCommandInvocation *invocation,
}
else
{
- if (!print_if_found (repo, OSTREE_OBJECT_TYPE_COMMIT, rev,
- &found, cancellable, error))
+ if (!print_if_found (repo, OSTREE_OBJECT_TYPE_COMMIT, rev, &found, cancellable, error))
return FALSE;
- if (!print_if_found (repo, OSTREE_OBJECT_TYPE_DIR_META, rev,
- &found, cancellable, error))
+ if (!print_if_found (repo, OSTREE_OBJECT_TYPE_DIR_META, rev, &found, cancellable, error))
return FALSE;
- if (!print_if_found (repo, OSTREE_OBJECT_TYPE_DIR_TREE, rev,
- &found, cancellable, error))
+ if (!print_if_found (repo, OSTREE_OBJECT_TYPE_DIR_TREE, rev, &found, cancellable, error))
return FALSE;
if (!found)
{
- g_autoptr(GFileInfo) finfo = NULL;
- g_autoptr(GVariant) xattrs = NULL;
+ g_autoptr (GFileInfo) finfo = NULL;
+ g_autoptr (GVariant) xattrs = NULL;
- if (!ostree_repo_load_file (repo, rev, NULL, &finfo, &xattrs,
- cancellable, error))
+ if (!ostree_repo_load_file (repo, rev, NULL, &finfo, &xattrs, cancellable, error))
return FALSE;
- g_print ("Object: %s\nType: %s\n", rev, ostree_object_type_to_string (OSTREE_OBJECT_TYPE_FILE));
+ g_print ("Object: %s\nType: %s\n", rev,
+ ostree_object_type_to_string (OSTREE_OBJECT_TYPE_FILE));
GFileType filetype = g_file_info_get_file_type (finfo);
g_print ("File Type: ");
switch (filetype)
diff --git a/src/ostree/ot-builtin-sign.c b/src/ostree/ot-builtin-sign.c
index f4e5c0e5..cd331a48 100644
--- a/src/ostree/ot-builtin-sign.c
+++ b/src/ostree/ot-builtin-sign.c
@@ -24,12 +24,12 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
-#include "ostree.h"
-#include "otutil.h"
#include "ostree-core-private.h"
#include "ostree-sign.h"
+#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
+#include "otutil.h"
static gboolean opt_delete;
static gboolean opt_verify;
@@ -42,16 +42,19 @@ static char *opt_keysdir;
* man page (man/ostree-sign.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "delete", 'd', 0, G_OPTION_ARG_NONE, &opt_delete, "Delete signatures having any of the KEY-IDs", NULL},
- { "verify", 0, 0, G_OPTION_ARG_NONE, &opt_verify, "Verify signatures", NULL},
- { "sign-type", 's', 0, G_OPTION_ARG_STRING, &opt_sign_name, "Signature type to use (defaults to 'ed25519')", "NAME"},
+static GOptionEntry options[]
+ = { { "delete", 'd', 0, G_OPTION_ARG_NONE, &opt_delete,
+ "Delete signatures having any of the KEY-IDs", NULL },
+ { "verify", 0, 0, G_OPTION_ARG_NONE, &opt_verify, "Verify signatures", NULL },
+ { "sign-type", 's', 0, G_OPTION_ARG_STRING, &opt_sign_name,
+ "Signature type to use (defaults to 'ed25519')", "NAME" },
#if defined(HAVE_LIBSODIUM)
- { "keys-file", 0, 0, G_OPTION_ARG_STRING, &opt_filename, "Read key(s) from file", "NAME"},
- { "keys-dir", 0, 0, G_OPTION_ARG_STRING, &opt_keysdir, "Redefine system-wide directories with public and revoked keys for verification", "NAME"},
+ { "keys-file", 0, 0, G_OPTION_ARG_STRING, &opt_filename, "Read key(s) from file", "NAME" },
+ { "keys-dir", 0, 0, G_OPTION_ARG_STRING, &opt_keysdir,
+ "Redefine system-wide directories with public and revoked keys for verification",
+ "NAME" },
#endif
- { NULL }
-};
+ { NULL } };
static void
usage_error (GOptionContext *context, const char *message, GError **error)
@@ -62,7 +65,8 @@ usage_error (GOptionContext *context, const char *message, GError **error)
}
gboolean
-ostree_builtin_sign (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_sign (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
g_autoptr (GOptionContext) context = NULL;
g_autoptr (OstreeRepo) repo = NULL;
@@ -76,8 +80,8 @@ ostree_builtin_sign (int argc, char **argv, OstreeCommandInvocation *invocation,
context = g_option_context_new ("COMMIT KEY-ID...");
-
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
goto out;
if (argc < 2)
@@ -89,9 +93,7 @@ ostree_builtin_sign (int argc, char **argv, OstreeCommandInvocation *invocation,
commit = argv[1];
/* Verification could be done via system files with public keys */
- if (!opt_verify &&
- !opt_filename &&
- argc < 3)
+ if (!opt_verify && !opt_filename && argc < 3)
{
usage_error (context, "Need at least one KEY-ID to sign with", error);
goto out;
@@ -119,18 +121,13 @@ ostree_builtin_sign (int argc, char **argv, OstreeCommandInvocation *invocation,
{
g_autoptr (GError) local_error = NULL;
-
// Pass the key as a string
- pk = g_variant_new_string(key_ids[ii]);
+ pk = g_variant_new_string (key_ids[ii]);
if (!ostree_sign_set_pk (sign, pk, &local_error))
continue;
- if (ostree_sign_commit_verify (sign,
- repo,
- resolved_commit,
- &success_message,
- cancellable,
+ if (ostree_sign_commit_verify (sign, repo, resolved_commit, &success_message, cancellable,
&local_error))
{
g_assert (success_message);
@@ -142,18 +139,14 @@ ostree_builtin_sign (int argc, char **argv, OstreeCommandInvocation *invocation,
else
{
// Pass the key as a string
- sk = g_variant_new_string(key_ids[ii]);
+ sk = g_variant_new_string (key_ids[ii]);
if (!ostree_sign_set_sk (sign, sk, error))
{
ret = FALSE;
goto out;
}
- ret = ostree_sign_commit (sign,
- repo,
- resolved_commit,
- cancellable,
- error);
+ ret = ostree_sign_commit (sign, repo, resolved_commit, cancellable, error);
if (ret != TRUE)
goto out;
}
@@ -168,22 +161,20 @@ ostree_builtin_sign (int argc, char **argv, OstreeCommandInvocation *invocation,
g_autoptr (GVariant) sign_options = NULL;
builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
- /* Use custom directory with public and revoked keys instead of system-wide directories */
+ /* Use custom directory with public and revoked keys instead of system-wide directories
+ */
if (opt_keysdir)
g_variant_builder_add (builder, "{sv}", "basedir", g_variant_new_string (opt_keysdir));
/* The last chance for verification source -- system files */
if (opt_filename)
- g_variant_builder_add (builder, "{sv}", "filename", g_variant_new_string (opt_filename));
+ g_variant_builder_add (builder, "{sv}", "filename",
+ g_variant_new_string (opt_filename));
sign_options = g_variant_builder_end (builder);
if (!ostree_sign_load_pk (sign, sign_options, error))
goto out;
- if (ostree_sign_commit_verify (sign,
- repo,
- resolved_commit,
- &success_message,
- cancellable,
+ if (ostree_sign_commit_verify (sign, repo, resolved_commit, &success_message, cancellable,
error))
{
g_print ("%s\n", success_message);
@@ -213,14 +204,15 @@ ostree_builtin_sign (int argc, char **argv, OstreeCommandInvocation *invocation,
if (key_stream_in == NULL)
goto out;
- key_data_in = g_data_input_stream_new (G_INPUT_STREAM(key_stream_in));
+ key_data_in = g_data_input_stream_new (G_INPUT_STREAM (key_stream_in));
g_assert (key_data_in != NULL);
/* Use simple file format with just a list of base64 public keys per line */
while (TRUE)
{
gsize len = 0;
- g_autofree char *line = g_data_input_stream_read_line (key_data_in, &len, NULL, error);
+ g_autofree char *line
+ = g_data_input_stream_read_line (key_data_in, &len, NULL, error);
g_autoptr (GVariant) sk = NULL;
if (*error != NULL)
@@ -229,20 +221,15 @@ ostree_builtin_sign (int argc, char **argv, OstreeCommandInvocation *invocation,
if (line == NULL)
break;
-
// Pass the key as a string
- sk = g_variant_new_string(line);
+ sk = g_variant_new_string (line);
if (!ostree_sign_set_sk (sign, sk, error))
{
ret = FALSE;
goto out;
}
- ret = ostree_sign_commit (sign,
- repo,
- resolved_commit,
- cancellable,
- error);
+ ret = ostree_sign_commit (sign, repo, resolved_commit, cancellable, error);
if (ret != TRUE)
goto out;
}
@@ -250,9 +237,7 @@ ostree_builtin_sign (int argc, char **argv, OstreeCommandInvocation *invocation,
}
// No valid signature found
if (opt_verify && (ret != TRUE) && (*error == NULL))
- g_set_error_literal (error,
- G_IO_ERROR, G_IO_ERROR_FAILED,
- "No valid signatures found");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "No valid signatures found");
out:
/* It is possible to have an error due multiple signatures check */
diff --git a/src/ostree/ot-builtin-static-delta.c b/src/ostree/ot-builtin-static-delta.c
index a5483c17..a10040bd 100644
--- a/src/ostree/ot-builtin-static-delta.c
+++ b/src/ostree/ot-builtin-static-delta.c
@@ -19,10 +19,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
-#include "ostree.h"
#include "ostree-cmd-private.h"
+#include "ostree.h"
+#include "ot-builtins.h"
#include "ot-main.h"
#include "otutil.h"
@@ -43,43 +42,35 @@ static char *opt_sign_name;
static char *opt_keysfilename;
static char *opt_keysdir;
-#define BUILTINPROTO(name) static gboolean ot_static_delta_builtin_ ## name (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+#define BUILTINPROTO(name) \
+ static gboolean ot_static_delta_builtin_##name (int argc, char **argv, \
+ OstreeCommandInvocation *invocation, \
+ GCancellable *cancellable, GError **error)
-BUILTINPROTO(list);
-BUILTINPROTO(show);
-BUILTINPROTO(delete);
-BUILTINPROTO(generate);
-BUILTINPROTO(apply_offline);
-BUILTINPROTO(verify);
-BUILTINPROTO(indexes);
-BUILTINPROTO(reindex);
+BUILTINPROTO (list);
+BUILTINPROTO (show);
+BUILTINPROTO (delete);
+BUILTINPROTO (generate);
+BUILTINPROTO (apply_offline);
+BUILTINPROTO (verify);
+BUILTINPROTO (indexes);
+BUILTINPROTO (reindex);
#undef BUILTINPROTO
static OstreeCommand static_delta_subcommands[] = {
- { "list", OSTREE_BUILTIN_FLAG_NONE,
- ot_static_delta_builtin_list,
- "List static delta files" },
- { "show", OSTREE_BUILTIN_FLAG_NONE,
- ot_static_delta_builtin_show,
- "Dump information on a delta" },
- { "delete", OSTREE_BUILTIN_FLAG_NONE,
- ot_static_delta_builtin_delete,
- "Remove a delta" },
- { "generate", OSTREE_BUILTIN_FLAG_NONE,
- ot_static_delta_builtin_generate,
+ { "list", OSTREE_BUILTIN_FLAG_NONE, ot_static_delta_builtin_list, "List static delta files" },
+ { "show", OSTREE_BUILTIN_FLAG_NONE, ot_static_delta_builtin_show, "Dump information on a delta" },
+ { "delete", OSTREE_BUILTIN_FLAG_NONE, ot_static_delta_builtin_delete, "Remove a delta" },
+ { "generate", OSTREE_BUILTIN_FLAG_NONE, ot_static_delta_builtin_generate,
"Generate static delta files" },
- { "apply-offline", OSTREE_BUILTIN_FLAG_NONE,
- ot_static_delta_builtin_apply_offline,
+ { "apply-offline", OSTREE_BUILTIN_FLAG_NONE, ot_static_delta_builtin_apply_offline,
"Apply static delta file" },
- { "verify", OSTREE_BUILTIN_FLAG_NONE,
- ot_static_delta_builtin_verify,
+ { "verify", OSTREE_BUILTIN_FLAG_NONE, ot_static_delta_builtin_verify,
"Verify static delta signatures" },
- { "indexes", OSTREE_BUILTIN_FLAG_NONE,
- ot_static_delta_builtin_indexes,
+ { "indexes", OSTREE_BUILTIN_FLAG_NONE, ot_static_delta_builtin_indexes,
"List static delta indexes" },
- { "reindex", OSTREE_BUILTIN_FLAG_NONE,
- ot_static_delta_builtin_reindex,
+ { "reindex", OSTREE_BUILTIN_FLAG_NONE, ot_static_delta_builtin_reindex,
"Regenerate static delta indexes" },
{ NULL, 0, NULL, NULL }
};
@@ -95,55 +86,63 @@ static GOptionEntry generate_options[] = {
{ "inline", 0, 0, G_OPTION_ARG_NONE, &opt_inline, "Inline delta parts into main delta", NULL },
{ "to", 0, 0, G_OPTION_ARG_STRING, &opt_to_rev, "Create delta to revision REV", "REV" },
{ "disable-bsdiff", 0, 0, G_OPTION_ARG_NONE, &opt_disable_bsdiff, "Disable use of bsdiff", NULL },
- { "if-not-exists", 'n', 0, G_OPTION_ARG_NONE, &opt_if_not_exists, "Only generate if a delta does not already exist", NULL },
- { "set-endianness", 0, 0, G_OPTION_ARG_STRING, &opt_endianness, "Choose metadata endianness ('l' or 'B')", "ENDIAN" },
- { "swap-endianness", 0, 0, G_OPTION_ARG_NONE, &opt_swap_endianness, "Swap metadata endianness from host order", NULL },
- { "min-fallback-size", 0, 0, G_OPTION_ARG_STRING, &opt_min_fallback_size, "Minimum uncompressed size in megabytes for individual HTTP request", NULL},
- { "max-bsdiff-size", 0, 0, G_OPTION_ARG_STRING, &opt_max_bsdiff_size, "Maximum size in megabytes to consider bsdiff compression for input files", NULL},
- { "max-chunk-size", 0, 0, G_OPTION_ARG_STRING, &opt_max_chunk_size, "Maximum size of delta chunks in megabytes", NULL},
- { "filename", 0, 0, G_OPTION_ARG_FILENAME, &opt_filename, "Write the delta content to PATH (a directory). If not specified, the OSTree repository is used", "PATH"},
- { "sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "Sign the delta with", "KEY_ID"},
- { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name, "Signature type to use (defaults to 'ed25519')", "NAME"},
+ { "if-not-exists", 'n', 0, G_OPTION_ARG_NONE, &opt_if_not_exists,
+ "Only generate if a delta does not already exist", NULL },
+ { "set-endianness", 0, 0, G_OPTION_ARG_STRING, &opt_endianness,
+ "Choose metadata endianness ('l' or 'B')", "ENDIAN" },
+ { "swap-endianness", 0, 0, G_OPTION_ARG_NONE, &opt_swap_endianness,
+ "Swap metadata endianness from host order", NULL },
+ { "min-fallback-size", 0, 0, G_OPTION_ARG_STRING, &opt_min_fallback_size,
+ "Minimum uncompressed size in megabytes for individual HTTP request", NULL },
+ { "max-bsdiff-size", 0, 0, G_OPTION_ARG_STRING, &opt_max_bsdiff_size,
+ "Maximum size in megabytes to consider bsdiff compression for input files", NULL },
+ { "max-chunk-size", 0, 0, G_OPTION_ARG_STRING, &opt_max_chunk_size,
+ "Maximum size of delta chunks in megabytes", NULL },
+ { "filename", 0, 0, G_OPTION_ARG_FILENAME, &opt_filename,
+ "Write the delta content to PATH (a directory). If not specified, the OSTree repository is "
+ "used",
+ "PATH" },
+ { "sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "Sign the delta with", "KEY_ID" },
+ { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name,
+ "Signature type to use (defaults to 'ed25519')", "NAME" },
#if defined(HAVE_LIBSODIUM)
- { "keys-file", 0, 0, G_OPTION_ARG_STRING, &opt_keysfilename, "Read key(s) from file", "NAME"},
+ { "keys-file", 0, 0, G_OPTION_ARG_STRING, &opt_keysfilename, "Read key(s) from file", "NAME" },
#endif
{ NULL }
};
static GOptionEntry apply_offline_options[] = {
- { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name, "Signature type to use (defaults to 'ed25519')", "NAME"},
+ { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name,
+ "Signature type to use (defaults to 'ed25519')", "NAME" },
#if defined(HAVE_LIBSODIUM)
- { "keys-file", 0, 0, G_OPTION_ARG_STRING, &opt_keysfilename, "Read key(s) from file", "NAME"},
- { "keys-dir", 0, 0, G_OPTION_ARG_STRING, &opt_keysdir, "Redefine system-wide directories with public and revoked keys for verification", "NAME"},
+ { "keys-file", 0, 0, G_OPTION_ARG_STRING, &opt_keysfilename, "Read key(s) from file", "NAME" },
+ { "keys-dir", 0, 0, G_OPTION_ARG_STRING, &opt_keysdir,
+ "Redefine system-wide directories with public and revoked keys for verification", "NAME" },
#endif
{ NULL }
};
-static GOptionEntry list_options[] = {
- { NULL }
-};
+static GOptionEntry list_options[] = { { NULL } };
static GOptionEntry verify_options[] = {
- { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name, "Signature type to use (defaults to 'ed25519')", "NAME"},
+ { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name,
+ "Signature type to use (defaults to 'ed25519')", "NAME" },
#if defined(HAVE_LIBSODIUM)
- { "keys-file", 0, 0, G_OPTION_ARG_STRING, &opt_keysfilename, "Read key(s) from file", "NAME"},
- { "keys-dir", 0, 0, G_OPTION_ARG_STRING, &opt_keysdir, "Redefine system-wide directories with public and revoked keys for verification", "NAME"},
+ { "keys-file", 0, 0, G_OPTION_ARG_STRING, &opt_keysfilename, "Read key(s) from file", "NAME" },
+ { "keys-dir", 0, 0, G_OPTION_ARG_STRING, &opt_keysdir,
+ "Redefine system-wide directories with public and revoked keys for verification", "NAME" },
#endif
{ NULL }
};
-static GOptionEntry indexes_options[] = {
- { NULL }
-};
+static GOptionEntry indexes_options[] = { { NULL } };
-static GOptionEntry reindex_options[] = {
- { "to", 0, 0, G_OPTION_ARG_STRING, &opt_to_rev, "Only update delta index to revision REV", "REV" },
- { NULL }
-};
+static GOptionEntry reindex_options[] = { { "to", 0, 0, G_OPTION_ARG_STRING, &opt_to_rev,
+ "Only update delta index to revision REV", "REV" },
+ { NULL } };
static void
-static_delta_usage (char **argv,
- gboolean is_error)
+static_delta_usage (char **argv, gboolean is_error)
{
OstreeCommand *command = static_delta_subcommands;
void (*print_func) (const gchar *format, ...);
@@ -168,15 +167,16 @@ static_delta_usage (char **argv,
}
static gboolean
-ot_static_delta_builtin_list (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_list (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(OstreeRepo) repo = NULL;
- g_autoptr(GOptionContext) context = g_option_context_new ("");
- if (!ostree_option_context_parse (context, list_options, &argc, &argv,
- invocation, &repo, cancellable, error))
+ g_autoptr (OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
+ if (!ostree_option_context_parse (context, list_options, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
- g_autoptr(GPtrArray) delta_names = NULL;
+ g_autoptr (GPtrArray) delta_names = NULL;
if (!ostree_repo_list_static_delta_names (repo, &delta_names, cancellable, error))
return FALSE;
@@ -185,22 +185,23 @@ ot_static_delta_builtin_list (int argc, char **argv, OstreeCommandInvocation *in
else
{
for (guint i = 0; i < delta_names->len; i++)
- g_print ("%s\n", (char*)delta_names->pdata[i]);
+ g_print ("%s\n", (char *)delta_names->pdata[i]);
}
return TRUE;
}
static gboolean
-ot_static_delta_builtin_indexes (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_indexes (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(OstreeRepo) repo = NULL;
- g_autoptr(GOptionContext) context = g_option_context_new ("");
- if (!ostree_option_context_parse (context, indexes_options, &argc, &argv,
- invocation, &repo, cancellable, error))
+ g_autoptr (OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
+ if (!ostree_option_context_parse (context, indexes_options, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
- g_autoptr(GPtrArray) indexes = NULL;
+ g_autoptr (GPtrArray) indexes = NULL;
if (!ostree_repo_list_static_delta_indexes (repo, &indexes, cancellable, error))
return FALSE;
@@ -209,19 +210,21 @@ ot_static_delta_builtin_indexes (int argc, char **argv, OstreeCommandInvocation
else
{
for (guint i = 0; i < indexes->len; i++)
- g_print ("%s\n", (char*)indexes->pdata[i]);
+ g_print ("%s\n", (char *)indexes->pdata[i]);
}
return TRUE;
}
static gboolean
-ot_static_delta_builtin_reindex (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_reindex (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("");
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, reindex_options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, reindex_options, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
if (!ostree_repo_static_delta_reindex (repo, 0, opt_to_rev, cancellable, error))
@@ -230,21 +233,21 @@ ot_static_delta_builtin_reindex (int argc, char **argv, OstreeCommandInvocation
return TRUE;
}
-
static gboolean
-ot_static_delta_builtin_show (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_show (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("");
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, list_options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, list_options, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
if (argc < 3)
{
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "DELTA must be specified");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "DELTA must be specified");
return FALSE;
}
@@ -257,18 +260,19 @@ ot_static_delta_builtin_show (int argc, char **argv, OstreeCommandInvocation *in
}
static gboolean
-ot_static_delta_builtin_delete (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_delete (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("");
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, list_options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, list_options, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
if (argc < 3)
{
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "DELTA must be specified");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "DELTA must be specified");
return FALSE;
}
@@ -280,13 +284,14 @@ ot_static_delta_builtin_delete (int argc, char **argv, OstreeCommandInvocation *
return TRUE;
}
-
static gboolean
-ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("[TO]");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, generate_options, &argc, &argv, invocation, &repo, cancellable, error))
+ g_autoptr (GOptionContext) context = g_option_context_new ("[TO]");
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, generate_options, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
if (!ostree_ensure_repo_writable (repo, error))
@@ -297,8 +302,7 @@ ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation
if (argc < 3 && opt_to_rev == NULL)
{
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "TO revision must be specified");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "TO revision must be specified");
return FALSE;
}
else
@@ -307,7 +311,7 @@ ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation
g_autofree char *from_resolved = NULL;
g_autofree char *to_resolved = NULL;
g_autofree char *from_parent_str = NULL;
- g_autoptr(GVariantBuilder) parambuilder = NULL;
+ g_autoptr (GVariantBuilder) parambuilder = NULL;
int endianness;
g_assert (opt_to_rev);
@@ -343,8 +347,11 @@ ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation
if (opt_if_not_exists)
{
gboolean does_exist;
- g_autofree char *delta_id = from_resolved ? g_strconcat (from_resolved, "-", to_resolved, NULL) : g_strdup (to_resolved);
- if (!ostree_cmd__private__ ()->ostree_static_delta_query_exists (repo, delta_id, &does_exist, cancellable, error))
+ g_autofree char *delta_id = from_resolved
+ ? g_strconcat (from_resolved, "-", to_resolved, NULL)
+ : g_strdup (to_resolved);
+ if (!ostree_cmd__private__ ()->ostree_static_delta_query_exists (
+ repo, delta_id, &does_exist, cancellable, error))
return FALSE;
if (does_exist)
{
@@ -361,8 +368,8 @@ ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation
endianness = G_BIG_ENDIAN;
else
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid endianness '%s'", opt_endianness);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Invalid endianness '%s'",
+ opt_endianness);
return FALSE;
}
}
@@ -386,31 +393,34 @@ ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation
parambuilder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
if (opt_min_fallback_size)
- g_variant_builder_add (parambuilder, "{sv}",
- "min-fallback-size", g_variant_new_uint32 (g_ascii_strtoull (opt_min_fallback_size, NULL, 10)));
+ g_variant_builder_add (
+ parambuilder, "{sv}", "min-fallback-size",
+ g_variant_new_uint32 (g_ascii_strtoull (opt_min_fallback_size, NULL, 10)));
if (opt_max_bsdiff_size)
- g_variant_builder_add (parambuilder, "{sv}",
- "max-bsdiff-size", g_variant_new_uint32 (g_ascii_strtoull (opt_max_bsdiff_size, NULL, 10)));
+ g_variant_builder_add (
+ parambuilder, "{sv}", "max-bsdiff-size",
+ g_variant_new_uint32 (g_ascii_strtoull (opt_max_bsdiff_size, NULL, 10)));
if (opt_max_chunk_size)
- g_variant_builder_add (parambuilder, "{sv}",
- "max-chunk-size", g_variant_new_uint32 (g_ascii_strtoull (opt_max_chunk_size, NULL, 10)));
+ g_variant_builder_add (
+ parambuilder, "{sv}", "max-chunk-size",
+ g_variant_new_uint32 (g_ascii_strtoull (opt_max_chunk_size, NULL, 10)));
if (opt_disable_bsdiff)
- g_variant_builder_add (parambuilder, "{sv}",
- "bsdiff-enabled", g_variant_new_boolean (FALSE));
+ g_variant_builder_add (parambuilder, "{sv}", "bsdiff-enabled",
+ g_variant_new_boolean (FALSE));
if (opt_inline)
- g_variant_builder_add (parambuilder, "{sv}",
- "inline-parts", g_variant_new_boolean (TRUE));
+ g_variant_builder_add (parambuilder, "{sv}", "inline-parts", g_variant_new_boolean (TRUE));
if (opt_filename)
- g_variant_builder_add (parambuilder, "{sv}",
- "filename", g_variant_new_bytestring (opt_filename));
+ g_variant_builder_add (parambuilder, "{sv}", "filename",
+ g_variant_new_bytestring (opt_filename));
g_variant_builder_add (parambuilder, "{sv}", "verbose", g_variant_new_boolean (TRUE));
if (opt_endianness || opt_swap_endianness)
- g_variant_builder_add (parambuilder, "{sv}", "endianness", g_variant_new_uint32 (endianness));
+ g_variant_builder_add (parambuilder, "{sv}", "endianness",
+ g_variant_new_uint32 (endianness));
if (opt_key_ids || opt_keysfilename)
{
- g_autoptr(GPtrArray) key_ids = g_ptr_array_new ();
+ g_autoptr (GPtrArray) key_ids = g_ptr_array_new ();
for (char **iter = opt_key_ids; iter != NULL && *iter != NULL; ++iter)
g_ptr_array_add (key_ids, *iter);
@@ -424,7 +434,8 @@ ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation
if (!g_file_test (opt_keysfilename, G_FILE_TEST_IS_REGULAR))
{
g_warning ("Can't open file '%s' with keys", opt_keysfilename);
- return glnx_throw (error, "File object '%s' is not a regular file", opt_keysfilename);
+ return glnx_throw (error, "File object '%s' is not a regular file",
+ opt_keysfilename);
}
keyfile = g_file_new_for_path (opt_keysfilename);
@@ -432,14 +443,15 @@ ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation
if (key_stream_in == NULL)
return FALSE;
- key_data_in = g_data_input_stream_new (G_INPUT_STREAM(key_stream_in));
+ key_data_in = g_data_input_stream_new (G_INPUT_STREAM (key_stream_in));
g_assert (key_data_in != NULL);
/* Use simple file format with just a list of base64 public keys per line */
while (TRUE)
{
gsize len = 0;
- g_autofree char *line = g_data_input_stream_read_line (key_data_in, &len, NULL, error);
+ g_autofree char *line
+ = g_data_input_stream_read_line (key_data_in, &len, NULL, error);
g_autoptr (GVariant) sk = NULL;
if (*error != NULL)
@@ -453,8 +465,8 @@ ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation
}
}
- g_autoptr(GVariant) key_ids_v = g_variant_new_strv ((const char *const *)key_ids->pdata,
- key_ids->len);
+ g_autoptr (GVariant) key_ids_v
+ = g_variant_new_strv ((const char *const *)key_ids->pdata, key_ids->len);
g_variant_builder_add (parambuilder, "{s@v}", "sign-key-ids",
g_variant_new_variant (g_steal_pointer (&key_ids_v)));
}
@@ -465,30 +477,31 @@ ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation
g_print ("Generating static delta:\n");
g_print (" From: %s\n", from_resolved ? from_resolved : "empty");
g_print (" To: %s\n", to_resolved);
- { g_autoptr(GVariant) params = g_variant_ref_sink (g_variant_builder_end (parambuilder));
+ {
+ g_autoptr (GVariant) params = g_variant_ref_sink (g_variant_builder_end (parambuilder));
if (!ostree_repo_static_delta_generate (repo, OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR,
- from_resolved, to_resolved, NULL,
- params,
+ from_resolved, to_resolved, NULL, params,
cancellable, error))
return FALSE;
}
-
}
return TRUE;
}
static gboolean
-ot_static_delta_builtin_apply_offline (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_apply_offline (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
g_autoptr (OstreeSign) sign = NULL;
char **key_ids;
int n_key_ids;
context = g_option_context_new ("");
- if (!ostree_option_context_parse (context, apply_offline_options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, apply_offline_options, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
if (!ostree_ensure_repo_writable (repo, error))
@@ -496,8 +509,7 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, OstreeCommandInvoc
if (argc < 3)
{
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "PATH must be specified");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "PATH must be specified");
return FALSE;
}
@@ -516,8 +528,8 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, OstreeCommandInvoc
n_key_ids = argc - 3;
for (int i = 0; i < n_key_ids; i++)
{
- g_autoptr (GVariant) pk = g_variant_new_string(key_ids[i]);
- if (!ostree_sign_add_pk(sign, pk, error))
+ g_autoptr (GVariant) pk = g_variant_new_string (key_ids[i]);
+ if (!ostree_sign_add_pk (sign, pk, error))
return FALSE;
}
if ((n_key_ids == 0) || opt_keysfilename)
@@ -525,21 +537,24 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, OstreeCommandInvoc
g_autoptr (GVariantBuilder) builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
g_autoptr (GVariant) options = NULL;
- /* Use custom directory with public and revoked keys instead of system-wide directories */
+ /* Use custom directory with public and revoked keys instead of system-wide directories
+ */
if (opt_keysdir)
g_variant_builder_add (builder, "{sv}", "basedir", g_variant_new_string (opt_keysdir));
/* The last chance for verification source -- system files */
if (opt_keysfilename)
- g_variant_builder_add (builder, "{sv}", "filename", g_variant_new_string (opt_keysfilename));
+ g_variant_builder_add (builder, "{sv}", "filename",
+ g_variant_new_string (opt_keysfilename));
options = g_variant_builder_end (builder);
if (!ostree_sign_load_pk (sign, options, error))
{
- /* If it fails to load system default public keys, consider there no signature engine */
+ /* If it fails to load system default public keys, consider there no signature engine
+ */
if (!opt_keysdir && !opt_keysfilename)
{
- g_clear_error(error);
- g_clear_object(&sign);
+ g_clear_error (error);
+ g_clear_object (&sign);
}
else
return FALSE;
@@ -548,12 +563,13 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, OstreeCommandInvoc
}
const char *patharg = argv[2];
- g_autoptr(GFile) path = g_file_new_for_path (patharg);
+ g_autoptr (GFile) path = g_file_new_for_path (patharg);
if (!ostree_repo_prepare_transaction (repo, NULL, cancellable, error))
return FALSE;
- if (!ostree_repo_static_delta_execute_offline_with_signature (repo, path, sign, FALSE, cancellable, error))
+ if (!ostree_repo_static_delta_execute_offline_with_signature (repo, path, sign, FALSE,
+ cancellable, error))
return FALSE;
if (!ostree_repo_commit_transaction (repo, NULL, cancellable, error))
@@ -563,7 +579,8 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, OstreeCommandInvoc
}
static gboolean
-ot_static_delta_builtin_verify (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_verify (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
g_autoptr (GOptionContext) context = g_option_context_new ("STATIC-DELTA-FILE [KEY-ID...]");
g_autoptr (OstreeRepo) repo = NULL;
@@ -571,13 +588,13 @@ ot_static_delta_builtin_verify (int argc, char **argv, OstreeCommandInvocation *
char **key_ids;
int n_key_ids;
- if (!ostree_option_context_parse (context, verify_options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, verify_options, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
if (argc < 3)
{
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "DELTA must be specified");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "DELTA must be specified");
return FALSE;
}
@@ -588,7 +605,7 @@ ot_static_delta_builtin_verify (int argc, char **argv, OstreeCommandInvocation *
g_autoptr (OstreeSign) sign = ostree_sign_get_by_name (opt_sign_name, error);
if (!sign)
{
- g_print("Sign-type not supported\n");
+ g_print ("Sign-type not supported\n");
return FALSE;
}
@@ -596,8 +613,8 @@ ot_static_delta_builtin_verify (int argc, char **argv, OstreeCommandInvocation *
n_key_ids = argc - 3;
for (int i = 0; i < n_key_ids; i++)
{
- g_autoptr (GVariant) pk = g_variant_new_string(key_ids[i]);
- if (!ostree_sign_add_pk(sign, pk, error))
+ g_autoptr (GVariant) pk = g_variant_new_string (key_ids[i]);
+ if (!ostree_sign_add_pk (sign, pk, error))
return FALSE;
}
if ((n_key_ids == 0) || opt_keysfilename)
@@ -611,7 +628,8 @@ ot_static_delta_builtin_verify (int argc, char **argv, OstreeCommandInvocation *
g_variant_builder_add (builder, "{sv}", "basedir", g_variant_new_string (opt_keysdir));
/* The last chance for verification source -- system files */
if (opt_keysfilename)
- g_variant_builder_add (builder, "{sv}", "filename", g_variant_new_string (opt_keysfilename));
+ g_variant_builder_add (builder, "{sv}", "filename",
+ g_variant_new_string (opt_keysfilename));
options = g_variant_builder_end (builder);
if (!ostree_sign_load_pk (sign, options, error))
@@ -625,7 +643,8 @@ ot_static_delta_builtin_verify (int argc, char **argv, OstreeCommandInvocation *
}
gboolean
-ostree_builtin_static_delta (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_static_delta (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
gboolean want_help = FALSE;
const char *cmdname = NULL;
diff --git a/src/ostree/ot-builtin-summary.c b/src/ostree/ot-builtin-summary.c
index b0a2a6ed..df980df8 100644
--- a/src/ostree/ot-builtin-summary.c
+++ b/src/ostree/ot-builtin-summary.c
@@ -20,12 +20,12 @@
#include "config.h"
#include "ostree-repo-private.h"
+#include "ostree-sign.h"
+#include "ostree.h"
+#include "ot-builtins.h"
#include "ot-dump.h"
#include "ot-main.h"
-#include "ot-builtins.h"
-#include "ostree.h"
#include "otutil.h"
-#include "ostree-sign.h"
static gboolean opt_update, opt_view, opt_raw;
static gboolean opt_list_metadata_keys;
@@ -41,27 +41,33 @@ static char **opt_metadata;
* man page (man/ostree-summary.xml) when changing the option list.
*/
-static GOptionEntry options[] = {
- { "update", 'u', 0, G_OPTION_ARG_NONE, &opt_update, "Update the summary", NULL },
- { "view", 'v', 0, G_OPTION_ARG_NONE, &opt_view, "View the local summary file", NULL },
- { "raw", 0, 0, G_OPTION_ARG_NONE, &opt_raw, "View the raw bytes of the summary file", NULL },
- { "list-metadata-keys", 0, 0, G_OPTION_ARG_NONE, &opt_list_metadata_keys, "List the available metadata keys", NULL },
- { "print-metadata-key", 0, 0, G_OPTION_ARG_STRING, &opt_print_metadata_key, "Print string value of metadata key", "KEY" },
- { "gpg-sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_gpg_key_ids, "GPG Key ID to sign the summary with", "KEY-ID"},
- { "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir, "GPG Homedir to use when looking for keyrings", "HOMEDIR"},
- { "sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "Key ID to sign the summary with", "KEY-ID"},
- { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name, "Signature type to use (defaults to 'ed25519')", "NAME"},
- { "add-metadata", 'm', 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata, "Additional metadata field to add to the summary", "KEY=VALUE" },
- { NULL }
-};
+static GOptionEntry options[]
+ = { { "update", 'u', 0, G_OPTION_ARG_NONE, &opt_update, "Update the summary", NULL },
+ { "view", 'v', 0, G_OPTION_ARG_NONE, &opt_view, "View the local summary file", NULL },
+ { "raw", 0, 0, G_OPTION_ARG_NONE, &opt_raw, "View the raw bytes of the summary file",
+ NULL },
+ { "list-metadata-keys", 0, 0, G_OPTION_ARG_NONE, &opt_list_metadata_keys,
+ "List the available metadata keys", NULL },
+ { "print-metadata-key", 0, 0, G_OPTION_ARG_STRING, &opt_print_metadata_key,
+ "Print string value of metadata key", "KEY" },
+ { "gpg-sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_gpg_key_ids,
+ "GPG Key ID to sign the summary with", "KEY-ID" },
+ { "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir,
+ "GPG Homedir to use when looking for keyrings", "HOMEDIR" },
+ { "sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "Key ID to sign the summary with",
+ "KEY-ID" },
+ { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name,
+ "Signature type to use (defaults to 'ed25519')", "NAME" },
+ { "add-metadata", 'm', 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata,
+ "Additional metadata field to add to the summary", "KEY=VALUE" },
+ { NULL } };
/* Take arguments of the form KEY=VALUE and put them into an a{sv} variant. The
* value arguments must be parsable using g_variant_parse(). */
static GVariant *
-build_additional_metadata (const char * const *args,
- GError **error)
+build_additional_metadata (const char *const *args, GError **error)
{
- g_autoptr(GVariantBuilder) builder = NULL;
+ g_autoptr (GVariantBuilder) builder = NULL;
builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
@@ -70,11 +76,10 @@ build_additional_metadata (const char * const *args,
const gchar *equals = strchr (args[i], '=');
g_autofree gchar *key = NULL;
const gchar *value_str;
- g_autoptr(GVariant) value = NULL;
+ g_autoptr (GVariant) value = NULL;
if (equals == NULL)
- return glnx_null_throw (error,
- "Missing '=' in KEY=VALUE metadata '%s'", args[i]);
+ return glnx_null_throw (error, "Missing '=' in KEY=VALUE metadata '%s'", args[i]);
key = g_strndup (args[i], equals - args[i]);
value_str = equals + 1;
@@ -90,13 +95,11 @@ build_additional_metadata (const char * const *args,
}
static gboolean
-get_summary_data (OstreeRepo *repo,
- GBytes **out_summary_data,
- GError **error)
+get_summary_data (OstreeRepo *repo, GBytes **out_summary_data, GError **error)
{
g_assert (out_summary_data != NULL);
- g_autoptr(GBytes) summary_data = NULL;
+ g_autoptr (GBytes) summary_data = NULL;
glnx_autofd int fd = -1;
if (!glnx_openat_rdonly (repo->repo_dir_fd, "summary", TRUE, &fd, error))
return FALSE;
@@ -110,16 +113,18 @@ get_summary_data (OstreeRepo *repo,
}
gboolean
-ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
g_autoptr (OstreeSign) sign = NULL;
OstreeDumpFlags flags = OSTREE_DUMP_NONE;
context = g_option_context_new ("");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
return FALSE;
/* Initialize crypto system */
@@ -134,34 +139,36 @@ ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocati
if (opt_update)
{
- g_autoptr(GVariant) additional_metadata = NULL;
+ g_autoptr (GVariant) additional_metadata = NULL;
if (!ostree_ensure_repo_writable (repo, error))
return FALSE;
if (opt_metadata != NULL)
{
- additional_metadata = build_additional_metadata ((const char * const *) opt_metadata, error);
+ additional_metadata
+ = build_additional_metadata ((const char *const *)opt_metadata, error);
if (additional_metadata == NULL)
return FALSE;
}
/* Regenerate and sign the repo metadata. */
- g_auto(GVariantBuilder) metadata_opts_builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT);
- g_autoptr(GVariant) metadata_opts = NULL;
+ g_auto (GVariantBuilder) metadata_opts_builder
+ = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT);
+ g_autoptr (GVariant) metadata_opts = NULL;
if (opt_gpg_key_ids != NULL)
g_variant_builder_add (&metadata_opts_builder, "{sv}", "gpg-key-ids",
- g_variant_new_strv ((const char * const *) opt_gpg_key_ids, -1));
+ g_variant_new_strv ((const char *const *)opt_gpg_key_ids, -1));
if (opt_gpg_homedir != NULL)
g_variant_builder_add (&metadata_opts_builder, "{sv}", "gpg-homedir",
g_variant_new_string (opt_gpg_homedir));
if (opt_key_ids != NULL)
{
- g_auto(GVariantBuilder) sk_builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_ARRAY);
+ g_auto (GVariantBuilder) sk_builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_ARRAY);
/* Currently only strings are used as keys for supported
* signature types. */
- for (const char * const *iter = (const char * const *) opt_key_ids;
+ for (const char *const *iter = (const char *const *)opt_key_ids;
iter != NULL && *iter != NULL; iter++)
{
const char *key_id = *iter;
@@ -176,13 +183,13 @@ ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocati
g_variant_new_string (opt_sign_name));
metadata_opts = g_variant_ref_sink (g_variant_builder_end (&metadata_opts_builder));
- if (!ostree_repo_regenerate_metadata (repo, additional_metadata, metadata_opts,
- cancellable, error))
+ if (!ostree_repo_regenerate_metadata (repo, additional_metadata, metadata_opts, cancellable,
+ error))
return FALSE;
}
else if (opt_view || opt_raw)
{
- g_autoptr(GBytes) summary_data = NULL;
+ g_autoptr (GBytes) summary_data = NULL;
if (opt_raw)
flags |= OSTREE_DUMP_RAW;
@@ -194,7 +201,7 @@ ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocati
}
else if (opt_list_metadata_keys)
{
- g_autoptr(GBytes) summary_data = NULL;
+ g_autoptr (GBytes) summary_data = NULL;
if (!get_summary_data (repo, &summary_data, error))
return FALSE;
@@ -203,7 +210,7 @@ ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocati
}
else if (opt_print_metadata_key)
{
- g_autoptr(GBytes) summary_data = NULL;
+ g_autoptr (GBytes) summary_data = NULL;
if (!get_summary_data (repo, &summary_data, error))
return FALSE;
diff --git a/src/ostree/ot-builtin-trivial-httpd.c b/src/ostree/ot-builtin-trivial-httpd.c
index 71c286b3..b5e84007 100644
--- a/src/ostree/ot-builtin-trivial-httpd.c
+++ b/src/ostree/ot-builtin-trivial-httpd.c
@@ -19,21 +19,22 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include "otutil.h"
gboolean
-ostree_builtin_trivial_httpd (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_trivial_httpd (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GPtrArray) new_argv = g_ptr_array_new ();
+ g_autoptr (GPtrArray) new_argv = g_ptr_array_new ();
g_ptr_array_add (new_argv, PKGLIBEXECDIR "/ostree-trivial-httpd");
for (int i = 1; i < argc; i++)
g_ptr_array_add (new_argv, argv[i]);
g_ptr_array_add (new_argv, NULL);
- execvp (new_argv->pdata[0], (char**)new_argv->pdata);
+ execvp (new_argv->pdata[0], (char **)new_argv->pdata);
/* Fall through on error */
glnx_set_error_from_errno (error);
return FALSE;
diff --git a/src/ostree/ot-builtins.h b/src/ostree/ot-builtins.h
index 63b1ea38..4d15b7a2 100644
--- a/src/ostree/ot-builtins.h
+++ b/src/ostree/ot-builtins.h
@@ -28,38 +28,40 @@
G_BEGIN_DECLS
-#define BUILTINPROTO(name) gboolean ostree_builtin_ ## name (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+#define BUILTINPROTO(name) \
+ gboolean ostree_builtin_##name (int argc, char **argv, OstreeCommandInvocation *invocation, \
+ GCancellable *cancellable, GError **error)
-BUILTINPROTO(admin);
-BUILTINPROTO(cat);
-BUILTINPROTO(config);
-BUILTINPROTO(checkout);
-BUILTINPROTO(checksum);
-BUILTINPROTO(commit);
-BUILTINPROTO(diff);
-BUILTINPROTO(export);
-BUILTINPROTO(find_remotes);
-BUILTINPROTO(create_usb);
+BUILTINPROTO (admin);
+BUILTINPROTO (cat);
+BUILTINPROTO (config);
+BUILTINPROTO (checkout);
+BUILTINPROTO (checksum);
+BUILTINPROTO (commit);
+BUILTINPROTO (diff);
+BUILTINPROTO (export);
+BUILTINPROTO (find_remotes);
+BUILTINPROTO (create_usb);
#ifndef OSTREE_DISABLE_GPGME
-BUILTINPROTO(gpg_sign);
+BUILTINPROTO (gpg_sign);
#endif
-BUILTINPROTO(init);
-BUILTINPROTO(log);
-BUILTINPROTO(pull);
-BUILTINPROTO(pull_local);
-BUILTINPROTO(ls);
-BUILTINPROTO(prune);
-BUILTINPROTO(refs);
-BUILTINPROTO(reset);
-BUILTINPROTO(fsck);
-BUILTINPROTO(sign);
-BUILTINPROTO(show);
-BUILTINPROTO(static_delta);
-BUILTINPROTO(summary);
-BUILTINPROTO(rev_parse);
-BUILTINPROTO(remote);
-BUILTINPROTO(write_refs);
-BUILTINPROTO(trivial_httpd);
+BUILTINPROTO (init);
+BUILTINPROTO (log);
+BUILTINPROTO (pull);
+BUILTINPROTO (pull_local);
+BUILTINPROTO (ls);
+BUILTINPROTO (prune);
+BUILTINPROTO (refs);
+BUILTINPROTO (reset);
+BUILTINPROTO (fsck);
+BUILTINPROTO (sign);
+BUILTINPROTO (show);
+BUILTINPROTO (static_delta);
+BUILTINPROTO (summary);
+BUILTINPROTO (rev_parse);
+BUILTINPROTO (remote);
+BUILTINPROTO (write_refs);
+BUILTINPROTO (trivial_httpd);
#undef BUILTINPROTO
diff --git a/src/ostree/ot-dump.c b/src/ostree/ot-dump.c
index 4cfac811..2ff2fe2e 100644
--- a/src/ostree/ot-dump.c
+++ b/src/ostree/ot-dump.c
@@ -27,15 +27,15 @@
#include "ostree-repo-private.h"
#include "ostree-repo-static-delta-private.h"
+#include "ot-admin-functions.h"
#include "ot-dump.h"
#include "otutil.h"
-#include "ot-admin-functions.h"
void
ot_dump_variant (GVariant *variant)
{
g_autofree char *formatted_variant = NULL;
- g_autoptr(GVariant) byteswapped = NULL;
+ g_autoptr (GVariant) byteswapped = NULL;
if (G_BYTE_ORDER != G_BIG_ENDIAN)
{
@@ -50,9 +50,7 @@ ot_dump_variant (GVariant *variant)
}
static gchar *
-format_timestamp (guint64 timestamp,
- gboolean local_tz,
- GError **error)
+format_timestamp (guint64 timestamp, gboolean local_tz, GError **error)
{
GDateTime *dt;
gchar *str;
@@ -70,7 +68,7 @@ format_timestamp (guint64 timestamp,
/* Convert to local time and display in the locale's preferred
* representation.
*/
- g_autoptr(GDateTime) dt_local = g_date_time_to_local (dt);
+ g_autoptr (GDateTime) dt_local = g_date_time_to_local (dt);
str = g_date_time_format (dt_local, "%c");
}
else
@@ -86,8 +84,8 @@ format_timestamp (guint64 timestamp,
static gchar *
uint64_secs_to_iso8601 (guint64 secs)
{
- g_autoptr(GDateTime) dt = g_date_time_new_from_unix_utc (secs);
- g_autoptr(GDateTime) local = (dt != NULL) ? g_date_time_to_local (dt) : NULL;
+ g_autoptr (GDateTime) dt = g_date_time_new_from_unix_utc (secs);
+ g_autoptr (GDateTime) local = (dt != NULL) ? g_date_time_to_local (dt) : NULL;
if (local != NULL)
return g_date_time_format (local, "%FT%T%:::z");
@@ -98,7 +96,7 @@ uint64_secs_to_iso8601 (guint64 secs)
static void
dump_indented_lines (const gchar *data)
{
- const char* indent = " ";
+ const char *indent = " ";
const gchar *pos;
for (;;)
@@ -119,8 +117,7 @@ dump_indented_lines (const gchar *data)
}
static void
-dump_commit (GVariant *variant,
- OstreeDumpFlags flags)
+dump_commit (GVariant *variant, OstreeDumpFlags flags)
{
const gchar *subject;
const gchar *body;
@@ -128,11 +125,11 @@ dump_commit (GVariant *variant,
g_autofree char *parent = NULL;
g_autofree char *str = NULL;
g_autofree char *version = NULL;
- g_autoptr(GError) local_error = NULL;
+ g_autoptr (GError) local_error = NULL;
/* See OSTREE_COMMIT_GVARIANT_FORMAT */
- g_variant_get (variant, "(a{sv}aya(say)&s&stayay)", NULL, NULL, NULL,
- &subject, &body, &timestamp, NULL, NULL);
+ g_variant_get (variant, "(a{sv}aya(say)&s&stayay)", NULL, NULL, NULL, &subject, &body, &timestamp,
+ NULL, NULL);
timestamp = GUINT64_FROM_BE (timestamp);
str = format_timestamp (timestamp, FALSE, &local_error);
@@ -142,7 +139,7 @@ dump_commit (GVariant *variant,
errx (1, "Failed to read commit: %s", local_error->message);
}
- if ((parent = ostree_commit_get_parent(variant)))
+ if ((parent = ostree_commit_get_parent (variant)))
{
g_print ("Parent: %s\n", parent);
}
@@ -175,10 +172,8 @@ dump_commit (GVariant *variant,
}
void
-ot_dump_object (OstreeObjectType objtype,
- const char *checksum,
- GVariant *variant,
- OstreeDumpFlags flags)
+ot_dump_object (OstreeObjectType objtype, const char *checksum, GVariant *variant,
+ OstreeDumpFlags flags)
{
g_print ("%s %s\n", ostree_object_type_to_string (objtype), checksum);
@@ -194,22 +189,19 @@ ot_dump_object (OstreeObjectType objtype,
}
switch (objtype)
- {
+ {
case OSTREE_OBJECT_TYPE_COMMIT:
dump_commit (variant, flags);
break;
/* TODO: Others could be implemented here */
default:
break;
- }
+ }
}
static void
-dump_summary_ref (const char *collection_id,
- const char *ref_name,
- guint64 commit_size,
- GVariant *csum_v,
- GVariantIter *metadata)
+dump_summary_ref (const char *collection_id, const char *ref_name, guint64 commit_size,
+ GVariant *csum_v, GVariantIter *metadata)
{
const guchar *csum_bytes;
GError *csum_error = NULL;
@@ -228,7 +220,7 @@ dump_summary_ref (const char *collection_id,
csum_bytes = ostree_checksum_bytes_peek_validate (csum_v, &csum_error);
if (csum_error == NULL)
{
- char csum[OSTREE_SHA256_STRING_LEN+1];
+ char csum[OSTREE_SHA256_STRING_LEN + 1];
ostree_checksum_inplace_from_bytes (csum_bytes, csum);
g_print (" %s\n", csum);
@@ -268,8 +260,7 @@ dump_summary_ref (const char *collection_id,
}
static void
-dump_summary_refs (const gchar *collection_id,
- GVariant *refs)
+dump_summary_refs (const gchar *collection_id, GVariant *refs)
{
GVariantIter iter;
GVariant *value;
@@ -284,12 +275,11 @@ dump_summary_refs (const gchar *collection_id,
if (ref_name != NULL)
{
- g_autoptr(GVariant) csum_v = NULL;
- g_autoptr(GVariantIter) metadata = NULL;
+ g_autoptr (GVariant) csum_v = NULL;
+ g_autoptr (GVariantIter) metadata = NULL;
guint64 commit_size;
- g_variant_get_child (value, 1, "(t@aya{sv})",
- &commit_size, &csum_v, &metadata);
+ g_variant_get_child (value, 1, "(t@aya{sv})", &commit_size, &csum_v, &metadata);
dump_summary_ref (collection_id, ref_name, commit_size, csum_v, metadata);
@@ -301,20 +291,18 @@ dump_summary_refs (const gchar *collection_id,
}
void
-ot_dump_summary_bytes (GBytes *summary_bytes,
- OstreeDumpFlags flags)
+ot_dump_summary_bytes (GBytes *summary_bytes, OstreeDumpFlags flags)
{
- g_autoptr(GVariant) summary = NULL;
- g_autoptr(GVariant) refs = NULL;
- g_autoptr(GVariant) exts = NULL;
+ g_autoptr (GVariant) summary = NULL;
+ g_autoptr (GVariant) refs = NULL;
+ g_autoptr (GVariant) exts = NULL;
GVariantIter iter;
GVariant *value;
char *key;
g_return_if_fail (summary_bytes != NULL);
- summary = g_variant_new_from_bytes (OSTREE_SUMMARY_GVARIANT_FORMAT,
- summary_bytes, FALSE);
+ summary = g_variant_new_from_bytes (OSTREE_SUMMARY_GVARIANT_FORMAT, summary_bytes, FALSE);
if (flags & OSTREE_DUMP_RAW)
{
@@ -327,7 +315,7 @@ ot_dump_summary_bytes (GBytes *summary_bytes,
/* Print the refs, including those with a collection ID specified. */
const gchar *main_collection_id;
- g_autoptr(GVariant) collection_map = NULL;
+ g_autoptr (GVariant) collection_map = NULL;
const gchar *collection_id;
if (!g_variant_lookup (exts, OSTREE_SUMMARY_COLLECTION_ID, "&s", &main_collection_id))
@@ -335,10 +323,11 @@ ot_dump_summary_bytes (GBytes *summary_bytes,
dump_summary_refs (main_collection_id, refs);
- collection_map = g_variant_lookup_value (exts, OSTREE_SUMMARY_COLLECTION_MAP, G_VARIANT_TYPE ("a{sa(s(taya{sv}))}"));
+ collection_map = g_variant_lookup_value (exts, OSTREE_SUMMARY_COLLECTION_MAP,
+ G_VARIANT_TYPE ("a{sa(s(taya{sv}))}"));
if (collection_map != NULL)
{
- g_autoptr(GVariant) collection_refs = NULL;
+ g_autoptr (GVariant) collection_refs = NULL;
g_variant_iter_init (&iter, collection_map);
while (g_variant_iter_loop (&iter, "{&s@a(s(taya{sv}))}", &collection_id, &collection_refs))
@@ -408,11 +397,10 @@ ot_dump_summary_bytes (GBytes *summary_bytes,
}
static gint
-strptr_cmp (gconstpointer a,
- gconstpointer b)
+strptr_cmp (gconstpointer a, gconstpointer b)
{
- const char *a_str = *((const char **) a);
- const char *b_str = *((const char **) b);
+ const char *a_str = *((const char **)a);
+ const char *b_str = *((const char **)b);
return g_strcmp0 (a_str, b_str);
}
@@ -420,22 +408,21 @@ strptr_cmp (gconstpointer a,
void
ot_dump_summary_metadata_keys (GBytes *summary_bytes)
{
- g_autoptr(GVariant) summary = NULL;
- g_autoptr(GVariant) metadata = NULL;
+ g_autoptr (GVariant) summary = NULL;
+ g_autoptr (GVariant) metadata = NULL;
- summary = g_variant_new_from_bytes (OSTREE_SUMMARY_GVARIANT_FORMAT,
- summary_bytes, FALSE);
+ summary = g_variant_new_from_bytes (OSTREE_SUMMARY_GVARIANT_FORMAT, summary_bytes, FALSE);
metadata = g_variant_get_child_value (summary, 1);
GVariantIter iter;
const char *key = NULL;
- g_autoptr(GPtrArray) keys = g_ptr_array_new ();
+ g_autoptr (GPtrArray) keys = g_ptr_array_new ();
g_variant_iter_init (&iter, metadata);
while (g_variant_iter_loop (&iter, "{&s@v}", &key, NULL))
- g_ptr_array_add (keys, (gpointer) key);
+ g_ptr_array_add (keys, (gpointer)key);
g_ptr_array_sort (keys, strptr_cmp);
- for (guint i = 0; i < keys-> len; i++)
+ for (guint i = 0; i < keys->len; i++)
{
key = keys->pdata[i];
g_print ("%s\n", key);
@@ -443,22 +430,18 @@ ot_dump_summary_metadata_keys (GBytes *summary_bytes)
}
gboolean
-ot_dump_summary_metadata_key (GBytes *summary_bytes,
- const char *key,
- GError **error)
+ot_dump_summary_metadata_key (GBytes *summary_bytes, const char *key, GError **error)
{
- g_autoptr(GVariant) summary = NULL;
- g_autoptr(GVariant) metadata = NULL;
- g_autoptr(GVariant) value = NULL;
+ g_autoptr (GVariant) summary = NULL;
+ g_autoptr (GVariant) metadata = NULL;
+ g_autoptr (GVariant) value = NULL;
- summary = g_variant_new_from_bytes (OSTREE_SUMMARY_GVARIANT_FORMAT,
- summary_bytes, FALSE);
+ summary = g_variant_new_from_bytes (OSTREE_SUMMARY_GVARIANT_FORMAT, summary_bytes, FALSE);
metadata = g_variant_get_child_value (summary, 1);
value = g_variant_lookup_value (metadata, key, NULL);
if (!value)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
- "No such metadata key '%s'", key);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "No such metadata key '%s'", key);
return FALSE;
}
@@ -468,9 +451,7 @@ ot_dump_summary_metadata_key (GBytes *summary_bytes,
}
static gboolean
-dump_gpg_subkey (GVariant *subkey,
- gboolean primary,
- GError **error)
+dump_gpg_subkey (GVariant *subkey, gboolean primary, GError **error)
{
const gchar *fingerprint = NULL;
gint64 created = 0;
@@ -478,64 +459,53 @@ dump_gpg_subkey (GVariant *subkey,
gboolean revoked = FALSE;
gboolean expired = FALSE;
gboolean invalid = FALSE;
- (void) g_variant_lookup (subkey, "fingerprint", "&s", &fingerprint);
- (void) g_variant_lookup (subkey, "created", "x", &created);
- (void) g_variant_lookup (subkey, "expires", "x", &expires);
- (void) g_variant_lookup (subkey, "revoked", "b", &revoked);
- (void) g_variant_lookup (subkey, "expired", "b", &expired);
- (void) g_variant_lookup (subkey, "invalid", "b", &invalid);
+ (void)g_variant_lookup (subkey, "fingerprint", "&s", &fingerprint);
+ (void)g_variant_lookup (subkey, "created", "x", &created);
+ (void)g_variant_lookup (subkey, "expires", "x", &expires);
+ (void)g_variant_lookup (subkey, "revoked", "b", &revoked);
+ (void)g_variant_lookup (subkey, "expired", "b", &expired);
+ (void)g_variant_lookup (subkey, "invalid", "b", &invalid);
/* Convert timestamps from big endian if needed */
created = GINT64_FROM_BE (created);
expires = GINT64_FROM_BE (expires);
- g_print ("%s: %s%s%s\n",
- primary ? "Key" : " Subkey",
- fingerprint,
- revoked ? " (revoked)" : "",
+ g_print ("%s: %s%s%s\n", primary ? "Key" : " Subkey", fingerprint, revoked ? " (revoked)" : "",
invalid ? " (invalid)" : "");
- g_autofree gchar *created_str = format_timestamp (created, TRUE,
- error);
+ g_autofree gchar *created_str = format_timestamp (created, TRUE, error);
if (created_str == NULL)
return FALSE;
- g_print ("%sCreated: %s\n",
- primary ? " " : " ",
- created_str);
+ g_print ("%sCreated: %s\n", primary ? " " : " ", created_str);
if (expires > 0)
{
- g_autofree gchar *expires_str = format_timestamp (expires, TRUE,
- error);
+ g_autofree gchar *expires_str = format_timestamp (expires, TRUE, error);
if (expires_str == NULL)
return FALSE;
- g_print ("%s%s: %s\n",
- primary ? " " : " ",
- expired ? "Expired" : "Expires",
- expires_str);
+ g_print ("%s%s: %s\n", primary ? " " : " ", expired ? "Expired" : "Expires", expires_str);
}
return TRUE;
}
gboolean
-ot_dump_gpg_key (GVariant *key,
- GError **error)
+ot_dump_gpg_key (GVariant *key, GError **error)
{
if (!g_variant_is_of_type (key, OSTREE_GPG_KEY_GVARIANT_FORMAT))
return glnx_throw (error, "GPG key variant type doesn't match '%s'",
OSTREE_GPG_KEY_GVARIANT_STRING);
- g_autoptr(GVariant) subkeys_v = g_variant_get_child_value (key, 0);
+ g_autoptr (GVariant) subkeys_v = g_variant_get_child_value (key, 0);
GVariantIter subkeys_iter;
g_variant_iter_init (&subkeys_iter, subkeys_v);
- g_autoptr(GVariant) primary_key = NULL;
+ g_autoptr (GVariant) primary_key = NULL;
g_variant_iter_next (&subkeys_iter, "@a{sv}", &primary_key);
if (!dump_gpg_subkey (primary_key, TRUE, error))
return FALSE;
- g_autoptr(GVariant) uids_v = g_variant_get_child_value (key, 1);
+ g_autoptr (GVariant) uids_v = g_variant_get_child_value (key, 1);
GVariantIter uids_iter;
g_variant_iter_init (&uids_iter, uids_v);
GVariant *uid_v = NULL;
@@ -544,18 +514,15 @@ ot_dump_gpg_key (GVariant *key,
const gchar *uid = NULL;
gboolean revoked = FALSE;
gboolean invalid = FALSE;
- (void) g_variant_lookup (uid_v, "uid", "&s", &uid);
- (void) g_variant_lookup (uid_v, "revoked", "b", &revoked);
- (void) g_variant_lookup (uid_v, "invalid", "b", &invalid);
- g_print (" UID: %s%s%s\n",
- uid,
- revoked ? " (revoked)" : "",
- invalid ? " (invalid)" : "");
+ (void)g_variant_lookup (uid_v, "uid", "&s", &uid);
+ (void)g_variant_lookup (uid_v, "revoked", "b", &revoked);
+ (void)g_variant_lookup (uid_v, "invalid", "b", &invalid);
+ g_print (" UID: %s%s%s\n", uid, revoked ? " (revoked)" : "", invalid ? " (invalid)" : "");
const char *advanced_url = NULL;
const char *direct_url = NULL;
- (void) g_variant_lookup (uid_v, "advanced_url", "m&s", &advanced_url);
- (void) g_variant_lookup (uid_v, "direct_url", "m&s", &direct_url);
+ (void)g_variant_lookup (uid_v, "advanced_url", "m&s", &advanced_url);
+ (void)g_variant_lookup (uid_v, "direct_url", "m&s", &direct_url);
g_print (" Advanced update URL: %s\n", advanced_url ?: "");
g_print (" Direct update URL: %s\n", direct_url ?: "");
}
diff --git a/src/ostree/ot-dump.h b/src/ostree/ot-dump.h
index da1a2cb2..8022e97c 100644
--- a/src/ostree/ot-dump.h
+++ b/src/ostree/ot-dump.h
@@ -25,27 +25,22 @@
#include "ostree-core.h"
-typedef enum {
+typedef enum
+{
OSTREE_DUMP_NONE = (1 << 0),
OSTREE_DUMP_RAW = (1 << 1),
OSTREE_DUMP_UNSWAPPED = (1 << 2),
} OstreeDumpFlags;
-void ot_dump_variant (GVariant *variant);
+void ot_dump_variant (GVariant *variant);
-void ot_dump_object (OstreeObjectType objtype,
- const char *checksum,
- GVariant *variant,
- OstreeDumpFlags flags);
+void ot_dump_object (OstreeObjectType objtype, const char *checksum, GVariant *variant,
+ OstreeDumpFlags flags);
-void ot_dump_summary_bytes (GBytes *summary_bytes,
- OstreeDumpFlags flags);
+void ot_dump_summary_bytes (GBytes *summary_bytes, OstreeDumpFlags flags);
void ot_dump_summary_metadata_keys (GBytes *summary_bytes);
-gboolean ot_dump_summary_metadata_key (GBytes *summary_bytes,
- const char *key,
- GError **error);
+gboolean ot_dump_summary_metadata_key (GBytes *summary_bytes, const char *key, GError **error);
-gboolean ot_dump_gpg_key (GVariant *key,
- GError **error);
+gboolean ot_dump_gpg_key (GVariant *key, GError **error);
diff --git a/src/ostree/ot-editor.c b/src/ostree/ot-editor.c
index 706a5299..7b2e2512 100644
--- a/src/ostree/ot-editor.c
+++ b/src/ostree/ot-editor.c
@@ -22,11 +22,11 @@
#include "config.h"
#include "libglnx.h"
-#include "otutil.h"
#include "ot-editor.h"
+#include "otutil.h"
-#include <sys/wait.h>
#include <string.h>
+#include <sys/wait.h>
#ifndef DEFAULT_EDITOR
#define DEFAULT_EDITOR "vi"
@@ -56,14 +56,11 @@ get_editor (void)
}
char *
-ot_editor_prompt (OstreeRepo *repo,
- const char *input,
- GCancellable *cancellable,
- GError **error)
+ot_editor_prompt (OstreeRepo *repo, const char *input, GCancellable *cancellable, GError **error)
{
glnx_unref_object GSubprocess *proc = NULL;
- g_autoptr(GFile) file = NULL;
- g_autoptr(GFileIOStream) io = NULL;
+ g_autoptr (GFile) file = NULL;
+ g_autoptr (GFileIOStream) io = NULL;
GOutputStream *output;
const char *editor;
char *ret = NULL;
@@ -82,8 +79,8 @@ ot_editor_prompt (OstreeRepo *repo,
goto out;
output = g_io_stream_get_output_stream (G_IO_STREAM (io));
- if (!g_output_stream_write_all (output, input, strlen (input), NULL, cancellable, error) ||
- !g_io_stream_close (G_IO_STREAM (io), cancellable, error))
+ if (!g_output_stream_write_all (output, input, strlen (input), NULL, cancellable, error)
+ || !g_io_stream_close (G_IO_STREAM (io), cancellable, error))
goto out;
{
@@ -91,8 +88,7 @@ ot_editor_prompt (OstreeRepo *repo,
args = g_strconcat (editor, " ", quoted_file, NULL);
}
- proc = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_INHERIT, error,
- "/bin/sh", "-c", args, NULL);
+ proc = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_INHERIT, error, "/bin/sh", "-c", args, NULL);
if (!g_subprocess_wait_check (proc, cancellable, error))
{
@@ -100,11 +96,11 @@ ot_editor_prompt (OstreeRepo *repo,
goto out;
}
- ret = glnx_file_get_contents_utf8_at (AT_FDCWD, gs_file_get_path_cached (file), NULL,
- cancellable, error);
+ ret = glnx_file_get_contents_utf8_at (AT_FDCWD, gs_file_get_path_cached (file), NULL, cancellable,
+ error);
out:
if (file)
- (void )g_file_delete (file, NULL, NULL);
+ (void)g_file_delete (file, NULL, NULL);
return ret;
}
diff --git a/src/ostree/ot-editor.h b/src/ostree/ot-editor.h
index c096bed4..eb65dd0e 100644
--- a/src/ostree/ot-editor.h
+++ b/src/ostree/ot-editor.h
@@ -25,5 +25,5 @@
#include "ostree.h"
-char * ot_editor_prompt (OstreeRepo *repo, const char *input,
- GCancellable *cancellable, GError **error);
+char *ot_editor_prompt (OstreeRepo *repo, const char *input, GCancellable *cancellable,
+ GError **error);
diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c
index da4735b6..59a3fcba 100644
--- a/src/ostree/ot-main.c
+++ b/src/ostree/ot-main.c
@@ -26,12 +26,12 @@
#include <locale.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/statvfs.h>
#include <sys/mount.h>
+#include <sys/statvfs.h>
-#include "ot-main.h"
#include "ostree.h"
#include "ot-admin-functions.h"
+#include "ot-main.h"
#include "otutil.h"
static char *opt_repo;
@@ -44,21 +44,25 @@ static gboolean opt_print_current_dir;
// to find where to put files. Maybe we can make it printed by the CLI?
#define _OSTREE_EXT_DIR PKGLIBEXECDIR "/ext"
-static GOptionEntry global_entries[] = {
- { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL },
- { "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Print version information and exit", NULL },
- { NULL }
-};
+static GOptionEntry global_entries[]
+ = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose,
+ "Print debug information during command processing", NULL },
+ { "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Print version information and exit",
+ NULL },
+ { NULL } };
-static GOptionEntry repo_entry[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &opt_repo, "Path to OSTree repository (defaults to current directory or /sysroot/ostree/repo)", "PATH" },
- { NULL }
-};
+static GOptionEntry repo_entry[]
+ = { { "repo", 0, 0, G_OPTION_ARG_FILENAME, &opt_repo,
+ "Path to OSTree repository (defaults to current directory or /sysroot/ostree/repo)",
+ "PATH" },
+ { NULL } };
static GOptionEntry global_admin_entries[] = {
/* No description since it's hidden from --help output. */
- { "print-current-dir", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_print_current_dir, NULL, NULL },
- { "sysroot", 0, 0, G_OPTION_ARG_FILENAME, &opt_sysroot, "Create a new OSTree sysroot at PATH", "PATH" },
+ { "print-current-dir", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_print_current_dir, NULL,
+ NULL },
+ { "sysroot", 0, 0, G_OPTION_ARG_FILENAME, &opt_sysroot, "Create a new OSTree sysroot at PATH",
+ "PATH" },
{ NULL }
};
@@ -67,7 +71,7 @@ ostree_option_context_new_with_commands (OstreeCommand *commands)
{
GOptionContext *context = g_option_context_new ("COMMAND");
- g_autoptr(GString) summary = g_string_new ("Builtin Commands:");
+ g_autoptr (GString) summary = g_string_new ("Builtin Commands:");
while (commands->name != NULL)
{
@@ -75,7 +79,7 @@ ostree_option_context_new_with_commands (OstreeCommand *commands)
{
g_string_append_printf (summary, "\n %-18s", commands->name);
- if (commands->description != NULL )
+ if (commands->description != NULL)
g_string_append_printf (summary, "%s", commands->description);
}
@@ -88,11 +92,9 @@ ostree_option_context_new_with_commands (OstreeCommand *commands)
}
int
-ostree_usage (OstreeCommand *commands,
- gboolean is_error)
+ostree_usage (OstreeCommand *commands, gboolean is_error)
{
- g_autoptr(GOptionContext) context =
- ostree_option_context_new_with_commands (commands);
+ g_autoptr (GOptionContext) context = ostree_option_context_new_with_commands (commands);
g_option_context_add_main_entries (context, global_entries, NULL);
g_autofree char *help = g_option_context_get_help (context, FALSE, NULL);
@@ -109,8 +111,7 @@ ostree_usage (OstreeCommand *commands,
* if so, and return *out_ns = TRUE. Otherwise, *out_ns = FALSE.
*/
static gboolean
-maybe_setup_mount_namespace (gboolean *out_ns,
- GError **error)
+maybe_setup_mount_namespace (gboolean *out_ns, GError **error)
{
*out_ns = FALSE;
@@ -132,9 +133,7 @@ maybe_setup_mount_namespace (gboolean *out_ns,
}
static void
-message_handler (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
+message_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message,
gpointer user_data)
{
/* Make this look like normal console output */
@@ -145,11 +144,9 @@ message_handler (const gchar *log_domain,
}
int
-ostree_main (int argc,
- char **argv,
- OstreeCommand *commands)
+ostree_main (int argc, char **argv, OstreeCommand *commands)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
setlocale (LC_ALL, "");
@@ -159,16 +156,13 @@ ostree_main (int argc,
if (error != NULL)
{
- g_printerr ("%s%serror:%s%s %s\n",
- ot_get_red_start (), ot_get_bold_start (),
- ot_get_bold_end (), ot_get_red_end (),
- error->message);
+ g_printerr ("%s%serror:%s%s %s\n", ot_get_red_start (), ot_get_bold_start (),
+ ot_get_bold_end (), ot_get_red_end (), error->message);
}
return ret;
}
-
/**
* ostree_command_lookup_external:
* @argc: number of entries in @argv
@@ -183,9 +177,7 @@ ostree_main (int argc,
* external command if found, or %NULL otherwise.
*/
gchar *
-ostree_command_lookup_external (int argc,
- char **argv,
- OstreeCommand *commands)
+ostree_command_lookup_external (int argc, char **argv, OstreeCommand *commands)
{
g_assert (commands != NULL);
@@ -196,10 +188,9 @@ ostree_command_lookup_external (int argc,
for (guint arg_index = 1; arg_index < argc; arg_index++)
{
char *current_arg = argv[arg_index];
- if (current_arg == NULL ||
- g_str_has_prefix (current_arg, "-") ||
- g_strcmp0 (current_arg, "") == 0)
- continue;
+ if (current_arg == NULL || g_str_has_prefix (current_arg, "-")
+ || g_strcmp0 (current_arg, "") == 0)
+ continue;
for (guint cmd_index = 0; commands[cmd_index].name != NULL; cmd_index++)
{
@@ -207,7 +198,6 @@ ostree_command_lookup_external (int argc,
return NULL;
}
-
g_autofree gchar *ext_command = g_strdup_printf ("ostree-%s", current_arg);
/* First, search in our libdir /usr/lib/ostree/ostree-$cmd */
@@ -218,7 +208,7 @@ ostree_command_lookup_external (int argc,
/* Otherwise, look in $PATH */
if (g_find_program_in_path (ext_command) == NULL)
- return NULL;
+ return NULL;
return g_steal_pointer (&ext_command);
}
@@ -236,23 +226,17 @@ ostree_command_lookup_external (int argc,
int
ostree_command_exec_external (char **argv)
{
- int r = execvp(argv[0], argv);
+ int r = execvp (argv[0], argv);
g_assert (r == -1);
setlocale (LC_ALL, "");
- g_printerr ("%s%serror:%s%s: Executing %s: %s\n",
- ot_get_red_start (), ot_get_bold_start (),
- ot_get_bold_end (), ot_get_red_end (),
- argv[0],
- g_strerror (errno));
+ g_printerr ("%s%serror:%s%s: Executing %s: %s\n", ot_get_red_start (), ot_get_bold_start (),
+ ot_get_bold_end (), ot_get_red_end (), argv[0], g_strerror (errno));
return 1;
}
int
-ostree_run (int argc,
- char **argv,
- OstreeCommand *commands,
- GError **res_error)
+ostree_run (int argc, char **argv, OstreeCommand *commands, GError **res_error)
{
GError *error = NULL;
GCancellable *cancellable = NULL;
@@ -266,7 +250,7 @@ ostree_run (int argc,
/* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */
if (!g_setenv ("GIO_USE_VFS", "local", TRUE))
{
- (void) glnx_throw (res_error, "Failed to set environment variable GIO_USE_FVS");
+ (void)glnx_throw (res_error, "Failed to set environment variable GIO_USE_FVS");
return 1;
}
@@ -306,21 +290,20 @@ ostree_run (int argc,
if (!command->fn)
{
- g_autoptr(GOptionContext) context =
- ostree_option_context_new_with_commands (commands);
+ g_autoptr (GOptionContext) context = ostree_option_context_new_with_commands (commands);
/* This will not return for some options (e.g. --version). */
- if (ostree_option_context_parse (context, NULL, &argc, &argv, NULL, NULL, cancellable, &error))
+ if (ostree_option_context_parse (context, NULL, &argc, &argv, NULL, NULL, cancellable,
+ &error))
{
if (command_name == NULL)
{
- g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "No command specified");
+ g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED, "No command specified");
}
else
{
- g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Unknown command '%s'", command_name);
+ g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown command '%s'",
+ command_name);
}
}
@@ -337,7 +320,7 @@ ostree_run (int argc,
goto out;
success = TRUE;
- out:
+out:
g_assert (success || error);
if (error)
@@ -350,17 +333,14 @@ ostree_run (int argc,
/* Process a --repo arg. */
static OstreeRepo *
-parse_repo_option (GOptionContext *context,
- const char *repo_path,
- gboolean skip_repo_open,
- GCancellable *cancellable,
- GError **error)
+parse_repo_option (GOptionContext *context, const char *repo_path, gboolean skip_repo_open,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
if (repo_path == NULL)
{
- g_autoptr(GError) local_error = NULL;
+ g_autoptr (GError) local_error = NULL;
repo = ostree_repo_new_default ();
if (!ostree_repo_open (repo, cancellable, &local_error))
@@ -384,7 +364,7 @@ parse_repo_option (GOptionContext *context,
}
else
{
- g_autoptr(GFile) repo_file = g_file_new_for_path (repo_path);
+ g_autoptr (GFile) repo_file = g_file_new_for_path (repo_path);
repo = ostree_repo_new (repo_file);
if (!skip_repo_open)
@@ -397,15 +377,15 @@ parse_repo_option (GOptionContext *context,
return g_steal_pointer (&repo);
}
-/* Process a --repo arg, determining if we should remount /sysroot; used below, and for the remote builtins */
+/* Process a --repo arg, determining if we should remount /sysroot; used below, and for the remote
+ * builtins */
static OstreeRepo *
-parse_repo_option_and_maybe_remount (GOptionContext *context,
- const char *repo_path,
- gboolean skip_repo_open,
- GCancellable *cancellable,
- GError **error)
+parse_repo_option_and_maybe_remount (GOptionContext *context, const char *repo_path,
+ gboolean skip_repo_open, GCancellable *cancellable,
+ GError **error)
{
- g_autoptr(OstreeRepo) repo = parse_repo_option (context, repo_path, skip_repo_open, cancellable, error);
+ g_autoptr (OstreeRepo) repo
+ = parse_repo_option (context, repo_path, skip_repo_open, cancellable, error);
if (!repo)
return NULL;
@@ -436,19 +416,16 @@ parse_repo_option_and_maybe_remount (GOptionContext *context,
/* Used by the remote builtins which are special in taking --sysroot or --repo */
gboolean
-ostree_parse_sysroot_or_repo_option (GOptionContext *context,
- const char *sysroot_path,
- const char *repo_path,
- OstreeSysroot **out_sysroot,
- OstreeRepo **out_repo,
- GCancellable *cancellable,
+ostree_parse_sysroot_or_repo_option (GOptionContext *context, const char *sysroot_path,
+ const char *repo_path, OstreeSysroot **out_sysroot,
+ OstreeRepo **out_repo, GCancellable *cancellable,
GError **error)
{
- g_autoptr(OstreeSysroot) sysroot = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
if (sysroot_path)
{
- g_autoptr(GFile) sysroot_file = g_file_new_for_path (sysroot_path);
+ g_autoptr (GFile) sysroot_file = g_file_new_for_path (sysroot_path);
sysroot = ostree_sysroot_new (sysroot_file);
if (!ostree_sysroot_load (sysroot, cancellable, error))
return FALSE;
@@ -468,18 +445,14 @@ ostree_parse_sysroot_or_repo_option (GOptionContext *context,
}
gboolean
-ostree_option_context_parse (GOptionContext *context,
- const GOptionEntry *main_entries,
- int *argc,
- char ***argv,
- OstreeCommandInvocation *invocation,
- OstreeRepo **out_repo,
- GCancellable *cancellable,
- GError **error)
+ostree_option_context_parse (GOptionContext *context, const GOptionEntry *main_entries, int *argc,
+ char ***argv, OstreeCommandInvocation *invocation,
+ OstreeRepo **out_repo, GCancellable *cancellable, GError **error)
{
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
/* When invocation is NULL, do not fetch repo */
- const OstreeBuiltinFlags flags = invocation ? invocation->command->flags : OSTREE_BUILTIN_FLAG_NO_REPO;
+ const OstreeBuiltinFlags flags
+ = invocation ? invocation->command->flags : OSTREE_BUILTIN_FLAG_NO_REPO;
if (invocation && invocation->command->description != NULL)
{
@@ -495,9 +468,10 @@ ostree_option_context_parse (GOptionContext *context,
{
/* TODO: remove this part once we deduplicate the ostree_option_context_new_with_commands
* function from other root commands( command with subcommands). Because
- * we can directly add the summary inside the ostree_option_context_new_with_commands function.
+ * we can directly add the summary inside the ostree_option_context_new_with_commands
+ * function.
*/
- g_autoptr(GString) new_summary_string = g_string_new (context_summary);
+ g_autoptr (GString) new_summary_string = g_string_new (context_summary);
g_string_prepend (new_summary_string, "\n\n");
g_string_prepend (new_summary_string, invocation->command->description);
@@ -539,7 +513,7 @@ ostree_option_context_parse (GOptionContext *context,
{
/* This should now be YAML, like `docker version`, so it's both nice to read
* possible to parse */
- g_auto(GStrv) features = g_strsplit (OSTREE_FEATURES, " ", -1);
+ g_auto (GStrv) features = g_strsplit (OSTREE_FEATURES, " ", -1);
g_print ("%s:\n", PACKAGE_NAME);
g_print (" Version: '%s'\n", PACKAGE_VERSION);
if (strlen (OSTREE_GITREV) > 0)
@@ -558,8 +532,8 @@ ostree_option_context_parse (GOptionContext *context,
if (!(flags & OSTREE_BUILTIN_FLAG_NO_REPO))
{
- repo = parse_repo_option_and_maybe_remount (context, opt_repo, (flags & OSTREE_BUILTIN_FLAG_NO_CHECK) > 0,
- cancellable, error);
+ repo = parse_repo_option_and_maybe_remount (
+ context, opt_repo, (flags & OSTREE_BUILTIN_FLAG_NO_CHECK) > 0, cancellable, error);
if (!repo)
return FALSE;
}
@@ -571,18 +545,14 @@ ostree_option_context_parse (GOptionContext *context,
}
static void
-on_sysroot_journal_msg (OstreeSysroot *sysroot,
- const char *msg,
- void *dummy)
+on_sysroot_journal_msg (OstreeSysroot *sysroot, const char *msg, void *dummy)
{
g_print ("%s\n", msg);
}
gboolean
-ostree_admin_sysroot_load (OstreeSysroot *sysroot,
- OstreeAdminBuiltinFlags flags,
- GCancellable *cancellable,
- GError **error)
+ostree_admin_sysroot_load (OstreeSysroot *sysroot, OstreeAdminBuiltinFlags flags,
+ GCancellable *cancellable, GError **error)
{
if ((flags & OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED) == 0)
{
@@ -617,23 +587,18 @@ ostree_admin_sysroot_load (OstreeSysroot *sysroot,
}
gboolean
-ostree_admin_option_context_parse (GOptionContext *context,
- const GOptionEntry *main_entries,
- int *argc,
- char ***argv,
- OstreeAdminBuiltinFlags flags,
- OstreeCommandInvocation *invocation,
- OstreeSysroot **out_sysroot,
- GCancellable *cancellable,
- GError **error)
+ostree_admin_option_context_parse (GOptionContext *context, const GOptionEntry *main_entries,
+ int *argc, char ***argv, OstreeAdminBuiltinFlags flags,
+ OstreeCommandInvocation *invocation, OstreeSysroot **out_sysroot,
+ GCancellable *cancellable, GError **error)
{
/* Entries are listed in --help output in the order added. We add the
* main entries ourselves so that we can add the --sysroot entry first. */
g_option_context_add_main_entries (context, global_admin_entries, NULL);
- if (!ostree_option_context_parse (context, main_entries, argc, argv,
- invocation, NULL, cancellable, error))
+ if (!ostree_option_context_parse (context, main_entries, argc, argv, invocation, NULL,
+ cancellable, error))
return FALSE;
if (!opt_print_current_dir && (flags & OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT))
@@ -643,11 +608,11 @@ ostree_admin_option_context_parse (GOptionContext *context,
return TRUE;
}
- g_autoptr(GFile) sysroot_path = NULL;
+ g_autoptr (GFile) sysroot_path = NULL;
if (opt_sysroot != NULL)
sysroot_path = g_file_new_for_path (opt_sysroot);
- g_autoptr(OstreeSysroot) sysroot = ostree_sysroot_new (sysroot_path);
+ g_autoptr (OstreeSysroot) sysroot = ostree_sysroot_new (sysroot_path);
if (!ostree_sysroot_initialize (sysroot, error))
return FALSE;
g_signal_connect (sysroot, "journal-msg", G_CALLBACK (on_sysroot_journal_msg), NULL);
@@ -660,9 +625,9 @@ ostree_admin_option_context_parse (GOptionContext *context,
if (opt_print_current_dir)
{
- g_autoptr(GPtrArray) deployments = NULL;
+ g_autoptr (GPtrArray) deployments = NULL;
OstreeDeployment *first_deployment;
- g_autoptr(GFile) deployment_file = NULL;
+ g_autoptr (GFile) deployment_file = NULL;
g_autofree char *deployment_path = NULL;
deployments = ostree_sysroot_get_deployments (sysroot);
@@ -691,8 +656,7 @@ ostree_admin_option_context_parse (GOptionContext *context,
}
gboolean
-ostree_ensure_repo_writable (OstreeRepo *repo,
- GError **error)
+ostree_ensure_repo_writable (OstreeRepo *repo, GError **error)
{
if (!ostree_repo_is_writable (repo, error))
return glnx_prefix_error (error, "Cannot write to repository");
@@ -706,10 +670,9 @@ ostree_print_gpg_verify_result (OstreeGpgVerifyResult *result)
guint n_sigs = ostree_gpg_verify_result_count_all (result);
/* XXX If we ever add internationalization, use ngettext() here. */
- g_print ("GPG: Verification enabled, found %u signature%s:\n",
- n_sigs, n_sigs == 1 ? "" : "s");
+ g_print ("GPG: Verification enabled, found %u signature%s:\n", n_sigs, n_sigs == 1 ? "" : "s");
- g_autoptr(GString) buffer = g_string_sized_new (256);
+ g_autoptr (GString) buffer = g_string_sized_new (256);
for (guint ii = 0; ii < n_sigs; ii++)
{
@@ -729,7 +692,8 @@ ot_enable_tombstone_commits (OstreeRepo *repo, GError **error)
GKeyFile *config = ostree_repo_get_config (repo);
tombstone_commits = g_key_file_get_boolean (config, "core", "tombstone-commits", NULL);
- /* tombstone_commits is FALSE either if it is not found or it is really set to FALSE in the config file. */
+ /* tombstone_commits is FALSE either if it is not found or it is really set to FALSE in the
+ * config file. */
if (!tombstone_commits)
{
g_key_file_set_boolean (config, "core", "tombstone-commits", TRUE);
diff --git a/src/ostree/ot-main.h b/src/ostree/ot-main.h
index e296501a..8df1ca8e 100644
--- a/src/ostree/ot-main.h
+++ b/src/ostree/ot-main.h
@@ -24,14 +24,16 @@
#include "libglnx.h"
#include "ostree.h"
-typedef enum {
+typedef enum
+{
OSTREE_BUILTIN_FLAG_NONE = 0,
OSTREE_BUILTIN_FLAG_NO_REPO = 1 << 0,
OSTREE_BUILTIN_FLAG_NO_CHECK = 1 << 1,
OSTREE_BUILTIN_FLAG_HIDDEN = 1 << 2,
} OstreeBuiltinFlags;
-typedef enum {
+typedef enum
+{
OSTREE_ADMIN_BUILTIN_FLAG_NONE = 0,
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER = (1 << 0),
OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED = (1 << 1),
@@ -39,13 +41,14 @@ typedef enum {
OSTREE_ADMIN_BUILTIN_FLAG_NO_LOAD = (1 << 3),
} OstreeAdminBuiltinFlags;
-
typedef struct OstreeCommandInvocation OstreeCommandInvocation;
-typedef struct {
+typedef struct
+{
const char *name;
OstreeBuiltinFlags flags;
- gboolean (*fn) (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
+ gboolean (*fn) (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error);
const char *description;
} OstreeCommand;
@@ -55,7 +58,8 @@ typedef struct {
* In the future if we want to add something new we won't need to
* touch every prototype
*/
-struct OstreeCommandInvocation {
+struct OstreeCommandInvocation
+{
OstreeCommand *command;
};
@@ -65,37 +69,29 @@ int ostree_run (int argc, char **argv, OstreeCommand *commands, GError **error);
int ostree_usage (OstreeCommand *commands, gboolean is_error);
-char* ostree_command_lookup_external (int argc, char **argv, OstreeCommand *commands);
+char *ostree_command_lookup_external (int argc, char **argv, OstreeCommand *commands);
int ostree_command_exec_external (char **argv);
-gboolean ostree_parse_sysroot_or_repo_option (GOptionContext *context,
- const char *sysroot_path,
- const char *repo_path,
- OstreeSysroot **out_sysroot,
- OstreeRepo **out_repo,
- GCancellable *cancellable,
+gboolean ostree_parse_sysroot_or_repo_option (GOptionContext *context, const char *sysroot_path,
+ const char *repo_path, OstreeSysroot **out_sysroot,
+ OstreeRepo **out_repo, GCancellable *cancellable,
GError **error);
-gboolean ostree_option_context_parse (GOptionContext *context,
- const GOptionEntry *main_entries,
- int *argc, char ***argv,
- OstreeCommandInvocation *invocation,
- OstreeRepo **out_repo,
- GCancellable *cancellable, GError **error);
+gboolean ostree_option_context_parse (GOptionContext *context, const GOptionEntry *main_entries,
+ int *argc, char ***argv, OstreeCommandInvocation *invocation,
+ OstreeRepo **out_repo, GCancellable *cancellable,
+ GError **error);
gboolean ostree_admin_option_context_parse (GOptionContext *context,
- const GOptionEntry *main_entries,
- int *argc, char ***argv,
- OstreeAdminBuiltinFlags flags,
+ const GOptionEntry *main_entries, int *argc,
+ char ***argv, OstreeAdminBuiltinFlags flags,
OstreeCommandInvocation *invocation,
- OstreeSysroot **out_sysroot,
- GCancellable *cancellable, GError **error);
+ OstreeSysroot **out_sysroot, GCancellable *cancellable,
+ GError **error);
-gboolean ostree_admin_sysroot_load (OstreeSysroot *sysroot,
- OstreeAdminBuiltinFlags flags,
- GCancellable *cancellable,
- GError **error);
+gboolean ostree_admin_sysroot_load (OstreeSysroot *sysroot, OstreeAdminBuiltinFlags flags,
+ GCancellable *cancellable, GError **error);
gboolean ostree_ensure_repo_writable (OstreeRepo *repo, GError **error);
@@ -104,16 +100,17 @@ void ostree_print_gpg_verify_result (OstreeGpgVerifyResult *result);
gboolean ot_enable_tombstone_commits (OstreeRepo *repo, GError **error);
/* Copied from rpm-ostree's rpmostree-libbuiltin.h */
-#define TERM_ESCAPE_SEQUENCE(type,seq) \
- static inline const char* ot_get_##type (void) { \
- if (glnx_stdout_is_tty ()) \
- return seq; \
- return ""; \
+#define TERM_ESCAPE_SEQUENCE(type, seq) \
+ static inline const char *ot_get_##type (void) \
+ { \
+ if (glnx_stdout_is_tty ()) \
+ return seq; \
+ return ""; \
}
-TERM_ESCAPE_SEQUENCE(red_start, "\x1b[31m")
-TERM_ESCAPE_SEQUENCE(red_end, "\x1b[22m")
-TERM_ESCAPE_SEQUENCE(bold_start, "\x1b[1m")
-TERM_ESCAPE_SEQUENCE(bold_end, "\x1b[0m")
+TERM_ESCAPE_SEQUENCE (red_start, "\x1b[31m")
+TERM_ESCAPE_SEQUENCE (red_end, "\x1b[22m")
+TERM_ESCAPE_SEQUENCE (bold_start, "\x1b[1m")
+TERM_ESCAPE_SEQUENCE (bold_end, "\x1b[0m")
#undef TERM_ESCAPE_SEQUENCE
diff --git a/src/ostree/ot-remote-builtin-add-cookie.c b/src/ostree/ot-remote-builtin-add-cookie.c
index 30aeacb3..900520dc 100644
--- a/src/ostree/ot-remote-builtin-add-cookie.c
+++ b/src/ostree/ot-remote-builtin-add-cookie.c
@@ -22,9 +22,9 @@
#include "otutil.h"
+#include "ostree-repo-private.h"
#include "ot-main.h"
#include "ot-remote-builtins.h"
-#include "ostree-repo-private.h"
#include "ot-remote-cookie-util.h"
/* ATTENTION:
@@ -32,22 +32,22 @@
* man page (man/ostree-remote.xml) when changing the option list.
*/
-static GOptionEntry option_entries[] = {
- { NULL }
-};
+static GOptionEntry option_entries[] = { { NULL } };
gboolean
-ot_remote_builtin_add_cookie (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_remote_builtin_add_cookie (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME VALUE");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
- invocation, &repo, cancellable, error))
+ g_autoptr (GOptionContext) context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME VALUE");
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
if (argc < 6)
{
- ot_util_usage_error (context, "NAME, DOMAIN, PATH, COOKIE_NAME and VALUE must be specified", error);
+ ot_util_usage_error (context, "NAME, DOMAIN, PATH, COOKIE_NAME and VALUE must be specified",
+ error);
return FALSE;
}
@@ -57,7 +57,8 @@ ot_remote_builtin_add_cookie (int argc, char **argv, OstreeCommandInvocation *in
const char *cookie_name = argv[4];
const char *value = argv[5];
g_autofree char *cookie_file = g_strdup_printf ("%s.cookies.txt", remote_name);
- if (!ot_add_cookie_at (ostree_repo_get_dfd (repo), cookie_file, domain, path, cookie_name, value, error))
+ if (!ot_add_cookie_at (ostree_repo_get_dfd (repo), cookie_file, domain, path, cookie_name, value,
+ error))
return FALSE;
return TRUE;
diff --git a/src/ostree/ot-remote-builtin-add.c b/src/ostree/ot-remote-builtin-add.c
index f07005f6..63b84a1e 100644
--- a/src/ostree/ot-remote-builtin-add.c
+++ b/src/ostree/ot-remote-builtin-add.c
@@ -42,41 +42,52 @@ static char *opt_repo;
* man page (man/ostree-remote.xml) when changing the option list.
*/
-static GOptionEntry option_entries[] = {
- { "set", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_set, "Set config option KEY=VALUE for remote", "KEY=VALUE" },
- { "no-gpg-verify", 0, 0, G_OPTION_ARG_NONE, &opt_no_gpg_verify, "Disable GPG verification", NULL },
- { "no-sign-verify", 0, 0, G_OPTION_ARG_NONE, &opt_no_sign_verify, "Disable signature verification", NULL },
- { "sign-verify", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_sign_verify, "Verify signatures using KEYTYPE=inline:PUBKEY or KEYTYPE=file:/path/to/key", "KEYTYPE=[inline|file]:PUBKEY" },
- { "if-not-exists", 0, 0, G_OPTION_ARG_NONE, &opt_if_not_exists, "Do nothing if the provided remote exists", NULL },
- { "force", 0, 0, G_OPTION_ARG_NONE, &opt_force, "Replace the provided remote if it exists", NULL },
- { "gpg-import", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_import, "Import GPG key from FILE", "FILE" },
- { "custom-backend", 0, 0, G_OPTION_ARG_STRING, &opt_custom_backend, "This remote has content not fetched via libostree", "NAME" },
- { "contenturl", 0, 0, G_OPTION_ARG_STRING, &opt_contenturl, "Use URL when fetching content", "URL" },
- { "collection-id", 0, 0, G_OPTION_ARG_STRING, &opt_collection_id,
- "Globally unique ID for this repository as an collection of refs for redistribution to other repositories", "COLLECTION-ID" },
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &opt_repo, "Path to OSTree repository (defaults to /sysroot/ostree/repo)", "PATH" },
- { "sysroot", 0, 0, G_OPTION_ARG_FILENAME, &opt_sysroot, "Use sysroot at PATH (overrides --repo)", "PATH" },
- { NULL }
-};
+static GOptionEntry option_entries[]
+ = { { "set", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_set,
+ "Set config option KEY=VALUE for remote", "KEY=VALUE" },
+ { "no-gpg-verify", 0, 0, G_OPTION_ARG_NONE, &opt_no_gpg_verify, "Disable GPG verification",
+ NULL },
+ { "no-sign-verify", 0, 0, G_OPTION_ARG_NONE, &opt_no_sign_verify,
+ "Disable signature verification", NULL },
+ { "sign-verify", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_sign_verify,
+ "Verify signatures using KEYTYPE=inline:PUBKEY or KEYTYPE=file:/path/to/key",
+ "KEYTYPE=[inline|file]:PUBKEY" },
+ { "if-not-exists", 0, 0, G_OPTION_ARG_NONE, &opt_if_not_exists,
+ "Do nothing if the provided remote exists", NULL },
+ { "force", 0, 0, G_OPTION_ARG_NONE, &opt_force, "Replace the provided remote if it exists",
+ NULL },
+ { "gpg-import", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_import, "Import GPG key from FILE",
+ "FILE" },
+ { "custom-backend", 0, 0, G_OPTION_ARG_STRING, &opt_custom_backend,
+ "This remote has content not fetched via libostree", "NAME" },
+ { "contenturl", 0, 0, G_OPTION_ARG_STRING, &opt_contenturl, "Use URL when fetching content",
+ "URL" },
+ { "collection-id", 0, 0, G_OPTION_ARG_STRING, &opt_collection_id,
+ "Globally unique ID for this repository as an collection of refs for redistribution to "
+ "other repositories",
+ "COLLECTION-ID" },
+ { "repo", 0, 0, G_OPTION_ARG_FILENAME, &opt_repo,
+ "Path to OSTree repository (defaults to /sysroot/ostree/repo)", "PATH" },
+ { "sysroot", 0, 0, G_OPTION_ARG_FILENAME, &opt_sysroot,
+ "Use sysroot at PATH (overrides --repo)", "PATH" },
+ { NULL } };
static char *
-add_verify_opt (GVariantBuilder *builder,
- const char *keyspec,
- GError **error)
+add_verify_opt (GVariantBuilder *builder, const char *keyspec, GError **error)
{
- g_auto(GStrv) parts = g_strsplit (keyspec, "=", 2);
+ g_auto (GStrv) parts = g_strsplit (keyspec, "=", 2);
g_assert (parts && *parts);
const char *keytype = parts[0];
if (!parts[1])
return glnx_null_throw (error, "Failed to parse KEYTYPE=[inline|file]:DATA in %s", keyspec);
- g_autoptr(OstreeSign) sign = ostree_sign_get_by_name (keytype, error);
+ g_autoptr (OstreeSign) sign = ostree_sign_get_by_name (keytype, error);
if (!sign)
return NULL;
const char *rest = parts[1];
g_assert (!parts[2]);
- g_auto(GStrv) keyparts = g_strsplit (rest, ":", 2);
+ g_auto (GStrv) keyparts = g_strsplit (rest, ":", 2);
g_assert (keyparts && *keyparts);
const char *keyref = keyparts[0];
g_assert (keyref);
@@ -89,33 +100,32 @@ add_verify_opt (GVariantBuilder *builder,
return glnx_null_throw (error, "Invalid key reference %s, expected inline|file", keyref);
g_assert (keyparts[1] && !keyparts[2]);
- g_variant_builder_add (builder, "{s@v}",
- optname,
+ g_variant_builder_add (builder, "{s@v}", optname,
g_variant_new_variant (g_variant_new_string (keyparts[1])));
return g_strdup (ostree_sign_get_name (sign));
}
gboolean
-ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeSysroot) sysroot = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
- g_autoptr(GString) sign_verify = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
+ g_autoptr (GString) sign_verify = NULL;
const char *remote_name;
const char *remote_url = NULL;
- g_autoptr(GVariantBuilder) optbuilder = NULL;
- g_autoptr(GVariant) options = NULL;
+ g_autoptr (GVariantBuilder) optbuilder = NULL;
+ g_autoptr (GVariant) options = NULL;
gboolean ret = FALSE;
context = g_option_context_new ("NAME [metalink=|mirrorlist=]URL [BRANCH...]");
- if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
- invocation, NULL, cancellable, error))
+ if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, NULL,
+ cancellable, error))
goto out;
- if (!ostree_parse_sysroot_or_repo_option (context, opt_sysroot, opt_repo,
- &sysroot, &repo,
+ if (!ostree_parse_sysroot_or_repo_option (context, opt_sysroot, opt_repo, &sysroot, &repo,
cancellable, error))
goto out;
@@ -142,9 +152,7 @@ ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_if_not_exists && opt_force)
{
- ot_util_usage_error (context,
- "Can only specify one of --if-not-exists and --force",
- error);
+ ot_util_usage_error (context, "Can only specify one of --if-not-exists and --force", error);
goto out;
}
@@ -152,16 +160,16 @@ ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocatio
if (argc > 3)
{
- g_autoptr(GPtrArray) branchesp = g_ptr_array_new ();
+ g_autoptr (GPtrArray) branchesp = g_ptr_array_new ();
int i;
for (i = 3; i < argc; i++)
g_ptr_array_add (branchesp, argv[i]);
g_ptr_array_add (branchesp, NULL);
- g_variant_builder_add (optbuilder, "{s@v}",
- "branches",
- g_variant_new_variant (g_variant_new_strv ((const char*const*)branchesp->pdata, -1)));
+ g_variant_builder_add (
+ optbuilder, "{s@v}", "branches",
+ g_variant_new_variant (g_variant_new_strv ((const char *const *)branchesp->pdata, -1)));
}
/* We could just make users use --set instead for this since it's a string,
@@ -169,11 +177,11 @@ ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocatio
* --set=contenturl=mirrorlist=... */
if (opt_contenturl != NULL)
- g_variant_builder_add (optbuilder, "{s@v}",
- "contenturl", g_variant_new_variant (g_variant_new_string (opt_contenturl)));
+ g_variant_builder_add (optbuilder, "{s@v}", "contenturl",
+ g_variant_new_variant (g_variant_new_string (opt_contenturl)));
if (opt_custom_backend != NULL)
- g_variant_builder_add (optbuilder, "{s@v}",
- "custom-backend", g_variant_new_variant (g_variant_new_string (opt_custom_backend)));
+ g_variant_builder_add (optbuilder, "{s@v}", "custom-backend",
+ g_variant_new_variant (g_variant_new_string (opt_custom_backend)));
for (char **iter = opt_set; iter && *iter; iter++)
{
@@ -184,15 +192,14 @@ ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocatio
if (!ot_parse_keyvalue (keyvalue, &subkey, &subvalue, error))
goto out;
- g_variant_builder_add (optbuilder, "{s@v}",
- subkey, g_variant_new_variant (g_variant_new_string (subvalue)));
+ g_variant_builder_add (optbuilder, "{s@v}", subkey,
+ g_variant_new_variant (g_variant_new_string (subvalue)));
}
#ifndef OSTREE_DISABLE_GPGME
/* No signature verification implies no verification for GPG signature as well */
if (opt_no_gpg_verify || opt_no_sign_verify)
- g_variant_builder_add (optbuilder, "{s@v}",
- "gpg-verify",
+ g_variant_builder_add (optbuilder, "{s@v}", "gpg-verify",
g_variant_new_variant (g_variant_new_boolean (FALSE)));
#endif /* OSTREE_DISABLE_GPGME */
@@ -200,9 +207,8 @@ ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocatio
{
if (opt_sign_verify)
return glnx_throw (error, "Cannot specify both --sign-verify and --no-sign-verify");
- g_variant_builder_add (optbuilder, "{s@v}",
- "sign-verify",
- g_variant_new_variant (g_variant_new_boolean (FALSE)));
+ g_variant_builder_add (optbuilder, "{s@v}", "sign-verify",
+ g_variant_new_variant (g_variant_new_boolean (FALSE)));
}
for (char **iter = opt_sign_verify; iter && *iter; iter++)
@@ -222,13 +228,13 @@ ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocatio
}
}
if (sign_verify != NULL)
- g_variant_builder_add (optbuilder, "{s@v}",
- "sign-verify",
- g_variant_new_variant (g_variant_new_string (sign_verify->str)));
+ g_variant_builder_add (optbuilder, "{s@v}", "sign-verify",
+ g_variant_new_variant (g_variant_new_string (sign_verify->str)));
if (opt_collection_id != NULL)
- g_variant_builder_add (optbuilder, "{s@v}", "collection-id",
- g_variant_new_variant (g_variant_new_take_string (g_steal_pointer (&opt_collection_id))));
+ g_variant_builder_add (
+ optbuilder, "{s@v}", "collection-id",
+ g_variant_new_variant (g_variant_new_take_string (g_steal_pointer (&opt_collection_id))));
options = g_variant_ref_sink (g_variant_builder_end (optbuilder));
@@ -239,9 +245,7 @@ ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocatio
changeop = OSTREE_REPO_REMOTE_CHANGE_REPLACE;
else
changeop = OSTREE_REPO_REMOTE_CHANGE_ADD;
- if (!ostree_repo_remote_change (repo, NULL, changeop,
- remote_name, remote_url,
- options,
+ if (!ostree_repo_remote_change (repo, NULL, changeop, remote_name, remote_url, options,
cancellable, error))
goto out;
@@ -254,27 +258,27 @@ ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocatio
* know whether the remote already existed. We import regardless. */
if (opt_gpg_import != NULL)
{
- g_autoptr(GFile) file = NULL;
- g_autoptr(GInputStream) input_stream = NULL;
+ g_autoptr (GFile) file = NULL;
+ g_autoptr (GInputStream) input_stream = NULL;
guint imported = 0;
file = g_file_new_for_path (opt_gpg_import);
- input_stream = (GInputStream *) g_file_read (file, cancellable, error);
+ input_stream = (GInputStream *)g_file_read (file, cancellable, error);
if (input_stream == NULL)
goto out;
- if (!ostree_repo_remote_gpg_import (repo, remote_name, input_stream,
- NULL, &imported, cancellable, error))
+ if (!ostree_repo_remote_gpg_import (repo, remote_name, input_stream, NULL, &imported,
+ cancellable, error))
goto out;
/* XXX If we ever add internationalization, use ngettext() here. */
- g_print ("Imported %u GPG key%s to remote \"%s\"\n",
- imported, (imported == 1) ? "" : "s", remote_name);
+ g_print ("Imported %u GPG key%s to remote \"%s\"\n", imported, (imported == 1) ? "" : "s",
+ remote_name);
}
#endif /* OSTREE_DISABLE_GPGME */
ret = TRUE;
- out:
+out:
return ret;
}
diff --git a/src/ostree/ot-remote-builtin-delete-cookie.c b/src/ostree/ot-remote-builtin-delete-cookie.c
index 0c22caa2..f79854ea 100644
--- a/src/ostree/ot-remote-builtin-delete-cookie.c
+++ b/src/ostree/ot-remote-builtin-delete-cookie.c
@@ -23,9 +23,9 @@
#include "otutil.h"
#include <sys/stat.h>
+#include "ostree-repo-private.h"
#include "ot-main.h"
#include "ot-remote-builtins.h"
-#include "ostree-repo-private.h"
#include "ot-remote-cookie-util.h"
/* ATTENTION:
@@ -33,18 +33,17 @@
* man page (man/ostree-remote.xml) when changing the option list.
*/
-static GOptionEntry option_entries[] = {
- { NULL }
-};
+static GOptionEntry option_entries[] = { { NULL } };
gboolean
-ot_remote_builtin_delete_cookie (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_remote_builtin_delete_cookie (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(OstreeRepo) repo = NULL;
- g_autoptr(GOptionContext) context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME");
+ g_autoptr (OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME");
- if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
- invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
if (argc < 5)
@@ -58,7 +57,8 @@ ot_remote_builtin_delete_cookie (int argc, char **argv, OstreeCommandInvocation
const char *path = argv[3];
const char *cookie_name = argv[4];
g_autofree char *cookie_file = g_strdup_printf ("%s.cookies.txt", remote_name);
- if (!ot_delete_cookie_at (ostree_repo_get_dfd (repo), cookie_file, domain, path, cookie_name, error))
+ if (!ot_delete_cookie_at (ostree_repo_get_dfd (repo), cookie_file, domain, path, cookie_name,
+ error))
return FALSE;
return TRUE;
diff --git a/src/ostree/ot-remote-builtin-delete.c b/src/ostree/ot-remote-builtin-delete.c
index eb60783c..e5e310f3 100644
--- a/src/ostree/ot-remote-builtin-delete.c
+++ b/src/ostree/ot-remote-builtin-delete.c
@@ -33,27 +33,29 @@ static char *opt_repo;
* man page (man/ostree-remote.xml) when changing the option list.
*/
-static GOptionEntry option_entries[] = {
- { "if-exists", 0, 0, G_OPTION_ARG_NONE, &opt_if_exists, "Do nothing if the provided remote does not exist", NULL },
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &opt_repo, "Path to OSTree repository (defaults to /sysroot/ostree/repo)", "PATH" },
- { "sysroot", 0, 0, G_OPTION_ARG_FILENAME, &opt_sysroot, "Use sysroot at PATH (overrides --repo)", "PATH" },
- { NULL }
-};
+static GOptionEntry option_entries[]
+ = { { "if-exists", 0, 0, G_OPTION_ARG_NONE, &opt_if_exists,
+ "Do nothing if the provided remote does not exist", NULL },
+ { "repo", 0, 0, G_OPTION_ARG_FILENAME, &opt_repo,
+ "Path to OSTree repository (defaults to /sysroot/ostree/repo)", "PATH" },
+ { "sysroot", 0, 0, G_OPTION_ARG_FILENAME, &opt_sysroot,
+ "Use sysroot at PATH (overrides --repo)", "PATH" },
+ { NULL } };
gboolean
-ot_remote_builtin_delete (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_remote_builtin_delete (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("NAME");
+ g_autoptr (GOptionContext) context = g_option_context_new ("NAME");
- if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
- invocation, NULL, cancellable, error))
+ if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, NULL,
+ cancellable, error))
return FALSE;
- g_autoptr(OstreeSysroot) sysroot = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_parse_sysroot_or_repo_option (context, opt_sysroot, opt_repo,
- &sysroot, &repo,
+ g_autoptr (OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_parse_sysroot_or_repo_option (context, opt_sysroot, opt_repo, &sysroot, &repo,
cancellable, error))
return FALSE;
@@ -66,10 +68,9 @@ ot_remote_builtin_delete (int argc, char **argv, OstreeCommandInvocation *invoca
const char *remote_name = argv[1];
if (!ostree_repo_remote_change (repo, NULL,
- opt_if_exists ? OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS :
- OSTREE_REPO_REMOTE_CHANGE_DELETE,
- remote_name, NULL, NULL,
- cancellable, error))
+ opt_if_exists ? OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS
+ : OSTREE_REPO_REMOTE_CHANGE_DELETE,
+ remote_name, NULL, NULL, cancellable, error))
return FALSE;
return TRUE;
diff --git a/src/ostree/ot-remote-builtin-gpg-import.c b/src/ostree/ot-remote-builtin-gpg-import.c
index ba4aa3b4..0d9744e5 100644
--- a/src/ostree/ot-remote-builtin-gpg-import.c
+++ b/src/ostree/ot-remote-builtin-gpg-import.c
@@ -19,8 +19,8 @@
#include "config.h"
-#include <libglnx.h>
#include <gio/gunixinputstream.h>
+#include <libglnx.h>
#include "otutil.h"
@@ -38,18 +38,16 @@ static char **opt_keyrings;
* man page (man/ostree-remote.xml) when changing the option list.
*/
-static GOptionEntry option_entries[] = {
- { "keyring", 'k', 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_keyrings, "Import keys from a keyring file (repeatable)", "FILE" },
- { "stdin", 0, 0, G_OPTION_ARG_NONE, &opt_stdin, "Import keys from standard input", NULL },
- { NULL }
-};
+static GOptionEntry option_entries[]
+ = { { "keyring", 'k', 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_keyrings,
+ "Import keys from a keyring file (repeatable)", "FILE" },
+ { "stdin", 0, 0, G_OPTION_ARG_NONE, &opt_stdin, "Import keys from standard input", NULL },
+ { NULL } };
static gboolean
-open_source_stream (GInputStream **out_source_stream,
- GCancellable *cancellable,
- GError **error)
+open_source_stream (GInputStream **out_source_stream, GCancellable *cancellable, GError **error)
{
- g_autoptr(GInputStream) source_stream = NULL;
+ g_autoptr (GInputStream) source_stream = NULL;
guint n_keyrings = 0;
gboolean ret = FALSE;
@@ -62,14 +60,14 @@ open_source_stream (GInputStream **out_source_stream,
}
else
{
- g_autoptr(GPtrArray) streams = NULL;
+ g_autoptr (GPtrArray) streams = NULL;
guint ii;
streams = g_ptr_array_new_with_free_func (g_object_unref);
for (ii = 0; ii < n_keyrings; ii++)
{
- g_autoptr(GFile) file = NULL;
+ g_autoptr (GFile) file = NULL;
GFileInputStream *input_stream = NULL;
file = g_file_new_for_path (opt_keyrings[ii]);
@@ -82,8 +80,8 @@ open_source_stream (GInputStream **out_source_stream,
g_ptr_array_add (streams, input_stream);
}
- /* Chain together all the --keyring options as one long stream. */
- source_stream = (GInputStream *) ostree_chain_input_stream_new (streams);
+ /* Chain together all the --keyring options as one long stream. */
+ source_stream = (GInputStream *)ostree_chain_input_stream_new (streams);
}
*out_source_stream = g_steal_pointer (&source_stream);
@@ -95,20 +93,21 @@ out:
}
gboolean
-ot_remote_builtin_gpg_import (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_remote_builtin_gpg_import (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
- g_autoptr(GInputStream) source_stream = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
+ g_autoptr (GInputStream) source_stream = NULL;
const char *remote_name;
- const char * const *key_ids;
+ const char *const *key_ids;
guint imported = 0;
gboolean ret = FALSE;
context = g_option_context_new ("NAME [KEY-ID...]");
- if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
- invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, &repo,
+ cancellable, error))
goto out;
if (argc < 2)
@@ -124,21 +123,21 @@ ot_remote_builtin_gpg_import (int argc, char **argv, OstreeCommandInvocation *in
}
remote_name = argv[1];
- key_ids = (argc > 2) ? (const char * const *) argv + 2 : NULL;
+ key_ids = (argc > 2) ? (const char *const *)argv + 2 : NULL;
if (!open_source_stream (&source_stream, cancellable, error))
goto out;
- if (!ostree_repo_remote_gpg_import (repo, remote_name, source_stream,
- key_ids, &imported, cancellable, error))
+ if (!ostree_repo_remote_gpg_import (repo, remote_name, source_stream, key_ids, &imported,
+ cancellable, error))
goto out;
/* XXX If we ever add internationalization, use ngettext() here. */
- g_print ("Imported %u GPG key%s to remote \"%s\"\n",
- imported, (imported == 1) ? "" : "s", remote_name);
+ g_print ("Imported %u GPG key%s to remote \"%s\"\n", imported, (imported == 1) ? "" : "s",
+ remote_name);
ret = TRUE;
- out:
+out:
return ret;
}
diff --git a/src/ostree/ot-remote-builtin-gpg-list-keys.c b/src/ostree/ot-remote-builtin-gpg-list-keys.c
index d0a388ee..8bd4c6b1 100644
--- a/src/ostree/ot-remote-builtin-gpg-list-keys.c
+++ b/src/ostree/ot-remote-builtin-gpg-list-keys.c
@@ -21,8 +21,8 @@
#include "otutil.h"
-#include "ot-main.h"
#include "ot-dump.h"
+#include "ot-main.h"
#include "ot-remote-builtins.h"
/* ATTENTION:
@@ -30,28 +30,22 @@
* man page (man/ostree-remote.xml) when changing the option list.
*/
-static GOptionEntry option_entries[] = {
- { NULL }
-};
+static GOptionEntry option_entries[] = { { NULL } };
gboolean
-ot_remote_builtin_list_gpg_keys (int argc,
- char **argv,
- OstreeCommandInvocation *invocation,
- GCancellable *cancellable,
- GError **error)
+ot_remote_builtin_list_gpg_keys (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("NAME");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
- invocation, &repo, cancellable, error))
+ g_autoptr (GOptionContext) context = g_option_context_new ("NAME");
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
const char *remote_name = (argc > 1) ? argv[1] : NULL;
- g_autoptr(GPtrArray) keys = NULL;
- if (!ostree_repo_remote_get_gpg_keys (repo, remote_name, NULL, &keys,
- cancellable, error))
+ g_autoptr (GPtrArray) keys = NULL;
+ if (!ostree_repo_remote_get_gpg_keys (repo, remote_name, NULL, &keys, cancellable, error))
return FALSE;
for (guint i = 0; i < keys->len; i++)
diff --git a/src/ostree/ot-remote-builtin-list-cookies.c b/src/ostree/ot-remote-builtin-list-cookies.c
index 04e7573b..2e576d50 100644
--- a/src/ostree/ot-remote-builtin-list-cookies.c
+++ b/src/ostree/ot-remote-builtin-list-cookies.c
@@ -22,9 +22,9 @@
#include "otutil.h"
+#include "ostree-repo-private.h"
#include "ot-main.h"
#include "ot-remote-builtins.h"
-#include "ostree-repo-private.h"
#include "ot-remote-cookie-util.h"
/* ATTENTION:
@@ -32,18 +32,17 @@
* man page (man/ostree-remote.xml) when changing the option list.
*/
-static GOptionEntry option_entries[] = {
- { NULL }
-};
+static GOptionEntry option_entries[] = { { NULL } };
gboolean
-ot_remote_builtin_list_cookies (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_remote_builtin_list_cookies (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(OstreeRepo) repo = NULL;
- g_autoptr(GOptionContext) context = g_option_context_new ("NAME");
+ g_autoptr (OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = g_option_context_new ("NAME");
- if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
- invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
if (argc < 2)
diff --git a/src/ostree/ot-remote-builtin-list.c b/src/ostree/ot-remote-builtin-list.c
index b8e875d4..31c60ec0 100644
--- a/src/ostree/ot-remote-builtin-list.c
+++ b/src/ostree/ot-remote-builtin-list.c
@@ -29,23 +29,23 @@ static gboolean opt_show_urls;
* man page (man/ostree-remote.xml) when changing the option list.
*/
-static GOptionEntry option_entries[] = {
- { "show-urls", 'u', 0, G_OPTION_ARG_NONE, &opt_show_urls, "Show remote URLs in list", NULL },
- { NULL }
-};
+static GOptionEntry option_entries[] = { { "show-urls", 'u', 0, G_OPTION_ARG_NONE, &opt_show_urls,
+ "Show remote URLs in list", NULL },
+ { NULL } };
gboolean
-ot_remote_builtin_list (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_remote_builtin_list (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("");
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
- invocation, &repo, cancellable, error))
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
guint n_remotes = 0;
- g_auto(GStrv) remotes = ostree_repo_remote_list (repo, &n_remotes);
+ g_auto (GStrv) remotes = ostree_repo_remote_list (repo, &n_remotes);
if (opt_show_urls)
{
diff --git a/src/ostree/ot-remote-builtin-refs.c b/src/ostree/ot-remote-builtin-refs.c
index 24ad0776..103c9134 100644
--- a/src/ostree/ot-remote-builtin-refs.c
+++ b/src/ostree/ot-remote-builtin-refs.c
@@ -25,27 +25,27 @@
#include "ot-remote-builtins.h"
static gboolean opt_revision;
-static char* opt_cache_dir;
+static char *opt_cache_dir;
/* ATTENTION:
* Please remember to update the bash-completion script (bash/ostree) and
* man page (man/ostree-remote.xml) when changing the option list.
*/
-static GOptionEntry option_entries[] = {
- { "revision", 'r', 0, G_OPTION_ARG_NONE, &opt_revision, "Show revisions in listing", NULL },
- { "cache-dir", 0, 0, G_OPTION_ARG_FILENAME, &opt_cache_dir, "Use custom cache dir", NULL },
- { NULL }
-};
+static GOptionEntry option_entries[]
+ = { { "revision", 'r', 0, G_OPTION_ARG_NONE, &opt_revision, "Show revisions in listing", NULL },
+ { "cache-dir", 0, 0, G_OPTION_ARG_FILENAME, &opt_cache_dir, "Use custom cache dir", NULL },
+ { NULL } };
gboolean
-ot_remote_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_remote_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("NAME");
+ g_autoptr (GOptionContext) context = g_option_context_new ("NAME");
- g_autoptr(OstreeRepo) repo = NULL;
- if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
- invocation, &repo, cancellable, error))
+ g_autoptr (OstreeRepo) repo = NULL;
+ if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, &repo,
+ cancellable, error))
return FALSE;
if (argc < 2)
@@ -61,17 +61,17 @@ ot_remote_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocati
}
const char *remote_name = argv[1];
- g_autoptr(GHashTable) refs = NULL;
+ g_autoptr (GHashTable) refs = NULL;
if (!ostree_repo_remote_list_refs (repo, remote_name, &refs, cancellable, error))
return FALSE;
else
{
- g_autoptr(GList) ordered_keys = NULL;
+ g_autoptr (GList) ordered_keys = NULL;
GList *iter = NULL;
ordered_keys = g_hash_table_get_keys (refs);
- ordered_keys = g_list_sort (ordered_keys, (GCompareFunc) strcmp);
+ ordered_keys = g_list_sort (ordered_keys, (GCompareFunc)strcmp);
for (iter = ordered_keys; iter; iter = iter->next)
{
diff --git a/src/ostree/ot-remote-builtin-show-url.c b/src/ostree/ot-remote-builtin-show-url.c
index f63908a9..f8316536 100644
--- a/src/ostree/ot-remote-builtin-show-url.c
+++ b/src/ostree/ot-remote-builtin-show-url.c
@@ -29,23 +29,22 @@
* man page (man/ostree-remote.xml) when changing the option list.
*/
-static GOptionEntry option_entries[] = {
- { NULL }
-};
+static GOptionEntry option_entries[] = { { NULL } };
gboolean
-ot_remote_builtin_show_url (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_remote_builtin_show_url (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
const char *remote_name;
g_autofree char *remote_url = NULL;
gboolean ret = FALSE;
context = g_option_context_new ("NAME");
- if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
- invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, &repo,
+ cancellable, error))
goto out;
if (argc < 2)
@@ -62,6 +61,6 @@ ot_remote_builtin_show_url (int argc, char **argv, OstreeCommandInvocation *invo
ret = TRUE;
}
- out:
+out:
return ret;
}
diff --git a/src/ostree/ot-remote-builtin-summary.c b/src/ostree/ot-remote-builtin-summary.c
index 55ccc396..ec508cbb 100644
--- a/src/ostree/ot-remote-builtin-summary.c
+++ b/src/ostree/ot-remote-builtin-summary.c
@@ -21,37 +21,39 @@
#include "otutil.h"
-#include "ot-main.h"
#include "ot-dump.h"
+#include "ot-main.h"
#include "ot-remote-builtins.h"
static gboolean opt_list_metadata_keys;
static gboolean opt_raw;
static char *opt_print_metadata_key;
-static char* opt_cache_dir;
+static char *opt_cache_dir;
/* ATTENTION:
* Please remember to update the bash-completion script (bash/ostree) and
* man page (man/ostree-remote.xml) when changing the option list.
*/
-static GOptionEntry option_entries[] = {
- { "list-metadata-keys", 0, 0, G_OPTION_ARG_NONE, &opt_list_metadata_keys, "List the available metadata keys", NULL },
- { "print-metadata-key", 0, 0, G_OPTION_ARG_STRING, &opt_print_metadata_key, "Print string value of metadata key", "KEY" },
- { "cache-dir", 0, 0, G_OPTION_ARG_FILENAME, &opt_cache_dir, "Use custom cache dir", NULL },
- { "raw", 0, 0, G_OPTION_ARG_NONE, &opt_raw, "Show raw variant data", NULL },
- { NULL }
-};
+static GOptionEntry option_entries[]
+ = { { "list-metadata-keys", 0, 0, G_OPTION_ARG_NONE, &opt_list_metadata_keys,
+ "List the available metadata keys", NULL },
+ { "print-metadata-key", 0, 0, G_OPTION_ARG_STRING, &opt_print_metadata_key,
+ "Print string value of metadata key", "KEY" },
+ { "cache-dir", 0, 0, G_OPTION_ARG_FILENAME, &opt_cache_dir, "Use custom cache dir", NULL },
+ { "raw", 0, 0, G_OPTION_ARG_NONE, &opt_raw, "Show raw variant data", NULL },
+ { NULL } };
gboolean
-ot_remote_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_remote_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
const char *remote_name;
- g_autoptr(GBytes) summary_bytes = NULL;
- g_autoptr(GBytes) signature_bytes = NULL;
+ g_autoptr (GBytes) summary_bytes = NULL;
+ g_autoptr (GBytes) signature_bytes = NULL;
OstreeDumpFlags flags = OSTREE_DUMP_NONE;
#ifndef OSTREE_DISABLE_GPGME
gboolean gpg_verify_summary;
@@ -60,8 +62,8 @@ ot_remote_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invoc
context = g_option_context_new ("NAME");
- if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
- invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, &repo,
+ cancellable, error))
goto out;
if (argc < 2)
@@ -81,16 +83,13 @@ ot_remote_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invoc
if (opt_raw)
flags |= OSTREE_DUMP_RAW;
- if (!ostree_repo_remote_fetch_summary (repo, remote_name,
- &summary_bytes,
- &signature_bytes,
+ if (!ostree_repo_remote_fetch_summary (repo, remote_name, &summary_bytes, &signature_bytes,
cancellable, error))
goto out;
if (summary_bytes == NULL)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Remote server has no summary file");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Remote server has no summary file");
goto out;
}
@@ -108,8 +107,7 @@ ot_remote_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invoc
ot_dump_summary_bytes (summary_bytes, flags);
#ifndef OSTREE_DISABLE_GPGME
- if (!ostree_repo_remote_get_gpg_verify_summary (repo, remote_name,
- &gpg_verify_summary,
+ if (!ostree_repo_remote_get_gpg_verify_summary (repo, remote_name, &gpg_verify_summary,
error))
goto out;
@@ -123,17 +121,13 @@ ot_remote_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invoc
* option for raw signature data like "--raw-signatures". */
if (signature_bytes != NULL && !opt_raw)
{
- g_autoptr(OstreeGpgVerifyResult) result = NULL;
+ g_autoptr (OstreeGpgVerifyResult) result = NULL;
/* The actual signed summary verification happens above in
* ostree_repo_remote_fetch_summary(). Here we just parse
* the signatures again for the purpose of printing. */
- result = ostree_repo_verify_summary (repo,
- remote_name,
- summary_bytes,
- signature_bytes,
- cancellable,
- error);
+ result = ostree_repo_verify_summary (repo, remote_name, summary_bytes, signature_bytes,
+ cancellable, error);
if (result == NULL)
goto out;
diff --git a/src/ostree/ot-remote-builtins.h b/src/ostree/ot-remote-builtins.h
index 4a0482a7..0386478f 100644
--- a/src/ostree/ot-remote-builtins.h
+++ b/src/ostree/ot-remote-builtins.h
@@ -23,23 +23,23 @@
G_BEGIN_DECLS
-#define BUILTINPROTO(name) gboolean ot_remote_builtin_ ## name (int argc, char **argv, \
- OstreeCommandInvocation *invocation, \
- GCancellable *cancellable, GError **error)
+#define BUILTINPROTO(name) \
+ gboolean ot_remote_builtin_##name (int argc, char **argv, OstreeCommandInvocation *invocation, \
+ GCancellable *cancellable, GError **error)
-BUILTINPROTO(add);
-BUILTINPROTO(delete);
-BUILTINPROTO(gpg_import);
-BUILTINPROTO(list_gpg_keys);
-BUILTINPROTO(list);
+BUILTINPROTO (add);
+BUILTINPROTO (delete);
+BUILTINPROTO (gpg_import);
+BUILTINPROTO (list_gpg_keys);
+BUILTINPROTO (list);
#ifdef HAVE_LIBCURL_OR_LIBSOUP
-BUILTINPROTO(add_cookie);
-BUILTINPROTO(list_cookies);
-BUILTINPROTO(delete_cookie);
+BUILTINPROTO (add_cookie);
+BUILTINPROTO (list_cookies);
+BUILTINPROTO (delete_cookie);
#endif
-BUILTINPROTO(show_url);
-BUILTINPROTO(refs);
-BUILTINPROTO(summary);
+BUILTINPROTO (show_url);
+BUILTINPROTO (refs);
+BUILTINPROTO (summary);
#undef BUILTINPROTO
diff --git a/src/ostree/ot-remote-cookie-util.c b/src/ostree/ot-remote-cookie-util.c
index 8cf1eb07..5b15dd3d 100644
--- a/src/ostree/ot-remote-cookie-util.c
+++ b/src/ostree/ot-remote-cookie-util.c
@@ -22,13 +22,14 @@
#include "ot-remote-cookie-util.h"
-#include "otutil.h"
+#include "ostree-repo-private.h"
#include "ot-main.h"
#include "ot-remote-builtins.h"
-#include "ostree-repo-private.h"
+#include "otutil.h"
typedef struct OtCookieParser OtCookieParser;
-struct OtCookieParser {
+struct OtCookieParser
+{
char *buf;
char *iter;
@@ -42,15 +43,11 @@ struct OtCookieParser {
char *value;
};
void ot_cookie_parser_free (OtCookieParser *parser);
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(OtCookieParser, ot_cookie_parser_free)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (OtCookieParser, ot_cookie_parser_free)
-gboolean
-ot_parse_cookies_at (int dfd, const char *path,
- OtCookieParser **out_parser,
- GCancellable *cancellable,
- GError **error);
-gboolean
-ot_parse_cookies_next (OtCookieParser *parser);
+gboolean ot_parse_cookies_at (int dfd, const char *path, OtCookieParser **out_parser,
+ GCancellable *cancellable, GError **error);
+gboolean ot_parse_cookies_next (OtCookieParser *parser);
static void
ot_cookie_parser_clear (OtCookieParser *parser)
@@ -72,10 +69,8 @@ ot_cookie_parser_free (OtCookieParser *parser)
}
gboolean
-ot_parse_cookies_at (int dfd, const char *path,
- OtCookieParser **out_parser,
- GCancellable *cancellable,
- GError **error)
+ot_parse_cookies_at (int dfd, const char *path, OtCookieParser **out_parser,
+ GCancellable *cancellable, GError **error)
{
OtCookieParser *parser;
g_autofree char *cookies_content = NULL;
@@ -120,14 +115,10 @@ ot_parse_cookies_next (OtCookieParser *parser)
parser->iter = NULL;
ot_cookie_parser_clear (parser);
- if (sscanf (iter, "%ms\t%ms\t%ms\t%ms\t%llu\t%ms\t%ms",
- &parser->domain,
- &parser->flag,
- &parser->path,
- &parser->secure,
- &parser->expiration,
- &parser->name,
- &parser->value) != 7)
+ if (sscanf (iter, "%ms\t%ms\t%ms\t%ms\t%llu\t%ms\t%ms", &parser->domain, &parser->flag,
+ &parser->path, &parser->secure, &parser->expiration, &parser->name,
+ &parser->value)
+ != 7)
continue;
parser->line = iter;
@@ -138,69 +129,58 @@ ot_parse_cookies_next (OtCookieParser *parser)
}
gboolean
-ot_add_cookie_at (int dfd, const char *jar_path,
- const char *domain, const char *path,
- const char *name, const char *value,
- GError **error)
+ot_add_cookie_at (int dfd, const char *jar_path, const char *domain, const char *path,
+ const char *name, const char *value, GError **error)
{
glnx_autofd int fd = openat (dfd, jar_path, O_WRONLY | O_APPEND | O_CREAT, 0644);
if (fd < 0)
return glnx_throw_errno_prefix (error, "open(%s)", jar_path);
- g_autoptr(GDateTime) now = g_date_time_new_now_utc ();
- g_autoptr(GDateTime) expires = g_date_time_add_years (now, 25);
+ g_autoptr (GDateTime) now = g_date_time_new_now_utc ();
+ g_autoptr (GDateTime) expires = g_date_time_add_years (now, 25);
/* Adapted from soup-cookie-jar-text.c:write_cookie() */
- g_autofree char *buf = g_strdup_printf ("%s\t%s\t%s\t%s\t%llu\t%s\t%s\n",
- domain,
- *domain == '.' ? "TRUE" : "FALSE",
- path,
- "FALSE",
- (long long unsigned)g_date_time_to_unix (expires),
- name,
- value);
+ g_autofree char *buf = g_strdup_printf (
+ "%s\t%s\t%s\t%s\t%llu\t%s\t%s\n", domain, *domain == '.' ? "TRUE" : "FALSE", path, "FALSE",
+ (long long unsigned)g_date_time_to_unix (expires), name, value);
if (glnx_loop_write (fd, buf, strlen (buf)) < 0)
return glnx_throw_errno_prefix (error, "write");
return TRUE;
}
gboolean
-ot_delete_cookie_at (int dfd, const char *jar_path,
- const char *domain, const char *path,
- const char *name,
- GError **error)
+ot_delete_cookie_at (int dfd, const char *jar_path, const char *domain, const char *path,
+ const char *name, GError **error)
{
gboolean found = FALSE;
- g_auto(GLnxTmpfile) tmpf = { 0, };
- g_autoptr(OtCookieParser) parser = NULL;
+ g_auto (GLnxTmpfile) tmpf = {
+ 0,
+ };
+ g_autoptr (OtCookieParser) parser = NULL;
if (!ot_parse_cookies_at (dfd, jar_path, &parser, NULL, error))
return FALSE;
g_assert (!strchr (jar_path, '/'));
- if (!glnx_open_tmpfile_linkable_at (dfd, ".", O_WRONLY | O_CLOEXEC,
- &tmpf, error))
+ if (!glnx_open_tmpfile_linkable_at (dfd, ".", O_WRONLY | O_CLOEXEC, &tmpf, error))
return FALSE;
while (ot_parse_cookies_next (parser))
{
- if (strcmp (domain, parser->domain) == 0 &&
- strcmp (path, parser->path) == 0 &&
- strcmp (name, parser->name) == 0)
+ if (strcmp (domain, parser->domain) == 0 && strcmp (path, parser->path) == 0
+ && strcmp (name, parser->name) == 0)
{
found = TRUE;
/* Match, skip writing this one */
continue;
}
- if (glnx_loop_write (tmpf.fd, parser->line, strlen (parser->line)) < 0 ||
- glnx_loop_write (tmpf.fd, "\n", 1) < 0)
+ if (glnx_loop_write (tmpf.fd, parser->line, strlen (parser->line)) < 0
+ || glnx_loop_write (tmpf.fd, "\n", 1) < 0)
return glnx_throw_errno_prefix (error, "write");
}
- if (!glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_REPLACE,
- dfd, jar_path,
- error))
+ if (!glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_REPLACE, dfd, jar_path, error))
return FALSE;
if (!found)
@@ -209,18 +189,17 @@ ot_delete_cookie_at (int dfd, const char *jar_path,
return TRUE;
}
-
gboolean
ot_list_cookies_at (int dfd, const char *jar_path, GError **error)
{
- g_autoptr(OtCookieParser) parser = NULL;
+ g_autoptr (OtCookieParser) parser = NULL;
if (!ot_parse_cookies_at (AT_FDCWD, jar_path, &parser, NULL, error))
return FALSE;
while (ot_parse_cookies_next (parser))
{
- g_autoptr(GDateTime) expires = g_date_time_new_from_unix_utc (parser->expiration);
+ g_autoptr (GDateTime) expires = g_date_time_new_from_unix_utc (parser->expiration);
g_autofree char *expires_str = NULL;
if (expires != NULL)
diff --git a/src/ostree/ot-remote-cookie-util.h b/src/ostree/ot-remote-cookie-util.h
index 838714f6..e0a84a1a 100644
--- a/src/ostree/ot-remote-cookie-util.h
+++ b/src/ostree/ot-remote-cookie-util.h
@@ -23,19 +23,12 @@
G_BEGIN_DECLS
-gboolean
-ot_add_cookie_at (int dfd, const char *jar_path,
- const char *domain, const char *path,
- const char *name, const char *value,
- GError **error);
+gboolean ot_add_cookie_at (int dfd, const char *jar_path, const char *domain, const char *path,
+ const char *name, const char *value, GError **error);
-gboolean
-ot_delete_cookie_at (int dfd, const char *jar_path,
- const char *domain, const char *path,
- const char *name,
- GError **error);
+gboolean ot_delete_cookie_at (int dfd, const char *jar_path, const char *domain, const char *path,
+ const char *name, GError **error);
-gboolean
-ot_list_cookies_at (int dfd, const char *jar_path, GError **error);
+gboolean ot_list_cookies_at (int dfd, const char *jar_path, GError **error);
G_END_DECLS