James Conroy | 210897d | 2022-08-04 16:55:05 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright © 2022 Arm Ltd and Contributors. All rights reserved. |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
| 7 | # Script which copies a file or directory from the /home/arm-user/ directory in Docker to the host machine |
| 8 | # This script creates a directory called 'docker_output' in the current directory and places the copied contents there |
| 9 | # Takes two arguments: |
| 10 | # 1. Name of created Docker image i.e. "--tag <name:tag>" provided at 'docker build' stage (tag is optional in image naming) |
| 11 | # 2. Relative path to file or directory to copy from the Docker /home/arm-user/ directory |
| 12 | # |
| 13 | # Examples: |
| 14 | # 1. Copy the tarball of the aarch64 build from the /home/arm-user/ directory |
| 15 | # ./scripts/docker-copy-to-host.sh armnn_image armnn_aarch64_build.tar.gz |
| 16 | # 2. Copy the unarchived Arm NN build |
| 17 | # ./scripts/docker-copy-to-host.sh armnn_image build/armnn |
| 18 | # 3. Copy the unarchived ACL build |
| 19 | # ./scripts/docker-copy-to-host.sh armnn_image build/acl |
| 20 | |
| 21 | set -o nounset # Catch references to undefined variables. |
| 22 | set -o pipefail # Catch non zero exit codes within pipelines. |
| 23 | set -o errexit # Catch and propagate non zero exit codes. |
| 24 | |
| 25 | image_name="$1" |
| 26 | file_path="$2" |
| 27 | |
| 28 | name=$(basename "$0") |
| 29 | |
| 30 | echo "***** $name: Copying file(s) from path /home/arm-user/$file_path inside Docker image '$image_name' to host *****" |
| 31 | |
| 32 | echo -e "\n***** Creating directory docker_output on host *****" |
| 33 | mkdir -p docker_output |
| 34 | |
| 35 | # Cleanup old 'armnn_temp' container in case a previous run of this script was not successful |
| 36 | docker rm --force armnn_temp 2> /dev/null |
| 37 | |
| 38 | echo -e "\n***** Creating temporary Docker container named armnn_temp using Docker image '$image_name' *****" |
| 39 | docker create --interactive --tty --name armnn_temp "$image_name" bash > /dev/null |
| 40 | |
| 41 | echo -e "\n***** Running Docker command: docker cp armnn_temp:/home/arm-user/$file_path ./docker_output *****" |
| 42 | docker cp armnn_temp:/home/arm-user/"$file_path" ./docker_output > /dev/null |
| 43 | |
| 44 | echo -e "\n***** Successfully copied file(s) to host in directory docker_output *****" |
| 45 | |
| 46 | # Remove temporary docker container 'armnn_temp' |
| 47 | docker rm --force armnn_temp > /dev/null |
| 48 | |
| 49 | echo -e "\n***** Deleted temporary Docker container armnn_temp *****" |