diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c index a4e7ae42..5232aa2b 100644 --- a/src/libostree/ostree-repo-static-delta-compilation.c +++ b/src/libostree/ostree-repo-static-delta-compilation.c @@ -848,10 +848,16 @@ process_one_bsdiff (OstreeRepo *repo, return ret; } +typedef enum { + DELTAOPT_FLAG_NONE = (1 << 0), + DELTAOPT_FLAG_DISABLE_BSDIFF = (1 << 1) +} DeltaOpts; + static gboolean generate_delta_lowlatency (OstreeRepo *repo, const char *from, const char *to, + DeltaOpts opts, OstreeStaticDeltaBuilder *builder, GCancellable *cancellable, GError **error) @@ -988,12 +994,15 @@ generate_delta_lowlatency (OstreeRepo *repo, continue; } - if (!try_content_bsdiff (repo, from_checksum, to_checksum, - &bsdiff, cancellable, error)) - goto out; + if (!(opts & DELTAOPT_FLAG_DISABLE_BSDIFF)) + { + if (!try_content_bsdiff (repo, from_checksum, to_checksum, + &bsdiff, cancellable, error)) + goto out; - if (bsdiff) - g_hash_table_insert (bsdiff_optimized_content_objects, g_strdup (to_checksum), bsdiff); + if (bsdiff) + g_hash_table_insert (bsdiff_optimized_content_objects, g_strdup (to_checksum), bsdiff); + } } g_printerr ("rollsum for %u/%u modified\n", @@ -1215,6 +1224,7 @@ ostree_repo_static_delta_generate (OstreeRepo *self, guint min_fallback_size; guint max_chunk_size; GVariant *metadata_source; + DeltaOpts delta_opts = DELTAOPT_FLAG_NONE; guint64 total_compressed_size = 0; guint64 total_uncompressed_size = 0; gs_unref_variant_builder GVariantBuilder *part_headers = NULL; @@ -1238,12 +1248,19 @@ ostree_repo_static_delta_generate (OstreeRepo *self, max_chunk_size = 32; builder.max_chunk_size_bytes = ((guint64)max_chunk_size) * 1000 * 1000; + { gboolean use_bsdiff; + if (!g_variant_lookup (params, "bsdiff-enabled", "b", &use_bsdiff)) + use_bsdiff = TRUE; + if (!use_bsdiff) + delta_opts |= DELTAOPT_FLAG_DISABLE_BSDIFF; + } + if (!ostree_repo_load_variant (self, OSTREE_OBJECT_TYPE_COMMIT, to, &to_commit, error)) goto out; /* Ignore optimization flags */ - if (!generate_delta_lowlatency (self, from, to, &builder, + if (!generate_delta_lowlatency (self, from, to, delta_opts, &builder, cancellable, error)) goto out; diff --git a/src/ostree/ot-builtin-static-delta.c b/src/ostree/ot-builtin-static-delta.c index 4c35dc69..0a53aafe 100644 --- a/src/ostree/ot-builtin-static-delta.c +++ b/src/ostree/ot-builtin-static-delta.c @@ -33,6 +33,7 @@ static char *opt_gpg_homedir; static char *opt_min_fallback_size; static char *opt_max_chunk_size; static gboolean opt_empty; +static gboolean opt_disable_bsdiff; #define BUILTINPROTO(name) static gboolean ot_static_delta_builtin_ ## name (int argc, char **argv, GCancellable *cancellable, GError **error) @@ -54,6 +55,7 @@ static GOptionEntry generate_options[] = { { "from", 0, 0, G_OPTION_ARG_STRING, &opt_from_rev, "Create delta from revision REV", "REV" }, { "empty", 0, 0, G_OPTION_ARG_NONE, &opt_empty, "Create delta from scratch", 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 }, { "gpg-sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "GPG Key ID to sign the delta with", "key-id"}, { "gpg-homedir", 0, 0, G_OPTION_ARG_STRING, &opt_gpg_homedir, "GPG Homedir to use when looking for keyrings", "homedir"}, { "min-fallback-size", 0, 0, G_OPTION_ARG_STRING, &opt_min_fallback_size, "Minimum uncompressed size in megabytes for individual HTTP request", NULL}, @@ -192,6 +194,9 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab 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))); + if (opt_disable_bsdiff) + g_variant_builder_add (parambuilder, "{sv}", + "bsdiff-enabled", g_variant_new_boolean (FALSE)); g_print ("Generating static delta:\n"); g_print (" From: %s\n", from_resolved ? from_resolved : "empty");