summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-repo-libarchive.c
diff options
context:
space:
mode:
authorWilliam Manley <will@stb-tester.com>2020-11-17 00:46:10 +0000
committerWilliam Manley <will@stb-tester.com>2020-11-17 16:54:32 +0000
commita88d2f5f7b788a1b04303ac56a1971bdd5f553e6 (patch)
tree4859fe3675f19dbebd405d71615b824179ea6b2f /src/libostree/ostree-repo-libarchive.c
parentabbe7ea4e7b55ebbbf1a62f6255ce98f399837aa (diff)
downloadostree-a88d2f5f7b788a1b04303ac56a1971bdd5f553e6.tar.gz
ostree commit --tree=tar: Import xattrs from tarballs
If you specify an `xattr_callback` the xattrs will still be taken from there for now.
Diffstat (limited to 'src/libostree/ostree-repo-libarchive.c')
-rw-r--r--src/libostree/ostree-repo-libarchive.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/libostree/ostree-repo-libarchive.c b/src/libostree/ostree-repo-libarchive.c
index ef7252e8..96b34c18 100644
--- a/src/libostree/ostree-repo-libarchive.c
+++ b/src/libostree/ostree-repo-libarchive.c
@@ -458,12 +458,43 @@ aic_get_xattrs (OstreeRepoArchiveImportContext *ctx,
g_autoptr(GVariant) xattrs = NULL;
const char *cb_path = abspath;
+ gboolean no_xattrs = ctx->modifier &&
+ ctx->modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS;
+
+ if (!no_xattrs && archive_entry_xattr_count (ctx->entry) > 0)
+ {
+ const char *name;
+ const void *value;
+ size_t size;
+
+ g_autoptr(GVariantBuilder) builder =
+ ot_util_variant_builder_from_variant (xattrs,
+ G_VARIANT_TYPE ("a(ayay)"));
+
+ archive_entry_xattr_reset (ctx->entry);
+ while (archive_entry_xattr_next (
+ ctx->entry, &name, &value, &size) == ARCHIVE_OK)
+ {
+ g_variant_builder_add (builder, "(@ay@ay)",
+ g_variant_new_bytestring (name),
+ g_variant_new_fixed_array (G_VARIANT_TYPE("y"),
+ value, size, 1));
+ }
+
+ xattrs = g_variant_builder_end (builder);
+ g_variant_ref_sink (xattrs);
+ }
+
if (ctx->opts->callback_with_entry_pathname)
cb_path = archive_entry_pathname (ctx->entry);
if (ctx->modifier && ctx->modifier->xattr_callback)
- xattrs = ctx->modifier->xattr_callback (ctx->repo, cb_path, file_info,
- ctx->modifier->xattr_user_data);
+ {
+ if (xattrs)
+ g_variant_unref (xattrs);
+ xattrs = ctx->modifier->xattr_callback (ctx->repo, cb_path, file_info,
+ ctx->modifier->xattr_user_data);
+ }
if (ctx->modifier && ctx->modifier->sepolicy)
{