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 21set -o nounset # Catch references to undefined variables. 22set -o pipefail # Catch non zero exit codes within pipelines. 23set -o errexit # Catch and propagate non zero exit codes. 24 25image_name="$1" 26file_path="$2" 27 28name=$(basename "$0") 29 30echo "***** $name: Copying file(s) from path /home/arm-user/$file_path inside Docker image '$image_name' to host *****" 31 32echo -e "\n***** Creating directory docker_output on host *****" 33mkdir -p docker_output 34 35# Cleanup old 'armnn_temp' container in case a previous run of this script was not successful 36docker rm --force armnn_temp 2> /dev/null 37 38echo -e "\n***** Creating temporary Docker container named armnn_temp using Docker image '$image_name' *****" 39docker create --interactive --tty --name armnn_temp "$image_name" bash > /dev/null 40 41echo -e "\n***** Running Docker command: docker cp armnn_temp:/home/arm-user/$file_path ./docker_output *****" 42docker cp armnn_temp:/home/arm-user/"$file_path" ./docker_output > /dev/null 43 44echo -e "\n***** Successfully copied file(s) to host in directory docker_output *****" 45 46# Remove temporary docker container 'armnn_temp' 47docker rm --force armnn_temp > /dev/null 48 49echo -e "\n***** Deleted temporary Docker container armnn_temp *****"