diff --git a/src/cmd-kola b/src/cmd-kola new file mode 100755 index 0000000000..6080b3f03d --- /dev/null +++ b/src/cmd-kola @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +dn=$(dirname $0) +. ${dn}/cmdlib.sh + +latest_qcow=$(get_latest_qemu) +if [ -z "${latest_qcow}" ]; then + fatal "No latest build" +fi + +# XXX: teach to kola to auto-detect based on prefix; see discussions in +# https://github.com/coreos/coreos-assembler/pull/85 +distro= +bn=$(basename "${latest_qcow}") +if [[ ${bn} = fedora-coreos-* ]]; then + distro="-b fcos" +elif [[ ${bn} = rhcos-* ]]; then + distro="-b rhcos --ignition-version v2" +else + echo "WARNING: Failed to detect distro, use -b to specify" +fi + +# let's print out the actual exec() call we do +set -x + +# shellcheck disable=SC2086 +exec kola $distro --output-dir tmp/kola --qemu-image "${latest_qcow}" "$@" diff --git a/src/cmd-run b/src/cmd-run index 4dafceae3f..6c89e60383 100755 --- a/src/cmd-run +++ b/src/cmd-run @@ -78,10 +78,8 @@ done preflight if [ -z "${VM_DISK}" ]; then - if [ -L ./builds/latest ]; then - latest_build=$(readlink builds/latest) - VM_DISK=$(ls builds/"${latest_build}"/*-"${latest_build}"-qemu.qcow2) - else + VM_DISK=$(get_latest_qemu) + 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 d38e2d2970..e8e5b0ab3b 100755 --- a/src/cmdlib.sh +++ b/src/cmdlib.sh @@ -515,3 +515,18 @@ run_virtinstall() { --ostree-repo="${ostree_repo}" "$@" mv "${tmpdest}" "${dest}" } + +get_latest_build() { + if [ -L builds/latest ]; then + readlink builds/latest + fi +} + +get_latest_qemu() { + local latest + latest=$(get_latest_build) + if [ -n "$latest" ]; then + # shellcheck disable=SC2086 + ls builds/${latest}/*-qemu.qcow2 + fi +} diff --git a/src/coreos-assembler b/src/coreos-assembler index 266b2d2dbd..251f82a084 100755 --- a/src/coreos-assembler +++ b/src/coreos-assembler @@ -39,7 +39,7 @@ build_commands="init fetch build run prune clean" # commands more likely to be used in a prod pipeline only advanced_build_commands="buildprep oscontainer" buildextend_commands="aws gcp openstack installer vmware metal" -utility_commands="tag compress bump-timestamp koji-upload" +utility_commands="tag compress bump-timestamp koji-upload kola" other_commands="shell" if [ -z "${cmd}" ]; then echo Usage: "coreos-assembler CMD ..."