assert_not_streq ${head_rev} ${prev_rev}
# check that we can't "upgrade" to an older commit without --allow-downgrade
if ${CMD_PREFIX} ostree admin upgrade --os=testos --override-commit=${prev_rev} 2> err.txt; then
+ ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo show "${prev_rev}"
+ ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo show "${head_rev}"
fatal "downgraded without --allow-downgrade?"
fi
assert_file_has_content err.txt "Upgrade.*is chronologically older"
cd ${oldpwd}
}
+timestamp_of_commit()
+{
+ date --date="$(ostree --repo=$1 show $2 | grep -Ee '^Date: ' | sed -e 's,^Date: *,,')" '+%s'
+}
+
os_repository_new_commit ()
{
boot_checksum_iteration=${1:-0}
echo "content iteration ${content_iteration}" > usr/bin/content-iteration
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string "version=${version}" -b $branch -s "Build"
+ if ${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo rev-parse ${branch} 2>/dev/null; then
+ prevdate=$(timestamp_of_commit ${test_tmpdir}/testos-repo "${branch}"^)
+ newdate=$(timestamp_of_commit ${test_tmpdir}/testos-repo "${branch}")
+ if [ $((${prevdate} > ${newdate})) = 1 ]; then
+ fatal "clock skew detected writing commits: prev=${prevdate} new=${newdate}"
+ fi
+ fi
cd ${test_tmpdir}
}