From c38a3007e01b85c06f77a10c5919ca2ea97e81ee Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 11 Sep 2018 15:22:51 -0400 Subject: [PATCH] Add a `kola` verb This is the first place we're wrapping mantle via our main entrypoint, and hopefully we'll increase that. For now we hardcode `-b rhcos`...but that should change. Example usage: `coreos-assembler kola run rhcos.basic`. Requires: https://github.com/coreos/mantle/pull/920 --- src/cmd-kola | 12 ++++++++++++ src/cmd-run | 9 +++++---- src/cmdlib.sh | 13 +++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 src/cmd-kola diff --git a/src/cmd-kola b/src/cmd-kola new file mode 100644 index 0000000000..466f2d9102 --- /dev/null +++ b/src/cmd-kola @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -xeuo pipefail + +dn=$(dirname $0) +. ${dn}/cmdlib.sh + +latest_qcow=$(get_latest_qcow) +if [ -z "${latest_qcow}" ]; then + fatal "No latest build" +fi + +exec sudo kola -b rhcos --tapfile test.tap --qemu-image ${latest_qcow} "$@" diff --git a/src/cmd-run b/src/cmd-run index 17f58c9e65..64e1dad5aa 100755 --- a/src/cmd-run +++ b/src/cmd-run @@ -7,6 +7,9 @@ set -euo pipefail +dn=$(dirname $0) +. ${dn}/cmdlib.sh + VM_DISK= VM_MEMORY=2048 VM_PERSIST=0 @@ -71,10 +74,8 @@ while [ $# -ge 1 ]; do done if [ -z "${VM_DISK}" ]; then - if [ -L ./builds/latest ]; then - latest_build=$(readlink builds/latest) - VM_DISK=$(ls builds/${latest_build}/*-qemu.qcow2) - else + VM_DISK=$(get_latest_qcow) + if [ -z "${VM_DISK}" ]; then die "No builds/latest, and no -d argument provided" fi fi diff --git a/src/cmdlib.sh b/src/cmdlib.sh index 31881d049e..95b71450b2 100755 --- a/src/cmdlib.sh +++ b/src/cmdlib.sh @@ -92,3 +92,16 @@ runcompose() { ${TREECOMPOSE_FLAGS:-} ${manifest} "$@" set +x } + +get_latest_build() { + if [ -L builds/latest ]; then + readlink builds/latest + fi +} + +get_latest_qcow() { + local latest=$(get_latest_build) + if [ -n "$latest" ]; then + ls builds/${latest}/*-qemu.qcow2 + fi +}