vmcheck/overlay: Drop dependency on host Python

Also switch to using `jq` on the controlling host instead of Python.

This is also prep for switching CI to FCOS which is likely to not ship
Python at all. There are still spots a bit everywhere where we currently
assume Python on the target host. We'll have to address those soon.

Closes: #1828
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2019-05-03 16:14:41 -04:00 committed by Atomic Bot
parent c89f81c138
commit 9f618d0acc

View File

@ -1,5 +1,5 @@
#!/bin/bash
set -euo pipefail
set -xeuo pipefail
# Execute this code path on the host
if test -z "${INSIDE_VM:-}"; then
@ -13,34 +13,31 @@ if test -z "${INSIDE_VM:-}"; then
vm_rsync
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
vm_cmd env \
RPMOSTREE_TEST_NO_OVERLAY="${RPMOSTREE_TEST_NO_OVERLAY:-}" \
INSIDE_VM=1 /var/roothome/sync/tests/vmcheck/overlay.sh
INSIDE_VM=1 /var/roothome/sync/tests/vmcheck/overlay.sh \
$commit $origin $version $timestamp
vm_reboot
exit 0
fi
set -x
# And then this code path in the VM
# get details from the current default deployment
rpm-ostree status --json > json.txt
json_field() {
field=$1; shift;
python -c "
import sys, json;
deployment = json.load(open('json.txt'))['deployments'][0]
print deployment.get('$field', '')
exit()"
}
commit=$(json_field checksum)
origin=$(json_field origin)
version=$(json_field version)
timestamp=$(json_field timestamp)
commit=$1; shift
origin=$1; shift
version=$1; shift
timestamp=$1; shift
[ -n "$timestamp" ]
timestamp=$(date -d "@$timestamp" "+%b %d %Y")
rm -f json.txt
if [[ -z $commit ]] || ! ostree rev-parse $commit; then
echo "Error while determining current commit" >&2
@ -83,7 +80,7 @@ fi
source_opt= # make this its own var since it contains spaces
if [ $origin != vmcheck ]; then
source_title="${origin}"
if [ -n "$version" ]; then
if [[ $version != null ]]; then
source_title="${source_title} (${version}; $timestamp)"
else
source_title="${source_title} ($timestamp)"