New upstream version 2017.9

This commit is contained in:
Simon McVittie committed 2017-07-28 08:57:43 +01:00
commit e5ac0cef85
134 files changed
+3986 -5324

No files matched your search

+15
View File
@@ -234,3 +234,18 @@ curr_rev=$(${CMD_PREFIX} ostree rev-parse --repo=sysroot/ostree/repo testos/buil
assert_streq ${curr_rev} ${head_rev}
echo "ok upgrade with and without override-commit"
deployment=$(${CMD_PREFIX} ostree admin --sysroot=sysroot --print-current-dir)
${CMD_PREFIX} ostree --sysroot=sysroot remote add --set=gpg-verify=false remote-test-physical file://$(pwd)/testos-repo
assert_not_has_file ${deployment}/etc/ostree/remotes.d/remote-test-physical.conf testos-repo
assert_file_has_content sysroot/ostree/repo/config remote-test-physical
echo "ok remote add physical sysroot"
# Now a hack...symlink ${deployment}/sysroot to the sysroot in lieu of a bind
# mount which we can't do in unit tests.
ln -sr sysroot ${deployment}/sysroot
ln -s sysroot/ostree ${deployment}/ostree
${CMD_PREFIX} ostree --sysroot=${deployment} remote add --set=gpg-verify=false remote-test-nonphysical file://$(pwd)/testos-repo
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"
+13 -3
View File
@@ -19,7 +19,7 @@
set -euo pipefail
echo "1..$((69 + ${extra_basic_tests:-0}))"
echo "1..$((70 + ${extra_basic_tests:-0}))"
$CMD_PREFIX ostree --version > version.yaml
python -c 'import yaml; yaml.safe_load(open("version.yaml"))'
@@ -112,6 +112,14 @@ ostree_repo_init test-repo --mode=bare-user
rm test-repo -rf
echo "ok repo-init on existing repo"
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"
rm checkout-test2 -rf
$OSTREE checkout test2 checkout-test2
cd checkout-test2
@@ -171,8 +179,10 @@ assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1"
echo "ok commit no parent"
cd ${test_tmpdir}
empty_rev=$($OSTREE commit ${COMMIT_ARGS} -b test2-no-subject -s '' --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
omitted_rev=$($OSTREE commit ${COMMIT_ARGS} -b test2-no-subject-2 --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
# Do the --bind-ref=<the other test branch>, so we store both branches sorted
# in metadata and thus the checksums remain the same.
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)
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)
assert_streq $empty_rev $omitted_rev
echo "ok commit no subject"
+13 -2
View File
@@ -23,7 +23,7 @@ function repo_init() {
cd ${test_tmpdir}
rm repo -rf
mkdir repo
ostree_repo_init repo
ostree_repo_init repo --mode=${repo_mode}
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo "$@"
}
@@ -35,7 +35,7 @@ function verify_initial_contents() {
assert_file_has_content baz/cow '^moo$'
}
echo "1..26"
echo "1..27"
# Try both syntaxes
repo_init --no-gpg-verify
@@ -413,3 +413,14 @@ rm $localsig
${CMD_PREFIX} ostree --repo=repo pull origin main
test -f $localsig
echo "ok re-pull signature for stored commit"
cd ${test_tmpdir}
repo_init --no-gpg-verify
mv ostree-srv/gnomerepo/refs/heads/main{,.orig}
rm ostree-srv/gnomerepo/summary
(for x in $(seq 20); do echo "lots of html here "; done) > ostree-srv/gnomerepo/refs/heads/main
if ${CMD_PREFIX} ostree --repo=repo pull origin main 2>err.txt; then
fatal "pull of invalid ref succeeded"
fi
assert_file_has_content_literal err.txt 'error: Fetching refs/heads/main: Invalid rev lots of html here lots of html here lots of html here lots of'
echo "ok pull got HTML for a ref"
+1 -1
View File
@@ -19,7 +19,7 @@
set -euo pipefail
echo "1..16"
echo "1..18"
. $(dirname $0)/libtest.sh
+1 -1
View File
@@ -19,7 +19,7 @@
set -euo pipefail
echo "1..16"
echo "1..18"
. $(dirname $0)/libtest.sh
+1 -1
View File
@@ -20,7 +20,7 @@
set -euo pipefail
echo "1..17"
echo "1..19"
. $(dirname $0)/libtest.sh
Regular → Executable
+3 -1
View File
@@ -25,6 +25,8 @@ function assertEquals(a, b) {
throw new Error("assertion failed " + JSON.stringify(a) + " == " + JSON.stringify(b));
}
print('1..1')
let testDataDir = Gio.File.new_for_path('test-data');
testDataDir.make_directory(null);
testDataDir.get_child('some-file').replace_contents("hello world!", null, false, 0, null);
@@ -66,4 +68,4 @@ repo.commit_transaction(null, null);
[,readCommit] = repo.resolve_rev('someref', true);
assertEquals(readCommit, null);
print("test-core complete");
print("ok test-core");
+1 -1
View File
@@ -258,6 +258,6 @@ ${CMD_PREFIX} ostree --repo=repo summary -u
if ${CMD_PREFIX} ostree --repo=repo static-delta show GARBAGE 2> err.txt; then
assert_not_reached "static-delta show GARBAGE unexpectedly succeeded"
fi
assert_file_has_content err.txt "Invalid rev 'GARBAGE'"
assert_file_has_content err.txt "Invalid rev GARBAGE"
echo 'ok handle bad delta name'
+229
View File
@@ -0,0 +1,229 @@
#!/bin/bash
#
# Copyright © 2017 Endless Mobile, Inc.
#
# 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.
set -euo pipefail
. $(dirname $0)/libtest.sh
echo '1..1'
# Create two upstream collection repositories with some example commits
cd ${test_tmpdir}
mkdir apps-collection
ostree_repo_init apps-collection --collection-id org.example.AppsCollection
mkdir -p files
pushd files
${CMD_PREFIX} ostree --repo=../apps-collection commit -s "Test apps-collection commit 1" -b app1 --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1} > ../app1-checksum
${CMD_PREFIX} ostree --repo=../apps-collection commit -s "Test apps-collection commit 2" -b app2 --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1} > ../app2-checksum
popd
${CMD_PREFIX} ostree --repo=apps-collection summary --update --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}
mkdir os-collection
ostree_repo_init os-collection --collection-id org.example.OsCollection
mkdir -p files
pushd files
${CMD_PREFIX} ostree --repo=../os-collection commit -s "Test os-collection commit 1" -b os/amd64/master --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_2} > ../os-checksum
popd
${CMD_PREFIX} ostree --repo=os-collection summary --update --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_2}
# Create a local repository where we pull the branches from the two remotes as normal, using GPG.
mkdir local
ostree_repo_init local
${CMD_PREFIX} ostree --repo=local remote add apps-remote file://$(pwd)/apps-collection --collection-id org.example.AppsCollection --gpg-import=${test_tmpdir}/gpghome/key1.asc
${CMD_PREFIX} ostree --repo=local remote add os-remote file://$(pwd)/os-collection --collection-id org.example.OsCollection --gpg-import=${test_tmpdir}/gpghome/key2.asc
${CMD_PREFIX} ostree --repo=local pull apps-remote app1
${CMD_PREFIX} ostree --repo=local pull os-remote os/amd64/master
${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$"
# 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.
mkdir local-mirror
ostree_repo_init local-mirror
${CMD_PREFIX} ostree --repo=local-mirror remote add apps-remote file://$(pwd)/apps-collection --collection-id org.example.AppsCollection --gpg-import=${test_tmpdir}/gpghome/key1.asc
${CMD_PREFIX} ostree --repo=local-mirror remote add os-remote file://$(pwd)/os-collection --collection-id org.example.OsCollection --gpg-import=${test_tmpdir}/gpghome/key2.asc
${CMD_PREFIX} ostree --repo=local-mirror pull --mirror apps-remote app1
${CMD_PREFIX} ostree --repo=local-mirror pull --mirror os-remote os/amd64/master
${CMD_PREFIX} ostree --repo=local-mirror refs | wc -l > refscount
assert_file_has_content refscount "^0$"
${CMD_PREFIX} ostree --repo=local-mirror refs --collections > refs
assert_file_has_content refs "^(org.example.AppsCollection, app1)$"
assert_file_has_content refs "^(org.example.OsCollection, os/amd64/master)$"
for repo in local local-mirror; do
# Try finding an update for an existing branch.
${CMD_PREFIX} ostree --repo=$repo find-remotes org.example.AppsCollection app1 > find
assert_file_has_content find "^Result [0-9]\+: file://$(pwd)/apps-collection$"
assert_file_has_content find "^ - Keyring: apps-remote.trustedkeys.gpg$"
assert_file_has_content find "^ - (org.example.AppsCollection, app1) = $(cat app1-checksum)$"
assert_file_has_content find "^1/1 refs were found.$"
assert_not_file_has_content find "^No results.$"
# Find several updates for several existing branches.
${CMD_PREFIX} ostree --repo=$repo find-remotes org.example.AppsCollection app1 org.example.OsCollection os/amd64/master > find
assert_file_has_content find "^Result [0-9]\+: file://$(pwd)/apps-collection$"
assert_file_has_content find "^ - Keyring: apps-remote.trustedkeys.gpg$"
assert_file_has_content find "^ - (org.example.AppsCollection, app1) = $(cat app1-checksum)$"
assert_file_has_content find "^Result [0-9]\+: file://$(pwd)/os-collection$"
assert_file_has_content find "^ - Keyring: os-remote.trustedkeys.gpg$"
assert_file_has_content find "^ - (org.example.OsCollection, os/amd64/master) = $(cat os-checksum)$"
assert_file_has_content find "^2/2 refs were found.$"
assert_not_file_has_content find "^No results.$"
# Find some updates and a new branch.
${CMD_PREFIX} ostree --repo=$repo find-remotes org.example.AppsCollection app1 org.example.AppsCollection app2 org.example.OsCollection os/amd64/master > find
assert_file_has_content find "^Result [0-9]\+: file://$(pwd)/apps-collection$"
assert_file_has_content find "^ - Keyring: apps-remote.trustedkeys.gpg$"
assert_file_has_content find "^ - (org.example.AppsCollection, app1) = $(cat app1-checksum)$"
assert_file_has_content find "^ - (org.example.AppsCollection, app2) = $(cat app2-checksum)$"
assert_file_has_content find "^Result [0-9]\+: file://$(pwd)/os-collection$"
assert_file_has_content find "^ - Keyring: os-remote.trustedkeys.gpg$"
assert_file_has_content find "^ - (org.example.OsCollection, os/amd64/master) = $(cat os-checksum)$"
assert_file_has_content find "^3/3 refs were found.$"
assert_not_file_has_content find "^No results.$"
# Find an update and a non-existent branch.
${CMD_PREFIX} ostree --repo=$repo find-remotes org.example.AppsCollection app1 org.example.AppsCollection not-an-app > find
assert_file_has_content find "^Result [0-9]\+: file://$(pwd)/apps-collection$"
assert_file_has_content find "^ - Keyring: apps-remote.trustedkeys.gpg$"
assert_file_has_content find "^ - (org.example.AppsCollection, not-an-app) = (not found)$"
assert_file_has_content find "^ - (org.example.AppsCollection, app1) = $(cat app1-checksum)$"
assert_file_has_content find "^Refs not found in any remote:$"
assert_file_has_content find "^ - (org.example.AppsCollection, not-an-app)$"
assert_file_has_content find "^1/2 refs were found.$"
assert_not_file_has_content find "^No results.$"
# Do all the above, but pull this time.
${CMD_PREFIX} ostree --repo=$repo find-remotes --pull org.example.AppsCollection app1 > pull || true
assert_file_has_content pull "^1/1 refs were found.$"
assert_file_has_content pull "^Pulled 1/1 refs successfully.$"
assert_not_file_has_content pull "Failed to pull some refs from the remotes"
assert_ref $repo app1 $(cat app1-checksum)
${CMD_PREFIX} ostree --repo=$repo find-remotes --pull org.example.AppsCollection app1 org.example.OsCollection os/amd64/master > pull
assert_file_has_content pull "^2/2 refs were found.$"
assert_file_has_content pull "^Pulled 2/2 refs successfully.$"
assert_not_file_has_content pull "Failed to pull some refs from the remotes"
assert_ref $repo app1 $(cat app1-checksum)
assert_ref $repo os/amd64/master $(cat os-checksum)
${CMD_PREFIX} ostree --repo=$repo find-remotes --pull org.example.AppsCollection app1 org.example.AppsCollection app2 org.example.OsCollection os/amd64/master > pull
assert_file_has_content pull "^3/3 refs were found.$"
assert_file_has_content pull "^Pulled 3/3 refs successfully.$"
assert_not_file_has_content pull "Failed to pull some refs from the remotes"
assert_ref $repo app1 $(cat app1-checksum)
assert_ref $repo app2 $(cat app2-checksum)
assert_ref $repo os/amd64/master $(cat os-checksum)
${CMD_PREFIX} ostree --repo=$repo find-remotes --pull org.example.AppsCollection app1 org.example.AppsCollection not-an-app > pull
assert_file_has_content pull "^1/2 refs were found.$"
assert_not_file_has_content pull "Failed to pull some refs from the remotes"
assert_ref $repo app1 $(cat app1-checksum)
assert_not_ref $repo not-an-app
done
# Test pulling a new commit into the local mirror from one of the repositories.
pushd files
${CMD_PREFIX} ostree --repo=../os-collection commit -s "Test os-collection commit 2" -b os/amd64/master --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_2} > ../os-checksum-2
popd
${CMD_PREFIX} ostree --repo=os-collection summary --update --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_2}
for repo in local-mirror; do
# Try finding an update for that branch.
${CMD_PREFIX} ostree --repo=$repo find-remotes org.example.OsCollection os/amd64/master > find
assert_file_has_content find "^Result [0-9]\+: file://$(pwd)/os-collection$"
assert_file_has_content find "^ - Keyring: os-remote.trustedkeys.gpg$"
assert_file_has_content find "^ - (org.example.OsCollection, os/amd64/master) = $(cat os-checksum-2)$"
assert_file_has_content find "^1/1 refs were found.$"
assert_not_file_has_content find "^No results.$"
# Pull it.
${CMD_PREFIX} ostree --repo=$repo find-remotes --pull org.example.OsCollection os/amd64/master > pull || true
assert_file_has_content pull "^1/1 refs were found.$"
assert_file_has_content pull "^Pulled 1/1 refs successfully.$"
assert_not_file_has_content pull "Failed to pull some refs from the remotes"
assert_ref $repo os/amd64/master $(cat os-checksum-2)
done
# Add the local mirror to the local repository as a remote, so that the local repo
# has two configured remotes for the os-collection. Ensure its summary is up to date first.
#${CMD_PREFIX} ostree --repo=local-mirror summary --update
# FIXME: This `cp` can be changed to `ostree summary --update` once PR #946 lands.
# Prior to that, we need to preserve the signatures.
cp os-collection/summary{,.sig} local-mirror/
${CMD_PREFIX} ostree --repo=local remote add os-remote-local-mirror file://$(pwd)/local-mirror --collection-id org.example.OsCollection --gpg-import=${test_tmpdir}/gpghome/key2.asc
for repo in local; do
# Try finding an update for that branch.
${CMD_PREFIX} ostree --repo=$repo find-remotes org.example.OsCollection os/amd64/master > find
assert_file_has_content find "^Result [0-9]\+: file://$(pwd)/os-collection$"
assert_file_has_content find "^ - Keyring: os-remote.trustedkeys.gpg$"
assert_file_has_content find "^ - (org.example.OsCollection, os/amd64/master) = $(cat os-checksum-2)$"
assert_file_has_content find "^Result [0-9]\+: file://$(pwd)/local-mirror$"
assert_file_has_content find "^ - Keyring: os-remote-local-mirror.trustedkeys.gpg$"
assert_file_has_content find "^ - (org.example.OsCollection, os/amd64/master) = $(cat os-checksum-2)$"
assert_file_has_content find "^1/1 refs were found.$"
assert_not_file_has_content find "^No results.$"
# Pull it.
${CMD_PREFIX} ostree --repo=$repo find-remotes --pull org.example.OsCollection os/amd64/master > pull || true
assert_file_has_content pull "^1/1 refs were found.$"
assert_file_has_content pull "^Pulled 1/1 refs successfully.$"
assert_not_file_has_content pull "Failed to pull some refs from the remotes"
assert_ref $repo os/amd64/master $(cat os-checksum-2)
done
# Add another commit to the OS collection, but don’t update the mirror. Then try pulling
# into the local repository again, and check that the outdated ref in the mirror is ignored.
pushd files
${CMD_PREFIX} ostree --repo=../os-collection commit -s "Test os-collection commit 3" -b os/amd64/master --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_2} > ../os-checksum-3
popd
${CMD_PREFIX} ostree --repo=os-collection summary --update --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_2}
for repo in local; do
# Try finding an update for that branch.
${CMD_PREFIX} ostree --repo=$repo find-remotes org.example.OsCollection os/amd64/master > find
assert_file_has_content find "^Result [0-9]\+: file://$(pwd)/os-collection$"
assert_file_has_content find "^ - Keyring: os-remote.trustedkeys.gpg$"
assert_file_has_content find "^ - (org.example.OsCollection, os/amd64/master) = $(cat os-checksum-3)$"
assert_file_has_content find "^Result [0-9]\+: file://$(pwd)/local-mirror$"
assert_file_has_content find "^ - Keyring: os-remote-local-mirror.trustedkeys.gpg$"
assert_file_has_content find "^ - (org.example.OsCollection, os/amd64/master) = $(cat os-checksum-3)$"
assert_file_has_content find "^1/1 refs were found.$"
assert_not_file_has_content find "^No results.$"
# Pull it.
${CMD_PREFIX} ostree --repo=$repo find-remotes --pull org.example.OsCollection os/amd64/master > pull || true
assert_file_has_content pull "^1/1 refs were found.$"
assert_file_has_content pull "^Pulled 1/1 refs successfully.$"
assert_not_file_has_content pull "Failed to pull some refs from the remotes"
assert_ref $repo os/amd64/master $(cat os-checksum-3)
done
echo "ok find-remotes"
+72
View File
@@ -0,0 +1,72 @@
#!/bin/bash
#
# Copyright © 2017 Endless Mobile, Inc.
#
# 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.
set -euo pipefail
. $(dirname $0)/libtest.sh
echo '1..2'
cd ${test_tmpdir}
# Check that fsck detects errors with refs which have collection IDs (i.e. refs in refs/mirrors).
set_up_repo() {
rm -rf repo files
mkdir repo
ostree_repo_init repo
mkdir files
pushd files
${CMD_PREFIX} ostree --repo=../repo commit -s "Commit 1" -b original-ref > ../original-ref-checksum
popd
${CMD_PREFIX} ostree --repo=repo refs --collections --create=org.example.Collection:some-ref $(cat original-ref-checksum)
}
set_up_repo
# fsck at this point should succeed
${CMD_PREFIX} ostree fsck --repo=repo > fsck
assert_file_has_content fsck "^Validating refs in collections...$"
# Drop the commit the ref points to, and drop the original ref so that fsck doesn’t prematurely fail on that.
find repo/objects -name '*.commit' -delete -print | wc -l > commitcount
assert_file_has_content commitcount "^1$"
rm repo/refs/heads/original-ref
# fsck should now fail
if ${CMD_PREFIX} ostree fsck --repo=repo > fsck; then
assert_not_reached "fsck unexpectedly succeeded after deleting commit!"
fi
assert_file_has_content fsck "^Validating refs...$"
assert_file_has_content fsck "^Validating refs in collections...$"
echo "ok 1 fsck-collections"
# Try fsck in an old repository where refs/mirrors doesn’t exist to begin with.
# It should succeed.
set_up_repo
rm -rf repo/refs/mirrors
${CMD_PREFIX} ostree fsck --repo=repo > fsck
assert_file_has_content fsck "^Validating refs...$"
assert_file_has_content fsck "^Validating refs in collections...$"
echo "ok 2 fsck-collections in old repository"
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
#
# Copyright © 2017 Endless Mobile, Inc.
#
# 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.
set -euo pipefail
. $(dirname $0)/libtest.sh
echo '1..1'
cd ${test_tmpdir}
# Check that initialising a repository with a collection ID results in the ID being in the config.
mkdir repo
ostree_repo_init repo --collection-id org.example.Collection
assert_file_has_content repo/config "^collection-id=org.example.Collection$"
echo "ok init-collections"
+79
View File
@@ -0,0 +1,79 @@
#!/bin/bash
#
# Copyright © 2017 Endless Mobile, Inc.
#
# 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.
set -euo pipefail
. $(dirname $0)/libtest.sh
echo '1..2'
cd ${test_tmpdir}
# Check that refs with collection IDs (i.e. refs in refs/mirrors) are taken into account
# when computing reachability of objects while pruning.
set_up_repo() {
rm -rf repo files
mkdir repo
ostree_repo_init repo
mkdir files
pushd files
${CMD_PREFIX} ostree --repo=../repo commit -s "Commit 1" -b original-ref > ../original-ref-checksum
popd
${CMD_PREFIX} ostree --repo=repo refs --collections --create=org.example.Collection:some-ref $(cat original-ref-checksum)
}
set_up_repo
# Try deleting a specific commit which is still pointed to by both refs.
if ${CMD_PREFIX} ostree --repo=repo prune --delete-commit=$(cat original-ref-checksum) 2>/dev/null; then
assert_not_reached "prune unexpectedly succeeded in deleting a referenced commit!"
fi
# Pruning normally should do nothing.
${CMD_PREFIX} ostree --repo=repo prune --refs-only > prune
assert_file_has_content prune "^Total objects: 3$"
assert_file_has_content prune "^No unreachable objects$"
# Remove the original-ref so that only the some-ref with a collection ID points to the commit.
${CMD_PREFIX} ostree --repo=repo refs --delete original-ref
${CMD_PREFIX} ostree --repo=repo prune --refs-only > prune
assert_file_has_content prune "^Total objects: 3$"
assert_file_has_content prune "^No unreachable objects$"
# Remove the second ref so that the commit is now orphaned.
${CMD_PREFIX} ostree --repo=repo refs --collections --delete org.example.Collection
${CMD_PREFIX} ostree --repo=repo prune --refs-only > prune
assert_file_has_content prune "^Total objects: 3$"
assert_file_has_content prune "^Deleted 3 objects, [0-9]\+ bytes freed$"
echo "ok 1 prune-collections"
# Try again, but in an old repository where refs/mirrors doesn’t exist to begin with.
set_up_repo
rm -rf repo/refs/mirrors
${CMD_PREFIX} ostree --repo=repo prune --refs-only > prune
assert_file_has_content prune "^Total objects: 3$"
assert_file_has_content prune "^No unreachable objects$"
echo "ok 2 prune-collections in old repository"
@@ -23,4 +23,5 @@ set -euo pipefail
setup_fake_remote_repo1 "archive"
repo_mode=bare
. ${test_srcdir}/pull-test.sh
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# 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.
set -euo pipefail
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive"
repo_mode=bare-user
. ${test_srcdir}/pull-test.sh
+246
View File
@@ -0,0 +1,246 @@
#!/bin/bash
#
# Copyright © 2017 Endless Mobile, Inc.
#
# 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.
set -euo pipefail
. $(dirname $0)/libtest.sh
echo '1..6'
cd ${test_tmpdir}
do_commit() {
local repo=$1
local branch=$2
shift 2
mkdir -p files
pushd files
${CMD_PREFIX} ostree --repo="../${repo}" commit -s "Test ${repo} commit for branch ${branch}" -b "${branch}" --gpg-homedir="${TEST_GPG_KEYHOME}" --gpg-sign="${TEST_GPG_KEYID_1}" "$@" > "../${branch}-checksum"
popd
}
do_summary() {
local repo=$1
shift 1
${CMD_PREFIX} ostree "--repo=${repo}" summary --update --gpg-homedir="${TEST_GPG_KEYHOME}" --gpg-sign="${TEST_GPG_KEYID_1}"
}
do_collection_ref_show() {
local repo=$1
local branch=$2
shift 2
echo -n "collection ID: "
if ${CMD_PREFIX} ostree "--repo=${repo}" show --print-metadata-key=ostree.collection-binding $(cat "${branch}-checksum")
then :
else return 1
fi
echo -n "refs: "
if ${CMD_PREFIX} ostree "--repo=${repo}" show --print-metadata-key=ostree.ref-binding $(cat "${branch}-checksum")
then return 0
else return 1
fi
}
ensure_no_collection_ref() {
local repo=$1
local branch=$2
local error=$3
shift 3
if do_collection_ref_show "${repo}" "${branch}" >/dev/null
then
assert_not_reached "${error}"
fi
}
do_join() {
local IFS=', '
echo "$*"
}
ensure_collection_ref() {
local repo=$1
local branch=$2
local collection_id=$3
shift 3
local refs=$(do_join "$@")
do_collection_ref_show "${repo}" "${branch}" >"${branch}-meta"
assert_file_has_content "${branch}-meta" "^collection ID: '${collection_id}'$"
assert_file_has_content "${branch}-meta" "^refs: \['${refs}'\]$"
}
do_remote_add() {
local repo=$1
local remote_repo=$2
shift 2
${CMD_PREFIX} ostree "--repo=${repo}" remote add "${remote_repo}-remote" "file://$(pwd)/${remote_repo}" "$@" --gpg-import="${test_tmpdir}/gpghome/key1.asc"
}
do_pull() {
local repo=$1
local remote_repo=$2
local branch=$3
shift 3
if ${CMD_PREFIX} ostree "--repo=${repo}" pull "${remote_repo}-remote" "${branch}"
then return 0
else return 1
fi
}
do_local_pull() {
local repo=$1
local remote_repo=$2
local branch=$3
shift 3
if ${CMD_PREFIX} ostree "--repo=${repo}" pull-local "${remote_repo}" "${branch}"
then return 0
else return 1
fi
}
# Create a repo without the collection ID.
mkdir no-collection-repo
ostree_repo_init no-collection-repo
do_commit no-collection-repo goodncref1
do_commit no-collection-repo sortofbadncref1 --add-metadata-string=ostree.collection-binding=org.example.Ignored
do_summary no-collection-repo
ensure_no_collection_ref \
no-collection-repo \
goodncref1 \
"commits in repository without collection ID shouldn't normally contain the ostree.commit.collection metadata information"
ensure_collection_ref no-collection-repo sortofbadncref1 'org.example.Ignored' 'sortofbadncref1'
echo "ok 1 setup remote repo without collection ID"
# Create a repo with a collection ID.
mkdir collection-repo
ostree_repo_init collection-repo
do_commit collection-repo badcref1 # has no collection ref
# We set the repo collection ID in this hacky way to get the commit
# without the collection ID.
echo "collection-id=org.example.CollectionRepo" >>collection-repo/config
do_commit collection-repo badcref2 --add-metadata-string=ostree.collection-binding=org.example.Whatever
do_commit collection-repo badcref3 --add-metadata-string=ostree.collection-binding=
do_commit collection-repo goodcref1
# create a badcref4 ref with a commit that has goodcref1 in its collection ref metadata
${CMD_PREFIX} ostree --repo=collection-repo refs --create=badcref4 $(cat goodcref1-checksum)
do_summary collection-repo
ensure_no_collection_ref \
collection-repo \
badcref1 \
"commit in badcref1 should not have the collection ref metadata information"
ensure_collection_ref collection-repo badcref2 'org.example.Whatever' 'badcref2'
ensure_collection_ref collection-repo badcref3 '' 'badcref3'
ensure_collection_ref collection-repo goodcref1 'org.example.CollectionRepo' 'goodcref1'
echo "ok 2 setup remote repo with collection ID"
# Create a local repo without the collection ID.
mkdir no-collection-local-repo
ostree_repo_init no-collection-local-repo
do_commit no-collection-local-repo goodnclref1
do_commit no-collection-local-repo sortofbadnclref1 --add-metadata-string=ostree.collection-binding=org.example.IgnoredLocal
do_summary no-collection-local-repo
ensure_no_collection_ref \
no-collection-local-repo \
goodnclref1 \
"commits in repository without collection ID shouldn't normally contain the ostree.commit.collection metadata information"
ensure_collection_ref no-collection-local-repo sortofbadnclref1 'org.example.IgnoredLocal' 'sortofbadnclref1'
echo "ok 3 setup local repo without collection ID"
# Create a local repo with a collection ID.
mkdir collection-local-repo
ostree_repo_init collection-local-repo
do_commit collection-local-repo badclref1 # has no collection ref
# We set the repo collection ID in this hacky way to get the commit
# without the collection ID.
echo "collection-id=org.example.CollectionRepoLocal" >>collection-local-repo/config
do_commit collection-local-repo badclref2 --add-metadata-string=ostree.collection-binding=org.example.WhateverLocal
do_commit collection-local-repo badclref3 --add-metadata-string=ostree.collection-binding=
do_commit collection-local-repo goodclref1
# create a badclref4 ref with a commit that has goodclref1 in its collection ref metadata
${CMD_PREFIX} ostree --repo=collection-local-repo refs --create=badclref4 $(cat goodclref1-checksum)
do_summary collection-local-repo
ensure_no_collection_ref \
collection-local-repo \
badclref1 \
"commit in badclref1 should not have the collection ref metadata information"
ensure_collection_ref collection-local-repo badclref2 'org.example.WhateverLocal' 'badclref2'
ensure_collection_ref collection-local-repo badclref3 '' 'badclref3'
ensure_collection_ref collection-local-repo goodclref1 'org.example.CollectionRepoLocal' 'goodclref1'
echo "ok 4 setup local repo with collection ID"
# Create a local repository where we pull the branches from the remotes as normal, using GPG.
mkdir local
ostree_repo_init local
do_remote_add local collection-repo --collection-id org.example.CollectionRepo
do_remote_add local no-collection-repo
do_pull local no-collection-repo goodncref1
do_pull local no-collection-repo sortofbadncref1
if do_pull local collection-repo badcref1
then
assert_not_reached "pulling a commit without collection ID from a repo with collection ID should fail"
fi
if do_pull local collection-repo badcref2
then
assert_not_reached "pulling a commit with a mismatched collection ID from a repo with collection ID should fail"
fi
if do_pull local collection-repo badcref3
then
assert_not_reached "pulling a commit with empty collection ID from repo with collection ID should fail"
fi
do_pull local collection-repo goodcref1
if do_pull local collection-repo badcref4
then
assert_not_reached "pulling a commit that was not requested from repo with collection ID should fail"
fi
echo "ok 5 pull refs from remote repos"
do_local_pull local no-collection-local-repo goodnclref1
do_local_pull local no-collection-local-repo sortofbadnclref1
if do_local_pull local collection-local-repo badclref1
then
assert_not_reached "pulling a commit without collection ID from a repo with collection ID should fail"
fi
if do_local_pull local collection-local-repo badclref2
then
assert_not_reached "pulling a commit with a mismatched collection ID from a repo with collection ID should fail"
fi
if do_local_pull local collection-local-repo badclref3
then
assert_not_reached "pulling a commit with empty collection ID from repo with collection ID should fail"
fi
do_local_pull local collection-local-repo goodclref1
if do_local_pull local collection-local-repo badclref4
then
assert_not_reached "pulling a commit that was not requested from repo with collection ID should fail"
fi
echo "ok 6 pull refs from local repos"
+125
View File
@@ -0,0 +1,125 @@
#!/bin/bash
#
# Copyright © 2016 Red Hat, Inc.
# Copyright © 2017 Endless Mobile, Inc.
#
# 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.
set -euo pipefail
. $(dirname $0)/libtest.sh
echo '1..2'
cd ${test_tmpdir}
mkdir repo
ostree_repo_init repo --collection-id org.example.Collection
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
# The collection IDs should only be listed if --collections is passed.
${CMD_PREFIX} ostree --repo=repo refs | wc -l > refscount
assert_file_has_content refscount "^5$"
${CMD_PREFIX} ostree --repo=repo refs > refs
assert_file_has_content refs "^test\-1$"
assert_file_has_content refs "^test\-5$"
assert_not_file_has_content refs "org.example.Collection"
${CMD_PREFIX} ostree --repo=repo refs --collections > refs
assert_file_has_content refs "^(org.example.Collection, test-1)$"
assert_file_has_content refs "^(org.example.Collection, test-5)$"
# Similarly, the collection IDs should only be listed when filtering if --collections is passed.
${CMD_PREFIX} ostree --repo=repo refs --list org.example.Collection | wc -l > refscount
assert_file_has_content refscount "^0$"
${CMD_PREFIX} ostree --repo=repo refs --collections --list org.example.Collection | wc -l > refscount
assert_file_has_content refscount "^5$"
# --delete by itself should fail.
${CMD_PREFIX} ostree --repo=repo refs --delete 2>/dev/null || true
${CMD_PREFIX} ostree --repo=repo refs | wc -l > refscount.delete1
assert_file_has_content refscount.delete1 "^5$"
# Deleting specific refs should work.
${CMD_PREFIX} ostree refs --delete 2>/dev/null && (echo 1>&2 "refs --delete (without prefix) unexpectedly succeeded!"; exit 1)
${CMD_PREFIX} ostree --repo=repo refs --delete test-1 test-2
${CMD_PREFIX} ostree --repo=repo refs | wc -l > refscount.delete2
assert_file_has_content refscount.delete2 "^3$"
${CMD_PREFIX} ostree --repo=repo refs > refs.delete2
assert_not_file_has_content refs.delete2 '^test-1$'
assert_not_file_has_content refs.delete2 '^test-2$'
assert_file_has_content refs.delete2 '^test-3$'
# Deleting by collection ID should only work if --collections is passed.
${CMD_PREFIX} ostree refs --repo=repo --delete org.example.Collection
${CMD_PREFIX} ostree refs --repo=repo | wc -l > refscount.delete3
assert_file_has_content refscount.delete3 "^3$"
${CMD_PREFIX} ostree refs --repo=repo --collections --delete org.example.Collection
${CMD_PREFIX} ostree refs --repo=repo | wc -l > refscount.delete4
assert_file_has_content refscount.delete4 "^0$"
# Add a few more commits, to test --create
${CMD_PREFIX} ostree --repo=repo commit --branch=ctest -m ctest -s ctest tree
${CMD_PREFIX} ostree --repo=repo refs | wc -l > refscount
assert_file_has_content refscount "^1$"
# and test mirrored branches
${CMD_PREFIX} ostree --repo=repo refs --collections --create=org.example.NewCollection:ctest-mirror ctest
${CMD_PREFIX} ostree --repo=repo refs | wc -l > refscount
assert_file_has_content refscount "^1$"
${CMD_PREFIX} ostree --repo=repo refs --collections | wc -l > refscount
assert_file_has_content refscount "^2$"
${CMD_PREFIX} ostree --repo=repo refs > refs
assert_file_has_content refs "^ctest$"
assert_not_file_has_content refs "^ctest-mirror$"
${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)$"
echo "ok 1 refs collections"
# Test that listing, creating and deleting refs works from an old repository
# where refs/mirrors doesn’t exist to begin with.
rm -rf repo/refs/mirrors
${CMD_PREFIX} ostree --repo=repo refs
rm -rf repo/refs/mirrors
${CMD_PREFIX} ostree --repo=repo refs --collections
rm -rf repo/refs/mirrors
${CMD_PREFIX} ostree --repo=repo refs --collections --create=org.example.NewCollection:ctest-mirror ctest
${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)$"
rm -rf repo/refs/mirrors
${CMD_PREFIX} ostree refs --repo=repo --collections --delete org.example.NonexistentCollection
echo "ok 2 refs collections in old repository"
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
#
# Copyright © 2017 Endless Mobile, Inc.
#
# 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.
set -euo pipefail
. $(dirname $0)/libtest.sh
echo '1..1'
cd ${test_tmpdir}
# Check that adding a remote with a collection ID results in the ID being in the config.
mkdir repo
ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add some-remote https://example.com/ --collection-id example-id --gpg-import=${test_tmpdir}/gpghome/key1.asc
assert_file_has_content repo/config "^collection-id=example-id$"
echo "ok remote-add-collections"
Regular → Executable
+3 -1
View File
@@ -26,6 +26,8 @@ function assertEquals(a, b) {
throw new Error("assertion failed " + JSON.stringify(a) + " == " + JSON.stringify(b));
}
print('1..1')
let testDataDir = Gio.File.new_for_path('test-data');
testDataDir.make_directory(null);
testDataDir.get_child('some-file').replace_contents("hello world!", null, false, 0, null);
@@ -79,4 +81,4 @@ if (expectedUncompressedSizes.length > 0) {
throw new Error("Failed to match expectedUncompressedSizes: " + JSON.stringify(expectedUncompressedSizes));
}
print("test-sizes complete");
print("ok test-sizes");
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash
#
# Copyright © 2016 Red Hat, Inc.
# Copyright © 2017 Endless Mobile, Inc.
#
# 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.
set -euo pipefail
. $(dirname $0)/libtest.sh
echo '1..1'
cd ${test_tmpdir}
mkdir repo
ostree_repo_init repo --collection-id org.example.Collection
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
# Check that they are all listed, with the repository’s collection ID, in the summary.
${CMD_PREFIX} ostree --repo=repo summary --update
${CMD_PREFIX} ostree --repo=repo summary --view > summary
assert_file_has_content summary "(org.example.Collection, test-1)$"
assert_file_has_content summary "(org.example.Collection, test-2)$"
assert_file_has_content summary "(org.example.Collection, test-3)$"
assert_file_has_content summary "(org.example.Collection, test-4)$"
assert_file_has_content summary "(org.example.Collection, test-5)$"
assert_file_has_content summary "^Collection ID (ostree\.summary\.collection-id): org.example.Collection$"
# Test that mirrored branches are listed too.
${CMD_PREFIX} ostree --repo=repo refs --collections --create=org.example.OtherCollection:test-1-mirror test-1
${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)$"
echo "ok summary collections"
+1 -1
View File
@@ -52,7 +52,7 @@ echo 'ok documented symbols'
# ONLY update this checksum in release commits!
cat > released-sha256.txt <<EOF
d3f3d564e4679d603220da0cea940867fde28622857d088a8287db730bcc8001 ${released_syms}
d96fc94ded6c862099654bf8eb3ea82c760ee4d6f193cb3380663f35602468d4 ${released_syms}
EOF
sha256sum -c released-sha256.txt
Regular → Executable
+5 -1
View File
@@ -33,11 +33,13 @@ function assertNotEquals(a, b) {
function libtestExec(shellCode) {
let testdatadir = GLib.getenv("G_TEST_SRCDIR");
let libtestPath = GLib.build_filenamev([testdatadir, 'libtest.sh'])
let libtestPath = GLib.build_filenamev([testdatadir, 'tests/libtest.sh'])
let proc = Gio.Subprocess.new(['bash', '-c', 'set -xeuo pipefail; . ' + GLib.shell_quote(libtestPath) + '; ' + shellCode], 0);
proc.wait_check(null);
}
print('1..1')
libtestExec('setup_os_repository archive-z2 syslinux');
let upstreamRepo = OSTree.Repo.new(Gio.File.new_for_path('testos-repo'));
@@ -145,3 +147,5 @@ newDeployments = [deployment, newDeployment, thirdDeployment];
sysroot.write_deployments(newDeployments, null);
deployments = sysroot.get_deployments();
assertEquals(deployments.length, 3);
print("ok test-sysroot")