nvidia-container-toolkit/hack/pull-packages.sh
Evan Lezar 6358c13dab [no-relnote] Add basic release workflow
Signed-off-by: Evan Lezar <elezar@nvidia.com>
2024-07-10 11:20:40 +02:00

59 lines
1.5 KiB
Bash
Executable File

#!/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: $*"
echo "$(basename ${BASH_SOURCE[0]}) IMAGE DIST_DIR"
exit 1
}
set -e -x
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../scripts && pwd )"
PROJECT_ROOT="$( cd ${SCRIPTS_DIR}/.. && pwd )"
if [[ $# -ne 2 ]]; then
assert_usage $*
fi
IMAGE=$1
DIST_DIR=$2
if [[ -z ${IMAGE} ]]; then
echo "ERROR: IMAGE must be non-empty"
exit 1
fi
if [[ -z ${DIST_DIR} ]]; then
echo "ERROR: DIST_DIR must be non-empty"
exit 1
fi
if [[ x"${IGNORE_DIST_DIR}" != x"yes" && -e ${DIST_DIR} ]]; then
echo "ERROR: The specified DIST_DIR ${DIST_DIR} exists."
exit 1
fi
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} \
-c "cp --preserve=timestamps -R /artifacts/* ${DIST_DIR}"