Blame tests/basic-test.sh

rpm-build 0fba15
# This file is to be sourced, not executed
rpm-build 0fba15
rpm-build 0fba15
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
rpm-build 0fba15
#
rpm-build 0fba15
# SPDX-License-Identifier: LGPL-2.0+
rpm-build 0fba15
#
rpm-build 0fba15
# This library is free software; you can redistribute it and/or
rpm-build 0fba15
# modify it under the terms of the GNU Lesser General Public
rpm-build 0fba15
# License as published by the Free Software Foundation; either
rpm-build 0fba15
# version 2 of the License, or (at your option) any later version.
rpm-build 0fba15
#
rpm-build 0fba15
# This library is distributed in the hope that it will be useful,
rpm-build 0fba15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build 0fba15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build 0fba15
# Lesser General Public License for more details.
rpm-build 0fba15
#
rpm-build 0fba15
# You should have received a copy of the GNU Lesser General Public
rpm-build 0fba15
# License along with this library; if not, write to the
rpm-build 0fba15
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
rpm-build 0fba15
# Boston, MA 02111-1307, USA.
rpm-build 0fba15
rpm-build 0fba15
set -euo pipefail
rpm-build 0fba15
rpm-build 0fba15
echo "1..$((86 + ${extra_basic_tests:-0}))"
rpm-build 0fba15
rpm-build 0fba15
CHECKOUT_U_ARG=""
rpm-build 0fba15
CHECKOUT_H_ARGS="-H"
rpm-build 0fba15
COMMIT_ARGS=""
rpm-build 0fba15
DIFF_ARGS=""
rpm-build 0fba15
if is_bare_user_only_repo repo; then
rpm-build 0fba15
    # In bare-user-only repos we can only represent files with uid/gid 0, no
rpm-build 0fba15
    # xattrs and canonical permissions, so we need to commit them as such, or
rpm-build 0fba15
    # we end up with repos that don't pass fsck
rpm-build 0fba15
    COMMIT_ARGS="--canonical-permissions"
rpm-build 0fba15
    DIFF_ARGS="--owner-uid=0 --owner-gid=0 --no-xattrs"
rpm-build 0fba15
    # Also, since we can't check out uid=0 files we need to check out in user mode
rpm-build 0fba15
    CHECKOUT_U_ARG="-U"
rpm-build 0fba15
    CHECKOUT_H_ARGS="-U -H"
rpm-build 0fba15
else
rpm-build 0fba15
    if grep -E -q '^mode=bare-user' repo/config; then
rpm-build 0fba15
        CHECKOUT_H_ARGS="-U -H"
rpm-build 0fba15
    fi
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
# This should be dynamic now
rpm-build 0fba15
assert_not_has_dir repo/uncompressed-objects-cache
rpm-build 0fba15
rpm-build 0fba15
validate_checkout_basic() {
rpm-build 0fba15
    (cd $1;
rpm-build 0fba15
     assert_has_file firstfile
rpm-build 0fba15
     assert_has_file baz/cow
rpm-build 0fba15
     assert_file_has_content baz/cow moo
rpm-build 0fba15
     assert_has_file baz/deeper/ohyeah
rpm-build 0fba15
     assert_symlink_has_content somelink nosuchfile
rpm-build 0fba15
     )
rpm-build 0fba15
}
rpm-build 0fba15
rpm-build 0fba15
$OSTREE checkout test2 checkout-test2
rpm-build 0fba15
validate_checkout_basic checkout-test2
rpm-build 0fba15
if grep -q 'mode=bare$' repo/config; then
rpm-build 0fba15
    assert_not_streq $(stat -c '%h' checkout-test2/firstfile) 1
rpm-build 0fba15
fi
rpm-build 0fba15
echo "ok checkout"
rpm-build 0fba15
rpm-build 0fba15
# Note this tests bare-user *and* bare-user-only
rpm-build 0fba15
rm checkout-test2 -rf
rpm-build 0fba15
if grep -q bare-user repo/config; then
rpm-build 0fba15
    $OSTREE checkout -U -H test2 checkout-test2
rpm-build 0fba15
else
rpm-build 0fba15
    $OSTREE checkout -H test2 checkout-test2
rpm-build 0fba15
fi
rpm-build 0fba15
validate_checkout_basic checkout-test2
rpm-build 0fba15
rm checkout-test2 -rf
rpm-build 0fba15
# Only do these tests on bare-user/bare, not bare-user-only
rpm-build 0fba15
# since the latter automatically synthesizes -U if it's not passed.
rpm-build 0fba15
if ! is_bare_user_only_repo repo; then
rpm-build 0fba15
if grep -q bare-user repo/config; then
rpm-build 0fba15
    if $OSTREE checkout -H test2 checkout-test2 2>err.txt; then
rpm-build 0fba15
        assert_not_reached "checkout -H worked?"
rpm-build 0fba15
    fi
rpm-build 0fba15
    assert_file_has_content err.txt "User repository.*requires.*user"
rpm-build 0fba15
else
rpm-build 0fba15
    if $OSTREE checkout -U -H test2 checkout-test2 2>err.txt; then
rpm-build 0fba15
        assert_not_reached "checkout -H worked?"
rpm-build 0fba15
    fi
rpm-build 0fba15
    assert_file_has_content err.txt "Bare repository mode cannot hardlink in user"
rpm-build 0fba15
fi
rpm-build 0fba15
fi
rpm-build 0fba15
echo "ok checkout -H"
rpm-build 0fba15
rpm-build 0fba15
rm checkout-test2 -rf
rpm-build 0fba15
$OSTREE checkout -C test2 checkout-test2
rpm-build 0fba15
for file in firstfile baz/cow baz/alink; do
rpm-build 0fba15
    assert_streq $(stat -c '%h' checkout-test2/$file) 1
rpm-build 0fba15
done
rpm-build 0fba15
rpm-build 0fba15
echo "ok checkout -C"
rpm-build 0fba15
rpm-build 0fba15
$OSTREE rev-parse test2
rpm-build 0fba15
$OSTREE rev-parse 'test2^'
rpm-build 0fba15
$OSTREE rev-parse 'test2^^' 2>/dev/null && fatal "rev-parse test2^^ unexpectedly succeeded!"
rpm-build 0fba15
echo "ok rev-parse"
rpm-build 0fba15
rpm-build 0fba15
checksum=$($OSTREE rev-parse test2)
rpm-build 0fba15
partial=${checksum:0:6} 
rpm-build 0fba15
echo "partial:" $partial
rpm-build 0fba15
echo "corresponds to:" $checksum
rpm-build 0fba15
$OSTREE rev-parse test2 > checksum
rpm-build 0fba15
$OSTREE rev-parse $partial > partial-results
rpm-build 0fba15
assert_file_has_content checksum $(cat partial-results)
rpm-build 0fba15
echo "ok shortened checksum"
rpm-build 0fba15
rpm-build 0fba15
(cd repo && ${CMD_PREFIX} ostree rev-parse test2)
rpm-build 0fba15
echo "ok repo-in-cwd"
rpm-build 0fba15
rpm-build 0fba15
if ! skip_one_without_user_xattrs; then
rpm-build 0fba15
    rm test-repo -rf
rpm-build 0fba15
    ostree_repo_init test-repo --mode=bare-user
rpm-build 0fba15
    ostree_repo_init test-repo --mode=bare-user
rpm-build 0fba15
    rm test-repo -rf
rpm-build 0fba15
    echo "ok repo-init on existing repo"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
if ! skip_one_without_user_xattrs; then
rpm-build 0fba15
    rm test-repo -rf
rpm-build 0fba15
    ostree_repo_init test-repo --mode=bare-user
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=test-repo refs
rpm-build 0fba15
    rm -rf test-repo/tmp
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=test-repo refs
rpm-build 0fba15
    assert_has_dir test-repo/tmp
rpm-build 0fba15
    echo "ok autocreate tmp"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
