mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
Use version from manifest to extract packages
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
39b0830a66
commit
1c1ce2c6f7
@ -67,13 +67,6 @@ fi
|
||||
|
||||
KITMAKER_SCRATCH="${KITMAKER_DIR}/.scratch"
|
||||
|
||||
# extract_info extracts the value of the specified variable from the manifest.txt file.
|
||||
function extract_info() {
|
||||
local variable=$1
|
||||
local value=$(cat "${ARTIFACTS_DIR}/manifest.txt" | grep "#${variable}=" | sed -e "s/#${variable}=//" | tr -d '\r')
|
||||
echo $value
|
||||
}
|
||||
|
||||
IMAGE_EPOCH=$(extract_info "IMAGE_EPOCH")
|
||||
# Note we use the main branch for the kitmaker archive.
|
||||
GIT_BRANCH=main
|
||||
@ -129,8 +122,6 @@ function create_archive() {
|
||||
rmdir "${scratch_dir}"
|
||||
}
|
||||
|
||||
function join_by { local IFS="$1"; shift; echo "$*"; }
|
||||
|
||||
function optionally_add_property() {
|
||||
local property=$1
|
||||
local value=$2
|
||||
|
@ -31,6 +31,8 @@ if [[ $# -lt 1 || $# -gt 2 ]]; then
|
||||
assert_usage $*
|
||||
fi
|
||||
|
||||
source "${SCRIPTS_DIR}"/utils.sh
|
||||
|
||||
PACKAGE_REPO_ROOT=$1
|
||||
if [[ ! -d ${PACKAGE_REPO_ROOT} ]]; then
|
||||
echo "The specified PACKAGE_REPO_ROOT '${PACKAGE_REPO_ROOT}' must exist"
|
||||
@ -42,21 +44,20 @@ if [[ $# -ge 2 ]]; then
|
||||
REFERENCE=$2
|
||||
fi
|
||||
|
||||
eval $(${SCRIPTS_DIR}/get-component-versions.sh)
|
||||
|
||||
TAG=v"${NVIDIA_CONTAINER_TOOLKIT_PACKAGE_VERSION}"
|
||||
SHA=$(git rev-parse --short=8 ${REFERENCE})
|
||||
IMAGE_NAME="registry.gitlab.com/nvidia/container-toolkit/container-toolkit/staging/container-toolkit"
|
||||
IMAGE_TAG=${SHA}-packaging
|
||||
|
||||
VERSION="$(get_version_from_image ${IMAGE_NAME}:${IMAGE_TAG} ${SHA})"
|
||||
|
||||
REPO="experimental"
|
||||
if [[ ${TAG/rc./} == ${TAG} ]]; then
|
||||
if [[ ${VERSION/rc./} == ${VERSION} ]]; then
|
||||
REPO="stable"
|
||||
fi
|
||||
|
||||
PACKAGE_CACHE=release-${TAG}-${REPO}
|
||||
PACKAGE_CACHE=release-${VERSION}-${REPO}
|
||||
|
||||
echo "Fetching packages with SHA '${SHA}' as tag '${TAG}' to ${PACKAGE_CACHE}"
|
||||
IMAGE_NAME="registry.gitlab.com/nvidia/container-toolkit/container-toolkit/staging/container-toolkit"
|
||||
IMAGE_TAG=${SHA}-packaging
|
||||
echo "Fetching packages with SHA '${SHA}' as tag '${VERSION}' to ${PACKAGE_CACHE}"
|
||||
${SCRIPTS_DIR}/pull-packages.sh \
|
||||
${IMAGE_NAME}:${IMAGE_TAG} \
|
||||
${PACKAGE_CACHE}
|
||||
@ -197,7 +198,7 @@ git -C ${PACKAGE_REPO_ROOT} add ${REPO}
|
||||
if [[ ${REPO} == "stable" ]]; then
|
||||
# Stable release
|
||||
git -C ${PACKAGE_REPO_ROOT} commit -s -F- <<EOF
|
||||
Add packages for NVIDIA Container Toolkit ${TAG} release
|
||||
Add packages for NVIDIA Container Toolkit ${VERSION} release
|
||||
|
||||
These include:
|
||||
* libnvidia-container* ${LIBNVIDIA_CONTAINER_PACKAGE_VERSION}
|
||||
@ -208,7 +209,7 @@ EOF
|
||||
else
|
||||
# Experimental / release candidate release
|
||||
git -C ${PACKAGE_REPO_ROOT} commit -s -F- <<EOF
|
||||
Add packages for NVIDIA Container Toolkit ${TAG} ${REPO} release
|
||||
Add packages for NVIDIA Container Toolkit ${VERSION} ${REPO} release
|
||||
|
||||
These include:
|
||||
* libnvidia-container* ${LIBNVIDIA_CONTAINER_PACKAGE_VERSION}
|
||||
@ -246,12 +247,12 @@ function sign() {
|
||||
sign deb
|
||||
|
||||
git -C ${PACKAGE_REPO_ROOT} add ${REPO}
|
||||
git -C ${PACKAGE_REPO_ROOT} commit -s -m "TOFIX: Sign deb packages for ${TAG} in ${REPO}"
|
||||
git -C ${PACKAGE_REPO_ROOT} commit -s -m "TOFIX: Sign deb packages for ${VERSION} in ${REPO}"
|
||||
|
||||
sign rpm
|
||||
|
||||
git -C ${PACKAGE_REPO_ROOT} add ${REPO}
|
||||
git -C ${PACKAGE_REPO_ROOT} commit -s -m "TOFIX: Sign rpm packages for ${TAG} in ${REPO}"
|
||||
git -C ${PACKAGE_REPO_ROOT} commit -s -m "TOFIX: Sign rpm packages for ${VERSION} in ${REPO}"
|
||||
|
||||
echo "To publish changes, go to ${PACKAGE_REPO_ROOT} and run: "
|
||||
echo " git rebase -i ${UPSTREAM_REFERENCE}"
|
||||
|
@ -1,3 +1,17 @@
|
||||
# Copyright (c) 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.
|
||||
|
||||
|
||||
# package_type returns the packaging type (deb or rpm) for the specfied distribution.
|
||||
# An error is returned if the ditribution is unsupported.
|
||||
@ -53,3 +67,48 @@ function get_package_target() {
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# extract-file copies a file from a specified image.
|
||||
# If regctl is available this is used, otherwise a docker container is run and the file is copied from
|
||||
# there.
|
||||
function copy_file() {
|
||||
local image=$1
|
||||
local path_in_image=$2
|
||||
local path_on_host=$3
|
||||
if command -v regctl > /dev/null; then
|
||||
regctl image get-file "${image}" "${path_in_image}" "${path_on_host}"
|
||||
else
|
||||
# Note this will only work for destinations where the `path_on_host` is in `pwd`
|
||||
docker run --rm \
|
||||
-v "$(pwd):$(pwd)" \
|
||||
-w "$(pwd)" \
|
||||
-u "$(id -u):$(id -g)" \
|
||||
--entrypoint="bash" \
|
||||
"${image}" \
|
||||
-c "cp ${path_in_image} ${path_on_host}"
|
||||
fi
|
||||
}
|
||||
|
||||
# extract_info extracts the value of the specified variable from the manifest.txt file.
|
||||
function extract_from_manifest() {
|
||||
local variable=$1
|
||||
local manifest=$2
|
||||
local value=$(cat ${manifest} | grep "#${variable}=" | sed -e "s/#${variable}=//" | tr -d '\r')
|
||||
echo $value
|
||||
}
|
||||
|
||||
# extract_info extracts the value of the specified variable from the manifest.txt file.
|
||||
function extract_info() {
|
||||
extract_from_manifest $1 "${ARTIFACTS_DIR}/manifest.txt"
|
||||
}
|
||||
|
||||
function get_version_from_image() {
|
||||
local image=$1
|
||||
local manifest="manifest-${2}.txt"
|
||||
copy_file ${image} "/artifacts/manifest.txt" ${manifest}
|
||||
version=$(extract_from_manifest "PACKAGE_VERSION" ${manifest})
|
||||
echo "v${version/\~/-}"
|
||||
rm -f ${manifest}
|
||||
}
|
||||
|
||||
function join_by { local IFS="$1"; shift; echo "$*"; }
|
Loading…
Reference in New Issue
Block a user