2021-11-25 19:04:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
function assert_usage() {
|
|
|
|
echo "Incorrect arguments: $*"
|
2021-11-26 14:15:46 +00:00
|
|
|
echo "$(basename ${BASH_SOURCE[0]}) IMAGE DIST_DIR"
|
2021-11-25 19:04:59 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
set -e -x
|
|
|
|
|
|
|
|
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../scripts && pwd )"
|
|
|
|
PROJECT_ROOT="$( cd ${SCRIPTS_DIR}/.. && pwd )"
|
|
|
|
|
2021-11-26 14:15:46 +00:00
|
|
|
if [[ $# -ne 2 ]]; then
|
2021-11-25 19:04:59 +00:00
|
|
|
assert_usage $*
|
|
|
|
fi
|
|
|
|
|
2021-11-26 14:15:46 +00:00
|
|
|
IMAGE=$1
|
|
|
|
DIST_DIR=$2
|
2021-11-25 19:04:59 +00:00
|
|
|
|
2021-11-26 14:15:46 +00:00
|
|
|
if [[ -z ${IMAGE} ]]; then
|
|
|
|
echo "ERROR: IMAGE must be non-empty"
|
|
|
|
exit 1
|
2021-11-25 19:04:59 +00:00
|
|
|
fi
|
|
|
|
|
2021-11-26 14:15:46 +00:00
|
|
|
if [[ -z ${DIST_DIR} ]]; then
|
|
|
|
echo "ERROR: DIST_DIR must be non-empty"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -e ${DIST_DIR} ]]; then
|
|
|
|
echo "ERROR: The specified DIST_DIR ${DIST_DIR} exists."
|
|
|
|
exit 1
|
2021-11-25 19:04:59 +00:00
|
|
|
fi
|
|
|
|
|
2021-11-26 14:15:46 +00:00
|
|
|
echo "Copying package files from ${IMAGE} to ${DIST_DIR}"
|
|
|
|
mkdir -p ${DIST_DIR}
|
|
|
|
docker run --rm \
|
|
|
|
-v $(pwd):$(pwd) \
|
|
|
|
-w $(pwd) \
|
|
|
|
-u $(id -u):$(id -g) \
|
|
|
|
--entrypoint="bash" \
|
|
|
|
${IMAGE} \
|
2023-05-08 13:36:24 +00:00
|
|
|
-c "cp --preserve=timestamps -R /artifacts/* ${DIST_DIR}"
|