2017-06-22 17:16:53 +03:00
#!/bin/bash
#
# Copyright © 2017 Endless Mobile, Inc.
#
2018-01-30 22:26:26 +03:00
# SPDX-License-Identifier: LGPL-2.0+
#
2017-06-22 17:16:53 +03:00
# 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.
#
# Authors:
# - Philip Withnall <withnall@endlessm.com>
set -euo pipefail
. $( dirname $0 ) /libtest.sh
echo "1..2"
2019-07-30 02:39:12 +03:00
COMMIT_SIGN = ""
if has_gpgme; then
COMMIT_SIGN = " --gpg-homedir= ${ TEST_GPG_KEYHOME } --gpg-sign= ${ TEST_GPG_KEYID_1 } "
fi
2017-06-22 17:16:53 +03:00
cd ${ test_tmpdir }
mkdir repo
ostree_repo_init repo
mkdir -p tree/root
touch tree/root/a
# Add a few commits
seq 5 | while read i; do
echo a >> tree/root/a
${ CMD_PREFIX } ostree --repo= repo commit --branch= test-$i -m test -s test tree
done
# Generate a plain summary file.
${ CMD_PREFIX } ostree --repo= repo summary --update
# Generate a signed summary file.
2019-07-30 02:39:12 +03:00
${ CMD_PREFIX } ostree --repo= repo summary --update ${ COMMIT_SIGN }
2017-06-22 17:16:53 +03:00
# Try various ways of adding additional data.
${ CMD_PREFIX } ostree --repo= repo summary --update --add-metadata key = "'value'" --add-metadata= key2 = true
${ CMD_PREFIX } ostree --repo= repo summary --update -m some-int= '@t 123'
${ CMD_PREFIX } ostree --repo= repo summary --update --add-metadata= map = '@a{sv} {}'
# Check the additional metadata turns up in the output.
${ CMD_PREFIX } ostree --repo= repo summary --view > summary
assert_file_has_content summary " ^map: {} $"
echo "ok 1 update summary"
2019-01-23 03:50:32 +03:00
# Test again, but with collections enabled in the repository.
2017-06-22 17:16:53 +03:00
cd ${ test_tmpdir }
rm -rf repo
ostree_repo_init repo --collection-id org.example.Collection1
mkdir -p tree/root
touch tree/root/a
# Add a few commits
seq 5 | while read i; do
echo a >> tree/root/a
${ CMD_PREFIX } ostree --repo= repo commit --branch= test-$i -m test -s test tree
${ CMD_PREFIX } ostree --repo= repo refs --collections --create= org.example.Collection2:test-$i test-$i
done
# Generate a plain summary file.
${ CMD_PREFIX } ostree --repo= repo summary --update
# Generate a signed summary file.
2019-07-30 02:39:12 +03:00
${ CMD_PREFIX } ostree --repo= repo summary --update ${ COMMIT_SIGN }
2017-06-22 17:16:53 +03:00
# Try various ways of adding additional data.
${ CMD_PREFIX } ostree --repo= repo summary --update --add-metadata key = "'value'" --add-metadata= key2 = true
${ CMD_PREFIX } ostree --repo= repo summary --update -m some-int= '@t 123'
${ CMD_PREFIX } ostree --repo= repo summary --update --add-metadata= map = '@a{sv} {}'
# Check the additional metadata turns up in the output.
${ CMD_PREFIX } ostree --repo= repo summary --view > summary
assert_file_has_content summary " ^map: {} $"
2017-09-11 16:42:52 +03:00
# Check the ostree-metadata ref has also been created with the same content and appropriate bindings.
${ CMD_PREFIX } ostree --repo= repo refs --collections > refs
2019-04-02 05:01:49 +03:00
assert_file_has_content refs " ^(org\.example\.Collection1, ostree-metadata) $"
2017-09-11 16:42:52 +03:00
${ CMD_PREFIX } ostree --repo= repo show ostree-metadata --raw > metadata
assert_file_has_content metadata "'map': <@a{sv} {}>"
2019-04-02 05:01:49 +03:00
assert_file_has_content metadata "'ostree\.ref-binding': <\['ostree-metadata'\]>"
assert_file_has_content metadata "'ostree\.collection-binding': <'org\.example\.Collection1'>"
2017-09-11 16:42:52 +03:00
# There should be 5 commits in the ostree-metadata branch, since we’ ve updated the summary 5 times.
${ CMD_PREFIX } ostree --repo= repo log ostree-metadata | grep 'commit ' | wc -l > commit-count
assert_file_has_content commit-count " ^5 $"
# The ostree-metadata commits should not contain any files
${ CMD_PREFIX } ostree --repo= repo ls ostree-metadata > files
assert_file_has_content files " / $"
cat files | wc -l > files-count
assert_file_has_content files-count " ^1 $"
2017-06-22 17:16:53 +03:00
echo "ok 2 update summary with collections"