rm checkout-test2 -rf
rpm-build 0fba15
$OSTREE checkout test2 checkout-test2
rpm-build 0fba15
cd checkout-test2
rpm-build 0fba15
rm firstfile
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2 -s delete
rpm-build 0fba15
rpm-build 0fba15
cd $test_tmpdir
rpm-build 0fba15
$OSTREE checkout test2 $test_tmpdir/checkout-test2-2
rpm-build 0fba15
cd $test_tmpdir/checkout-test2-2
rpm-build 0fba15
assert_not_has_file firstfile
rpm-build 0fba15
assert_has_file baz/saucer
rpm-build 0fba15
echo "ok removal"
rpm-build 0fba15
rpm-build 0fba15
mkdir -p a/nested/tree
rpm-build 0fba15
echo one > a/nested/tree/1
rpm-build 0fba15
echo two2 > a/nested/2
rpm-build 0fba15
echo 3 > a/nested/3
rpm-build 0fba15
touch a/4
rpm-build 0fba15
echo fivebaby > a/5
rpm-build 0fba15
touch a/6
rpm-build 0fba15
echo whee > 7
rpm-build 0fba15
mkdir -p another/nested/tree
rpm-build 0fba15
echo anotherone > another/nested/tree/1
rpm-build 0fba15
echo whee2 > another/whee
rpm-build 0fba15
# FIXME - remove grep for .
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Another commit"
rpm-build 0fba15
echo "ok commit"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE checkout test2 $test_tmpdir/checkout-test2-3
rpm-build 0fba15
cd checkout-test2-3
rpm-build 0fba15
assert_has_file a/nested/2
rpm-build 0fba15
assert_file_has_content a/nested/2 'two2'
rpm-build 0fba15
echo "ok stdin contents"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}/checkout-test2-3
rpm-build 0fba15
echo 4 > four
rpm-build 0fba15
mkdir -p yet/another/tree
rpm-build 0fba15
echo leaf > yet/another/tree/green
rpm-build 0fba15
echo helloworld > yet/message
rpm-build 0fba15
rm a/5
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Current directory"
rpm-build 0fba15
echo "ok cwd commit"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE checkout test2 $test_tmpdir/checkout-test2-4
rpm-build 0fba15
cd checkout-test2-4
rpm-build 0fba15
assert_file_has_content yet/another/tree/green 'leaf'
rpm-build 0fba15
assert_file_has_content four '4'
rpm-build 0fba15
echo "ok cwd contents"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm checkout-test2-l -rf
rpm-build 0fba15
$OSTREE checkout ${CHECKOUT_H_ARGS} test2 $test_tmpdir/checkout-test2-l
rpm-build 0fba15
date > $test_tmpdir/checkout-test2-l/newdatefile.txt
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} --link-checkout-speedup --consume -b test2 --tree=dir=$test_tmpdir/checkout-test2-l
rpm-build 0fba15
assert_not_has_dir $test_tmpdir/checkout-test2-l
rpm-build 0fba15
$OSTREE fsck
rpm-build 0fba15
# Some of the later tests are sensitive to state
rpm-build 0fba15
$OSTREE reset test2 test2^
rpm-build 0fba15
$OSTREE prune --refs-only
rpm-build 0fba15
echo "ok consume (nom nom nom)"
rpm-build 0fba15
rpm-build 0fba15
# Test adopt
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm checkout-test2-l -rf
rpm-build 0fba15
$OSTREE checkout ${CHECKOUT_H_ARGS} test2 $test_tmpdir/checkout-test2-l
rpm-build 0fba15
echo 'a file to consume 🍔' > $test_tmpdir/checkout-test2-l/eatme.txt
rpm-build 0fba15
# Save a link to it for device/inode comparison
rpm-build 0fba15
ln $test_tmpdir/checkout-test2-l/eatme.txt $test_tmpdir/eatme-savedlink.txt
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} --link-checkout-speedup --consume -b test2 --tree=dir=$test_tmpdir/checkout-test2-l
rpm-build 0fba15
$OSTREE fsck
rpm-build 0fba15
# Adoption isn't implemented for bare-user yet
rpm-build 0fba15
eatme_objpath=$(ostree_file_path_to_object_path repo test2 /eatme.txt)
rpm-build 0fba15
if grep -q '^mode=bare$' repo/config || is_bare_user_only_repo repo; then
rpm-build 0fba15
    assert_files_hardlinked ${test_tmpdir}/eatme-savedlink.txt ${eatme_objpath}
rpm-build 0fba15
else
rpm-build 0fba15
    if files_are_hardlinked ${test_tmpdir}/eatme-savedlink.txt ${eatme_objpath}; then
rpm-build 0fba15
        fatal "bare-user adopted?"
rpm-build 0fba15
    fi
rpm-build 0fba15
fi
rpm-build 0fba15
assert_not_has_dir $test_tmpdir/checkout-test2-l
rpm-build 0fba15
# Some of the later tests are sensitive to state
rpm-build 0fba15
$OSTREE reset test2 test2^
rpm-build 0fba15
$OSTREE prune --refs-only
rpm-build 0fba15
rm -f ${test_tmpdir}/eatme-savedlink.txt
rpm-build 0fba15
echo "ok adopt"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2-no-parent -s '' $test_tmpdir/checkout-test2-4
rpm-build 0fba15
assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1"
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2-no-parent -s '' --parent=none $test_tmpdir/checkout-test2-4
rpm-build 0fba15
assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1"
rpm-build 0fba15
echo "ok commit no parent"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
# Do the --bind-ref=<the other test branch>, so we store both branches sorted
rpm-build 0fba15
# in metadata and thus the checksums remain the same.
rpm-build 0fba15
empty_rev=$($OSTREE commit ${COMMIT_ARGS} -b test2-no-subject --bind-ref=test2-no-subject-2 -s '' --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
rpm-build 0fba15
omitted_rev=$($OSTREE commit ${COMMIT_ARGS} -b test2-no-subject-2 --bind-ref=test2-no-subject --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
rpm-build 0fba15
assert_streq $empty_rev $omitted_rev
rpm-build 0fba15
echo "ok commit no subject"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
cat >commitmsg.txt <
rpm-build 0fba15
This is a long
rpm-build 0fba15
commit message.
rpm-build 0fba15
rpm-build 0fba15
Build-Host: foo.example.com
rpm-build 0fba15
Crunchy-With-Extra-Ketchup: true
rpm-build 0fba15
EOF
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b branch-with-commitmsg -F commitmsg.txt -s 'a message' $test_tmpdir/checkout-test2-4
rpm-build 0fba15
$OSTREE log branch-with-commitmsg > log.txt
rpm-build 0fba15
assert_file_has_content log.txt '^ *This is a long$'
rpm-build 0fba15
assert_file_has_content log.txt '^ *Build-Host:.*example\.com$'
rpm-build 0fba15
assert_file_has_content log.txt '^ *Crunchy-With.*true$'
rpm-build 0fba15
$OSTREE refs --delete branch-with-commitmsg
rpm-build 0fba15
echo "ok commit body file"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
rpm-build 0fba15
assert_streq $($OSTREE log test2-custom-parent |grep '^commit' | wc -l) "3"
rpm-build 0fba15
prevparent=$($OSTREE rev-parse test2-custom-parent^)
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' --parent=${prevparent} $test_tmpdir/checkout-test2-4
rpm-build 0fba15
assert_streq $($OSTREE log test2-custom-parent |grep '^commit' | wc -l) "3"
rpm-build 0fba15
echo "ok commit custom parent"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
orphaned_rev=$($OSTREE commit ${COMMIT_ARGS} --orphan -s "$(date)" $test_tmpdir/checkout-test2-4)
rpm-build 0fba15
$OSTREE ls ${orphaned_rev} >/dev/null
rpm-build 0fba15
$OSTREE prune --refs-only
rpm-build 0fba15
if $OSTREE ls ${orphaned_rev} 2>err.txt; then
rpm-build 0fba15
    assert_not_reached "Found orphaned commit"
rpm-build 0fba15
fi
rpm-build 0fba15
assert_file_has_content err.txt "No such metadata object"
rpm-build 0fba15
echo "ok commit orphaned"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
# in bare-user-only mode, we canonicalize ownership to 0:0, so checksums won't
rpm-build 0fba15
# match -- we could add a --ignore-ownership option I suppose?
rpm-build 0fba15
if is_bare_user_only_repo repo; then
rpm-build 0fba15
    echo "ok # SKIP checksums won't match up in bare-user-only"
rpm-build 0fba15
else
rpm-build 0fba15
    $OSTREE fsck
rpm-build 0fba15
    CHECKSUM_FLAG=
rpm-build 0fba15
    if [ -n "${OSTREE_NO_XATTRS:-}" ]; then
rpm-build 0fba15
        CHECKSUM_FLAG=--ignore-xattrs
rpm-build 0fba15
    fi
rpm-build 0fba15
    rm -rf checksum-test
rpm-build 0fba15
    $OSTREE checkout test2 checksum-test
rpm-build 0fba15
    find checksum-test/ -type f | while read fn; do
rpm-build 0fba15
        checksum=$($CMD_PREFIX ostree checksum $CHECKSUM_FLAG $fn)
rpm-build 0fba15
        objpath=repo/objects/${checksum::2}/${checksum:2}.file
rpm-build 0fba15
        assert_has_file $objpath
rpm-build 0fba15
        # running `ostree checksum` on the obj might not necessarily match, let's
rpm-build 0fba15
        # just check that they have the same content to confirm that it's
rpm-build 0fba15
        # (probably) the originating file
rpm-build 0fba15
        object_content_checksum=$(sha256sum $objpath | cut -f1 -d' ')
rpm-build 0fba15
        checkout_content_checksum=$(sha256sum $fn | cut -f1 -d' ')
rpm-build 0fba15
        assert_streq "$object_content_checksum" "$checkout_content_checksum"
rpm-build 0fba15
    done
rpm-build 0fba15
    echo "ok checksum CLI"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE diff test2^ test2 > diff-test2
rpm-build 0fba15
assert_file_has_content diff-test2 'D */a/5'
rpm-build 0fba15
assert_file_has_content diff-test2 'A */yet$'
rpm-build 0fba15
assert_file_has_content diff-test2 'A */yet/message$'
rpm-build 0fba15
assert_file_has_content diff-test2 'A */yet/another/tree/green$'
rpm-build 0fba15
echo "ok diff revisions"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}/checkout-test2-4
rpm-build 0fba15
echo afile > oh-look-a-file
rpm-build 0fba15
$OSTREE diff test2 ./ > ${test_tmpdir}/diff-test2-2
rpm-build 0fba15
rm oh-look-a-file
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
assert_file_has_content diff-test2-2 'A *oh-look-a-file$'
rpm-build 0fba15
echo "ok diff cwd"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}/checkout-test2-4
rpm-build 0fba15
$OSTREE diff ${DIFF_ARGS} test2 ./ > ${test_tmpdir}/diff-test2
rpm-build 0fba15
assert_file_empty ${test_tmpdir}/diff-test2
rpm-build 0fba15
$OSTREE diff ${DIFF_ARGS} test2 --owner-uid=$((`id -u`+1)) ./ > ${test_tmpdir}/diff-test2
rpm-build 0fba15
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet$'
rpm-build 0fba15
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/message$'
rpm-build 0fba15
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/another/tree/green$'
rpm-build 0fba15
echo "ok diff file with different uid"
rpm-build 0fba15
rpm-build 0fba15
$OSTREE diff ${DIFF_ARGS} test2 --owner-gid=$((`id -g`+1)) ./ > ${test_tmpdir}/diff-test2
rpm-build 0fba15
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet$'
rpm-build 0fba15
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/message$'
rpm-build 0fba15
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/another/tree/green$'
rpm-build 0fba15
echo "ok diff file with different gid"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}/checkout-test2-4
rpm-build 0fba15
rm four
rpm-build 0fba15
mkdir four
rpm-build 0fba15
touch four/other
rpm-build 0fba15
$OSTREE diff test2 ./ > ${test_tmpdir}/diff-test2-2
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
assert_file_has_content diff-test2-2 'M */four$'
rpm-build 0fba15
echo "ok diff file changing type"
rpm-build 0fba15
rpm-build 0fba15
if ! skip_one_without_user_xattrs; then
rpm-build 0fba15
    cd ${test_tmpdir}
