From eb6f7c6db83ce384f89a142f173c2c064dad2f33 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 23 Aug 2017 10:09:44 -0400 Subject: [PATCH] lib/commit: Honor commit filter for libarchive --tar-autocreate-parents This makes `ostree commit --tree=tar` honor `--owner-uid` and `--owner-gid` for the root directory. Prep for further commit filtering work, although mostly for the unit test cases; this ensures we can use `ostree checkout` after autocreating a root directory. Closes: #1104 Approved by: jlebon --- src/libostree/ostree-repo-libarchive.c | 6 +++++- tests/test-libarchive.sh | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libostree/ostree-repo-libarchive.c b/src/libostree/ostree-repo-libarchive.c index 1839a088..8d9e8969 100644 --- a/src/libostree/ostree-repo-libarchive.c +++ b/src/libostree/ostree-repo-libarchive.c @@ -861,7 +861,11 @@ ostree_repo_import_archive_to_mtree (OstreeRepo *self, g_file_info_set_attribute_uint32 (fi, "unix::gid", 0); g_file_info_set_attribute_uint32 (fi, "unix::mode", DEFAULT_DIRMODE); - if (!aic_ensure_parent_dir_with_file_info (&aictx, mtree, "/", fi, NULL, + g_autoptr(GFileInfo) mfi = NULL; + (void)_ostree_repo_commit_modifier_apply (self, modifier, "/", + fi, &mfi); + + if (!aic_ensure_parent_dir_with_file_info (&aictx, mtree, "/", mfi, NULL, cancellable, error)) goto out; } diff --git a/tests/test-libarchive.sh b/tests/test-libarchive.sh index 6540b94b..6653fa6a 100755 --- a/tests/test-libarchive.sh +++ b/tests/test-libarchive.sh @@ -26,7 +26,7 @@ fi . $(dirname $0)/libtest.sh -echo "1..20" +echo "1..21" setup_test_repository "bare" @@ -154,3 +154,13 @@ $OSTREE checkout partial partial-checkout cd partial-checkout assert_file_has_content subdir/original "original" echo "ok tar partial commit contents" + +cd ${test_tmpdir} +tar -cf empty.tar.gz -T /dev/null +uid=$(id -u) +gid=$(id -g) +$OSTREE commit -b tar-empty --tar-autocreate-parents \ + --owner-uid=${uid} --owner-gid=${gid} --tree=tar=empty.tar.gz +$OSTREE ls tar-empty > ls.txt +assert_file_has_content ls.txt "d00755 ${uid} ${gid} 0 /" +echo "ok tar autocreate with owner uid/gid"