From b8342ebeb4834a857b8d154c61115dc2825cf496 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 26 Jan 2021 11:15:24 +0000 Subject: [PATCH] scripts: Don't download container on help invocations Delay downloading the container until it is being used. Fixes: #2065 Signed-off-by: Rob Bradford --- scripts/dev_cli.sh | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/scripts/dev_cli.sh b/scripts/dev_cli.sh index 924c91f7d..df6f67a34 100755 --- a/scripts/dev_cli.sh +++ b/scripts/dev_cli.sh @@ -235,6 +235,12 @@ cmd_build() { esac shift done + + ensure_build_dir + if [ $(uname -m) = "x86_64" ]; then + ensure_latest_ctr + fi + process_volumes_args if [[ "$hypervisor" != "kvm" ]]; then die "Hypervisor value must be kvm" @@ -269,6 +275,11 @@ cmd_build() { cmd_clean() { cargo_args=("$@") + ensure_build_dir + if [ $(uname -m) = "x86_64" ]; then + ensure_latest_ctr + fi + $DOCKER_RUNTIME run \ --user "$(id -u):$(id -g)" \ --workdir "$CTR_CLH_ROOT_DIR" \ @@ -324,6 +335,11 @@ cmd_tests() { fi set -- "$@" '--hypervisor' $hypervisor + ensure_build_dir + if [ $(uname -m) = "x86_64" ]; then + ensure_latest_ctr + fi + process_volumes_args target="$(uname -m)-unknown-linux-${libc}" cflags="" @@ -433,6 +449,11 @@ cmd_build-container() { shift done + ensure_build_dir + if [ $(uname -m) = "x86_64" ]; then + ensure_latest_ctr + fi + BUILD_DIR=/tmp/cloud-hypervisor/container/ mkdir -p $BUILD_DIR @@ -450,6 +471,10 @@ cmd_build-container() { } cmd_shell() { + ensure_build_dir + if [ $(uname -m) = "x86_64" ]; then + ensure_latest_ctr + fi say_warn "Starting a privileged shell prompt as root ..." say_warn "WARNING: Your $CLH_ROOT_DIR folder will be bind-mounted in the container under $CTR_CLH_ROOT_DIR" $DOCKER_RUNTIME run \ @@ -496,9 +521,5 @@ ok_or_die "Unknown command: $1. Please use \`$0 help\` for help." cmd=cmd_$1 shift -ensure_build_dir -if [ $(uname -m) = "x86_64" ]; then - ensure_latest_ctr -fi $cmd "$@"