2016-11-14 20:07:43 +03:00
#!/bin/bash
set -euo pipefail
# 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-07-27 17:16:23 +03:00
vm_cmd env INSIDE_VM = 1 /var/roothome/sync/tests/vmcheck/overlay.sh
2016-11-22 06:22:51 +03:00
vm_reboot
2016-11-14 20:07:43 +03:00
exit 0
fi
set -x
# And then this code path in the VM
2017-06-12 19:50:42 +03:00
# get csum of current default deployment
2016-11-14 20:07:43 +03:00
commit = $( rpm-ostree status --json | \
python -c '
import sys, json;
2017-06-12 19:50:42 +03:00
deployment = json.load( sys.stdin) [ "deployments" ] [ 0]
print deployment[ "checksum" ]
exit( ) ' )
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
# Now, overlay our built binaries & config files
INSTTREE = /var/roothome/sync/insttree
rsync -rlv $INSTTREE /usr/ vmcheck/usr/
if [ -d $INSTTREE /etc ] ; then # on CentOS, the dbus service file is in /usr
rsync -rlv $INSTTREE /etc/ vmcheck/usr/etc/
fi
2017-09-01 23:35:52 +03:00
# ✀✀✀ BEGIN hack to get --selinux-policy (https://github.com/ostreedev/ostree/pull/1114) ✀✀✀
if ! ostree commit --help | grep -q -e --selinux-policy; 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 --selinux-policy ✀✀✀
2017-09-19 22:20:09 +03:00
# ✀✀✀ BEGIN tmp hack for https://github.com/projectatomic/rpm-ostree/pull/999
rm -vrf vmcheck/usr/etc/selinux/targeted/semanage.*.LOCK
# ✀✀✀ END tmp hack
2016-11-14 20:07:43 +03:00
ostree refs --delete vmcheck || true
2017-09-01 23:35:52 +03:00
ostree commit -b vmcheck --link-checkout-speedup \
--selinux-policy= vmcheck --tree= dir = vmcheck
2016-11-14 20:07:43 +03:00
ostree admin deploy vmcheck