diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2023-05-28 07:26:42 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2023-05-31 14:42:09 +0000 |
commit | dde788957d5bf61c3eb1db7894aa0eeec34bc2f4 (patch) | |
tree | 5fab44185c3d7347db7291c7d714d40bf36516b1 /docker-run.sh | |
parent | 70960829f8525127181dff4e95644a42e878abef (diff) |
docker-run.sh: Add new options: ++rsync_to and ++rsync_from
These options provide a convenient way of transferring data
between the host and the container. It is useful in two
scenarios:
1. The container is using scratch volumes for its filesystem
and has no access to the host's filesystem -- e.g., container
for precommit testing.
2. The container is started on a remote host, and there is
a need to transfer back and forth.
On the backend side this is implemented with a new command
${prefix}container_rsync. Marker ":" at the start of an argument
expands into remote specification. E.g.,
"container_rsync -a --del data_to/ :data/" will transfer
"./data_to/" inside the container; while
"container rsync -a --del :data/ data_from/" will transfer it back.
Change-Id: I3f1353862899e3843f7454a0e84af38794bbd6ba
Diffstat (limited to 'docker-run.sh')
-rwxr-xr-x | docker-run.sh | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/docker-run.sh b/docker-run.sh index b021b9bf..c0cd6835 100755 --- a/docker-run.sh +++ b/docker-run.sh @@ -35,4 +35,24 @@ else JENKINS_FLOCK="" fi -${prefix}container_exec "$@" +# Rsync specified directories to the container. +# This is, primarily, for task==precommit, when we don't bind-mount $WORKSPACE. +if test_array rsync_to; then + declare -a rsync_to + for dir in "${rsync_to[@]}"; do + ${prefix}container_rsync -a --del "$dir" ":$dir" + done +fi + +${prefix}container_exec "$@" & +res=0 && wait $! || res=$? + +# Rsync specified directories from the container. +if test_array rsync_from; then + declare -a rsync_from + for dir in "${rsync_from[@]}"; do + ${prefix}container_rsync -a --del ":$dir" "$dir" + done +fi + +exit $res |