Blame tests/test-local-pull.sh

rpm-build 0fba15
#!/bin/bash
rpm-build 0fba15
#
rpm-build 0fba15
# Copyright (C) 2014 Alexander Larsson <alexl@redhat.com>
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
# We don't want OSTREE_GPG_HOME used for these tests.
rpm-build 0fba15
unset OSTREE_GPG_HOME
rpm-build 0fba15
rpm-build 0fba15
. $(dirname $0)/libtest.sh
rpm-build 0fba15
rpm-build 0fba15
skip_without_user_xattrs
rpm-build 0fba15
rpm-build 0fba15
echo "1..8"
rpm-build 0fba15
rpm-build 0fba15
setup_test_repository "archive"
rpm-build 0fba15
echo "ok setup"
rpm-build 0fba15
rpm-build 0fba15
cd ${test_tmpdir}
rpm-build 0fba15
mkdir repo2
rpm-build 0fba15
ostree_repo_init repo2 --mode="bare-user"
rpm-build 0fba15
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo2 fsck
rpm-build 0fba15
echo "ok pull-local z2 to bare-user"
rpm-build 0fba15
rpm-build 0fba15
mkdir repo3
rpm-build 0fba15
ostree_repo_init repo3 --mode="archive"
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo3 pull-local repo2
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo3 fsck
rpm-build 0fba15
echo "ok pull-local bare-user to z2"
rpm-build 0fba15
rpm-build 0fba15
rpm-build 0fba15
# Verify the name + size + mode + type + symlink target + owner/group are the same
rpm-build 0fba15
# for all checkouts
rpm-build 0fba15
${CMD_PREFIX} ostree checkout --repo repo test2 checkout1
rpm-build 0fba15
find checkout1 -printf '%P %s %#m %u/%g %y %l\n' | sort > checkout1.files
rpm-build 0fba15
rpm-build 0fba15
${CMD_PREFIX} ostree checkout --repo repo2 test2 checkout2
rpm-build 0fba15
find checkout2 -printf '%P %s %#m %u/%g %y %l\n' | sort > checkout2.files
rpm-build 0fba15
rpm-build 0fba15
${CMD_PREFIX} ostree checkout --repo repo3 test2 checkout3
rpm-build 0fba15
find checkout3 -printf '%P %s %#m %u/%g %y %l\n' | sort > checkout3.files
rpm-build 0fba15
rpm-build 0fba15
cmp checkout1.files checkout2.files
rpm-build 0fba15
cmp checkout1.files checkout3.files
rpm-build 0fba15
echo "ok checkouts same"
rpm-build 0fba15
rpm-build 0fba15
if has_gpgme; then
rpm-build 0fba15
    # These tests are needed GPG support
rpm-build 0fba15
    mkdir repo4
rpm-build 0fba15
    ostree_repo_init repo4 --mode="archive"
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo4 remote add --gpg-import ${test_tmpdir}/gpghome/key1.asc origin repo
rpm-build 0fba15
rpm-build 0fba15
    if ${CMD_PREFIX} ostree --repo=repo4 pull-local --remote=origin --gpg-verify repo test2 2>&1; then
rpm-build 0fba15
        assert_not_reached "GPG verification unexpectedly succeeded"
rpm-build 0fba15
    fi
rpm-build 0fba15
    echo "ok --gpg-verify with no signature"
rpm-build 0fba15
rpm-build 0fba15
    ${OSTREE} gpg-sign --gpg-homedir=${TEST_GPG_KEYHOME} test2  ${TEST_GPG_KEYID_1}
rpm-build 0fba15
rpm-build 0fba15
    mkdir repo5
rpm-build 0fba15
    ostree_repo_init repo5 --mode="archive"
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo5 remote add --gpg-import ${test_tmpdir}/gpghome/key1.asc origin repo
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo5 pull-local --remote=origin --gpg-verify repo test2
rpm-build 0fba15
    echo "ok --gpg-verify"
rpm-build 0fba15
rpm-build 0fba15
    mkdir repo6
rpm-build 0fba15
    ostree_repo_init repo6 --mode="archive"
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo6 remote add --gpg-import ${test_tmpdir}/gpghome/key1.asc origin repo
rpm-build 0fba15
    if ${CMD_PREFIX} ostree --repo=repo6 pull-local --remote=origin --gpg-verify-summary repo test2 2>&1; then
rpm-build 0fba15
        assert_not_reached "GPG summary verification with no summary unexpectedly succeeded"
rpm-build 0fba15
    fi
rpm-build 0fba15
rpm-build 0fba15
    ${OSTREE} summary --update
rpm-build 0fba15
rpm-build 0fba15
    if ${CMD_PREFIX} ostree --repo=repo6 pull-local --remote=origin --gpg-verify-summary repo test2 2>&1; then
rpm-build 0fba15
        assert_not_reached "GPG summary verification with signed no summary unexpectedly succeeded"
rpm-build 0fba15
    fi
rpm-build 0fba15
rpm-build 0fba15
    ${OSTREE} summary --update --gpg-sign=${TEST_GPG_KEYID_1} --gpg-homedir=${TEST_GPG_KEYHOME}
rpm-build 0fba15
rpm-build 0fba15
    ${CMD_PREFIX} ostree --repo=repo6 pull-local --remote=origin --gpg-verify-summary repo test2 2>&1
rpm-build 0fba15
rpm-build 0fba15
    echo "ok --gpg-verify-summary"
rpm-build 0fba15
else
rpm-build 0fba15
    echo "ok --gpg-verify with no signature | # SKIP due GPG unavailability"
rpm-build 0fba15
    echo "ok --gpg-verify | # SKIP due GPG unavailability"
rpm-build 0fba15
    echo "ok --gpg-verify-summary | # SKIP due GPG unavailability"
rpm-build 0fba15
fi
rpm-build 0fba15
rpm-build 0fba15
mkdir repo7
rpm-build 0fba15
ostree_repo_init repo7 --mode="archive"
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo7 pull-local repo
rpm-build 0fba15
${CMD_PREFIX} ostree --repo=repo7 fsck
rpm-build 0fba15
for src_object in `find repo/objects -name '*.filez'`; do
rpm-build 0fba15
    dst_object=${src_object/repo/repo7}
rpm-build 0fba15
    assert_files_hardlinked "$src_object" "$dst_object"
rpm-build 0fba15
done
rpm-build 0fba15
echo "ok pull-local z2 to z2 default hardlink"