rpm-build 0fba15
    mkdir repo2
rpm-build 0fba15
    # Use a different mode to test hardlinking metadata only
rpm-build 0fba15
    if grep -q 'mode=archive' repo/config || is_bare_user_only_repo repo; then
rpm-build 0fba15
        opposite_mode=bare-user
rpm-build 0fba15
    else
rpm-build 0fba15
        opposite_mode=archive
rpm-build 0fba15
    fi
rpm-build 0fba15
    ostree_repo_init repo2 --mode=$opposite_mode
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo2 pull-local repo >out.txt
rpm-build 0fba15
    assert_file_has_content out.txt "[1-9][0-9]* metadata, [1-9][0-9]* content objects imported"
rpm-build 0fba15
    test2_commitid=$(${CMD_PREFIX} ostree --repo=repo rev-parse test2)
rpm-build 0fba15
    test2_commit_relpath=/objects/${test2_commitid:0:2}/${test2_commitid:2}.commit
rpm-build 0fba15
    assert_files_hardlinked repo/${test2_commit_relpath} repo2/${test2_commit_relpath}
rpm-build 0fba15
    echo "ok pull-local (hardlinking metadata)"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
if ! skip_one_without_user_xattrs; then
rpm-build 0fba15
    cd ${test_tmpdir}
rpm-build 0fba15
    rm repo2 -rf && mkdir repo2
rpm-build 0fba15
    ostree_repo_init repo2 --mode=$opposite_mode
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo2 pull-local --bareuseronly-files repo test2
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo2 fsck -q
rpm-build 0fba15
    echo "ok pull-local --bareuseronly-files"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
rm repo2 -rf
rpm-build 0fba15
ostree_repo_init repo2 --mode="$mode"
rpm-build 0fba15
$CMD_PREFIX ostree --repo=repo2 pull-local --untrusted repo test2
rpm-build 0fba15
target_file_object=$(ostree_file_path_to_relative_object_path repo test2 baz/saucer)
rpm-build 0fba15
target_file_checksum=$(ostree_file_path_to_checksum repo test2 baz/saucer)
rpm-build 0fba15
assert_files_hardlinked repo{,2}/${target_file_object}
rpm-build 0fba15
echo "ok pull-local hardlinking, untrusted"
rpm-build 0fba15
rpm-build 0fba15
if grep -q 'mode=bare' repo/config; then
rpm-build 0fba15
    # Now copy/corrupt an object in a 3rd repo, pull into 2nd (leaving the first pristine)
rpm-build 0fba15
    rm repo{2,3} -rf
rpm-build 0fba15
    ostree_repo_init repo2 --mode="$mode"
rpm-build 0fba15
    ostree_repo_init repo3 --mode="$mode"
rpm-build 0fba15
    # Pull into 3rd repo, corrupt an object
rpm-build 0fba15
    $CMD_PREFIX ostree --repo=repo3 pull-local repo test2
rpm-build 0fba15
    cp -a --reflink=auto repo3/${target_file_object}{,.tmp}
rpm-build 0fba15
    mv repo3/${target_file_object}{.tmp,}
rpm-build 0fba15
    echo blah >> repo3/${target_file_object}
rpm-build 0fba15
    if $CMD_PREFIX ostree --repo=repo2 pull-local --untrusted repo3 2>err.txt; then
rpm-build 0fba15
        assert_not_reached "pulled --untrusted from corrupted repo"
rpm-build 0fba15
    fi
rpm-build 0fba15
    assert_file_has_content err.txt 'Corrupted.*'${target_file_checksum}
rpm-build 0fba15
    rm -f err.txt
rpm-build 0fba15
    # But this one should succeed
rpm-build 0fba15
    $CMD_PREFIX ostree --repo=repo2 pull-local repo3
rpm-build 0fba15
    if $CMD_PREFIX ostree --repo=repo2 fsck 2>err.txt; then
rpm-build 0fba15
        fatal "repo should have pulled corrupted object"
rpm-build 0fba15
    fi
rpm-build 0fba15
    assert_file_has_content err.txt 'Corrupted.*'${target_file_checksum}
rpm-build 0fba15
fi
rpm-build 0fba15
echo "ok pull-local --untrusted corruption"
rpm-build 0fba15
rm repo{2,3} -rf
rpm-build 0fba15
rpm-build 0fba15
# This is mostly a copy of the suid test in test-basic-user-only.sh,
rpm-build 0fba15
# but for the `pull --bareuseronly-files` case.
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm repo-input -rf
rpm-build 0fba15
ostree_repo_init repo-input init --mode=archive
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
cat > statoverride.txt <
rpm-build 0fba15
2048 /some-setuid
rpm-build 0fba15
EOF
rpm-build 0fba15
mkdir -p files/
rpm-build 0fba15
echo "a setuid file" > files/some-setuid
rpm-build 0fba15
chmod 0644 files/some-setuid
rpm-build 0fba15
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-suid --statoverride=statoverride.txt --tree=dir=files
rpm-build 0fba15
if $CMD_PREFIX ostree pull-local --repo=repo --bareuseronly-files repo-input content-with-suid 2>err.txt; then
rpm-build 0fba15
    assert_not_reached "copying suid file with --bareuseronly-files worked?"
rpm-build 0fba15
fi
rpm-build 0fba15
assert_file_has_content err.txt 'Content object.*: invalid mode.*with bits 040.*'
rpm-build 0fba15
echo "ok pull-local (bareuseronly files)"
rpm-build 0fba15
rpm-build 0fba15
if ! skip_one_without_user_xattrs; then
rpm-build 0fba15
    cd ${test_tmpdir}
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo checkout ${CHECKOUT_U_ARG} test2 test2-checkout-from-local-clone
rpm-build 0fba15
    cd test2-checkout-from-local-clone
rpm-build 0fba15
    assert_file_has_content yet/another/tree/green 'leaf'
rpm-build 0fba15
    echo "ok local clone checkout"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
$OSTREE checkout -U test2 checkout-user-test2
rpm-build 0fba15
echo "ok user checkout"
rpm-build 0fba15
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Another commit" --tree=ref=test2
rpm-build 0fba15
echo "ok commit from ref"
rpm-build 0fba15
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Another commit with modifier" --tree=ref=test2 --owner-uid=`id -u`
rpm-build 0fba15
echo "ok commit from ref with modifier"
rpm-build 0fba15
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b trees/test2 -s 'ref with / in it' --tree=ref=test2
rpm-build 0fba15
echo "ok commit ref with /"
rpm-build 0fba15
rpm-build 0fba15
mkdir badutf8
rpm-build 0fba15
echo "invalid utf8 filename" > badutf8/$(printf '\x80')
rpm-build 0fba15
if $OSTREE commit ${COMMIT_ARGS} -b badutf8 --tree=dir=badutf8 2>err.txt; then
rpm-build 0fba15
    assert_not_reached "commit filename with invalid UTF-8"
