2016-11-14 20:07:43 +03:00
#!/bin/bash
2019-05-03 23:14:41 +03:00
set -xeuo pipefail
2016-11-14 20:07:43 +03:00
# Execute this code path on the host
2016-11-22 06:22:51 +03:00
if test -z " ${ INSIDE_VM :- } " ; then
2016-11-14 20:07:43 +03:00
. ${ commondir } /libvm.sh
2016-11-22 06:22:51 +03:00
vm_setup
if ! vm_ssh_wait 30; then
echo "ERROR: A running VM is required for 'make vmcheck'."
exit 1
fi
2016-11-14 20:07:43 +03:00
vm_rsync
2017-12-15 20:01:46 +03:00
2019-05-03 23:14:41 +03:00
vm_rpmostree status --json > ${ VM } -out.json
commit = $( jq -r '.deployments[0]["checksum"]' < ${ VM } -out.json)
origin = $( jq -r '.deployments[0]["origin"]' < ${ VM } -out.json)
version = $( jq -r '.deployments[0]["version"]' < ${ VM } -out.json)
timestamp = $( jq -r '.deployments[0]["timestamp"]' < ${ VM } -out.json)
rm -f ${ VM } -out.json
2018-02-27 00:16:21 +03:00
vm_cmd env \
RPMOSTREE_TEST_NO_OVERLAY = " ${ RPMOSTREE_TEST_NO_OVERLAY :- } " \
2019-05-03 23:14:41 +03:00
INSIDE_VM = 1 /var/roothome/sync/tests/vmcheck/overlay.sh \
$commit $origin $version $timestamp
2016-11-22 06:22:51 +03:00
vm_reboot
2016-11-14 20:07:43 +03:00
exit 0
fi
# And then this code path in the VM
2018-01-12 23:55:34 +03:00
# get details from the current default deployment
rpm-ostree status --json > json.txt
2019-05-03 23:14:41 +03:00
commit = $1 ; shift
origin = $1 ; shift
version = $1 ; shift
timestamp = $1 ; shift
2018-01-12 23:55:34 +03:00
[ -n " $timestamp " ]
timestamp = $( date -d " @ $timestamp " "+%b %d %Y" )
2016-11-14 20:07:43 +03:00
if [ [ -z $commit ] ] || ! ostree rev-parse $commit ; then
echo "Error while determining current commit" >& 2
exit 1
fi
cd /ostree/repo/tmp
rm vmcheck -rf
ostree checkout $commit vmcheck --fsync= 0
2017-04-13 17:52:04 +03:00
rm vmcheck/etc -rf
2017-07-27 18:25:38 +03:00
2018-02-14 17:55:39 +03:00
# Now, overlay our built binaries & config files, unless
# explicitly requested not to (with the goal of testing the
# tree shipped as is with our existing tests).
if test -z " ${ RPMOSTREE_TEST_NO_OVERLAY } " ; then
INSTTREE = /var/roothome/sync/insttree
rsync -rlv $INSTTREE /usr/ vmcheck/usr/
rsync -rlv $INSTTREE /etc/ vmcheck/usr/etc/
else
echo "Skipping overlay of built rpm-ostree"
fi
2017-09-01 23:35:52 +03:00
2018-01-12 23:55:34 +03:00
# ✀✀✀ BEGIN hack to get --keep-metadata
if ! ostree commit --help | grep -q -e --keep-metadata; then
# this is fine, rsync doesn't modify in place
mount -o rw,remount /usr
# don't overwrite /etc/ to not mess up 3-way merge
rsync -rlv --exclude '/etc/' vmcheck/usr/ /usr/
fi
# ✀✀✀ END hack to get --keep-metadata ✀✀✀
2017-12-15 20:01:46 +03:00
# if the commit already has pkglist metadata (i.e. the tree was composed with at
# least v2018.1), make sure it gets preserved, because it's useful for playing
# around (but note it's not a requirement for our tests)
2017-12-22 10:50:19 +03:00
commit_opts =
2017-12-15 20:01:46 +03:00
if ostree show $commit --raw | grep -q rpmostree.rpmdb.pkglist; then
commit_opts = " ${ commit_opts } --keep-metadata=rpmostree.rpmdb.pkglist "
fi
2018-01-12 23:55:34 +03:00
source_opt = # make this its own var since it contains spaces
if [ $origin != vmcheck ] ; then
source_title = " ${ origin } "
2019-05-03 23:14:41 +03:00
if [ [ $version != null ] ] ; then
2018-01-12 23:55:34 +03:00
source_title = " ${ source_title } ( ${ version } ; $timestamp ) "
else
source_title = " ${ source_title } ( $timestamp ) "
fi
source_opt = " --add-metadata-string=ostree.source-title=Dev overlay on ${ source_title } "
commit_opts = " ${ commit_opts } --add-metadata-string=rpmostree.original-origin= ${ origin } "
2018-01-12 23:55:34 +03:00
else
2018-01-12 23:55:34 +03:00
source_opt = "--keep-metadata=ostree.source-title"
commit_opts = " ${ commit_opts } --keep-metadata=rpmostree.original-origin "
2018-01-12 23:55:34 +03:00
fi
2018-01-18 21:13:39 +03:00
ostree commit --parent= $commit -b vmcheck --consume --no-bindings \
2018-01-12 23:55:34 +03:00
--link-checkout-speedup ${ commit_opts } " ${ source_opt } " \
2017-11-29 05:37:06 +03:00
--selinux-policy= vmcheck --tree= dir = vmcheck
2017-12-15 20:01:46 +03:00
2016-11-14 20:07:43 +03:00
ostree admin deploy vmcheck