From dfa4bcb68fee1570c55660a9285292b840cba22e Mon Sep 17 00:00:00 2001 From: Thomas Woerner <twoerner@redhat.com> Date: Wed, 16 Apr 2025 16:06:04 +0200 Subject: [PATCH] infra/image/shcontainer: Volume support and new container_tee This change adds support for volumes to container_create. Now it can be used like in this example: container_create "${name}" "${local_image}" "hostname=${hostname}" \ "${capabilities:+capabilities=$capabilities}" \ volume=$PWD:/root/src The new function container_tee has been added to enable creation of fiiles with content from stdin like in this example: cat <<EOF | container_tee "${name}" "/root/.gdbinit" set debuginfod enabled on set follow-fork-mode child EOF --- infra/image/shcontainer | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/infra/image/shcontainer b/infra/image/shcontainer index 636cd678..71b086d5 100644 --- a/infra/image/shcontainer +++ b/infra/image/shcontainer @@ -19,6 +19,7 @@ container_create() { cpus=*) extra_opts+=("--${opt}") ;; memory=*) extra_opts+=("--${opt}") ;; capabilities=*) extra_opts+=("--cap-add=${opt##*=}") ;; + volume=*) extra_opts+=("--volume=${opt##*=}") ;; *) log error "container_create: Invalid option: ${opt}" ;; esac done @@ -197,3 +198,15 @@ container_fetch() { podman cp "${name}:${source}" "${destination}" echo } + +container_tee() { + local name=${1} + local destination=${2} + tmpfile=$(mktemp /tmp/container-temp.XXXXXX) + + log info "= Creating ${name}:${filename} from stdin =" + cat - > ${tmpfile} + podman cp "${tmpfile}" "${name}:${destination}" + rm "${tmpfile}" + echo +} -- GitLab