rpm-build 0fba15
fi
rpm-build 0fba15
assert_file_has_content err.txt "Invalid UTF-8 in filename"
rpm-build 0fba15
echo "ok commit bad UTF-8"
rpm-build 0fba15
rpm-build 0fba15
old_rev=$($OSTREE rev-parse test2)
rpm-build 0fba15
$OSTREE ls -R -C test2
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} --skip-if-unchanged -b trees/test2 -s 'should not be committed' --tree=ref=test2
rpm-build 0fba15
$OSTREE ls -R -C test2
rpm-build 0fba15
new_rev=$($OSTREE rev-parse test2)
rpm-build 0fba15
assert_streq "${old_rev}" "${new_rev}"
rpm-build 0fba15
echo "ok commit --skip-if-unchanged"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}/checkout-test2-4
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2 -s "no xattrs" --no-xattrs
rpm-build 0fba15
echo "ok commit with no xattrs"
rpm-build 0fba15
rpm-build 0fba15
mkdir tree-A tree-B
rpm-build 0fba15
touch tree-A/file-a tree-B/file-b
rpm-build 0fba15
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-1 -s "Initial tree" --tree=dir=tree-A
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-2 -s "Replacement tree" --tree=dir=tree-B
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-combined -s "combined tree" --tree=ref=test3-1 --tree=ref=test3-2
rpm-build 0fba15
rpm-build 0fba15
$OSTREE checkout test3-combined checkout-test3-combined
rpm-build 0fba15
rpm-build 0fba15
assert_has_file checkout-test3-combined/file-a
rpm-build 0fba15
assert_has_file checkout-test3-combined/file-b
rpm-build 0fba15
rpm-build 0fba15
mkdir -p tree-C/usr/share tree-C/usr/bin tree-C/etc tree-D/etc
rpm-build 0fba15
rpm-build 0fba15
echo exe >tree-C/usr/bin/exe
rpm-build 0fba15
echo sudoers1 >tree-C/etc/sudoers
rpm-build 0fba15
echo mtab >tree-C/etc/mtab
rpm-build 0fba15
rpm-build 0fba15
echo sudoers2 >tree-D/etc/sudoers
rpm-build 0fba15
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-C1 --tree=dir=tree-C
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-D --tree=dir=tree-D
rpm-build 0fba15
rpm-build 0fba15
echo sudoers2 >tree-C/etc/sudoers
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-C2 --tree=dir=tree-C
rpm-build 0fba15
echo sudoers1 >tree-C/etc/sudoers
rpm-build 0fba15
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-ref-ref --tree=ref=test3-C1 --tree=ref=test3-D
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-dir-ref --tree=dir=tree-C --tree=ref=test3-D
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-ref-dir --tree=ref=test3-C1 --tree=dir=tree-D
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-dir-dir --tree=dir=tree-C --tree=dir=tree-D
rpm-build 0fba15
rpm-build 0fba15
assert_trees_identical() {
rpm-build 0fba15
    $OSTREE diff "$1" "$2" > "diff-$1-$2"
rpm-build 0fba15
    cat "diff-$1-$2" 1>&2
rpm-build 0fba15
    assert_file_empty "diff-$1-$2"
rpm-build 0fba15
    rm "diff-$1-$2"
rpm-build 0fba15
}
rpm-build 0fba15
rpm-build 0fba15
for x in ref dir
rpm-build 0fba15
do
rpm-build 0fba15
    for y in ref dir
rpm-build 0fba15
    do
rpm-build 0fba15
        assert_trees_identical test3-C2 "test3-$x-$y"
rpm-build 0fba15
    done
rpm-build 0fba15
done
rpm-build 0fba15
rpm-build 0fba15
# Regression test
rpm-build 0fba15
rpm-build 0fba15
mkdir -p tree-E/etc
rpm-build 0fba15
mkdir -p tree-F/etc/apt/sources.list.d/
rpm-build 0fba15
echo contents >tree-F/etc/apt/sources.list.d/universe.list
rpm-build 0fba15
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-E --tree=dir=tree-E
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-F --tree=dir=tree-F
rpm-build 0fba15
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test3-F2 --tree=ref=test3-E --tree=ref=test3-F
rpm-build 0fba15
rpm-build 0fba15
assert_trees_identical test3-F test3-F2
rpm-build 0fba15
rpm-build 0fba15
echo "ok commit combined ref trees"
rpm-build 0fba15
rpm-build 0fba15
# NB: The + is optional, but we need to make sure we support it
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
cat > test-statoverride.txt <
rpm-build 0fba15
+1048 /a/nested/2
rpm-build 0fba15
2048 /a/nested/3
rpm-build 0fba15
=384 /a/readable-only
rpm-build 0fba15
EOF
rpm-build 0fba15
cd ${test_tmpdir}/checkout-test2-4
rpm-build 0fba15
echo readable only > a/readable-only
rpm-build 0fba15
chmod 664 a/readable-only
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2-override -s "with statoverride" --statoverride=../test-statoverride.txt
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE checkout test2-override checkout-test2-override
rpm-build 0fba15
if ! is_bare_user_only_repo repo; then
rpm-build 0fba15
    test -g checkout-test2-override/a/nested/2
rpm-build 0fba15
    test -u checkout-test2-override/a/nested/3
rpm-build 0fba15
else
rpm-build 0fba15
    test '!' -g checkout-test2-override/a/nested/2
rpm-build 0fba15
    test '!' -u checkout-test2-override/a/nested/3
rpm-build 0fba15
fi
rpm-build 0fba15
assert_file_has_mode checkout-test2-override/a/readable-only 600
rpm-build 0fba15
echo "ok commit statoverride"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm test2-checkout -rf
rpm-build 0fba15
$OSTREE checkout test2 test2-checkout
rpm-build 0fba15
cd test2-checkout
rpm-build 0fba15
install -m 0755 /dev/null user-wx
rpm-build 0fba15
install -m 0575 /dev/null group-wx
rpm-build 0fba15
install -m 0775 /dev/null both-wx
rpm-build 0fba15
install -m 0555 /dev/null ugox
rpm-build 0fba15
install -m 0644 /dev/null user-writable
rpm-build 0fba15
cd ..
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2-w-xor-x --mode-ro-executables --tree=dir=test2-checkout
rpm-build 0fba15
$OSTREE ls test2-w-xor-x > ls.txt
rpm-build 0fba15
for x in /{user,group,both}-wx; do
rpm-build 0fba15
    assert_file_has_content ls.txt '^-00555 .*'$x
rpm-build 0fba15
done
rpm-build 0fba15
assert_file_has_content ls.txt '^-00644 .*/user-writable'
rpm-build 0fba15
echo "ok commit --mode-ro-executables"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
cat > test-skiplist.txt <
rpm-build 0fba15
/a/nested/3
rpm-build 0fba15
EOF
rpm-build 0fba15
cd ${test_tmpdir}/checkout-test2-4
rpm-build 0fba15
assert_has_file a/nested/3
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2-skiplist -s "with skiplist" --skip-list=../test-skiplist.txt
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE checkout test2-skiplist checkout-test2-skiplist
rpm-build 0fba15
assert_not_has_file checkout-test2-skiplist/a/nested/3
rpm-build 0fba15
echo "ok commit skiplist"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE prune
rpm-build 0fba15
echo "ok prune didn't fail"
rpm-build 0fba15
rpm-build 0fba15
# https://github.com/ostreedev/ostree/issues/1467
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
mv repo/refs/remotes{,.orig}
rpm-build 0fba15
if $OSTREE refs --list >/dev/null 2>err.txt; then
rpm-build 0fba15
    fatal "listed refs without remotes dir?"
rpm-build 0fba15
fi
rpm-build 0fba15
assert_file_has_content err.txt 'Listing refs.*opendir.*No such file or directory'
rpm-build 0fba15
mv repo/refs/remotes{.orig,}
rpm-build 0fba15
$OSTREE refs --list >/dev/null
rpm-build 0fba15
echo "ok refs enoent error"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
# Verify we can't cat dirs
rpm-build 0fba15
for path in / /baz; do
rpm-build 0fba15
    if $OSTREE cat test2 $path 2>err.txt; then
rpm-build 0fba15
        assert_not_reached "cat directory"
rpm-build 0fba15
    fi
rpm-build 0fba15
    assert_file_has_content err.txt "open directory"
rpm-build 0fba15
done
rpm-build 0fba15
rm checkout-test2 -rf
rpm-build 0fba15
$OSTREE cat test2 /yet/another/tree/green > greenfile-contents
rpm-build 0fba15
assert_file_has_content greenfile-contents "leaf"
rpm-build 0fba15
$OSTREE checkout test2 checkout-test2
rpm-build 0fba15
ls -alR checkout-test2
rpm-build 0fba15
ln -sr checkout-test2/{four,four-link}
rpm-build 0fba15
ln -sr checkout-test2/{baz/cow,cow-link}
rpm-build 0fba15
ln -sr checkout-test2/{cow-link,cow-link-link}
rpm-build 0fba15
$OSTREE commit -b test2-withlink --tree=dir=checkout-test2
rpm-build 0fba15
if $OSTREE cat test2-withlink /four-link 2>err.txt; then
rpm-build 0fba15
    assert_not_reached "cat directory"
