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
set -x
2016-12-21 07:22:03 +03:00
cd ${ topsrcdir }
2017-03-11 01:43:23 +03:00
2017-03-23 20:57:56 +03:00
# Support local development with e.g. an ostree built from git too,
# or libasan.
export VMCHECK_INSTTREE = ${ VMCHECK_INSTTREE :- $( pwd ) /insttree }
2017-03-11 01:43:23 +03:00
# Use a lock in case we're called in parallel (make install might fail).
# Plus, we can just share the same install tree, and sharing is caring!
flock insttree.lock sh -ec \
2017-03-23 20:57:56 +03:00
' [ ! -d ${ VMCHECK_INSTTREE } ] || exit 0
DESTDIR = ${ VMCHECK_INSTTREE }
2017-04-28 18:40:22 +03:00
mkdir -p ${ DESTDIR }
# Always pull ostree from the build container; we assume development and testing
2017-05-29 17:46:47 +03:00
# is against git master. See also sync.sh and build.sh.
2017-04-28 18:40:22 +03:00
ostree --version
for pkg in ostree{ ,-libs,-grub2} ; do
rpm -q $pkg
# We do not have perms to read /etc/grub2 as non-root
2017-07-11 02:18:47 +03:00
rpm -ql $pkg | grep -v '^/etc/' | sed "s/^/+ /" > list.txt
echo "- *" >> list.txt
2017-04-28 18:40:22 +03:00
# In the prebuilt container case, manpages are missing. Ignore that.
# Also chown everything to writable, due to https://bugzilla.redhat.com/show_bug.cgi?id=517575
chmod -R u+w ${ DESTDIR } /
2017-07-11 02:18:47 +03:00
# The --ignore-missing-args option was added in rsync 3.1.0,
# but CentOS7 only has rsync 3.0.9. Can simulate the behavior
# with --include-from and the way we constructed list.txt.
rsync -l --include-from= list.txt / ${ DESTDIR } /
2017-04-28 18:40:22 +03:00
rm -f list.txt
done
2017-03-11 01:43:23 +03:00
make install DESTDIR = ${ DESTDIR }
touch ${ DESTDIR } /.completed'
2017-03-23 20:57:56 +03:00
[ -f ${ VMCHECK_INSTTREE } /.completed ]
2017-03-11 01:43:23 +03:00
2016-11-14 20:07:43 +03:00
vm_rsync
2016-11-22 06:22:51 +03:00
$SSH "env INSIDE_VM=1 /var/roothome/sync/tests/vmcheck/overlay.sh"
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-03-18 16:21:56 +03:00
# ✀✀✀ BEGIN hack for https://github.com/projectatomic/rpm-ostree/pull/693 ✀✀✀
rm -f vmcheck/usr/etc/{ .pwd.lock,passwd-,group-,shadow-,gshadow-,subuid-,subgid-}
# ✀✀✀ END hack for https://github.com/projectatomic/rpm-ostree/pull/693 ✀✀✀
2017-04-13 17:52:04 +03:00
rm vmcheck/etc -rf
2017-03-18 16:44:05 +03:00
# Now, overlay our built binaries
2017-01-19 21:21:14 +03:00
rsync -rlv /var/roothome/sync/insttree/usr/ vmcheck/usr/
2016-11-14 20:07:43 +03:00
ostree refs --delete vmcheck || true
ostree commit -b vmcheck -s '' --tree= dir = vmcheck --link-checkout-speedup
ostree admin deploy vmcheck