New upstream version 2017.11

This commit is contained in:
Simon McVittie committed 2017-09-15 11:18:25 +01:00
commit 573491dc3d
154 files changed
+3866 -2564

No files matched your search

+55 -4
View File
@@ -19,6 +19,8 @@
set -euo pipefail
echo "1..$((22 + ${extra_admin_tests:-0}))"
function validate_bootloader() {
cd ${test_tmpdir};
bootloader=""
@@ -33,6 +35,13 @@ function validate_bootloader() {
cd -
}
# Test generate_deployment_refs()
assert_ostree_deployment_refs() {
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo refs ostree | sort > ostree-refs.txt
(for v in "$@"; do echo $v; done) | sort > ostree-refs-expected.txt
diff -u ostree-refs{-expected,}.txt
}
orig_mtime=$(stat -c '%.Y' sysroot/ostree/deploy)
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
@@ -53,6 +62,7 @@ assert_file_has_content curdir ^`pwd`/sysroot/ostree/deploy/testos/deploy/${rev}
echo "ok --print-current-dir"
# Test layout of bootloader config and refs
assert_not_has_dir sysroot/boot/loader.0
assert_has_dir sysroot/boot/loader.1
assert_has_dir sysroot/ostree/boot.1.1
@@ -62,9 +72,8 @@ assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'option
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/vmlinuz-3.6.0 'a kernel'
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/etc/os-release 'NAME=TestOS'
assert_file_has_content sysroot/ostree/boot.1/testos/${bootcsum}/0/etc/os-release 'NAME=TestOS'
assert_ostree_deployment_refs 1/1/0
${CMD_PREFIX} ostree admin status
echo "ok layout"
orig_mtime=$(stat -c '%.Y' sysroot/ostree/deploy)
@@ -82,6 +91,7 @@ assert_not_has_dir sysroot/ostree/boot.1.1
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'options.* root=LABEL=MOO'
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.1/etc/os-release 'NAME=TestOS'
assert_file_has_content sysroot/ostree/boot.0/testos/${bootcsum}/0/etc/os-release 'NAME=TestOS'
assert_ostree_deployment_refs 0/1/{0,1}
${CMD_PREFIX} ostree admin status
validate_bootloader
@@ -94,6 +104,7 @@ assert_not_has_dir sysroot/boot/loader.1
# But swap subbootversion
assert_has_dir sysroot/ostree/boot.0.0
assert_not_has_dir sysroot/ostree/boot.0.1
assert_ostree_deployment_refs 0/0/{0,1}
${CMD_PREFIX} ostree admin status
validate_bootloader
@@ -108,6 +119,7 @@ assert_has_file sysroot/boot/loader/entries/ostree-testos-1.conf
assert_has_file sysroot/boot/loader/entries/ostree-otheros-0.conf
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.1/etc/os-release 'NAME=TestOS'
assert_file_has_content sysroot/ostree/deploy/otheros/deploy/${rev}.0/etc/os-release 'NAME=TestOS'
assert_ostree_deployment_refs 1/1/{0,1,2}
${CMD_PREFIX} ostree admin status
validate_bootloader
@@ -121,6 +133,7 @@ assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.2/etc/os-rele
assert_has_file sysroot/boot/loader/entries/ostree-testos-2.conf
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/os-release 'NAME=TestOS'
${CMD_PREFIX} ostree admin status
assert_ostree_deployment_refs 0/1/{0,1,2,3}
validate_bootloader
echo "ok fourth deploy (retain)"
@@ -130,6 +143,8 @@ rm -r sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/testdirectory
rm sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/aconfigfile
ln -s /ENOENT sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/a-new-broken-symlink
${CMD_PREFIX} ostree admin deploy --retain --os=testos testos:testos/buildmaster/x86_64-runtime
assert_not_has_dir sysroot/boot/loader.0
assert_has_dir sysroot/boot/loader.1
linktarget=$(readlink sysroot/ostree/deploy/testos/deploy/${rev}.4/etc/a-new-broken-symlink)
test "${linktarget}" = /ENOENT
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/os-release 'NAME=TestOS'
@@ -138,9 +153,36 @@ assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.4/etc/a-new-c
assert_not_has_file sysroot/ostree/deploy/testos/deploy/${rev}.4/etc/aconfigfile
${CMD_PREFIX} ostree admin status
validate_bootloader
echo "ok deploy with modified /etc"
# we now have 5 deployments, let's bring that back down to 1
for i in $(seq 4); do
${CMD_PREFIX} ostree admin undeploy 0
done
assert_has_file sysroot/boot/loader/entries/ostree-testos-0.conf
assert_not_has_file sysroot/boot/loader/entries/ostree-testos-1.conf
assert_not_has_file sysroot/boot/loader/entries/ostree-otheros-1.conf
${CMD_PREFIX} ostree admin deploy --not-as-default --os=otheros testos:testos/buildmaster/x86_64-runtime
assert_has_dir sysroot/boot/loader.0
assert_not_has_dir sysroot/boot/loader.1
assert_has_file sysroot/boot/loader/entries/ostree-testos-0.conf
assert_has_file sysroot/boot/loader/entries/ostree-otheros-1.conf
${CMD_PREFIX} ostree admin status
validate_bootloader
echo "ok deploy --not-as-default"
${CMD_PREFIX} ostree admin deploy --retain-rollback --os=otheros testos:testos/buildmaster/x86_64-runtime
assert_not_has_dir sysroot/boot/loader.0
assert_has_dir sysroot/boot/loader.1
assert_has_file sysroot/boot/loader/entries/ostree-otheros-0.conf
assert_has_file sysroot/boot/loader/entries/ostree-testos-1.conf
assert_has_file sysroot/boot/loader/entries/ostree-otheros-2.conf
${CMD_PREFIX} ostree admin status
validate_bootloader
echo "ok deploy --retain-rollback"
os_repository_new_commit
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
newrev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos:testos/buildmaster/x86_64-runtime)
@@ -153,7 +195,7 @@ assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/os-r
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/a-new-default-config-file "a new default config file"
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/new-default-dir/moo "a new default dir and file"
# And persist /etc changes from before
assert_not_has_file sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/aconfigfile
assert_not_has_file sysroot/ostree/deploy/testos/deploy/${rev}.4/etc/aconfigfile
${CMD_PREFIX} ostree admin status
validate_bootloader
@@ -250,6 +292,15 @@ assert_not_file_has_content sysroot/ostree/repo/config remote-test-nonphysical
assert_file_has_content ${deployment}/etc/ostree/remotes.d/remote-test-nonphysical.conf testos-repo
echo "ok remote add nonphysical sysroot"
# Test that setting add-remotes-config-dir to false adds a remote in the
# config file rather than the remotes config dir even though this is a
# "system" repo.
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo config set core.add-remotes-config-dir false
${CMD_PREFIX} ostree --sysroot=${deployment} remote add --set=gpg-verify=false remote-test-config-dir file://$(pwd)/testos-repo
assert_not_has_file ${deployment}/etc/ostree/remotes.d/remote-test-config-dir.conf testos-repo
assert_file_has_content sysroot/ostree/repo/config remote-test-config-dir
echo "ok remote add nonphysical sysroot add-remotes-config-dir false"
if env OSTREE_SYSROOT_DEBUG="${OSTREE_SYSROOT_DEBUG},test-fifreeze" \
${CMD_PREFIX} ostree admin deploy --os=testos testos:testos/buildmaster/x86_64-runtime 2>err.txt; then
fatal "fifreeze-test exited successfully?"
+134 -61
View File
@@ -19,13 +19,14 @@
set -euo pipefail
echo "1..$((70 + ${extra_basic_tests:-0}))"
echo "1..$((72 + ${extra_basic_tests:-0}))"
$CMD_PREFIX ostree --version > version.yaml
python -c 'import yaml; yaml.safe_load(open("version.yaml"))'
echo "ok yaml version"
CHECKOUT_U_ARG=""
CHECKOUT_H_ARGS="-H"
COMMIT_ARGS=""
DIFF_ARGS=""
if is_bare_user_only_repo repo; then
@@ -36,6 +37,11 @@ if is_bare_user_only_repo repo; then
DIFF_ARGS="--owner-uid=0 --owner-gid=0 --no-xattrs"
# Also, since we can't check out uid=0 files we need to check out in user mode
CHECKOUT_U_ARG="-U"
CHECKOUT_H_ARGS="-U -H"
else
if grep -E -q '^mode=bare-user' repo/config; then
CHECKOUT_H_ARGS="-U -H"
fi
fi
validate_checkout_basic() {
@@ -106,19 +112,23 @@ echo "ok shortened checksum"
(cd repo && ${CMD_PREFIX} ostree rev-parse test2)
echo "ok repo-in-cwd"
rm test-repo -rf
ostree_repo_init test-repo --mode=bare-user
ostree_repo_init test-repo --mode=bare-user
rm test-repo -rf
echo "ok repo-init on existing repo"
if ! skip_one_without_user_xattrs; then
rm test-repo -rf
ostree_repo_init test-repo --mode=bare-user
ostree_repo_init test-repo --mode=bare-user
rm test-repo -rf
echo "ok repo-init on existing repo"
fi
rm test-repo -rf
ostree_repo_init test-repo --mode=bare-user
${CMD_PREFIX} ostree --repo=test-repo refs
rm -rf test-repo/tmp
${CMD_PREFIX} ostree --repo=test-repo refs
assert_has_dir test-repo/tmp
echo "ok autocreate tmp"
if ! skip_one_without_user_xattrs; then
rm test-repo -rf
ostree_repo_init test-repo --mode=bare-user
${CMD_PREFIX} ostree --repo=test-repo refs
rm -rf test-repo/tmp
${CMD_PREFIX} ostree --repo=test-repo refs
assert_has_dir test-repo/tmp
echo "ok autocreate tmp"
fi
rm checkout-test2 -rf
$OSTREE checkout test2 checkout-test2
@@ -262,27 +272,31 @@ cd ${test_tmpdir}
assert_file_has_content diff-test2-2 'M */four$'
echo "ok diff file changing type"
cd ${test_tmpdir}
mkdir repo2
# Use a different mode to test hardlinking metadata only
if grep -q 'mode=archive' repo/config || is_bare_user_only_repo repo; then
opposite_mode=bare-user
else
opposite_mode=archive
if ! skip_one_without_user_xattrs; then
cd ${test_tmpdir}
mkdir repo2
# Use a different mode to test hardlinking metadata only
if grep -q 'mode=archive' repo/config || is_bare_user_only_repo repo; then
opposite_mode=bare-user
else
opposite_mode=archive
fi
ostree_repo_init repo2 --mode=$opposite_mode
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
test2_commitid=$(${CMD_PREFIX} ostree --repo=repo rev-parse test2)
test2_commit_relpath=/objects/${test2_commitid:0:2}/${test2_commitid:2}.commit
assert_files_hardlinked repo/${test2_commit_relpath} repo2/${test2_commit_relpath}
echo "ok pull-local (hardlinking metadata)"
fi
ostree_repo_init repo2 --mode=$opposite_mode
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
test2_commitid=$(${CMD_PREFIX} ostree --repo=repo rev-parse test2)
test2_commit_relpath=/objects/${test2_commitid:0:2}/${test2_commitid:2}.commit
assert_files_hardlinked repo/${test2_commit_relpath} repo2/${test2_commit_relpath}
echo "ok pull-local (hardlinking metadata)"
cd ${test_tmpdir}
rm repo2 -rf && mkdir repo2
ostree_repo_init repo2 --mode=$opposite_mode
${CMD_PREFIX} ostree --repo=repo2 pull-local --bareuseronly-files repo test2
${CMD_PREFIX} ostree --repo=repo2 fsck -q
echo "ok pull-local --bareuseronly-files"
if ! skip_one_without_user_xattrs; then
cd ${test_tmpdir}
rm repo2 -rf && mkdir repo2
ostree_repo_init repo2 --mode=$opposite_mode
${CMD_PREFIX} ostree --repo=repo2 pull-local --bareuseronly-files repo test2
${CMD_PREFIX} ostree --repo=repo2 fsck -q
echo "ok pull-local --bareuseronly-files"
fi
# This is mostly a copy of the suid test in test-basic-user-only.sh,
# but for the `pull --bareuseronly-files` case.
@@ -303,11 +317,13 @@ fi
assert_file_has_content err.txt 'object.*\.file: invalid mode.*with bits 040.*'
echo "ok pull-local (bareuseronly files)"
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=repo2 checkout ${CHECKOUT_U_ARG} test2 test2-checkout-from-local-clone
cd test2-checkout-from-local-clone
assert_file_has_content yet/another/tree/green 'leaf'
echo "ok local clone checkout"
if ! skip_one_without_user_xattrs; then
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=repo2 checkout ${CHECKOUT_U_ARG} test2 test2-checkout-from-local-clone
cd test2-checkout-from-local-clone
assert_file_has_content yet/another/tree/green 'leaf'
echo "ok local clone checkout"
fi
$OSTREE checkout -U test2 checkout-user-test2
echo "ok user checkout"
@@ -459,6 +475,57 @@ assert_file_has_content checkout-test-union-add/union-add-test 'existing file fo
assert_file_has_content checkout-test-union-add/union-add-test2 'another file for union add testing'
echo "ok checkout union add"
# Test --union-identical <https://github.com/projectatomic/rpm-ostree/issues/982>
# Prepare data:
cd ${test_tmpdir}
for x in $(seq 3); do
mkdir -p pkg${x}/usr/{bin,share/licenses}
# Separate binaries and symlinks
echo 'binary for pkg'${x} > pkg${x}/usr/bin/pkg${x}
ln -s pkg${x} pkg${x}/usr/bin/link${x}
# But they share the GPL
echo 'this is the GPL' > pkg${x}/usr/share/licenses/COPYING
ln -s COPYING pkg${x}/usr/share/licenses/LICENSE
$OSTREE commit -b union-identical-pkg${x} --tree=dir=pkg${x}
done
rm union-identical-test -rf
for x in $(seq 3); do
$OSTREE checkout ${CHECKOUT_H_ARGS} --union-identical union-identical-pkg${x} union-identical-test
done
if $OSTREE checkout ${CHECKOUT_H_ARGS/-H/} --union-identical union-identical-pkg${x} union-identical-test-tmp 2>err.txt; then
fatal "--union-identical without -H"
fi
assert_file_has_content err.txt "error:.*--union-identical requires --require-hardlinks"
for x in $(seq 3); do
for v in pkg link; do
assert_file_has_content union-identical-test/usr/bin/${v}${x} "binary for pkg"${x}
done
for v in COPYING LICENSE; do
assert_file_has_content union-identical-test/usr/share/licenses/${v} GPL
done
done
echo "ok checkout union identical merges"
# Make conflicting packages, one with regfile, one with symlink
mkdir -p pkg-conflict1bin/usr/{bin,share/licenses}
echo 'binary for pkg-conflict1bin' > pkg-conflict1bin/usr/bin/pkg1
echo 'this is the GPL' > pkg-conflict1bin/usr/share/licenses/COPYING
$OSTREE commit -b union-identical-conflictpkg1bin --tree=dir=pkg-conflict1bin
mkdir -p pkg-conflict1link/usr/{bin,share/licenses}
ln -s somewhere-else > pkg-conflict1link/usr/bin/pkg1
echo 'this is the GPL' > pkg-conflict1link/usr/share/licenses/COPYING
$OSTREE commit -b union-identical-conflictpkg1link --tree=dir=pkg-conflict1link
for v in bin link; do
rm union-identical-test -rf
$OSTREE checkout ${CHECKOUT_H_ARGS} --union-identical union-identical-pkg1 union-identical-test
if $OSTREE checkout ${CHECKOUT_H_ARGS} --union-identical union-identical-conflictpkg1${v} union-identical-test 2>err.txt; then
fatal "union identical $v succeeded?"
fi
assert_file_has_content err.txt 'error:.*File exists'
done
echo "ok checkout union identical conflicts"
cd ${test_tmpdir}
rm files -rf && mkdir files
mkdir files/worldwritable-dir
@@ -496,24 +563,28 @@ cd ${test_tmpdir}
$OSTREE checkout test2 --allow-noent --subpath /enoent 2>/dev/null
echo "ok subdir noent"
cd ${test_tmpdir}
mkdir repo3
ostree_repo_init repo3 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo3 pull-local --remote=aremote repo test2
${CMD_PREFIX} ostree --repo=repo3 rev-parse aremote/test2
echo "ok pull-local with --remote arg"
if ! skip_one_without_user_xattrs; then
cd ${test_tmpdir}
mkdir repo3
ostree_repo_init repo3 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo3 pull-local --remote=aremote repo test2
${CMD_PREFIX} ostree --repo=repo3 rev-parse aremote/test2
echo "ok pull-local with --remote arg"
fi
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=repo3 prune
find repo3/objects -name '*.commit' > objlist-before-prune
rm repo3/refs/heads/* repo3/refs/mirrors/* repo3/refs/remotes/* -rf
${CMD_PREFIX} ostree --repo=repo3 prune --refs-only
find repo3/objects -name '*.commit' > objlist-after-prune
if cmp -s objlist-before-prune objlist-after-prune; then
fatal "Prune didn't delete anything!"
if ! skip_one_without_user_xattrs; then
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=repo3 prune
find repo3/objects -name '*.commit' > objlist-before-prune
rm repo3/refs/heads/* repo3/refs/mirrors/* repo3/refs/remotes/* -rf
${CMD_PREFIX} ostree --repo=repo3 prune --refs-only
find repo3/objects -name '*.commit' > objlist-after-prune
if cmp -s objlist-before-prune objlist-after-prune; then
fatal "Prune didn't delete anything!"
fi
rm repo3 objlist-before-prune objlist-after-prune -rf
echo "ok prune"
fi
rm repo3 objlist-before-prune objlist-after-prune -rf
echo "ok prune"
cd ${test_tmpdir}
rm repo3 -rf
@@ -597,14 +668,16 @@ $OSTREE show --print-detached-metadata-key=SIGNATURE test2 > test2-meta
assert_file_has_content test2-meta "HANCOCK"
echo "ok metadata commit with strings"
cd ${test_tmpdir}
rm repo2 -rf
mkdir repo2
ostree_repo_init repo2 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
${CMD_PREFIX} ostree --repo=repo2 show --print-detached-metadata-key=SIGNATURE test2 > test2-meta
assert_file_has_content test2-meta "HANCOCK"
echo "ok pull-local after commit metadata"
if ! skip_one_without_user_xattrs; then
cd ${test_tmpdir}
rm repo2 -rf
mkdir repo2
ostree_repo_init repo2 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
${CMD_PREFIX} ostree --repo=repo2 show --print-detached-metadata-key=SIGNATURE test2 > test2-meta
assert_file_has_content test2-meta "HANCOCK"
echo "ok pull-local after commit metadata"
fi
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=repo remote --set=tls-permissive=true add aremote http://remote.example.com/repo testos/buildmaster/x86_64-runtime
+15 -36
View File
@@ -33,9 +33,7 @@
gboolean
ot_test_run_libtest (const char *cmd, GError **error)
{
gboolean ret = FALSE;
const char *srcdir = g_getenv ("G_TEST_SRCDIR");
int estatus;
g_autoptr(GPtrArray) argv = g_ptr_array_new ();
g_autoptr(GString) cmdstr = g_string_new ("");
@@ -50,53 +48,39 @@ ot_test_run_libtest (const char *cmd, GError **error)
g_ptr_array_add (argv, cmdstr->str);
g_ptr_array_add (argv, NULL);
int estatus;
if (!g_spawn_sync (NULL, (char**)argv->pdata, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL, &estatus, error))
goto out;
return FALSE;
if (!g_spawn_check_exit_status (estatus, error))
goto out;
return FALSE;
ret = TRUE;
out:
return ret;
return TRUE;
}
OstreeRepo *
ot_test_setup_repo (GCancellable *cancellable,
GError **error)
{
gboolean ret = FALSE;
if (!ot_test_run_libtest ("setup_test_repository archive", error))
return NULL;
g_autoptr(GFile) repo_path = g_file_new_for_path ("repo");
glnx_unref_object OstreeRepo* ret_repo = NULL;
if (!ot_test_run_libtest ("setup_test_repository archive-z2", error))
goto out;
ret_repo = ostree_repo_new (repo_path);
g_autoptr(OstreeRepo) ret_repo = ostree_repo_new (repo_path);
if (!ostree_repo_open (ret_repo, cancellable, error))
goto out;
return NULL;
ret = TRUE;
out:
if (ret)
return g_steal_pointer (&ret_repo);
return NULL;
return g_steal_pointer (&ret_repo);
}
OstreeSysroot *
ot_test_setup_sysroot (GCancellable *cancellable,
GError **error)
{
gboolean ret = FALSE;
g_autoptr(GFile) sysroot_path = g_file_new_for_path ("sysroot");
glnx_unref_object OstreeSysroot *ret_sysroot = NULL;
if (!ot_test_run_libtest ("setup_os_repository \"archive\" \"syslinux\"", error))
return FALSE;
struct statfs stbuf;
if (!ot_test_run_libtest ("setup_os_repository \"archive-z2\" \"syslinux\"", error))
goto out;
{ g_autoptr(GString) buf = g_string_new ("mutable-deployments");
if (statfs ("/", &stbuf) < 0)
return glnx_null_throw_errno (error);
@@ -113,11 +97,6 @@ ot_test_setup_sysroot (GCancellable *cancellable,
g_setenv ("OSTREE_SYSROOT_DEBUG", buf->str, TRUE);
}
ret_sysroot = ostree_sysroot_new (sysroot_path);
ret = TRUE;
out:
if (ret)
return g_steal_pointer (&ret_sysroot);
return NULL;
g_autoptr(GFile) sysroot_path = g_file_new_for_path ("sysroot");
return ostree_sysroot_new (sysroot_path);
}
+61 -20
View File
@@ -366,7 +366,7 @@ setup_os_repository () {
shift
bootmode=$1
shift
bootdir=${1:-usr/lib/ostree-boot}
bootdir=${1:-usr/lib/modules/3.6.0}
oldpwd=`pwd`
@@ -381,17 +381,25 @@ setup_os_repository () {
cd ${test_tmpdir}
mkdir osdata
cd osdata
mkdir -p usr/bin usr/lib/modules/3.6.0 usr/share usr/etc
mkdir -p ${bootdir}
echo "a kernel" > ${bootdir}/vmlinuz-3.6.0
echo "an initramfs" > ${bootdir}/initramfs-3.6.0
bootcsum=$(cat ${bootdir}/vmlinuz-3.6.0 ${bootdir}/initramfs-3.6.0 | sha256sum | cut -f 1 -d ' ')
kver=3.6.0
mkdir -p usr/bin ${bootdir} usr/lib/modules/${kver} usr/share usr/etc
kernel_path=${bootdir}/vmlinuz
initramfs_path=${bootdir}/initramfs.img
# /usr/lib/modules just uses "vmlinuz", since the version is in the module
# directory name.
if [[ $bootdir != usr/lib/modules/* ]]; then
kernel_path=${kernel_path}-${kver}
initramfs_path=${bootdir}/initramfs-${kver}.img
fi
echo "a kernel" > ${kernel_path}
echo "an initramfs" > ${initramfs_path}
bootcsum=$(cat ${kernel_path} ${initramfs_path} | sha256sum | cut -f 1 -d ' ')
export bootcsum
# Add the checksum for legacy dirs (/boot, /usr/lib/ostree-boot), but not
# /usr/lib/modules.
if [[ $bootdir != usr/lib/modules ]]; then
mv ${bootdir}/vmlinuz-3.6.0{,-${bootcsum}}
mv ${bootdir}/initramfs-3.6.0{,-${bootcsum}}
if [[ $bootdir != usr/lib/modules/* ]]; then
mv ${kernel_path}{,-${bootcsum}}
mv ${initramfs_path}{,-${bootcsum}}
fi
echo "an executable" > usr/bin/sh
@@ -412,7 +420,7 @@ EOF
echo "a default daemon file" > usr/etc/testdirectory/test
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string version=1.0.9 -b testos/buildmaster/x86_64-runtime -s "Build"
# Ensure these commits have distinct second timestamps
sleep 2
echo "a new executable" > usr/bin/sh
@@ -447,7 +455,7 @@ EOF
setup_os_boot_grub2 "${bootmode}"
;;
esac
cd ${test_tmpdir}
mkdir ${test_tmpdir}/httpd
cd httpd
@@ -465,17 +473,31 @@ os_repository_new_commit ()
branch=${3:-testos/buildmaster/x86_64-runtime}
echo "BOOT ITERATION: $boot_checksum_iteration"
cd ${test_tmpdir}/osdata
bootdir=usr/lib/ostree-boot
if ! test -d ${bootdir}; then
bootdir=boot
kver=3.6.0
if test -f usr/lib/modules/${kver}/vmlinuz; then
bootdir=usr/lib/modules/${kver}
else
if test -d usr/lib/ostree-boot; then
bootdir=usr/lib/ostree-boot
else
bootdir=boot
fi
fi
rm ${bootdir}/*
echo "new: a kernel ${boot_checksum_iteration}" > ${bootdir}/vmlinuz-3.6.0
echo "new: an initramfs ${boot_checksum_iteration}" > ${bootdir}/initramfs-3.6.0
bootcsum=$(cat ${bootdir}/vmlinuz-3.6.0 ${bootdir}/initramfs-3.6.0 | sha256sum | cut -f 1 -d ' ')
kernel_path=${bootdir}/vmlinuz
initramfs_path=${bootdir}/initramfs.img
if [[ $bootdir != usr/lib/modules/* ]]; then
kernel_path=${kernel_path}-${kver}
initramfs_path=${bootdir}/initramfs-${kver}.img
fi
echo "new: a kernel ${boot_checksum_iteration}" > ${kernel_path}
echo "new: an initramfs ${boot_checksum_iteration}" > ${initramfs_path}
bootcsum=$(cat ${kernel_path} ${initramfs_path} | sha256sum | cut -f 1 -d ' ')
export bootcsum
mv ${bootdir}/vmlinuz-3.6.0 ${bootdir}/vmlinuz-3.6.0-${bootcsum}
mv ${bootdir}/initramfs-3.6.0 ${bootdir}/initramfs-3.6.0-${bootcsum}
if [[ $bootdir != usr/lib/modules/* ]]; then
mv ${kernel_path}{,-${bootcsum}}
mv ${initramfs_path}{,-${bootcsum}}
fi
echo "a new default config file" > usr/etc/a-new-default-config-file
mkdir -p usr/etc/new-default-dir
@@ -489,6 +511,17 @@ os_repository_new_commit ()
cd ${test_tmpdir}
}
# Usage: if ! skip_one_without_user_xattrs; then ... more tests ...; fi
skip_one_without_user_xattrs () {
touch test-xattrs
if ! setfattr -n user.testvalue -v somevalue test-xattrs; then
echo "ok # SKIP - this test requires xattr support"
return 0
else
return 1
fi
}
skip_without_user_xattrs () {
touch test-xattrs
setfattr -n user.testvalue -v somevalue test-xattrs || \
@@ -528,6 +561,14 @@ ostree_file_path_to_checksum() {
$CMD_PREFIX ostree --repo=$repo ls -C $ref $path | awk '{ print $5 }'
}
# Given an object checksum, print its relative file path
ostree_checksum_to_relative_object_path() {
repo=$1
checksum=$2
if grep -Eq -e '^mode=archive' ${repo}/config; then suffix=z; else suffix=''; fi
echo objects/${checksum:0:2}/${checksum:2}.file${suffix}
}
# Given a path to a file in a repo for a ref, print the (relative) path to its
# object
ostree_file_path_to_relative_object_path() {
@@ -536,7 +577,7 @@ ostree_file_path_to_relative_object_path() {
path=$3
checksum=$(ostree_file_path_to_checksum $repo $ref $path)
test -n "${checksum}"
echo objects/${checksum:0:2}/${checksum:2}.file
ostree_checksum_to_relative_object_path ${repo} ${checksum}
}
# Given a path to a file in a repo for a ref, print the path to its object
+26 -1
View File
@@ -35,7 +35,7 @@ function verify_initial_contents() {
assert_file_has_content baz/cow '^moo$'
}
echo "1..28"
echo "1..29"
# Try both syntaxes
repo_init --no-gpg-verify
@@ -205,6 +205,31 @@ ${CMD_PREFIX} ostree --repo=parentpullrepo rev-parse origin:main > main.txt
assert_file_has_content main.txt ${rev}
echo "ok pull specific commit"
# test pull -T
cd ${test_tmpdir}
repo_init --no-gpg-verify
${CMD_PREFIX} ostree --repo=repo pull origin main
origrev=$(${CMD_PREFIX} ostree --repo=repo rev-parse main)
# Check we can pull the same commit with timestamp checking enabled
${CMD_PREFIX} ostree --repo=repo pull -T origin main
assert_streq ${origrev} "$(${CMD_PREFIX} ostree --repo=repo rev-parse main)"
newrev=$(${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit -b main --tree=ref=main)
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u
# New commit with timestamp checking
${CMD_PREFIX} ostree --repo=repo pull -T origin main
assert_not_streq "${origrev}" "${newrev}"
assert_streq ${newrev} "$(${CMD_PREFIX} ostree --repo=repo rev-parse main)"
newrev2=$(${CMD_PREFIX} ostree --timestamp="October 25 1985" --repo=ostree-srv/gnomerepo commit -b main --tree=ref=main)
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u
if ${CMD_PREFIX} ostree --repo=repo pull -T origin main 2>err.txt; then
fatal "pulled older commit with timestamp checking enabled?"
fi
assert_file_has_content err.txt "Upgrade.*is chronologically older"
assert_streq ${newrev} "$(${CMD_PREFIX} ostree --repo=repo rev-parse main)"
# But we can pull it without timestamp checking
${CMD_PREFIX} ostree --repo=repo pull origin main
echo "ok pull timestamp checking"
cd ${test_tmpdir}
repo_init --no-gpg-verify
${CMD_PREFIX} ostree --repo=repo pull origin main
+1 -1
View File
@@ -22,7 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
echo "1..3"
+1 -1
View File
@@ -22,7 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
echo "1..1"
+1 -1
View File
@@ -22,7 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
echo "1..1"
@@ -22,7 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
echo "1..2"
+3 -3
View File
@@ -19,11 +19,11 @@
set -euo pipefail
echo "1..19"
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "grub2 ostree-grub-generator"
setup_os_repository "archive" "grub2 ostree-grub-generator"
extra_admin_tests=0
. $(dirname $0)/admin-test.sh
+1 -1
View File
@@ -22,7 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
echo "1..3"
+1 -1
View File
@@ -22,7 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
echo "1..4"
+36 -15
View File
@@ -19,31 +19,52 @@
set -euo pipefail
echo "1..20"
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
extra_admin_tests=3
. $(dirname $0)/admin-test.sh
# Test the legacy dirs
for test_bootdir in "boot" "usr/lib/ostree-boot"; do
cd ${test_tmpdir}
rm httpd osdata testos-repo sysroot -rf
setup_os_repository "archive" "syslinux" $test_bootdir
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'options.* root=LABEL=MOO'
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'options.* quiet'
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/vmlinuz-3.6.0 'a kernel'
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/initramfs-3.6.0.img 'an initramfs'
# kernel/initrams should also be in the tree's /boot with the checksum
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/$test_bootdir/vmlinuz-3.6.0-${bootcsum} 'a kernel'
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/$test_bootdir/initramfs-3.6.0.img-${bootcsum} 'an initramfs'
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/etc/os-release 'NAME=TestOS'
assert_file_has_content sysroot/ostree/boot.1/testos/${bootcsum}/0/etc/os-release 'NAME=TestOS'
${CMD_PREFIX} ostree admin status
validate_bootloader
echo "ok kernel in $test_bootdir"
done
# And test that legacy overrides /usr/lib/modules
cd ${test_tmpdir}
rm httpd osdata testos-repo sysroot -rf
setup_os_repository "archive-z2" "syslinux" "boot"
setup_os_repository "archive" "syslinux" "usr/lib/ostree-boot"
cd osdata
echo "this is a kernel without an initramfs like Fedora 26" > usr/lib/modules/3.6.0/vmlinuz
usrlib_modules_bootcsum=$(cat usr/lib/modules/3.6.0/vmlinuz | sha256sum | cut -f 1 -d ' ')
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string version=1.0.9 -b testos/buildmaster/x86_64-runtime -s "Build"
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'options.* root=LABEL=MOO'
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'options.* quiet'
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/vmlinuz-3.6.0 'a kernel'
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/initramfs-3.6.0 'an initramfs'
# kernel/initrams should also be in the tree's /boot with the checksum
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/boot/vmlinuz-3.6.0-${bootcsum} 'a kernel'
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/boot/initramfs-3.6.0-${bootcsum} 'an initramfs'
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/etc/os-release 'NAME=TestOS'
assert_file_has_content sysroot/ostree/boot.1/testos/${bootcsum}/0/etc/os-release 'NAME=TestOS'
${CMD_PREFIX} ostree admin status
validate_bootloader
echo "ok kernel in tree's /boot"
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/initramfs-3.6.0.img 'an initramfs'
# Note this bootcsum shouldn't be the modules one
assert_not_streq "${bootcsum}" "${usrlib_modules_bootcsum}"
echo "ok kernel in /usr/lib/modules and /usr/lib/ostree-boot"
+6 -3
View File
@@ -20,16 +20,17 @@
set -euo pipefail
echo "1..20"
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "uboot"
setup_os_repository "archive" "uboot"
extra_admin_tests=1
. $(dirname $0)/admin-test.sh
cd ${test_tmpdir}
mkdir -p osdata/usr/lib/ostree-boot
cat << 'EOF' > osdata/usr/lib/ostree-boot/uEnv.txt
loaduimage=load mmc ${bootpart} ${loadaddr} ${kernel_image}
loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}${fdtfile}
@@ -41,5 +42,7 @@ ${CMD_PREFIX} ostree --repo=testos-repo commit --tree=dir=osdata/ -b testos/buil
${CMD_PREFIX} ostree admin upgrade --os=testos
assert_file_has_content sysroot/boot/uEnv.txt "loadfdt="
assert_file_has_content sysroot/boot/uEnv.txt "kernel_image="
assert_file_has_content sysroot/boot/uEnv.txt "kernel_image2="
assert_file_has_content sysroot/boot/uEnv.txt "kernel_image3="
echo "ok merging uEnv.txt files"
+1 -1
View File
@@ -23,7 +23,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
echo "1..5"
+1 -1
View File
@@ -22,7 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
# If parallel is not installed, skip the test
if ! parallel --gnu /bin/true </dev/null >/dev/null 2>&1; then
+1 -1
View File
@@ -25,7 +25,7 @@ set -euo pipefail
echo "1..1"
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos $(cat httpd-address)/ostree/testos-repo
+1 -1
View File
@@ -25,7 +25,7 @@ set -euo pipefail
echo "1..1"
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos $(cat httpd-address)/ostree/testos-repo
+1 -1
View File
@@ -22,7 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
# This does:
# - init ostree repo in testos-repo
# - create system files in osdata and commit twice those contents into testos-repo
+25 -8
View File
@@ -22,30 +22,47 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
echo "1..2"
ref=testos/buildmaster/x86_64-runtime
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos $(cat httpd-address)/ostree/testos-repo
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos testos/buildmaster/x86_64-runtime
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos ${ref}
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse ${ref})
export rev
echo "rev=${rev}"
# This initial deployment gets kicked off with some kernel arguments
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
# This initial deployment gets kicked off with some kernel arguments
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:${ref}
assert_has_dir sysroot/boot/ostree/testos-${bootcsum}
# This should be a no-op
${CMD_PREFIX} ostree admin upgrade --os=testos
# Now reset to an older revision
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo reset testos/buildmaster/x86_64-runtime{,^}
# Generate a new commit with an older timestamp that also has
# some new content, so we test timestamp checking during pull
# <https://github.com/ostreedev/ostree/pull/1055>
origrev=$(ostree --repo=${test_tmpdir}/sysroot/ostree/repo rev-parse testos:${ref})
cd ${test_tmpdir}/osdata
echo "new content for pull timestamp checking" > usr/share/test-pull-ts-check.txt
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string "version=tscheck" \
-b ${ref} --timestamp='October 25 1985'
newrev=$(ostree --repo=${test_tmpdir}/testos-repo rev-parse ${ref})
assert_not_streq ${origrev} ${newrev}
cd ${test_tmpdir}
tscheck_checksum=$(ostree_file_path_to_checksum testos-repo ${ref} /usr/share/test-pull-ts-check.txt)
tscheck_filez_objpath=$(ostree_checksum_to_relative_object_path testos-repo ${tscheck_checksum})
assert_has_file testos-repo/${tscheck_filez_objpath}
if ${CMD_PREFIX} ostree admin upgrade --os=testos 2>upgrade-err.txt; then
assert_not_reached 'upgrade unexpectedly succeeded'
fi
assert_file_has_content upgrade-err.txt 'chronologically older'
currev=$(ostree --repo=sysroot/ostree/repo rev-parse testos:${ref})
assert_not_streq ${newrev} ${currev}
assert_streq ${origrev} ${currev}
tscheck_file_objpath=$(ostree_checksum_to_relative_object_path sysroot/ostree/repo ${tscheck_checksum})
assert_not_has_file sysroot/ostree/repo/${tscheck_file_objpath}
echo 'ok upgrade will not go backwards'
+1 -1
View File
@@ -22,7 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
setup_os_repository "archive" "syslinux"
echo "1..2"
+5 -2
View File
@@ -21,12 +21,15 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
echo '1..11'
echo '1..12'
setup_test_repository "archive-z2"
setup_test_repository "archive"
. ${test_srcdir}/archive-test.sh
${CMD_PREFIX} ostree --repo=repo-archive-z2 init --mode=archive-z2
echo "ok did an init with archive-z2 alias"
cd ${test_tmpdir}
mkdir repo2
ostree_repo_init repo2
+2 -2
View File
@@ -55,7 +55,7 @@ input_stream_to_bytes (GInputStream *input)
}
static void
test_raw_file_to_archive_z2_stream (gconstpointer data)
test_raw_file_to_archive_stream (gconstpointer data)
{
OstreeRepo *repo = OSTREE_REPO (data);
g_autofree gchar *commit_checksum = NULL;
@@ -249,7 +249,7 @@ int main (int argc, char **argv)
goto out;
g_test_add_data_func ("/repo-not-system", repo, test_repo_is_not_system);
g_test_add_data_func ("/raw-file-to-archive-z2-stream", repo, test_raw_file_to_archive_z2_stream);
g_test_add_data_func ("/raw-file-to-archive-stream", repo, test_raw_file_to_archive_stream);
g_test_add_data_func ("/objectwrites", repo, test_object_writes);
g_test_add_func ("/remotename", test_validate_remotename);
+19 -17
View File
@@ -72,21 +72,23 @@ $CMD_PREFIX ostree --repo=repo checkout -U -H content-with-dir-world-writable di
assert_file_has_mode dir-co/worldwritable-dir 775
echo "ok didn't make world-writable dir"
cd ${test_tmpdir}
rm repo-input -rf
rm repo -rf
ostree_repo_init repo init --mode=bare-user-only
ostree_repo_init repo-input init --mode=bare-user
rm files -rf && mkdir files
echo afile > files/afile
ln -s afile files/afile-link
$CMD_PREFIX ostree --repo=repo-input commit --canonical-permissions -b testtree --tree=dir=files
afile_relobjpath=$(ostree_file_path_to_relative_object_path repo-input testtree /afile)
afile_link_relobjpath=$(ostree_file_path_to_relative_object_path repo-input testtree /afile-link)
$CMD_PREFIX ostree pull-local --repo=repo repo-input
assert_files_hardlinked repo/${afile_relobjpath} repo-input/${afile_relobjpath}
if files_are_hardlinked repo/${afile_link_relobjpath} repo-input/${afile_link_relobjpath}; then
assert_not_reached "symlinks hardlinked across bare-user?"
if ! skip_one_without_user_xattrs; then
cd ${test_tmpdir}
rm repo-input -rf
rm repo -rf
ostree_repo_init repo init --mode=bare-user-only
ostree_repo_init repo-input init --mode=bare-user
rm files -rf && mkdir files
echo afile > files/afile
ln -s afile files/afile-link
$CMD_PREFIX ostree --repo=repo-input commit --canonical-permissions -b testtree --tree=dir=files
afile_relobjpath=$(ostree_file_path_to_relative_object_path repo-input testtree /afile)
afile_link_relobjpath=$(ostree_file_path_to_relative_object_path repo-input testtree /afile-link)
$CMD_PREFIX ostree pull-local --repo=repo repo-input
assert_files_hardlinked repo/${afile_relobjpath} repo-input/${afile_relobjpath}
if files_are_hardlinked repo/${afile_link_relobjpath} repo-input/${afile_link_relobjpath}; then
assert_not_reached "symlinks hardlinked across bare-user?"
fi
$OSTREE fsck -q
echo "ok hardlink pull from bare-user"
fi
$OSTREE fsck -q
echo "ok hardlink pull from bare-user"
+1 -1
View File
@@ -33,7 +33,7 @@ oldpwd=`pwd`
mkdir ostree-srv
cd ostree-srv
mkdir gnomerepo
ostree_repo_init gnomerepo --mode="archive-z2"
ostree_repo_init gnomerepo --mode="archive"
mkdir gnomerepo-files
cd gnomerepo-files
echo first > firstfile
+1 -1
View File
@@ -29,7 +29,7 @@ morebindatafiles="false ls"
echo '1..12'
mkdir repo
ostree_repo_init repo --mode=archive-z2
ostree_repo_init repo --mode=archive
mkdir files
for bin in ${bindatafiles}; do
+1 -1
View File
@@ -68,7 +68,7 @@ packages="bash systemd"
mkdir build-repo
ostree_repo_init build-repo --mode=bare-user
mkdir repo
ostree_repo_init repo --mode=archive-z2
ostree_repo_init repo --mode=archive
# Our FUSE mount point
mkdir mnt
+1 -1
View File
@@ -21,7 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_test_repository "archive-z2"
setup_test_repository "archive"
echo '1..5'
+5 -2
View File
@@ -56,8 +56,11 @@ ${CMD_PREFIX} ostree --repo=local refs > refs
assert_file_has_content refs "^apps-remote:app1$"
assert_file_has_content refs "^os-remote:os/amd64/master$"
${CMD_PREFIX} ostree --repo=local refs --collections | wc -l > refscount
assert_file_has_content refscount "^0$"
${CMD_PREFIX} ostree --repo=local refs --collections > refs
cat refs | wc -l > refscount
assert_file_has_content refs "^(org.example.AppsCollection, app1)$"
assert_file_has_content refs "^(org.example.OsCollection, os/amd64/master)$"
assert_file_has_content refscount "^2$"
# Create a local mirror repository where we pull the branches *in mirror mode* from the two remotes.
# This should pull them into refs/mirrors, since the remotes advertise a collection ID.
+1 -1
View File
@@ -29,7 +29,7 @@ fi
echo "1..1"
setup_test_repository "archive-z2"
setup_test_repository "archive"
export OSTREE_GPG_SIGN="${OSTREE} gpg-sign --gpg-homedir=${TEST_GPG_KEYHOME}"
+1 -1
View File
@@ -173,7 +173,7 @@ test_attribute_basics (TestFixture *fixture,
tuple = ostree_gpg_verify_result_get_all (fixture->result, ii);
type_string = g_variant_get_type_string (tuple);
g_assert_cmpstr (type_string, ==, "(bbbbbsxxssss)");
g_assert_cmpstr (type_string, ==, "(bbbbbsxxsssss)");
/* Check attributes which should be common to all signatures. */
+43 -18
View File
@@ -23,41 +23,66 @@ set -euo pipefail
echo "1..1"
echo "Testing:" 1>&2
test_usage_output() {
file=$1; shift
cmd=$1; shift
assert_file_has_content $file '^Usage'
# check that it didn't print twice somehow
if [ "$(grep --count '^Usage' $file)" != 1 ]; then
_fatal_print_file "$file" "File '$file' has '^Usage' more than once."
fi
assert_file_has_content $file "$cmd"
}
# check that we found at least one command with subcommands
found_subcommands=0
test_recursive() {
local cmd=$1
local root=$2
echo "$cmd" 1>&2
$cmd --help 1>out 2>err
# --help message goes to standard output
if [ "$root" = "1" ] ; then
assert_file_has_content out "[Uu]sage"
assert_file_has_content out "$cmd"
fi
test_usage_output out "$cmd"
assert_file_empty err
builtins=`sed -n '/^Builtin commands/,/^[^ ]/p' <out | tail -n +2`
builtins=`sed -n '/^Builtin \("[^"]*" \)\?Commands:$/,/^$/p' <out | tail -n +2`
if [ "$builtins" != "" ] ; then
found_subcommands=1
# A command with subcommands
# Running the command without a subcommand should produce the help output, but fail
set +e
$cmd 1>out 2>err
if [ $? = 0 ] ; then
echo 1>&2 "missing subcommand but 0 exit status"; exit 1
rc=0
$cmd 1>out 2>err || rc=$?
if [ $rc = 0 ] ; then
assert_not_reached "missing subcommand but 0 exit status"
fi
set -euo pipefail
# error message and usage goes to standard error
assert_file_has_content err "[Uu]sage"
assert_file_has_content err "$cmd"
assert_file_has_content err "Builtin commands"
test_usage_output err "$cmd"
assert_file_has_content err 'No \("[^"]*" sub\)\?command specified'
assert_file_empty out
for subcmd in $builtins ; do
test_recursive "$cmd $subcmd" 0
rc=0
$cmd non-existent-subcommand 1>out 2>err || rc=$?
if [ $rc = 0 ] ; then
assert_not_reached "non-existent subcommand but 0 exit status"
fi
test_usage_output err "$cmd"
assert_file_has_content err 'Unknown \("[^"]*" sub\)\?command'
assert_file_empty out
for subcmd in $builtins; do
test_recursive "$cmd $subcmd"
done
fi
}
test_recursive ostree 1
test_recursive ostree
if [ $found_subcommands != 1 ]; then
assert_not_reached "no ostree commands with subcommands found!"
fi
echo "ok help option is properly supported"
+67 -19
View File
@@ -35,6 +35,7 @@ typedef struct {
int fd;
int fd_empty;
char *tmpd;
GError *skip_all;
} TestData;
static void
@@ -136,7 +137,13 @@ test_data_init (TestData *td)
g_assert_cmpint (0, ==, mkdir ("repo", 0755));
ostree_repo_create (td->repo, OSTREE_REPO_MODE_BARE_USER, NULL, &error);
g_assert_no_error (error);
/* G_IO_ERROR_NOT_SUPPORTED probably means no extended attribute support */
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
g_propagate_prefixed_error (&td->skip_all, g_steal_pointer (&error),
"Unable to set up repository: ");
else
g_assert_no_error (error);
}
}
@@ -169,6 +176,12 @@ test_libarchive_noautocreate_empty (gconstpointer data)
OstreeRepoImportArchiveOptions opts = { 0, };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
if (td->skip_all != NULL)
{
g_test_skip (td->skip_all->message);
return;
}
test_archive_setup (td->fd_empty, a);
(void)ostree_repo_import_archive_to_mtree (td->repo, &opts, a, mtree, NULL, NULL, &error);
@@ -185,6 +198,12 @@ test_libarchive_autocreate_empty (gconstpointer data)
OstreeRepoImportArchiveOptions opts = { 0, };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
if (td->skip_all != NULL)
{
g_test_skip (td->skip_all->message);
return;
}
opts.autocreate_parents = 1;
test_archive_setup (td->fd_empty, a);
@@ -203,6 +222,12 @@ test_libarchive_error_device_file (gconstpointer data)
OstreeRepoImportArchiveOptions opts = { 0, };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
if (td->skip_all != NULL)
{
g_test_skip (td->skip_all->message);
return;
}
test_archive_setup (td->fd, a);
(void)ostree_repo_import_archive_to_mtree (td->repo, &opts, a, mtree, NULL, NULL, &error);
@@ -235,34 +260,31 @@ import_write_and_ref (OstreeRepo *repo,
OstreeRepoCommitModifier *modifier,
GError **error)
{
gboolean ret = FALSE;
glnx_unref_object GFile *root = NULL;
g_autofree char *commit_checksum = NULL;
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
g_autoptr(OstreeMutableTree) mtree = ostree_mutable_tree_new ();
if (!ostree_repo_prepare_transaction (repo, NULL, NULL, error))
goto out;
return FALSE;
if (!ostree_repo_import_archive_to_mtree (repo, opts, a, mtree, modifier,
NULL, error))
goto out;
return FALSE;
g_autoptr(GFile) root = NULL;
if (!ostree_repo_write_mtree (repo, mtree, &root, NULL, error))
goto out;
return FALSE;
g_autofree char *commit_checksum = NULL;
if (!ostree_repo_write_commit (repo, NULL, "", "", NULL,
OSTREE_REPO_FILE (root),
&commit_checksum, NULL, error))
goto out;
return FALSE;
ostree_repo_transaction_set_ref (repo, NULL, ref, commit_checksum);
if (!ostree_repo_commit_transaction (repo, NULL, NULL, error))
goto out;
return FALSE;
ret = TRUE;
out:
return ret;
return TRUE;
}
static void
@@ -276,6 +298,12 @@ test_libarchive_ignore_device_file (gconstpointer data)
if (skip_if_no_xattr (td))
goto out;
if (td->skip_all != NULL)
{
g_test_skip (td->skip_all->message);
goto out;
}
test_archive_setup (td->fd, a);
opts.ignore_unsupported_content = TRUE;
@@ -338,6 +366,12 @@ test_libarchive_ostree_convention (gconstpointer data)
if (skip_if_no_xattr (td))
goto out;
if (td->skip_all != NULL)
{
g_test_skip (td->skip_all->message);
goto out;
}
test_archive_setup (td->fd, a);
opts.autocreate_parents = TRUE;
@@ -376,12 +410,18 @@ test_libarchive_xattr_callback (gconstpointer data)
GError *error = NULL;
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
OstreeRepoCommitModifier *modifier = NULL;
g_autoptr(OstreeRepoCommitModifier) modifier = NULL;
char buf[7] = { 0 };
if (skip_if_no_xattr (td))
goto out;
if (td->skip_all != NULL)
{
g_test_skip (td->skip_all->message);
goto out;
}
modifier = ostree_repo_commit_modifier_new (0, NULL, NULL, NULL);
ostree_repo_commit_modifier_set_xattr_callback (modifier, xattr_cb,
NULL, NULL);
@@ -409,8 +449,6 @@ test_libarchive_xattr_callback (gconstpointer data)
g_assert_cmpstr (buf, ==, "mydata");
out:
if (modifier)
ostree_repo_commit_modifier_unref (modifier);
g_assert_no_error (error);
}
@@ -437,6 +475,12 @@ entry_pathname_test_helper (gconstpointer data, gboolean on)
if (skip_if_no_xattr (td))
goto out;
if (td->skip_all != NULL)
{
g_test_skip (td->skip_all->message);
goto out;
}
modifier = ostree_repo_commit_modifier_new (0, NULL, NULL, NULL);
ostree_repo_commit_modifier_set_xattr_callback (modifier, path_cb,
NULL, &met_etc_file);
@@ -494,12 +538,18 @@ test_libarchive_selinux (gconstpointer data)
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
glnx_unref_object OstreeSePolicy *sepol = NULL;
OstreeRepoCommitModifier *modifier = NULL;
g_autoptr(OstreeRepoCommitModifier) modifier = NULL;
char buf[64] = { 0 };
if (skip_if_no_xattr (td))
goto out;
if (td->skip_all != NULL)
{
g_test_skip (td->skip_all->message);
goto out;
}
{
glnx_unref_object GFile *root = g_file_new_for_path ("/");
@@ -536,8 +586,6 @@ test_libarchive_selinux (gconstpointer data)
g_assert_cmpstr (buf, ==, "system_u:object_r:etc_t:s0");
out:
if (modifier)
ostree_repo_commit_modifier_unref (modifier);
g_assert_no_error (error);
}
+77 -13
View File
@@ -26,14 +26,14 @@ fi
. $(dirname $0)/libtest.sh
echo "1..20"
echo "1..13"
setup_test_repository "bare"
cd ${test_tmpdir}
mkdir foo
cd foo
mkdir -p usr/bin
mkdir -p usr/bin usr/lib
echo contents > usr/bin/foo
touch usr/bin/foo0
ln usr/bin/foo usr/bin/bar
@@ -45,8 +45,12 @@ ln usr/bin/foo0 usr/local/bin/baz0
ln usr/bin/sl usr/local/bin/slhl
touch usr/bin/setuidme
touch usr/bin/skipme
echo "a library" > usr/lib/libfoo.so
echo "another library" > usr/lib/libbar.so
# Create a tar archive
tar -c -z -f ../foo.tar.gz .
# Create a cpio archive
find . | cpio -o -H newc > ../foo.cpio
cd ..
@@ -71,10 +75,17 @@ $OSTREE commit -s "from cpio" -b test-cpio \
echo "ok cpio commit"
assert_valid_checkout () {
cd ${test_tmpdir}
$OSTREE checkout test-$1 test-$1-checkout
cd test-$1-checkout
ref=$1
rm test-${ref}-checkout -rf
$OSTREE checkout test-${ref} test-${ref}-checkout
assert_valid_content test-${ref}-checkout
rm -rf test-${ref}-checkout
}
assert_valid_content () {
dn=$1
cd ${dn}
# basic content check
assert_file_has_content usr/bin/foo contents
assert_file_has_content usr/bin/bar contents
@@ -82,39 +93,35 @@ assert_valid_checkout () {
assert_file_empty usr/bin/foo0
assert_file_empty usr/bin/bar0
assert_file_empty usr/local/bin/baz0
echo "ok $1 contents"
assert_file_has_content usr/lib/libfoo.so 'a library'
assert_file_has_content usr/lib/libbar.so 'another library'
# hardlinks
assert_files_hardlinked usr/bin/foo usr/bin/bar
assert_files_hardlinked usr/bin/foo usr/local/bin/baz
echo "ok $1 hardlink"
assert_files_hardlinked usr/bin/foo0 usr/bin/bar0
assert_files_hardlinked usr/bin/foo0 usr/local/bin/baz0
echo "ok $1 hardlink to empty files"
# symlinks
assert_symlink_has_content usr/bin/sl foo
assert_file_has_content usr/bin/sl contents
echo "ok $1 symlink"
# ostree checkout doesn't care if two symlinks are actually hardlinked
# together (which is fine). checking that it's also a symlink is good enough.
assert_symlink_has_content usr/local/bin/slhl foo
echo "ok $1 hardlink to symlink"
# stat override
test -u usr/bin/setuidme
echo "ok $1 setuid"
# skip list
test ! -f usr/bin/skipme
echo "ok $1 file skip"
cd ${test_tmpdir}
rm -rf test-$1-checkout
}
assert_valid_checkout tar
echo "ok tar contents"
assert_valid_checkout cpio
echo "ok cpio contents"
cd ${test_tmpdir}
mkdir multicommit-files
@@ -154,3 +161,60 @@ $OSTREE checkout partial partial-checkout
cd partial-checkout
assert_file_has_content subdir/original "original"
echo "ok tar partial commit contents"
uid=$(id -u)
gid=$(id -g)
autocreate_args="--tar-autocreate-parents --owner-uid=${uid} --owner-gid=${gid}"
cd ${test_tmpdir}
tar -cf empty.tar.gz -T /dev/null
$OSTREE commit -b tar-empty ${autocreate_args} --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"
# noop pathname filter
cd ${test_tmpdir}
$OSTREE commit -b test-tar ${autocreate_args} \
--tar-pathname-filter='^nosuchfile/,nootherfile/' \
--statoverride=statoverride.txt \
--skip-list=skiplist.txt \
--tree=tar=foo.tar.gz
rm test-tar-co -rf
$OSTREE checkout test-tar test-tar-co
assert_valid_content ${test_tmpdir}/test-tar-co
echo "ok tar pathname filter prefix (noop)"
# Add a prefix
cd ${test_tmpdir}
# Update the metadata overrides matching our pathname filter
for f in statoverride.txt skiplist.txt; do
sed -i -e 's,/usr/,/foo/usr/,' $f
done
$OSTREE commit -b test-tar ${autocreate_args} \
--tar-pathname-filter='^,foo/' \
--statoverride=statoverride.txt \
--skip-list=skiplist.txt \
--tree=tar=foo.tar.gz
rm test-tar-co -rf
$OSTREE checkout test-tar test-tar-co
assert_has_dir test-tar-co/foo
assert_valid_content ${test_tmpdir}/test-tar-co/foo
echo "ok tar pathname filter prefix"
# Test anchored and not-anchored
for filter in '^usr/bin/,usr/sbin/' '/bin/,/sbin/'; do
cd ${test_tmpdir}
$OSTREE commit -b test-tar ${autocreate_args} \
--tar-pathname-filter=$filter \
--tree=tar=foo.tar.gz
rm test-tar-co -rf
$OSTREE checkout test-tar test-tar-co
cd test-tar-co
# Check that we just had usr/bin → usr/sbin
assert_not_has_file usr/bin/foo
assert_file_has_content usr/sbin/foo contents
assert_not_has_file usr/sbin/libfoo.so
assert_file_has_content usr/lib/libfoo.so 'a library'
echo "ok tar pathname filter modification: ${filter}"
done
+2 -2
View File
@@ -21,13 +21,13 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_test_repository "archive-z2"
setup_test_repository "archive"
echo "1..1"
cd ${test_tmpdir}
mkdir repo2
ostree_repo_init repo2 --mode="archive-z2"
ostree_repo_init repo2 --mode="archive"
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
find repo2/objects -name '*.commit' | wc -l > commitcount
+6 -6
View File
@@ -28,7 +28,7 @@ skip_without_user_xattrs
echo "1..8"
setup_test_repository "archive-z2"
setup_test_repository "archive"
echo "ok setup"
cd ${test_tmpdir}
@@ -40,7 +40,7 @@ ${CMD_PREFIX} ostree --repo=repo2 fsck
echo "ok pull-local z2 to bare-user"
mkdir repo3
ostree_repo_init repo3 --mode="archive-z2"
ostree_repo_init repo3 --mode="archive"
${CMD_PREFIX} ostree --repo=repo3 pull-local repo2
${CMD_PREFIX} ostree --repo=repo3 fsck
echo "ok pull-local bare-user to z2"
@@ -62,7 +62,7 @@ cmp checkout1.files checkout3.files
echo "ok checkouts same"
mkdir repo4
ostree_repo_init repo4 --mode="archive-z2"
ostree_repo_init repo4 --mode="archive"
${CMD_PREFIX} ostree --repo=repo4 remote add --gpg-import ${test_tmpdir}/gpghome/key1.asc origin repo
if ${CMD_PREFIX} ostree --repo=repo4 pull-local --remote=origin --gpg-verify repo test2 2>&1; then
assert_not_reached "GPG verification unexpectedly succeeded"
@@ -72,13 +72,13 @@ echo "ok --gpg-verify with no signature"
${OSTREE} gpg-sign --gpg-homedir=${TEST_GPG_KEYHOME} test2 ${TEST_GPG_KEYID_1}
mkdir repo5
ostree_repo_init repo5 --mode="archive-z2"
ostree_repo_init repo5 --mode="archive"
${CMD_PREFIX} ostree --repo=repo5 remote add --gpg-import ${test_tmpdir}/gpghome/key1.asc origin repo
${CMD_PREFIX} ostree --repo=repo5 pull-local --remote=origin --gpg-verify repo test2
echo "ok --gpg-verify"
mkdir repo6
ostree_repo_init repo6 --mode="archive-z2"
ostree_repo_init repo6 --mode="archive"
${CMD_PREFIX} ostree --repo=repo6 remote add --gpg-import ${test_tmpdir}/gpghome/key1.asc origin repo
if ${CMD_PREFIX} ostree --repo=repo6 pull-local --remote=origin --gpg-verify-summary repo test2 2>&1; then
assert_not_reached "GPG summary verification with no summary unexpectedly succeeded"
@@ -97,7 +97,7 @@ ${CMD_PREFIX} ostree --repo=repo6 pull-local --remote=origin --gpg-verify-summar
echo "ok --gpg-verify-summary"
mkdir repo7
ostree_repo_init repo7 --mode="archive-z2"
ostree_repo_init repo7 --mode="archive"
${CMD_PREFIX} ostree --repo=repo7 pull-local repo
${CMD_PREFIX} ostree --repo=repo7 fsck
for src_object in `find repo/objects -name '*.filez'`; do
+1 -1
View File
@@ -21,7 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
echo '1..1'
+1 -1
View File
@@ -25,7 +25,7 @@ skip_without_user_xattrs
echo '1..2'
setup_test_repository "archive-z2"
setup_test_repository "archive"
export OSTREE_GPG_SIGN="${OSTREE} gpg-sign --gpg-homedir=${TEST_GPG_KEYHOME}"
+1 -1
View File
@@ -23,7 +23,7 @@ set -euo pipefail
skip_without_user_xattrs
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
echo '1..5'
+1
View File
@@ -21,6 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
skip_without_user_xattrs
setup_fake_remote_repo1 "archive"
repo_mode=bare-user
+1 -1
View File
@@ -21,7 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
echo '1..1'
+1 -1
View File
@@ -28,7 +28,7 @@ if has_gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi
setup_fake_remote_repo1 "archive-z2" "${COMMIT_SIGN}"
setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}"
# create a summary
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo \
+43 -2
View File
@@ -27,9 +27,9 @@ fi
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
echo '1..2'
echo '1..3'
repopath=${test_tmpdir}/ostree-srv/gnomerepo
cp -a ${repopath} ${repopath}.orig
@@ -59,3 +59,44 @@ gjs $(dirname $0)/corrupt-repo-ref.js ${repopath} main || true
assert_file_has_content corrupted-status.txt 'Changed byte'
do_corrupt_pull_test
echo "ok corruption"
if ! skip_one_without_user_xattrs; then
# Set up a corrupted commit object
rm ostree-srv httpd repo -rf
setup_fake_remote_repo1 "archive"
rev=$(ostree --repo=ostree-srv/gnomerepo rev-parse main)
corruptrev=$(echo ${rev} hello | sha256sum | cut -f 1 -d ' ')
assert_not_streq ${rev} ${corruptrev}
rev_path=ostree-srv/gnomerepo/objects/${rev:0:2}/${rev:2}.commit
corruptrev_path=ostree-srv/gnomerepo/objects/${corruptrev:0:2}/${corruptrev:2}.commit
mkdir -p $(dirname ${corruptrev_path})
mv ${rev_path} ${corruptrev_path}
echo ${corruptrev} > ostree-srv/gnomerepo/refs/heads/main
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u
if ${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo fsck 2>err.txt; then
assert_not_reached "fsck with corrupted commit worked?"
fi
assert_file_has_content err.txt "corrupted object ${corruptrev}\.commit"
# Do a pull-local; this should succeed since we don't verify checksums
# for local repos by default.
rm repo err.txt -rf
ostree_repo_init repo --mode=bare-user
${CMD_PREFIX} ostree --repo=repo pull-local ostree-srv/gnomerepo main
rm repo err.txt -rf
ostree_repo_init repo --mode=bare-user
if ${CMD_PREFIX} ostree --repo=repo pull-local --untrusted ostree-srv/gnomerepo main 2>err.txt; then
assert_not_reached "pull-local --untrusted worked?"
fi
assert_file_has_content err.txt "Corrupted commit object ${corruptrev}.*actual checksum is ${rev}"
rm repo err.txt -rf
ostree_repo_init repo --mode=bare-user
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
if ${CMD_PREFIX} ostree --repo=repo pull origin main 2>err.txt; then
assert_not_reached "pull unexpectedly succeeded!"
fi
assert_file_has_content err.txt "Corrupted commit object ${corruptrev}.*actual checksum is ${rev}"
echo "ok pull commit corruption"
fi
+1 -1
View File
@@ -21,7 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
echo '1..1'
+1 -1
View File
@@ -21,7 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
echo '1..1'
+1 -1
View File
@@ -21,7 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
echo '1..9'
+6 -6
View File
@@ -24,7 +24,7 @@ set -euo pipefail
echo "1..5"
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
setup_fake_remote_repo1 "archive-z2" "${COMMIT_SIGN}"
setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}"
# Now, setup multiple branches
mkdir ${test_tmpdir}/ostree-srv/other-files
@@ -41,7 +41,7 @@ ${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u
prev_dir=`pwd`
cd ${test_tmpdir}
ostree_repo_init repo --mode=archive-z2
ostree_repo_init repo --mode=archive
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull --mirror origin
assert_has_file repo/summary
@@ -69,13 +69,13 @@ cd $prev_dir
cd ${test_tmpdir}
rm -rf repo
ostree_repo_init repo --mode=archive-z2
ostree_repo_init repo --mode=archive
${OSTREE} --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
echo "ok pull mirror without checking signed summary"
cd ${test_tmpdir}
rm -rf repo
ostree_repo_init repo --mode=archive-z2
ostree_repo_init repo --mode=archive
${OSTREE} --repo=repo remote add --set=gpg-verify-summary=true origin $(cat httpd-address)/ostree/gnomerepo
if ${OSTREE} --repo=repo pull --mirror origin 2>err.txt; then
assert_not_reached "Mirroring unexpectedly succeeded"
@@ -86,7 +86,7 @@ ${OSTREE} --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u ${COMMIT_SIGN}
cd ${test_tmpdir}
rm -rf repo
ostree_repo_init repo --mode=archive-z2
ostree_repo_init repo --mode=archive
${OSTREE} --repo=repo remote add --set=gpg-verify-summary=true origin $(cat httpd-address)/ostree/gnomerepo
${OSTREE} --repo=repo pull --mirror origin
assert_has_file repo/summary
@@ -99,7 +99,7 @@ truncate --size=1 ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig
cd ${test_tmpdir}
rm -rf repo
mkdir repo
ostree_repo_init repo --mode=archive-z2
ostree_repo_init repo --mode=archive
${OSTREE} --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
${OSTREE} --repo=repo pull --mirror origin
assert_has_file repo/summary
+1 -1
View File
@@ -23,7 +23,7 @@ set -euo pipefail
echo "1..3"
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
setup_mirror () {
name=$1; shift
+2 -2
View File
@@ -21,7 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
echo '1..1'
@@ -34,7 +34,7 @@ gnomerepo_url="$(cat httpd-address)/ostree/gnomerepo"
mkdir mirror-srv
cd mirror-srv
mkdir gnomerepo
ostree_repo_init gnomerepo --mode "archive-z2"
ostree_repo_init gnomerepo --mode "archive"
${CMD_PREFIX} ostree --repo=gnomerepo remote add --set=gpg-verify=false origin ${gnomerepo_url}
${CMD_PREFIX} ostree --repo=gnomerepo pull --mirror --depth=-1 origin main
+2 -2
View File
@@ -24,10 +24,10 @@ set -euo pipefail
echo "1..1"
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
setup_fake_remote_repo1 "archive-z2" "${COMMIT_SIGN}" --random-500s=50
setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}" --random-500s=50
cd ${test_tmpdir}
ostree_repo_init repo --mode=archive-z2
ostree_repo_init repo --mode=archive
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
for x in $(seq 200); do
if ${CMD_PREFIX} ostree --repo=repo pull --mirror origin main 2>err.txt; then
+1 -1
View File
@@ -21,7 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2" "" "--force-range-requests"
setup_fake_remote_repo1 "archive" "" "--force-range-requests"
echo '1..1'
+1 -1
View File
@@ -21,7 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
echo '1..4'
+3 -3
View File
@@ -24,7 +24,7 @@ set -euo pipefail
echo "1..7"
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
setup_fake_remote_repo1 "archive-z2" "${COMMIT_SIGN}"
setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}"
# Now, setup multiple branches
mkdir ${test_tmpdir}/ostree-srv/other-files
@@ -41,7 +41,7 @@ ${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u
prev_dir=`pwd`
cd ${test_tmpdir}
ostree_repo_init repo --mode=archive-z2
ostree_repo_init repo --mode=archive
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull --mirror origin
assert_has_file repo/summary
@@ -66,7 +66,7 @@ repo_reinit () {
cd ${test_tmpdir}
rm -rf repo
mkdir repo
ostree_repo_init repo --mode=archive-z2
ostree_repo_init repo --mode=archive
${OSTREE} --repo=repo remote add --set=gpg-verify-summary=true origin $(cat httpd-address)/ostree/gnomerepo
}
+29
View File
@@ -103,6 +103,35 @@ ${CMD_PREFIX} ostree --repo=repo refs --collections > refs
assert_file_has_content refs "^(org.example.Collection, ctest)$"
assert_file_has_content refs "^(org.example.NewCollection, ctest-mirror)$"
# Remote refs should be listed if they have collection IDs
cd ${test_tmpdir}
mkdir collection-repo
ostree_repo_init collection-repo --collection-id org.example.RemoteCollection
mkdir -p adir
${CMD_PREFIX} ostree --repo=collection-repo commit --branch=rcommit -m rcommit -s rcommit adir
${CMD_PREFIX} ostree --repo=repo remote add --no-gpg-verify --collection-id org.example.RemoteCollection collection-repo-remote "file://${test_tmpdir}/collection-repo"
${CMD_PREFIX} ostree --repo=repo pull collection-repo-remote rcommit
${CMD_PREFIX} ostree --repo=repo refs --collections > refs
assert_file_has_content refs "^(org.example.RemoteCollection, rcommit)$"
${CMD_PREFIX} ostree --repo=repo refs --collections org.example.RemoteCollection > refs
assert_file_has_content refs "^(org.example.RemoteCollection, rcommit)$"
${CMD_PREFIX} ostree --repo=repo refs --collections org.example.NonexistentID > refs
assert_not_file_has_content refs "^(org.example.RemoteCollection, rcommit)$"
cd ${test_tmpdir}
mkdir no-collection-repo
ostree_repo_init no-collection-repo
mkdir -p adir2
${CMD_PREFIX} ostree --repo=no-collection-repo commit --branch=rcommit2 -m rcommit2 -s rcommit2 adir2
${CMD_PREFIX} ostree --repo=repo remote add --no-gpg-verify no-collection-repo-remote "file://${test_tmpdir}/no-collection-repo"
${CMD_PREFIX} ostree --repo=repo pull no-collection-repo-remote rcommit2
${CMD_PREFIX} ostree --repo=repo refs --collections > refs
assert_not_file_has_content refs "rcommit2"
echo "ok 1 refs collections"
# Test that listing, creating and deleting refs works from an old repository
+1 -1
View File
@@ -21,7 +21,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
echo '1..2'
+1 -1
View File
@@ -24,7 +24,7 @@ echo '1..4'
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2" "" \
setup_fake_remote_repo1 "archive" "" \
"--expected-cookies foo=bar --expected-cookies baz=badger"
assert_fail (){
+1 -1
View File
@@ -24,7 +24,7 @@ set -euo pipefail
# We don't want OSTREE_GPG_HOME used for these tests.
unset OSTREE_GPG_HOME
setup_fake_remote_repo1 "archive-z2"
setup_fake_remote_repo1 "archive"
echo "1..4"
+114
View File
@@ -0,0 +1,114 @@
#!/usr/bin/env gjs
//
// Copyright (C) 2013 Colin Walters <walters@verbum.org>
// Copyright (C) 2017 Dan Nicholson <nicholson@endlessm.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const OSTree = imports.gi.OSTree;
function assertEquals(a, b) {
if (a != b)
throw new Error("assertion failed " + JSON.stringify(a) + " == " + JSON.stringify(b));
}
function assertNotEquals(a, b) {
if (a == b)
throw new Error("assertion failed " + JSON.stringify(a) + " != " + JSON.stringify(b));
}
print('1..6')
let remotesDir = Gio.File.new_for_path('remotes.d');
remotesDir.make_directory(null);
let remoteConfig = GLib.KeyFile.new()
remoteConfig.set_value('remote "foo"', 'url', 'http://foo')
let remoteConfigFile = remotesDir.get_child('foo.conf')
remoteConfig.save_to_file(remoteConfigFile.get_path())
// Use the full Repo constructor to set remotes-config-dir
let repoFile = Gio.File.new_for_path('repo');
let repo = new OSTree.Repo({path: repoFile,
remotes_config_dir: remotesDir.get_path()});
repo.create(OSTree.RepoMode.ARCHIVE_Z2, null);
repo.open(null);
// See if the remotes.d remote exists
let remotes = repo.remote_list()
assertNotEquals(remotes.indexOf('foo'), -1);
print("ok read-remotes-config-dir");
// Adding a remote should not go in the remotes.d dir unless this is a
// system repo or add-remotes-config-dir is set to true
repo.remote_add('bar', 'http://bar', null, null);
remotes = repo.remote_list()
assertNotEquals(remotes.indexOf('bar'), -1);
assertEquals(remotesDir.get_child('bar.conf').query_exists(null), false);
print("ok add-not-in-remotes-config-dir");
// Removing the remotes.d remote should delete the conf file
repo.remote_delete('foo', null);
remotes = repo.remote_list()
assertEquals(remotes.indexOf('foo'), -1);
assertEquals(remotesDir.get_child('foo.conf').query_exists(null), false);
print("ok delete-in-remotes-config-dir");
// Set add-remotes-config-dir to true and check that a remote gets added
// in the config dir
let repoConfig = repo.copy_config();
repoConfig.set_boolean('core', 'add-remotes-config-dir', true);
repo.write_config(repoConfig);
repo.reload_config(null);
repo.remote_add('baz', 'http://baz', null, null);
remotes = repo.remote_list()
assertNotEquals(remotes.indexOf('baz'), -1);
assertEquals(remotesDir.get_child('baz.conf').query_exists(null), true);
print("ok add-in-remotes-config-dir");
// Trying to set a remote config option via write_config() for a remote
// defined in the config file should succeed
let [, gpg_verify] = repo.remote_get_gpg_verify('bar');
assertEquals(gpg_verify, true);
repoConfig = repo.copy_config();
repoConfig.set_boolean('remote "bar"', 'gpg-verify', false);
repo.write_config(repoConfig);
repo.reload_config(null);
[, gpg_verify] = repo.remote_get_gpg_verify('bar');
assertEquals(gpg_verify, false);
print("ok config-remote-in-config-file-succeeds");
// Trying to set a remote config option via write_config() for a remote
// defined in the config dir should fail with G_IO_ERROR_EXISTS
repoConfig = repo.copy_config();
repoConfig.set_boolean('remote "baz"', 'gpg-verify', false);
try {
if (repo.write_config(repoConfig))
throw new Error("config of remote in config dir should fail");
} catch (e) {
if (!(e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.EXISTS)))
throw e;
}
print("ok config-remote-in-config-dir-fails");
+1 -1
View File
@@ -23,7 +23,7 @@ echo "1..1"
. $(dirname $0)/libtest.sh
setup_test_repository "archive-z2"
setup_test_repository "archive"
cd ${test_tmpdir}/files
$OSTREE commit -b testx -s "Another Commit"
cd ${test_tmpdir}
+46 -13
View File
@@ -24,13 +24,16 @@ set -euo pipefail
skip_without_fuse
skip_without_user_xattrs
setup_test_repository "bare-user"
setup_test_repository "bare"
echo "1..6"
echo "1..7"
cd ${test_tmpdir}
mkdir mnt
$OSTREE checkout -U test2 checkout-test2
# The default content set amazingly doesn't have a non-broken link
ln -s firstfile files/firstfile-link
$OSTREE commit -b test2 --tree=dir=files
$OSTREE checkout -H test2 checkout-test2
rofiles-fuse checkout-test2 mnt
cleanup_fuse() {
@@ -40,25 +43,55 @@ trap cleanup_fuse EXIT
assert_file_has_content mnt/firstfile first
echo "ok mount"
if cp /dev/null mnt/firstfile 2>err.txt; then
assert_not_reached "inplace mutation"
# Test open(O_TRUNC) directly and via symlink
for path in firstfile{,-link}; do
if cp /dev/null mnt/${path} 2>err.txt; then
assert_not_reached "inplace mutation ${path}"
fi
assert_file_has_content err.txt "Read-only file system"
assert_file_has_content mnt/firstfile first
assert_file_has_content checkout-test2/firstfile first
done
echo "ok failed inplace mutation (open O_TRUNCATE)"
# Test chmod
if chmod 0600 mnt/firstfile 2>err.txt; then
assert_not_reached "chmod inplace"
fi
assert_file_has_content err.txt "Read-only file system"
assert_file_has_content mnt/firstfile first
assert_file_has_content checkout-test2/firstfile first
echo "ok failed inplace mutation"
assert_file_has_content err.txt "chmod:.*Read-only file system"
# Test chown with regfiles and symlinks
for path in firstfile baz/alink; do
if chown -h $(id -u) mnt/${path} 2>err.txt; then
assert_not_reached "chown inplace ${path}"
fi
assert_file_has_content err.txt "chown:.*Read-only file system"
done
# And test via dereferencing a symlink
if chown $(id -u) mnt/firstfile-link 2>err.txt; then
assert_not_reached "chown inplace firstfile-link"
fi
assert_file_has_content err.txt "chown:.*Read-only file system"
echo "ok failed mutation chmod + chown"
# 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
assert_file_has_content checkout-test2/anewfile-for-fuse anewfile-for-fuse
ln -s anewfile-for-fuse mnt/anewfile-for-fuse-link
# And also test modifications through a symlink
echo writevialink > mnt/anewfile-for-fuse-link
for path in anewfile-for-fuse{,-link}; do
assert_file_has_content mnt/${path} writevialink
done
chown $(id -u) mnt/anewfile-for-fuse-link
mkdir mnt/newfusedir
for i in $(seq 5); do
echo ${i}-morenewfuse-${i} > mnt/newfusedir/test-morenewfuse.${i}
chmod 0600 mnt/newfusedir/test-morenewfuse.${i}
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"
rm mnt/baz/cow
@@ -73,7 +106,7 @@ ${CMD_PREFIX} ostree --repo=repo commit -b test2 -s fromfuse --link-checkout-spe
echo "ok commit"
${CMD_PREFIX} ostree --repo=repo checkout -U test2 mnt/test2-checkout-copy-fallback
assert_file_has_content mnt/test2-checkout-copy-fallback/anewfile-for-fuse anewfile-for-fuse
assert_file_has_content mnt/test2-checkout-copy-fallback/anewfile-for-fuse writevialink
if ${CMD_PREFIX} ostree --repo=repo checkout -UH test2 mnt/test2-checkout-copy-hardlinked 2>err.txt; then
assert_not_reached "Checking out via hardlinks across mountpoint unexpectedly succeeded!"
+25
View File
@@ -55,4 +55,29 @@ ${CMD_PREFIX} ostree --repo=repo summary --update
${CMD_PREFIX} ostree --repo=repo summary --view > summary
assert_file_has_content summary "(org.example.OtherCollection, test-1-mirror)$"
# Test that remote refs are listed, but only if they have collection IDs
cd ${test_tmpdir}
mkdir collection-repo
ostree_repo_init collection-repo --collection-id org.example.RemoteCollection
mkdir -p adir
${CMD_PREFIX} ostree --repo=collection-repo commit --branch=rcommit -m rcommit -s rcommit adir
${CMD_PREFIX} ostree --repo=repo remote add --no-gpg-verify --collection-id org.example.RemoteCollection collection-repo-remote "file://${test_tmpdir}/collection-repo"
${CMD_PREFIX} ostree --repo=repo pull collection-repo-remote rcommit
${CMD_PREFIX} ostree --repo=repo summary --update
${CMD_PREFIX} ostree --repo=repo summary --view > summary
assert_file_has_content summary "(org.example.RemoteCollection, rcommit)$"
cd ${test_tmpdir}
mkdir no-collection-repo
ostree_repo_init no-collection-repo
mkdir -p adir2
${CMD_PREFIX} ostree --repo=no-collection-repo commit --branch=rcommit2 -m rcommit2 -s rcommit2 adir2
${CMD_PREFIX} ostree --repo=repo remote add --no-gpg-verify no-collection-repo-remote "file://${test_tmpdir}/no-collection-repo"
${CMD_PREFIX} ostree --repo=repo pull no-collection-repo-remote rcommit2
${CMD_PREFIX} ostree --repo=repo summary --update
${CMD_PREFIX} ostree --repo=repo summary --view > summary
assert_not_file_has_content summary "rcommit2"
echo "ok summary collections"
+2 -2
View File
@@ -27,7 +27,7 @@ set -euo pipefail
echo "1..2"
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
setup_fake_remote_repo1 "archive-z2" "${COMMIT_SIGN}"
setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}"
# Set up a second branch.
mkdir ${test_tmpdir}/ostree-srv/other-files
@@ -41,7 +41,7 @@ ${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u
# Check out the repository.
prev_dir=`pwd`
cd ${test_tmpdir}
ostree_repo_init repo --mode=archive-z2
ostree_repo_init repo --mode=archive
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull --mirror origin
+1 -1
View File
@@ -52,7 +52,7 @@ echo 'ok documented symbols'
# ONLY update this checksum in release commits!
cat > released-sha256.txt <<EOF
c993c42dee8ee0c52b01d317b214391698818a0c20efe99c5273c60fa9278b3c ${released_syms}
b486764b32fbf3d8b7d16114a206cb0789281fe663a1d3d3c13cc48171be4fd7 ${released_syms}
EOF
sha256sum -c released-sha256.txt
+3 -1
View File
@@ -40,7 +40,9 @@ function libtestExec(shellCode) {
print('1..1')
libtestExec('setup_os_repository archive-z2 syslinux');
libtestExec('setup_os_repository archive syslinux');
GLib.setenv("OSTREE_SYSROOT_DEBUG", "mutable-deployments", true);
let upstreamRepo = OSTree.Repo.new(Gio.File.new_for_path('testos-repo'));
upstreamRepo.open(null);
+1 -1
View File
@@ -28,7 +28,7 @@ skip_without_user_xattrs
echo "1..2"
setup_test_repository "archive-z2"
setup_test_repository "archive"
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=repo checkout test2 test2-checkout1