rpm-build 0fba15
fi
rpm-build 0fba15
assert_file_has_content err.txt "open directory"
rpm-build 0fba15
for path in /cow-link /cow-link-link; do
rpm-build 0fba15
    $OSTREE cat test2-withlink $path >contents.txt
rpm-build 0fba15
    assert_file_has_content contents.txt moo
rpm-build 0fba15
done
rpm-build 0fba15
echo "ok cat-file"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE checkout --subpath /yet/another test2 checkout-test2-subpath
rpm-build 0fba15
cd checkout-test2-subpath
rpm-build 0fba15
assert_file_has_content tree/green "leaf"
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm checkout-test2-subpath -rf
rpm-build 0fba15
$OSTREE ls -R test2
rpm-build 0fba15
# Test checking out a file
rpm-build 0fba15
$OSTREE checkout --subpath /baz/saucer test2 checkout-test2-subpath
rpm-build 0fba15
assert_file_has_content checkout-test2-subpath/saucer alien
rpm-build 0fba15
# Test checking out a file without making a subdir
rpm-build 0fba15
mkdir t
rpm-build 0fba15
cd t
rpm-build 0fba15
$OSTREE checkout --subpath /baz/saucer test2 .
rpm-build 0fba15
assert_file_has_content saucer alien
rpm-build 0fba15
rm t -rf
rpm-build 0fba15
echo "ok checkout subpath"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm -rf checkout-test2-skiplist
rpm-build 0fba15
cat > test-skiplist.txt <
rpm-build 0fba15
/baz/saucer
rpm-build 0fba15
/yet/another/tree
rpm-build 0fba15
EOF
rpm-build 0fba15
$OSTREE checkout --skip-list test-skiplist.txt test2 checkout-test2-skiplist
rpm-build 0fba15
cd checkout-test2-skiplist
rpm-build 0fba15
! test -f baz/saucer
rpm-build 0fba15
! test -d yet/another/tree
rpm-build 0fba15
test -f baz/cow
rpm-build 0fba15
test -d baz/deeper
rpm-build 0fba15
echo "ok checkout skip-list"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm -rf checkout-test2-skiplist
rpm-build 0fba15
cat > test-skiplist.txt <
rpm-build 0fba15
/saucer
rpm-build 0fba15
/deeper
rpm-build 0fba15
EOF
rpm-build 0fba15
$OSTREE checkout --skip-list test-skiplist.txt --subpath /baz \
rpm-build 0fba15
  test2 checkout-test2-skiplist
rpm-build 0fba15
cd checkout-test2-skiplist
rpm-build 0fba15
! test -f saucer
rpm-build 0fba15
! test -d deeper
rpm-build 0fba15
test -f cow
rpm-build 0fba15
test -d another
rpm-build 0fba15
echo "ok checkout skip-list with subpath"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE checkout  --union test2 checkout-test2-union
rpm-build 0fba15
find checkout-test2-union | wc -l > union-files-count
rpm-build 0fba15
$OSTREE checkout  --union test2 checkout-test2-union
rpm-build 0fba15
find checkout-test2-union | wc -l > union-files-count.new
rpm-build 0fba15
cmp union-files-count{,.new}
rpm-build 0fba15
cd checkout-test2-union
rpm-build 0fba15
assert_file_has_content ./yet/another/tree/green "leaf"
rpm-build 0fba15
echo "ok checkout union 1"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test-union-add --tree=ref=test2
rpm-build 0fba15
$OSTREE checkout test-union-add checkout-test-union-add
rpm-build 0fba15
echo 'file for union add testing' > checkout-test-union-add/union-add-test
rpm-build 0fba15
echo 'another file for union add testing' > checkout-test-union-add/union-add-test2
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test-union-add --tree=dir=checkout-test-union-add
rpm-build 0fba15
rm checkout-test-union-add -rf
rpm-build 0fba15
# Check out previous
rpm-build 0fba15
$OSTREE checkout test-union-add^ checkout-test-union-add
rpm-build 0fba15
assert_not_has_file checkout-test-union-add/union-add-test
rpm-build 0fba15
assert_not_has_file checkout-test-union-add/union-add-test2
rpm-build 0fba15
# Now create a file we don't want overwritten
rpm-build 0fba15
echo 'existing file for union add' > checkout-test-union-add/union-add-test
rpm-build 0fba15
$OSTREE checkout --union-add test-union-add checkout-test-union-add
rpm-build 0fba15
assert_file_has_content checkout-test-union-add/union-add-test 'existing file for union add'
rpm-build 0fba15
assert_file_has_content checkout-test-union-add/union-add-test2 'another file for union add testing'
rpm-build 0fba15
echo "ok checkout union add"
rpm-build 0fba15
rpm-build 0fba15
# Test --union-identical <https://github.com/projectatomic/rpm-ostree/issues/982>
rpm-build 0fba15
# Prepare data:
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
for x in $(seq 3); do
rpm-build 0fba15
    mkdir -p pkg${x}/usr/{bin,share/licenses}
rpm-build 0fba15
    # Separate binaries and symlinks
rpm-build 0fba15
    echo 'binary for pkg'${x} > pkg${x}/usr/bin/pkg${x}
rpm-build 0fba15
    ln -s pkg${x} pkg${x}/usr/bin/link${x}
rpm-build 0fba15
    # But they share the GPL
rpm-build 0fba15
    echo 'this is the GPL' > pkg${x}/usr/share/licenses/COPYING
rpm-build 0fba15
    ln -s COPYING pkg${x}/usr/share/licenses/LICENSE
rpm-build 0fba15
    $OSTREE commit -b union-identical-pkg${x} --tree=dir=pkg${x}
rpm-build 0fba15
done
rpm-build 0fba15
rm union-identical-test -rf
rpm-build 0fba15
for x in $(seq 3); do
rpm-build 0fba15
    $OSTREE checkout ${CHECKOUT_H_ARGS} --union-identical union-identical-pkg${x} union-identical-test
rpm-build 0fba15
done
rpm-build 0fba15
if $OSTREE checkout ${CHECKOUT_H_ARGS/-H/} --union-identical union-identical-pkg${x} union-identical-test-tmp 2>err.txt; then
rpm-build 0fba15
    fatal "--union-identical without -H"
rpm-build 0fba15
fi
rpm-build 0fba15
assert_file_has_content err.txt "error:.*--union-identical requires --require-hardlinks"
rpm-build 0fba15
for x in $(seq 3); do
rpm-build 0fba15
    for v in pkg link; do
rpm-build 0fba15
        assert_file_has_content union-identical-test/usr/bin/${v}${x} "binary for pkg"${x}
rpm-build 0fba15
    done
rpm-build 0fba15
    for v in COPYING LICENSE; do
rpm-build 0fba15
        assert_file_has_content union-identical-test/usr/share/licenses/${v} GPL
rpm-build 0fba15
    done
rpm-build 0fba15
done
rpm-build 0fba15
# now checkout the first pkg in force copy mode to make sure we can checksum
rpm-build 0fba15
rm union-identical-test -rf
rpm-build 0fba15
$OSTREE checkout --force-copy union-identical-pkg1 union-identical-test
rpm-build 0fba15
for x in 2 3; do
rpm-build 0fba15
    $OSTREE checkout ${CHECKOUT_H_ARGS} --union-identical union-identical-pkg${x} union-identical-test
rpm-build 0fba15
done
rpm-build 0fba15
echo "ok checkout union identical merges"
rpm-build 0fba15
rpm-build 0fba15
# Make conflicting packages, one with regfile, one with symlink
rpm-build 0fba15
mkdir -p pkg-conflict1bin/usr/{bin,share/licenses}
rpm-build 0fba15
echo 'binary for pkg-conflict1bin' > pkg-conflict1bin/usr/bin/pkg1
rpm-build 0fba15
echo 'this is the GPL' > pkg-conflict1bin/usr/share/licenses/COPYING
rpm-build 0fba15
$OSTREE commit -b union-identical-conflictpkg1bin --tree=dir=pkg-conflict1bin
rpm-build 0fba15
mkdir -p pkg-conflict1link/usr/{bin,share/licenses}
rpm-build 0fba15
ln -s somewhere-else > pkg-conflict1link/usr/bin/pkg1
rpm-build 0fba15
echo 'this is the GPL' > pkg-conflict1link/usr/share/licenses/COPYING
rpm-build 0fba15
$OSTREE commit -b union-identical-conflictpkg1link --tree=dir=pkg-conflict1link
rpm-build 0fba15
rpm-build 0fba15
for v in bin link; do
rpm-build 0fba15
    rm union-identical-test -rf
rpm-build 0fba15
    $OSTREE checkout ${CHECKOUT_H_ARGS} --union-identical union-identical-pkg1 union-identical-test
rpm-build 0fba15
    if $OSTREE checkout ${CHECKOUT_H_ARGS} --union-identical union-identical-conflictpkg1${v} union-identical-test 2>err.txt; then
rpm-build 0fba15
        fatal "union identical $v succeeded?"
rpm-build 0fba15
    fi
rpm-build 0fba15
    assert_file_has_content err.txt 'error:.*File exists'
