New upstream version 2021.2
This commit is contained in:
commit
3b95643e80
41 files changed
+1625
-406
No files matched your search
@@ -637,12 +637,6 @@ skip_without_fuse () {
|
||||
[ -e /etc/mtab ] || skip "no /etc/mtab"
|
||||
}
|
||||
|
||||
skip_without_experimental () {
|
||||
if ! ostree --version | grep -q -e '- experimental'; then
|
||||
skip "No experimental API is compiled in"
|
||||
fi
|
||||
}
|
||||
|
||||
has_gpgme () {
|
||||
local ret
|
||||
${CMD_PREFIX} ostree --version > version.txt
|
||||
|
||||
+3
-3
@@ -196,7 +196,7 @@ if ! skip_one_without_user_xattrs; then
|
||||
# Preserve user.ostreemeta xattr
|
||||
cp -a ${path}{,.new}
|
||||
(dd if=${path} conv=swab) > ${path}.new
|
||||
mv ${path}{.new,}
|
||||
mv -f ${path}{.new,}
|
||||
if ${CMD_PREFIX} ostree --repo=cacherepo fsck 2>err.txt; then
|
||||
fatal "corrupt repo fsck?"
|
||||
fi
|
||||
@@ -631,12 +631,12 @@ if has_gpgme; then
|
||||
objpath=objects/${csum::2}/${csum:2}.commitmeta
|
||||
remotesig=ostree-srv/gnomerepo/$objpath
|
||||
localsig=repo/$objpath
|
||||
mv $remotesig $remotesig.bak
|
||||
mv -f $remotesig $remotesig.bak
|
||||
if ${CMD_PREFIX} ostree --repo=repo --depth=0 pull origin main; then
|
||||
assert_not_reached "pull with gpg-verify unexpectedly succeeded?"
|
||||
fi
|
||||
# ok now check that we can pull correctly
|
||||
mv $remotesig.bak $remotesig
|
||||
mv -f $remotesig.bak $remotesig
|
||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||
echo "ok pull signed commit"
|
||||
rm $localsig
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
const ByteArray = imports.byteArray;
|
||||
const Gio = imports.gi.Gio;
|
||||
const OSTree = imports.gi.OSTree;
|
||||
|
||||
@@ -27,6 +28,22 @@ function assertEquals(a, b) {
|
||||
throw new Error("assertion failed " + JSON.stringify(a) + " == " + JSON.stringify(b));
|
||||
}
|
||||
|
||||
function assertThrows(s, f) {
|
||||
let success = false;
|
||||
try {
|
||||
f();
|
||||
success = true;
|
||||
} catch(e) {
|
||||
let msg = e.toString();
|
||||
if (msg.indexOf(s) == -1) {
|
||||
throw new Error("Error message didn't match '" + s + "': " + msg)
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
throw new Error("Function was expected to throw, but didn't")
|
||||
}
|
||||
}
|
||||
|
||||
print('1..1')
|
||||
|
||||
let testDataDir = Gio.File.new_for_path('test-data');
|
||||
@@ -49,6 +66,36 @@ let [,dirTree] = repo.write_mtree(mtree, null);
|
||||
let [,commit] = repo.write_commit(null, 'Some subject', 'Some body', null, dirTree, null);
|
||||
print("commit => " + commit);
|
||||
|
||||
// Test direct write APIs
|
||||
let inline_content = "default 0.0.0.0\nloopback 127.0.0.0\nlink-local 169.254.0.0\n";
|
||||
let networks_checksum = "8aaa9dc13a0c5839fe4a277756798c609c53fac6fa2290314ecfef9041065873";
|
||||
let regfile_mode = 33188; // 0o100000 | 0o644 (but in decimal so old gjs works)
|
||||
let inline_checksum = repo.write_regfile_inline(null, 0, 0, regfile_mode, null, inline_content, null);
|
||||
assertEquals(inline_checksum, networks_checksum);
|
||||
assertThrows("Corrupted file object", function() {
|
||||
// Changed an a to b from above to make the checksum not match
|
||||
repo.write_regfile_inline("8baa9dc13a0c5839fe4a277756798c609c53fac6fa2290314ecfef9041065873", 0, 0, regfile_mode, null, inline_content, null);
|
||||
});
|
||||
|
||||
{
|
||||
let [_, instream, info, xattrs] = repo.load_file(networks_checksum, null);
|
||||
// Read the whole content into a string via this amazing rube goldberg machine
|
||||
let datain = Gio.DataInputStream.new(instream);
|
||||
let bufw = Gio.MemoryOutputStream.new_resizable();
|
||||
bufw.splice(datain, 0, null);
|
||||
bufw.close(null);
|
||||
let contents = bufw.steal_as_bytes();
|
||||
let contentsStr = ByteArray.toString(contents.get_data())
|
||||
assertEquals(contentsStr, inline_content);
|
||||
|
||||
let uid = info.get_attribute_uint32("unix::uid");
|
||||
assertEquals(uid, 0);
|
||||
let mode = info.get_attribute_uint32("unix::mode");
|
||||
assertEquals(mode, regfile_mode);
|
||||
|
||||
assertEquals(xattrs.n_children(), 0);
|
||||
}
|
||||
|
||||
repo.commit_transaction(null, null);
|
||||
|
||||
let [,root,checksum] = repo.read_commit(commit, null);
|
||||
@@ -70,4 +117,21 @@ repo.commit_transaction(null, null);
|
||||
[,readCommit] = repo.resolve_rev('someref', true);
|
||||
assertEquals(readCommit, null);
|
||||
|
||||
// Test direct write API for regular files
|
||||
let clen = inline_content.length;
|
||||
assertThrows("Cannot currently use", function() {
|
||||
let w = repo.write_regfile(null, 0, 0, regfile_mode, clen, null);
|
||||
});
|
||||
|
||||
let bareRepoPath = Gio.File.new_for_path('repo');
|
||||
let repo_bareu = OSTree.Repo.new(Gio.File.new_for_path('repo-bare'));
|
||||
repo_bareu.create(OSTree.RepoMode.BARE_USER_ONLY, null);
|
||||
let w = repo_bareu.write_regfile(null, 0, 0, regfile_mode, clen, null);
|
||||
// Test multiple write() calls
|
||||
w.write(inline_content.slice(0, 4), null)
|
||||
w.write(inline_content.slice(4, 10), null)
|
||||
w.write(inline_content.slice(10), null)
|
||||
let actual_checksum = w.finish(null)
|
||||
assertEquals(actual_checksum, networks_checksum)
|
||||
|
||||
print("ok test-core");
|
||||
@@ -510,6 +510,7 @@ test_libarchive_xattr_import_skip_xattr (gconstpointer data)
|
||||
GError *error = NULL;
|
||||
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||
OstreeRepoImportArchiveOptions opts = { 0 };
|
||||
g_autoptr(OstreeRepoCommitModifier) modifier = NULL;
|
||||
|
||||
if (skip_if_no_xattr (td))
|
||||
goto out;
|
||||
@@ -524,7 +525,7 @@ test_libarchive_xattr_import_skip_xattr (gconstpointer data)
|
||||
|
||||
opts.ignore_unsupported_content = TRUE;
|
||||
|
||||
g_autoptr(OstreeRepoCommitModifier) modifier = ostree_repo_commit_modifier_new (
|
||||
modifier = ostree_repo_commit_modifier_new (
|
||||
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS, NULL, NULL, NULL);
|
||||
if (!import_write_and_ref (td->repo, &opts, a, "baz", modifier, &error))
|
||||
goto out;
|
||||
|
||||
+54
-1
@@ -197,6 +197,58 @@ test_repo_get_min_free_space (Fixture *fixture,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_write_regfile_api (Fixture *fixture,
|
||||
gconstpointer test_data)
|
||||
{
|
||||
g_autoptr (GKeyFile) config = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
g_autoptr(OstreeRepo) repo = ostree_repo_create_at (fixture->tmpdir.fd, ".",
|
||||
OSTREE_REPO_MODE_ARCHIVE,
|
||||
NULL,
|
||||
NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_auto(GVariantBuilder) xattrs_builder;
|
||||
g_variant_builder_init (&xattrs_builder, (GVariantType*)"a(ayay)");
|
||||
g_variant_builder_add (&xattrs_builder, "(^ay^ay)", "security.selinux", "system_u:object_r:etc_t:s0");
|
||||
g_autoptr(GVariant) xattrs = g_variant_ref_sink (g_variant_builder_end (&xattrs_builder));
|
||||
|
||||
// Current contents of /etc/networks in Fedora
|
||||
static const char contents[] = "default 0.0.0.0\nloopback 127.0.0.0\nlink-local 169.254.0.0\n";
|
||||
// First with no xattrs
|
||||
g_autofree char *checksum = ostree_repo_write_regfile_inline (repo, NULL, 0, 0, S_IFREG | 0644, NULL, (const guint8*)contents, sizeof (contents)-1, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpstr (checksum, ==, "8aaa9dc13a0c5839fe4a277756798c609c53fac6fa2290314ecfef9041065873");
|
||||
g_clear_pointer (&checksum, g_free);
|
||||
|
||||
// Invalid checksum
|
||||
checksum = ostree_repo_write_regfile_inline (repo, "3272139f889f6a7007b3d64adc74be9e2979bf6bbe663d1512e5bd43f4de24a1",
|
||||
0, 0, S_IFREG | 0644, NULL, (const guint8*)contents, sizeof (contents)-1, NULL, &error);
|
||||
g_assert (checksum == NULL);
|
||||
g_assert (error != NULL);
|
||||
g_clear_error (&error);
|
||||
|
||||
// Now with xattrs
|
||||
g_clear_pointer (&checksum, g_free);
|
||||
checksum = ostree_repo_write_regfile_inline (repo, NULL, 0, 0, S_IFREG | 0644, xattrs, (const guint8*)contents, sizeof (contents)-1, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpstr (checksum, ==, "4f600d252338f93279c51c964915cb2c26f0d09082164c54890d1a3c78cdeb1e");
|
||||
g_clear_pointer (&checksum, g_free);
|
||||
|
||||
// Test symlinks
|
||||
g_clear_pointer (&xattrs, g_variant_unref);
|
||||
g_variant_builder_init (&xattrs_builder, (GVariantType*)"a(ayay)");
|
||||
g_variant_builder_add (&xattrs_builder, "(^ay^ay)", "security.selinux", "system_u:object_r:bin_t:s0");
|
||||
xattrs = g_variant_ref_sink (g_variant_builder_end (&xattrs_builder));
|
||||
|
||||
g_clear_pointer (&checksum, g_free);
|
||||
checksum = ostree_repo_write_symlink (repo, NULL, 0, 0, xattrs, "bash", NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpstr (checksum, ==, "23a2e97d21d960ac7a4e39a8721b1baff7b213e00e5e5641334f50506012fcff");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
@@ -212,7 +264,8 @@ main (int argc,
|
||||
test_repo_equal, teardown);
|
||||
g_test_add ("/repo/get_min_free_space", Fixture, NULL, setup,
|
||||
test_repo_get_min_free_space, teardown);
|
||||
|
||||
g_test_add ("/repo/write_regfile_api", Fixture, NULL, setup,
|
||||
test_write_regfile_api, teardown);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
@@ -28,7 +28,7 @@ skip_without_user_xattrs
|
||||
|
||||
setup_test_repository "bare"
|
||||
|
||||
echo "1..11"
|
||||
echo "1..12"
|
||||
|
||||
cd ${test_tmpdir}
|
||||
mkdir mnt
|
||||
@@ -75,6 +75,10 @@ fi
|
||||
assert_file_has_content err.txt "chown:.*Read-only file system"
|
||||
echo "ok failed mutation chmod + chown"
|
||||
|
||||
if setfattr -n user.foo -v bar mnt/firstfile-link; then
|
||||
assert_not_reached "set xattr on linked file"
|
||||
fi
|
||||
|
||||
# Test creating new files, using chown + chmod on them as well
|
||||
echo anewfile-for-fuse > mnt/anewfile-for-fuse
|
||||
assert_file_has_content mnt/anewfile-for-fuse anewfile-for-fuse
|
||||
@@ -94,8 +98,14 @@ for i in $(seq 5); do
|
||||
chown $(id -u) mnt/newfusedir/test-morenewfuse.${i}
|
||||
done
|
||||
assert_file_has_content checkout-test2/newfusedir/test-morenewfuse.3 3-morenewfuse-3
|
||||
|
||||
echo "ok new content"
|
||||
|
||||
setfattr -n user.foo -v bar mnt/anewfile-for-fuse
|
||||
getfattr -d -m . mnt/anewfile-for-fuse > out.txt
|
||||
assert_file_has_content_literal out.txt 'user.foo="bar"'
|
||||
echo "ok new xattrs"
|
||||
|
||||
rm mnt/baz/cow
|
||||
assert_not_has_file checkout-test2/baz/cow
|
||||
rm mnt/baz/another -rf
|
||||
@@ -152,6 +162,16 @@ firstfile_new_inode=$(stat -c %i checkout-test2/firstfile)
|
||||
assert_not_streq "${firstfile_orig_inode}" "${firstfile_new_inode}"
|
||||
assert_test_file -f checkout-test2/firstfile
|
||||
|
||||
# Test xattr modifications
|
||||
copyup_reset
|
||||
firstfile_orig_inode=$(stat -c %i checkout-test2/firstfile)
|
||||
setfattr -n user.foo -v bar mnt/firstfile
|
||||
getfattr -d -m . mnt/firstfile > out.txt
|
||||
assert_file_has_content_literal out.txt 'user.foo="bar"'
|
||||
firstfile_new_inode=$(stat -c %i checkout-test2/firstfile)
|
||||
assert_not_streq "${firstfile_orig_inode}" "${firstfile_new_inode}"
|
||||
assert_test_file -f checkout-test2/firstfile
|
||||
|
||||
copyup_reset
|
||||
firstfile_link_orig_inode=$(stat -c %i checkout-test2/firstfile-link)
|
||||
firstfile_orig_inode=$(stat -c %i checkout-test2/firstfile)
|
||||
|
||||
+3
-13
@@ -31,16 +31,9 @@ if echo "$OSTREE_FEATURES" | grep --quiet --no-messages "devel"; then
|
||||
else
|
||||
devel_syms=
|
||||
fi
|
||||
if echo "$OSTREE_FEATURES" | grep --quiet --no-messages "experimental"; then
|
||||
experimental_sym="${G_TEST_SRCDIR}/src/libostree/libostree-experimental.sym"
|
||||
experimental_sections="${G_TEST_SRCDIR}/apidoc/ostree-experimental-sections.txt"
|
||||
else
|
||||
experimental_sym=""
|
||||
experimental_sections=""
|
||||
fi
|
||||
|
||||
echo "Verifying all expected symbols are actually exported..."
|
||||
grep --no-filename ' ostree_[A-Za-z0-9_]*;' ${released_syms} ${devel_syms} ${experimental_sym} | sed -e 's,^ *\([A-Za-z0-9_]*\);,\1,' | sort -u > expected-symbols.txt
|
||||
grep --no-filename ' ostree_[A-Za-z0-9_]*;' ${released_syms} ${devel_syms} | sed -e 's,^ *\([A-Za-z0-9_]*\);,\1,' | sort -u > expected-symbols.txt
|
||||
eu-readelf -a ${G_TEST_BUILDDIR}/.libs/libostree-1.so | grep 'FUNC.*GLOBAL.*DEFAULT.*@@LIBOSTREE_' | sed -e 's,^.* \(ostree_[A-Za-z0-9_]*\)@@LIBOSTREE_[0-9A-Z_.]*,\1,' |sort -u > found-symbols.txt
|
||||
diff -u expected-symbols.txt found-symbols.txt
|
||||
|
||||
@@ -48,9 +41,6 @@ echo "Checking that the example symbol wasn't copy-pasted..."
|
||||
if test -f ${devel_syms}; then
|
||||
assert_file_has_content_once ${devel_syms} "someostree_symbol_deleteme"
|
||||
fi
|
||||
if test -f ${experimental_sym}; then
|
||||
assert_not_file_has_content ${experimental_sym} "someostree_symbol_deleteme"
|
||||
fi
|
||||
assert_not_file_has_content ${released_syms} "someostree_symbol_deleteme"
|
||||
|
||||
echo "ok exports"
|
||||
@@ -59,14 +49,14 @@ echo "ok exports"
|
||||
grep -E -v '(ostree_cmd__private__)|(ostree_fetcher_config_flags_get_type)' found-symbols.txt > expected-documented.txt
|
||||
|
||||
echo "Verifying all public symbols are documented:"
|
||||
grep --no-filename '^ostree_' ${G_TEST_SRCDIR}/apidoc/ostree-sections.txt $experimental_sections |sort -u > found-documented.txt
|
||||
grep --no-filename '^ostree_' ${G_TEST_SRCDIR}/apidoc/ostree-sections.txt |sort -u > found-documented.txt
|
||||
diff -u expected-documented.txt found-documented.txt
|
||||
|
||||
echo 'ok documented symbols'
|
||||
|
||||
# ONLY update this checksum in release commits!
|
||||
cat > released-sha256.txt <<EOF
|
||||
07a58e073b075b0c1c9862846dba2bb177d121bbbf503d960b30ede27aef30eb ${released_syms}
|
||||
d42f7000de88e3c7280c2d55ad3a5e2e7a8d968758fe1d66a95863e2f5269d3c ${released_syms}
|
||||
EOF
|
||||
sha256sum -c released-sha256.txt
|
||||
|
||||
|
||||
Reference in new issue
Block a user