summaryrefslogtreecommitdiff
path: root/src/ostree/ot-builtin-static-delta.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2016-02-24 14:29:56 -0500
committerColin Walters <walters@verbum.org>2016-02-26 08:19:01 -0500
commit04d77da0056c89f2f18ae9e47ef121c960f2307b (patch)
tree2da2422d158c88dae80462ad685f8f3917a758f9 /src/ostree/ot-builtin-static-delta.c
parent277220aaa6e73002d5186ba1166c11be07481727 (diff)
downloadostree-04d77da0056c89f2f18ae9e47ef121c960f2307b.tar.gz
deltas: Use endianness marker when parsing
Extend the `static-delta show` and `pull` commands to use the endianness information (if available).
Diffstat (limited to 'src/ostree/ot-builtin-static-delta.c')
-rw-r--r--src/ostree/ot-builtin-static-delta.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ostree/ot-builtin-static-delta.c b/src/ostree/ot-builtin-static-delta.c
index c3c99ba0..36fb63fa 100644
--- a/src/ostree/ot-builtin-static-delta.c
+++ b/src/ostree/ot-builtin-static-delta.c
@@ -32,7 +32,9 @@ static char *opt_to_rev;
static char *opt_min_fallback_size;
static char *opt_max_bsdiff_size;
static char *opt_max_chunk_size;
+static char *opt_endianness;
static gboolean opt_empty;
+static gboolean opt_swap_endianness;
static gboolean opt_inline;
static gboolean opt_disable_bsdiff;
@@ -60,6 +62,8 @@ 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 },
+ { "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},
@@ -194,6 +198,7 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab
g_autofree char *to_resolved = NULL;
g_autofree char *from_parent_str = NULL;
g_autoptr(GVariantBuilder) parambuilder = NULL;
+ int endianness;
g_assert (opt_to_rev);
@@ -224,6 +229,37 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab
}
if (!ostree_repo_resolve_rev (repo, opt_to_rev, FALSE, &to_resolved, error))
goto out;
+
+ if (opt_endianness)
+ {
+ if (strcmp (opt_endianness, "l") == 0)
+ endianness = G_LITTLE_ENDIAN;
+ else if (strcmp (opt_endianness, "B") == 0)
+ endianness = G_BIG_ENDIAN;
+ else
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Invalid endianness '%s'", opt_endianness);
+ goto out;
+ }
+ }
+ else
+ endianness = G_BYTE_ORDER;
+
+ if (opt_swap_endianness)
+ {
+ switch (endianness)
+ {
+ case G_LITTLE_ENDIAN:
+ endianness = G_BIG_ENDIAN;
+ break;
+ case G_BIG_ENDIAN:
+ endianness = G_LITTLE_ENDIAN;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
parambuilder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
if (opt_min_fallback_size)
@@ -243,6 +279,8 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab
"inline-parts", g_variant_new_boolean (TRUE));
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_print ("Generating static delta:\n");
g_print (" From: %s\n", from_resolved ? from_resolved : "empty");