rpm-build 0fba15
done
rpm-build 0fba15
echo "ok checkout union identical conflicts"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm files -rf && mkdir files
rpm-build 0fba15
touch files/anemptyfile
rpm-build 0fba15
touch files/anotheremptyfile
rpm-build 0fba15
$CMD_PREFIX ostree --repo=repo commit --consume -b tree-with-empty-files --tree=dir=files
Packit Service 42f4da
$CMD_PREFIX ostree --repo=repo checkout ${CHECKOUT_H_ARGS} tree-with-empty-files tree-with-empty-files
rpm-build 0fba15
if files_are_hardlinked tree-with-empty-files/an{,other}emptyfile; then
rpm-build 0fba15
    fatal "--force-copy-zerosized failed"
rpm-build 0fba15
fi
Packit Service 42f4da
# And pass the now-defunct -z option to validate it does nothing
rpm-build 0fba15
rm tree-with-empty-files -rf
Packit Service 42f4da
$CMD_PREFIX ostree --repo=repo checkout ${CHECKOUT_H_ARGS} -z tree-with-empty-files tree-with-empty-files
Packit Service 42f4da
if files_are_hardlinked tree-with-empty-files/an{,other}emptyfile; then
Packit Service 42f4da
    fatal "--force-copy-zerosized failed"
Packit Service 42f4da
fi
Packit Service 42f4da
echo "ok checkout zero sized files are not hardlinked"
rpm-build 0fba15
rpm-build 0fba15
# These should merge, they're identical
rpm-build 0fba15
$CMD_PREFIX ostree --repo=repo checkout ${CHECKOUT_H_ARGS} --union-identical -z tree-with-empty-files tree-with-empty-files
rpm-build 0fba15
$CMD_PREFIX ostree --repo=repo checkout ${CHECKOUT_H_ARGS} --union-identical -z tree-with-empty-files tree-with-empty-files
rpm-build 0fba15
echo notempty > tree-with-empty-files/anemptyfile.new && mv tree-with-empty-files/anemptyfile{.new,}
rpm-build 0fba15
$CMD_PREFIX ostree --repo=repo commit --consume -b tree-with-conflicting-empty-files --tree=dir=tree-with-empty-files
rpm-build 0fba15
# Reset back to base
rpm-build 0fba15
rm tree-with-empty-files -rf
rpm-build 0fba15
$CMD_PREFIX ostree --repo=repo checkout ${CHECKOUT_H_ARGS} --union-identical -z tree-with-empty-files tree-with-empty-files
rpm-build 0fba15
if $CMD_PREFIX ostree --repo=repo checkout ${CHECKOUT_H_ARGS} --union-identical -z tree-with-conflicting-empty-files tree-with-empty-files 2>err.txt; then
rpm-build 0fba15
    fatal "--union-identical --force-copy-zerosized unexpectedly succeeded with non-identical files"
rpm-build 0fba15
fi
rpm-build 0fba15
assert_file_has_content err.txt 'error:.*File exists'
rpm-build 0fba15
echo "ok checkout --union-identical --force-copy-zerosized"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm files -rf && mkdir files
rpm-build 0fba15
mkdir files/worldwritable-dir
rpm-build 0fba15
chmod a+w files/worldwritable-dir
rpm-build 0fba15
$CMD_PREFIX ostree --repo=repo commit -b content-with-dir-world-writable --tree=dir=files
rpm-build 0fba15
rm dir-co -rf
rpm-build 0fba15
$CMD_PREFIX ostree --repo=repo checkout -U -H -M content-with-dir-world-writable dir-co
rpm-build 0fba15
assert_file_has_mode dir-co/worldwritable-dir 775
rpm-build 0fba15
if ! is_bare_user_only_repo repo; then
rpm-build 0fba15
    rm dir-co -rf
rpm-build 0fba15
    $CMD_PREFIX ostree --repo=repo checkout -U -H content-with-dir-world-writable dir-co
rpm-build 0fba15
    assert_file_has_mode dir-co/worldwritable-dir 777
rpm-build 0fba15
fi
rpm-build 0fba15
rm dir-co -rf
rpm-build 0fba15
echo "ok checkout bareuseronly dir"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm -rf shadow-repo
rpm-build 0fba15
mkdir shadow-repo
rpm-build 0fba15
ostree_repo_init shadow-repo
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=shadow-repo config set core.parent $(pwd)/repo
rpm-build 0fba15
rm -rf test2-checkout
rpm-build 0fba15
parent_rev_test2=$(${CMD_PREFIX} ostree --repo=repo rev-parse test2)
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=shadow-repo checkout ${CHECKOUT_U_ARG} "${parent_rev_test2}" test2-checkout
rpm-build 0fba15
echo "ok checkout from shadow repo"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
if $OSTREE checkout test2 --subpath /enoent 2>err.txt; then
rpm-build 0fba15
    assert_not_reached "checking outnonexistent file unexpectedly succeeded!"
rpm-build 0fba15
fi
rpm-build 0fba15
assert_file_has_content err.txt 'No such file or directory'
rpm-build 0fba15
echo "ok subdir enoent"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE checkout test2 --allow-noent --subpath /enoent 2>/dev/null
rpm-build 0fba15
echo "ok subdir noent"
rpm-build 0fba15
rpm-build 0fba15
if ! skip_one_without_user_xattrs; then
rpm-build 0fba15
    cd ${test_tmpdir}
rpm-build 0fba15
    mkdir repo4
rpm-build 0fba15
    ostree_repo_init repo4 --mode=bare-user
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo4 pull-local --commit-metadata-only repo test2
rpm-build 0fba15
    csum1=$($OSTREE rev-parse test2)
rpm-build 0fba15
    csum2=$(${CMD_PREFIX} ostree --repo=repo4 rev-parse test2)
rpm-build 0fba15
    assert_streq "${csum1}" "${csum2}"
rpm-build 0fba15
    test -f repo4/state/$csum1.commitpartial
rpm-build 0fba15
    echo "ok pull-local --commit-metadata-only"
rpm-build 0fba15
    rm -rf repo4
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
if ! skip_one_without_user_xattrs; then
rpm-build 0fba15
    cd ${test_tmpdir}
rpm-build 0fba15
    ostree_repo_init repo3 --mode=bare-user
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo3 pull-local --remote=aremote repo test2
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo3 rev-parse aremote/test2
rpm-build 0fba15
    echo "ok pull-local with --remote arg"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
if ! skip_one_without_user_xattrs; then
rpm-build 0fba15
    cd ${test_tmpdir}
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo3 prune
rpm-build 0fba15
    find repo3/objects -name '*.commit' > objlist-before-prune
rpm-build 0fba15
    rm repo3/refs/heads/* repo3/refs/mirrors/* repo3/refs/remotes/* -rf
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo3 prune --refs-only
rpm-build 0fba15
    find repo3/objects -name '*.commit' > objlist-after-prune
rpm-build 0fba15
    if cmp -s objlist-before-prune objlist-after-prune; then
rpm-build 0fba15
        fatal "Prune didn't delete anything!"
rpm-build 0fba15
    fi
rpm-build 0fba15
    rm repo3 objlist-before-prune objlist-after-prune -rf
rpm-build 0fba15
    echo "ok prune"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm repo3 -rf
rpm-build 0fba15
ostree_repo_init repo3 --mode=archive
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo3 pull-local --remote=aremote repo test2
rpm-build 0fba15
rm repo3/refs/remotes -rf
rpm-build 0fba15
mkdir repo3/refs/remotes
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo3 prune --refs-only
rpm-build 0fba15
find repo3/objects -name '*.filez' > file-objects
rpm-build 0fba15
if test -s file-objects; then
rpm-build 0fba15
    assert_not_reached "prune didn't delete all objects"
rpm-build 0fba15
fi
rpm-build 0fba15
echo "ok prune in archive deleted everything"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm -rf test2-checkout
rpm-build 0fba15
$OSTREE checkout test2 test2-checkout
rpm-build 0fba15
(cd test2-checkout && $OSTREE commit ${COMMIT_ARGS} --link-checkout-speedup -b test2 -s "tmp")
rpm-build 0fba15
echo "ok commit with link speedup"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm -rf test2-checkout
rpm-build 0fba15
$OSTREE checkout test2 test2-checkout
rpm-build 0fba15
# set cow to different perms, but re-set cowro to the same perms
rpm-build 0fba15
cat > statoverride.txt <
rpm-build 0fba15
=$((0600)) /baz/cow
rpm-build 0fba15
=$((0600)) /baz/cowro
rpm-build 0fba15
EOF
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} --statoverride=statoverride.txt \
rpm-build 0fba15
  --table-output --link-checkout-speedup -b test2-tmp test2-checkout > stats.txt
rpm-build 0fba15
$OSTREE diff test2 test2-tmp > diff-test2
rpm-build 0fba15
assert_file_has_content diff-test2 'M */baz/cow$'
rpm-build 0fba15
assert_not_file_has_content diff-test2 'M */baz/cowro$'
rpm-build 0fba15
assert_not_file_has_content diff-test2 'baz/saucer'
rpm-build 0fba15
# only /baz/cow is a cache miss
rpm-build 0fba15
assert_file_has_content stats.txt '^Content Written: 1$'
rpm-build 0fba15
echo "ok commit with link speedup and modifier"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE ls test2
rpm-build 0fba15
echo "ok ls with no argument"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
if $OSTREE ls test2 /baz/cow/notadir 2>errmsg; then
rpm-build 0fba15
    assert_not_reached
