deltas: Use endianness marker when parsing
Extend the `static-delta show` and `pull` commands to use the endianness information (if available).
This commit is contained in:
1 parent
277220aaa6
commit
04d77da005
7 files changed
+201
-36
No files matched your search
@@ -59,6 +59,7 @@ typedef struct {
|
||||
guint n_rollsum;
|
||||
guint n_bsdiff;
|
||||
guint n_fallback;
|
||||
gboolean swap_endian;
|
||||
} OstreeStaticDeltaBuilder;
|
||||
|
||||
typedef enum {
|
||||
@@ -1191,7 +1192,8 @@ get_fallback_headers (OstreeRepo *self,
|
||||
g_variant_new ("(y@aytt)",
|
||||
objtype,
|
||||
ostree_checksum_to_bytes_v (checksum),
|
||||
compressed_size, uncompressed_size));
|
||||
maybe_swap_endian_u64 (builder->swap_endian, compressed_size),
|
||||
maybe_swap_endian_u64 (builder->swap_endian, uncompressed_size)));
|
||||
}
|
||||
|
||||
ret_headers = g_variant_ref_sink (g_variant_builder_end (fallback_builder));
|
||||
@@ -1228,6 +1230,7 @@ get_fallback_headers (OstreeRepo *self,
|
||||
* - bsdiff-enabled: b: Enable bsdiff compression. Default TRUE.
|
||||
* - inline-parts: b: Put part data in header, to get a single file delta. Default FALSE.
|
||||
* - verbose: b: Print diagnostic messages. Default FALSE.
|
||||
* - endianness: b: Deltas use host byte order by default; this option allows choosing (G_BIG_ENDIAN or G_LITTLE_ENDIAN)
|
||||
* - filename: ay: Save delta superblock to this filename, and parts in the same directory. Default saves to repository.
|
||||
*/
|
||||
gboolean
|
||||
@@ -1262,6 +1265,7 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
g_autoptr(GVariant) fallback_headers = NULL;
|
||||
g_autoptr(GVariant) detached = NULL;
|
||||
gboolean inline_parts;
|
||||
guint endianness = G_BYTE_ORDER;
|
||||
g_autoptr(GFile) tmp_dir = NULL;
|
||||
builder.parts = g_ptr_array_new_with_free_func ((GDestroyNotify)ostree_static_delta_part_builder_unref);
|
||||
builder.fallback_objects = g_ptr_array_new_with_free_func ((GDestroyNotify)g_variant_unref);
|
||||
@@ -1277,6 +1281,11 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
max_chunk_size = 32;
|
||||
builder.max_chunk_size_bytes = ((guint64)max_chunk_size) * 1000 * 1000;
|
||||
|
||||
(void) g_variant_lookup (params, "endianness", "u", &endianness);
|
||||
g_return_val_if_fail (endianness == G_BIG_ENDIAN || endianness == G_LITTLE_ENDIAN, FALSE);
|
||||
|
||||
builder.swap_endian = endianness != G_BYTE_ORDER;
|
||||
|
||||
{ gboolean use_bsdiff;
|
||||
if (!g_variant_lookup (params, "bsdiff-enabled", "b", &use_bsdiff))
|
||||
use_bsdiff = TRUE;
|
||||
@@ -1325,7 +1334,8 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
}
|
||||
|
||||
{ guint8 endianness_char;
|
||||
switch (G_BYTE_ORDER)
|
||||
|
||||
switch (endianness)
|
||||
{
|
||||
case G_LITTLE_ENDIAN:
|
||||
endianness_char = 'l';
|
||||
@@ -1433,10 +1443,10 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
checksum_bytes = g_bytes_new (part_checksum, OSTREE_SHA256_DIGEST_LEN);
|
||||
objtype_checksum_array = objtype_checksum_array_new (part_builder->objects);
|
||||
delta_part_header = g_variant_new ("(u@aytt@ay)",
|
||||
OSTREE_DELTAPART_VERSION,
|
||||
maybe_swap_endian_u32 (builder.swap_endian, OSTREE_DELTAPART_VERSION),
|
||||
ot_gvariant_new_ay_bytes (checksum_bytes),
|
||||
(guint64) g_variant_get_size (delta_part),
|
||||
part_builder->uncompressed_size,
|
||||
maybe_swap_endian_u64 (builder.swap_endian, (guint64) g_variant_get_size (delta_part)),
|
||||
maybe_swap_endian_u64 (builder.swap_endian, part_builder->uncompressed_size),
|
||||
ot_gvariant_new_ay_bytes (objtype_checksum_array));
|
||||
|
||||
g_variant_builder_add_value (part_headers, g_variant_ref (delta_part_header));
|
||||
|
||||
Reference in new issue
Block a user