rpm-build 0fba15
fi
rpm-build 0fba15
assert_file_has_content errmsg "Not a directory"
rpm-build 0fba15
echo "ok ls of not a directory"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE show test2
rpm-build 0fba15
echo "ok show with non-checksum"
rpm-build 0fba15
rpm-build 0fba15
cd $test_tmpdir/checkout-test2
rpm-build 0fba15
checksum=$($OSTREE commit ${COMMIT_ARGS} -b test4 -s "Third commit")
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE show test4 > show-output
rpm-build 0fba15
assert_file_has_content show-output "Third commit"
rpm-build 0fba15
assert_file_has_content show-output "commit $checksum"
rpm-build 0fba15
echo "ok show full output"
rpm-build 0fba15
rpm-build 0fba15
grep -E -e '^ContentChecksum' show-output > previous-content-checksum.txt
rpm-build 0fba15
cd $test_tmpdir/checkout-test2
rpm-build 0fba15
checksum=$($OSTREE commit ${COMMIT_ARGS} -b test4 -s "Another commit with different subject")
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE show test4 | grep -E -e '^ContentChecksum' > new-content-checksum.txt
rpm-build 0fba15
if ! diff -u previous-content-checksum.txt new-content-checksum.txt; then
rpm-build 0fba15
    fatal "content checksum differs"
rpm-build 0fba15
fi
rpm-build 0fba15
echo "ok content checksum"
rpm-build 0fba15
rpm-build 0fba15
cd $test_tmpdir/checkout-test2
rpm-build 0fba15
checksum1=$($OSTREE commit ${COMMIT_ARGS} -b test5 -s "First commit")
rpm-build 0fba15
checksum2=$($OSTREE commit ${COMMIT_ARGS} -b test5 -s "Second commit")
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE log test5 > log-output
rpm-build 0fba15
assert_file_has_content log-output "First commit"
rpm-build 0fba15
assert_file_has_content log-output "commit $checksum1"
rpm-build 0fba15
assert_file_has_content log-output "Second commit"
rpm-build 0fba15
assert_file_has_content log-output "commit $checksum2"
rpm-build 0fba15
echo "ok log output"
rpm-build 0fba15
rpm-build 0fba15
cd $test_tmpdir/checkout-test2
rpm-build 0fba15
checksum1=$($OSTREE commit ${COMMIT_ARGS} -b test6 -s "First commit")
rpm-build 0fba15
checksum2=$($OSTREE commit ${COMMIT_ARGS} -b test6 -s "Second commit")
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE show test6 > show-output
rpm-build 0fba15
assert_file_has_content show-output "commit $checksum2"
rpm-build 0fba15
$OSTREE reset test6 $checksum1
rpm-build 0fba15
$OSTREE show test6 > show-output
rpm-build 0fba15
assert_file_has_content show-output "commit $checksum1"
rpm-build 0fba15
echo "ok basic reset"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm checkout-test2 -rf
rpm-build 0fba15
$OSTREE checkout test2 checkout-test2
rpm-build 0fba15
touch checkout-test2/sometestfile
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -s sometest -b test2 checkout-test2
rpm-build 0fba15
echo "ok commit with directory filename"
rpm-build 0fba15
rpm-build 0fba15
cd $test_tmpdir/checkout-test2
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Metadata string" --add-metadata-string=FOO=BAR \
rpm-build 0fba15
        --add-metadata-string=KITTENS=CUTE --add-detached-metadata-string=SIGNATURE=HANCOCK \
rpm-build 0fba15
        --add-metadata=SOMENUM='uint64 42' --tree=ref=test2
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE show --print-metadata-key=FOO test2 > test2-meta
rpm-build 0fba15
assert_file_has_content test2-meta "BAR"
rpm-build 0fba15
$OSTREE show --print-metadata-key=KITTENS test2 > test2-meta
rpm-build 0fba15
assert_file_has_content test2-meta "CUTE"
rpm-build 0fba15
rpm-build 0fba15
$OSTREE show --print-metadata-key=SOMENUM test2 > test2-meta
rpm-build 0fba15
case "$("${test_builddir}/get-byte-order")" in
rpm-build 0fba15
    (4321)
rpm-build 0fba15
        assert_file_has_content test2-meta "uint64 42"
rpm-build 0fba15
        ;;
rpm-build 0fba15
    (1234)
rpm-build 0fba15
        assert_file_has_content test2-meta "uint64 3026418949592973312"
rpm-build 0fba15
        ;;
rpm-build 0fba15
    (*)
rpm-build 0fba15
        fatal "neither little-endian nor big-endian?"
rpm-build 0fba15
        ;;
rpm-build 0fba15
esac
rpm-build 0fba15
rpm-build 0fba15
$OSTREE show -B --print-metadata-key=SOMENUM test2 > test2-meta
rpm-build 0fba15
assert_file_has_content test2-meta "uint64 42"
rpm-build 0fba15
$OSTREE show --print-detached-metadata-key=SIGNATURE test2 > test2-meta
rpm-build 0fba15
assert_file_has_content test2-meta "HANCOCK"
rpm-build 0fba15
echo "ok metadata commit with strings"
rpm-build 0fba15
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2 --tree=ref=test2 \
rpm-build 0fba15
   --add-detached-metadata-string=SIGNATURE=HANCOCK \
rpm-build 0fba15
  --keep-metadata=KITTENS --keep-metadata=SOMENUM
rpm-build 0fba15
if $OSTREE show --print-metadata-key=FOO test2; then
rpm-build 0fba15
  assert_not_reached "FOO was kept without explicit --keep-metadata?"
rpm-build 0fba15
fi
rpm-build 0fba15
$OSTREE show --print-metadata-key=KITTENS test2 > test2-meta
rpm-build 0fba15
assert_file_has_content test2-meta "CUTE"
rpm-build 0fba15
$OSTREE show -B --print-metadata-key=SOMENUM test2 > test2-meta
rpm-build 0fba15
assert_file_has_content test2-meta "uint64 42"
rpm-build 0fba15
echo "ok keep metadata from parent"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
$OSTREE show --print-metadata-key=ostree.ref-binding test2 > test2-ref-binding
rpm-build 0fba15
assert_file_has_content test2-ref-binding 'test2'
rpm-build 0fba15
rpm-build 0fba15
$OSTREE commit ${COMMIT_ARGS} -b test2-unbound --no-bindings --tree=dir=${test_tmpdir}/checkout-test2
rpm-build 0fba15
if $OSTREE show --print-metadata-key=ostree.ref-binding test2-unbound; then
rpm-build 0fba15
    fatal "ref bindings found with --no-bindings?"
rpm-build 0fba15
fi
rpm-build 0fba15
echo "ok refbinding"
rpm-build 0fba15
rpm-build 0fba15
if ! skip_one_without_user_xattrs; then
rpm-build 0fba15
    cd ${test_tmpdir}
rpm-build 0fba15
    rm repo2 -rf
rpm-build 0fba15
    mkdir repo2
rpm-build 0fba15
    ostree_repo_init repo2 --mode=bare-user
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo2 pull-local repo
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo2 show --print-detached-metadata-key=SIGNATURE test2 > test2-meta
rpm-build 0fba15
    assert_file_has_content test2-meta "HANCOCK"
rpm-build 0fba15
    echo "ok pull-local after commit metadata"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo remote --set=tls-permissive=true add aremote http://remote.example.com/repo testos/buildmaster/x86_64-runtime
rpm-build 0fba15
assert_file_has_content repo/config 'tls-permissive=true'
rpm-build 0fba15
assert_file_has_content repo/config 'remote\.example\.com'
rpm-build 0fba15
echo "ok remote add with set"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo remote show-url aremote > aremote-url.txt
rpm-build 0fba15
assert_file_has_content aremote-url.txt 'http.*remote\.example\.com/repo'
rpm-build 0fba15
echo "ok remote show-url"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm -rf test2-checkout
rpm-build 0fba15
if grep bare-user repo/config; then
rpm-build 0fba15
    $OSTREE checkout -U test2 test2-checkout
rpm-build 0fba15
else
rpm-build 0fba15
    $OSTREE checkout test2 test2-checkout
rpm-build 0fba15
fi
rpm-build 0fba15
stat '--format=%Y' test2-checkout/baz/cow > cow-mtime
rpm-build 0fba15
assert_file_has_content cow-mtime 0
rpm-build 0fba15
stat '--format=%Y' test2-checkout/baz/deeper > deeper-mtime
rpm-build 0fba15
assert_file_has_content deeper-mtime 0
rpm-build 0fba15
echo "ok content mtime"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm repo2 -rf
rpm-build 0fba15
mkdir repo2
rpm-build 0fba15
ostree_repo_init repo2 --mode=archive
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
rpm-build 0fba15
rm -rf test2-checkout
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo2 checkout -U --disable-cache test2 test2-checkout
rpm-build 0fba15
if test -d repo2/uncompressed-objects-cache; then
rpm-build 0fba15
    ls repo2/uncompressed-objects-cache > ls.txt
rpm-build 0fba15
    if test -s ls.txt; then
rpm-build 0fba15
	assert_not_reached "repo has uncompressed objects"
rpm-build 0fba15
    fi
rpm-build 0fba15
fi
rpm-build 0fba15
rm test2-checkout -rf
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo2 checkout -U test2 test2-checkout
rpm-build 0fba15
assert_file_has_content test2-checkout/baz/cow moo
rpm-build 0fba15
assert_has_dir repo2/uncompressed-objects-cache
rpm-build 0fba15
ls repo2/uncompressed-objects-cache > ls.txt
rpm-build 0fba15
if ! test -s ls.txt; then
rpm-build 0fba15
    assert_not_reached "repo didn't cache uncompressed objects"
rpm-build 0fba15
fi
rpm-build 0fba15
# we're in archive mode, but the repo we pull-local from might be
rpm-build 0fba15
# bare-user-only, in which case, we skip these checks since bare-user-only
rpm-build 0fba15
# doesn't store permission bits
rpm-build 0fba15
if ! is_bare_user_only_repo repo; then
rpm-build 0fba15
    assert_file_has_mode test2-checkout/baz/cowro 600
rpm-build 0fba15
    assert_file_has_mode test2-checkout/baz/deeper/ohyeahx 755
rpm-build 0fba15
fi
rpm-build 0fba15
echo "ok disable cache checkout"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm checkout-test2 -rf
rpm-build 0fba15
$OSTREE checkout test2 checkout-test2
rpm-build 0fba15
date > checkout-test2/date.txt
rpm-build 0fba15
rm repo/tmp/* -rf
rpm-build 0fba15
export TEST_BOOTID=3072029c-8b10-60d1-d31b-8422eeff9b42
rpm-build 0fba15
if env OSTREE_REPO_TEST_ERROR=pre-commit OSTREE_BOOTID=${TEST_BOOTID} \
rpm-build 0fba15
       $OSTREE commit ${COMMIT_ARGS} -b test2 -s '' $test_tmpdir/checkout-test2 2>err.txt; then
rpm-build 0fba15
    assert_not_reached "Should have hit OSTREE_REPO_TEST_ERROR_PRE_COMMIT"
rpm-build 0fba15
fi
rpm-build 0fba15
assert_file_has_content err.txt OSTREE_REPO_TEST_ERROR_PRE_COMMIT
rpm-build 0fba15
found_staging=0
rpm-build 0fba15
for d in $(find repo/tmp/ -maxdepth 1 -type d); do
rpm-build 0fba15
    bn=$(basename $d)
rpm-build 0fba15
    if test ${bn##staging-} != ${bn}; then
rpm-build 0fba15
	assert_str_match "${bn}" "^staging-${TEST_BOOTID}-"
rpm-build 0fba15
	found_staging=1
rpm-build 0fba15
    fi
rpm-build 0fba15
done
rpm-build 0fba15
assert_streq "${found_staging}" 1
rpm-build 0fba15
echo "ok test error pre commit/bootid"
rpm-build 0fba15
rpm-build 0fba15
# Whiteouts
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
mkdir -p overlay/baz/
rpm-build 0fba15
if touch overlay/baz/.wh.cow && touch overlay/.wh.deeper && touch overlay/baz/another/.wh..wh..opq; then
rpm-build 0fba15
    touch overlay/anewfile
rpm-build 0fba15
    mkdir overlay/anewdir/
rpm-build 0fba15
    touch overlay/anewdir/blah
rpm-build 0fba15
    $OSTREE --repo=repo commit ${COMMIT_ARGS} -b overlay -s 'overlay' --tree=dir=overlay
rpm-build 0fba15
    rm overlay -rf
rpm-build 0fba15
rpm-build 0fba15
    for branch in test2 overlay; do
rpm-build 0fba15
        $OSTREE --repo=repo checkout --union --whiteouts ${branch} overlay-co
rpm-build 0fba15
    done
rpm-build 0fba15
    for f in .wh.deeper baz/cow baz/.wh.cow; do
rpm-build 0fba15
        assert_not_has_file overlay-co/${f}
rpm-build 0fba15
    done
rpm-build 0fba15
    assert_not_has_dir overlay-co/deeper
rpm-build 0fba15
    assert_has_file overlay-co/anewdir/blah
rpm-build 0fba15
    assert_has_file overlay-co/anewfile
rpm-build 0fba15
    assert_not_has_file overlay-co/baz/another/y
rpm-build 0fba15
rpm-build 0fba15
    # And test replacing a directory wholesale with a symlink as well as a regular file
rpm-build 0fba15
    mkdir overlay
rpm-build 0fba15
    echo baz to file > overlay/baz
rpm-build 0fba15
    ln -s anewfile overlay/anewdir
rpm-build 0fba15
    $OSTREE --repo=repo commit ${COMMIT_ARGS} -b overlay-dir-convert --tree=dir=overlay
rpm-build 0fba15
    rm overlay -rf
rpm-build 0fba15
rpm-build 0fba15
    rm overlay-co -rf
rpm-build 0fba15
    for branch in test2 overlay-dir-convert; do
rpm-build 0fba15
        $OSTREE --repo=repo checkout --union --whiteouts ${branch} overlay-co
rpm-build 0fba15
    done
rpm-build 0fba15
    assert_has_file overlay-co/baz
rpm-build 0fba15
    test -L overlay-co/anewdir
rpm-build 0fba15
rpm-build 0fba15
    echo "ok whiteouts enabled"
rpm-build 0fba15
rpm-build 0fba15
    # Now double check whiteouts are not processed without --whiteouts
rpm-build 0fba15
    rm overlay-co -rf
rpm-build 0fba15
    for branch in test2 overlay; do
rpm-build 0fba15
        $OSTREE --repo=repo checkout --union ${branch} overlay-co
rpm-build 0fba15
    done
rpm-build 0fba15
    for f in .wh.deeper baz/cow baz/.wh.cow; do
rpm-build 0fba15
        assert_has_file overlay-co/${f}
rpm-build 0fba15
    done
rpm-build 0fba15
    assert_not_has_dir overlay-co/deeper
rpm-build 0fba15
    assert_has_file overlay-co/anewdir/blah
rpm-build 0fba15
    assert_has_file overlay-co/anewfile
rpm-build 0fba15
    echo "ok whiteouts disabled"
rpm-build 0fba15
else
rpm-build 0fba15
    echo "ok # SKIP whiteouts do not work, are you using aufs?"
rpm-build 0fba15
    echo "ok # SKIP whiteouts do not work, are you using aufs?"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
rm -rf test2-checkout
rpm-build 0fba15
mkdir -p test2-checkout
rpm-build 0fba15
cd test2-checkout
rpm-build 0fba15
echo 'should not be fsynced' > should-not-be-fsynced
rpm-build 0fba15
if ! skip_one_without_strace_fault_injection; then
rpm-build 0fba15
    # Test that --fsync=false doesn't fsync
rpm-build 0fba15
    fsync_inject_error_ostree="strace -o /dev/null -f -e inject=syncfs,fsync,sync:error=EPERM ostree"
rpm-build 0fba15
    ${fsync_inject_error_ostree} --repo=${test_tmpdir}/repo commit ${COMMIT_ARGS} -b test2-no-fsync --fsync=false
rpm-build 0fba15
    # And test that we get EPERM if we inject an error
rpm-build 0fba15
    if ${fsync_inject_error_ostree} --repo=${test_tmpdir}/repo commit ${COMMIT_ARGS} -b test2-no-fsync 2>err.txt; then
rpm-build 0fba15
        fatal "fsync error injection failed"
rpm-build 0fba15
    fi
rpm-build 0fba15
    assert_file_has_content err.txt 'sync.*Operation not permitted'
rpm-build 0fba15
    echo "ok fsync disabled"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
# Run this test only as non-root user.  When run as root, the chmod
rpm-build 0fba15
# won't have any effect.
rpm-build 0fba15
if test "$(id -u)" != "0"; then
rpm-build 0fba15
    cd ${test_tmpdir}
rpm-build 0fba15
    rm -f expected-fail error-message
rpm-build 0fba15
    $OSTREE init --mode=archive --repo=repo-noperm
rpm-build 0fba15
    chmod -w repo-noperm/objects
rpm-build 0fba15
    $OSTREE --repo=repo-noperm pull-local repo 2> error-message || touch expected-fail
rpm-build 0fba15
    chmod +w repo-noperm/objects
rpm-build 0fba15
    assert_has_file expected-fail
rpm-build 0fba15
    assert_file_has_content error-message "Permission denied"
rpm-build 0fba15
    echo "ok unwritable repo was caught"
rpm-build 0fba15
else
rpm-build 0fba15
    echo "ok # SKIP not run when root"
rpm-build 0fba15
fi