From 278fa433034f7a7c24d65ae7bd1302581b82270b Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 13 Jun 2022 15:41:35 +0200 Subject: [PATCH] Allow libnvidia-container1 version to be specified directly Signed-off-by: Evan Lezar --- docker/Dockerfile.amazonlinux | 5 ++++- docker/Dockerfile.centos | 5 ++++- docker/Dockerfile.debian | 7 +++++-- docker/Dockerfile.opensuse-leap | 5 ++++- docker/Dockerfile.ubuntu | 7 +++++-- docker/docker.mk | 10 ++++++++++ packaging/debian/control | 2 +- packaging/debian/prepare | 2 +- packaging/rpm/SPECS/nvidia-container-toolkit.spec | 4 ++-- scripts/build-all-components.sh | 11 +++++++---- scripts/build-packages.sh | 9 +++++++++ 11 files changed, 52 insertions(+), 15 deletions(-) diff --git a/docker/Dockerfile.amazonlinux b/docker/Dockerfile.amazonlinux index cd1e2c86..6fd00c1e 100644 --- a/docker/Dockerfile.amazonlinux +++ b/docker/Dockerfile.amazonlinux @@ -61,13 +61,16 @@ COPY oci-nvidia-hook.json $DIST_DIR/oci-nvidia-hook.json WORKDIR $DIST_DIR/.. COPY packaging/rpm . +ARG LIBNVIDIA_CONTAINER_TOOLS_VERSION +ENV LIBNVIDIA_CONTAINER_TOOLS_VERSION ${LIBNVIDIA_CONTAINER_TOOLS_VERSION} + CMD arch=$(uname -m) && \ rpmbuild --clean --target=$arch -bb \ -D "_topdir $PWD" \ -D "release_date $(date +'%a %b %d %Y')" \ -D "git_commit ${GIT_COMMIT}" \ -D "version $VERSION" \ - -D "libnvidia_container_version ${VERSION}-${RELEASE}" \ + -D "libnvidia_container_tools_version ${LIBNVIDIA_CONTAINER_TOOLS_VERSION}" \ -D "release $RELEASE" \ SPECS/nvidia-container-toolkit.spec && \ mv RPMS/$arch/*.rpm /dist diff --git a/docker/Dockerfile.centos b/docker/Dockerfile.centos index 0c8befe2..a64409d9 100644 --- a/docker/Dockerfile.centos +++ b/docker/Dockerfile.centos @@ -59,13 +59,16 @@ COPY oci-nvidia-hook.json $DIST_DIR/oci-nvidia-hook.json WORKDIR $DIST_DIR/.. COPY packaging/rpm . +ARG LIBNVIDIA_CONTAINER_TOOLS_VERSION +ENV LIBNVIDIA_CONTAINER_TOOLS_VERSION ${LIBNVIDIA_CONTAINER_TOOLS_VERSION} + CMD arch=$(uname -m) && \ rpmbuild --clean --target=$arch -bb \ -D "_topdir $PWD" \ -D "release_date $(date +'%a %b %d %Y')" \ -D "git_commit ${GIT_COMMIT}" \ -D "version $VERSION" \ - -D "libnvidia_container_version ${VERSION}-${RELEASE}" \ + -D "libnvidia_container_tools_version ${LIBNVIDIA_CONTAINER_TOOLS_VERSION}" \ -D "release $RELEASE" \ SPECS/nvidia-container-toolkit.spec && \ mv RPMS/$arch/*.rpm /dist diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index 2fbbda2d..8e0c099e 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -65,14 +65,17 @@ RUN if [ "$(lsb_release -cs)" = "jessie" ]; then \ WORKDIR $DIST_DIR COPY packaging/debian ./debian +ARG LIBNVIDIA_CONTAINER_TOOLS_VERSION +ENV LIBNVIDIA_CONTAINER_TOOLS_VERSION ${LIBNVIDIA_CONTAINER_TOOLS_VERSION} + RUN dch --create --package="${PKG_NAME}" \ --newversion "${REVISION}" \ "See https://gitlab.com/nvidia/container-toolkit/container-toolkit/-/blob/${GIT_COMMIT}/CHANGELOG.md for the changelog" && \ - dch --append "Bump libnvidia-container dependency to ${REVISION}" && \ + dch --append "Bump libnvidia-container dependency to ${LIBNVIDIA_CONTAINER1_VERSION}" && \ dch -r "" && \ if [ "$REVISION" != "$(dpkg-parsechangelog --show-field=Version)" ]; then exit 1; fi CMD export DISTRIB="$(lsb_release -cs)" && \ - debuild -eDISTRIB -eSECTION -eLIBNVIDIA_CONTAINER_VERSION="${REVISION}" \ + debuild -eDISTRIB -eSECTION -eLIBNVIDIA_CONTAINER_TOOLS_VERSION \ --dpkg-buildpackage-hook='sh debian/prepare' -i -us -uc -b && \ mv /tmp/nvidia-container-toolkit_*.deb /dist diff --git a/docker/Dockerfile.opensuse-leap b/docker/Dockerfile.opensuse-leap index d00a9714..5d1d3acb 100644 --- a/docker/Dockerfile.opensuse-leap +++ b/docker/Dockerfile.opensuse-leap @@ -57,13 +57,16 @@ COPY config/config.toml.${CONFIG_TOML_SUFFIX} $DIST_DIR/config.toml WORKDIR $DIST_DIR/.. COPY packaging/rpm . +ARG LIBNVIDIA_CONTAINER_TOOLS_VERSION +ENV LIBNVIDIA_CONTAINER_TOOLS_VERSION ${LIBNVIDIA_CONTAINER_TOOLS_VERSION} + CMD arch=$(uname -m) && \ rpmbuild --clean --target=$arch -bb \ -D "_topdir $PWD" \ -D "release_date $(date +'%a %b %d %Y')" \ -D "git_commit ${GIT_COMMIT}" \ -D "version $VERSION" \ - -D "libnvidia_container_version ${VERSION}-${RELEASE}" \ + -D "libnvidia_container_tools_version ${LIBNVIDIA_CONTAINER_TOOLS_VERSION}" \ -D "release $RELEASE" \ SPECS/nvidia-container-toolkit.spec && \ mv RPMS/$arch/*.rpm /dist diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu index 53845d2c..dcd71c21 100644 --- a/docker/Dockerfile.ubuntu +++ b/docker/Dockerfile.ubuntu @@ -58,14 +58,17 @@ COPY config/config.toml.${CONFIG_TOML_SUFFIX} $DIST_DIR/config.toml WORKDIR $DIST_DIR COPY packaging/debian ./debian +ARG LIBNVIDIA_CONTAINER_TOOLS_VERSION +ENV LIBNVIDIA_CONTAINER_TOOLS_VERSION ${LIBNVIDIA_CONTAINER_TOOLS_VERSION} + RUN dch --create --package="${PKG_NAME}" \ --newversion "${REVISION}" \ "See https://gitlab.com/nvidia/container-toolkit/container-toolkit/-/blob/${GIT_COMMIT}/CHANGELOG.md for the changelog" && \ - dch --append "Bump libnvidia-container dependency to ${REVISION}" && \ + dch --append "Bump libnvidia-container dependency to ${LIBNVIDIA_CONTAINER_TOOLS_VERSION}" && \ dch -r "" && \ if [ "$REVISION" != "$(dpkg-parsechangelog --show-field=Version)" ]; then exit 1; fi CMD export DISTRIB="$(lsb_release -cs)" && \ - debuild -eDISTRIB -eSECTION -eLIBNVIDIA_CONTAINER_VERSION="${REVISION}" \ + debuild -eDISTRIB -eSECTION -eLIBNVIDIA_CONTAINER_TOOLS_VERSION \ --dpkg-buildpackage-hook='sh debian/prepare' -i -us -uc -b && \ mv /tmp/*.deb /dist diff --git a/docker/docker.mk b/docker/docker.mk index a22a504c..a1ec9d02 100644 --- a/docker/docker.mk +++ b/docker/docker.mk @@ -85,32 +85,41 @@ docker-all: $(AMD64_TARGETS) $(X86_64_TARGETS) \ --%: docker-build-% @ +LIBNVIDIA_CONTAINER_VERSION ?= $(LIB_VERSION) +LIBNVIDIA_CONTAINER_TAG ?= $(LIB_TAG) + # private ubuntu target --ubuntu%: OS := ubuntu --ubuntu%: LIB_VERSION := $(LIB_VERSION)$(if $(LIB_TAG),~$(LIB_TAG)) +--ubuntu%: LIBNVIDIA_CONTAINER_TOOLS_VERSION := $(LIBNVIDIA_CONTAINER_VERSION)$(if $(LIBNVIDIA_CONTAINER_TAG),~$(LIBNVIDIA_CONTAINER_TAG))-1 --ubuntu%: PKG_REV := 1 # private debian target --debian%: OS := debian --debian%: LIB_VERSION := $(LIB_VERSION)$(if $(LIB_TAG),~$(LIB_TAG)) +--debian%: LIBNVIDIA_CONTAINER_TOOLS_VERSION := $(LIBNVIDIA_CONTAINER_VERSION)$(if $(LIBNVIDIA_CONTAINER_TAG),~$(LIBNVIDIA_CONTAINER_TAG))-1 --debian%: PKG_REV := 1 # private centos target --centos%: OS := centos --centos%: PKG_REV := $(if $(LIB_TAG),0.1.$(LIB_TAG),1) +--centos%: LIBNVIDIA_CONTAINER_TOOLS_VERSION := $(LIBNVIDIA_CONTAINER_VERSION)-$(if $(LIBNVIDIA_CONTAINER_TAG),0.1.$(LIBNVIDIA_CONTAINER_TAG),1) --centos8%: BASEIMAGE = quay.io/centos/centos:stream8 # private amazonlinux target --amazonlinux%: OS := amazonlinux +--amazonlinux%: LIBNVIDIA_CONTAINER_TOOLS_VERSION := $(LIBNVIDIA_CONTAINER_VERSION)-$(if $(LIBNVIDIA_CONTAINER_TAG),0.1.$(LIBNVIDIA_CONTAINER_TAG),1) --amazonlinux%: PKG_REV := $(if $(LIB_TAG),0.1.$(LIB_TAG),1) # private opensuse-leap target --opensuse-leap%: OS = opensuse-leap --opensuse-leap%: BASEIMAGE = opensuse/leap:$(VERSION) +--opensuse-leap%: LIBNVIDIA_CONTAINER_TOOLS_VERSION := $(LIBNVIDIA_CONTAINER_VERSION)-$(if $(LIBNVIDIA_CONTAINER_TAG),0.1.$(LIBNVIDIA_CONTAINER_TAG),1) --opensuse-leap%: PKG_REV := $(if $(LIB_TAG),0.1.$(LIB_TAG),1) # private rhel target (actually built on centos) --rhel%: OS := centos +--rhel%: LIBNVIDIA_CONTAINER_TOOLS_VERSION := $(LIBNVIDIA_CONTAINER_VERSION)-$(if $(LIBNVIDIA_CONTAINER_TAG),0.1.$(LIBNVIDIA_CONTAINER_TAG),1) --rhel%: PKG_REV := $(if $(LIB_TAG),0.1.$(LIB_TAG),1) --rhel%: VERSION = $(patsubst rhel%-$(ARCH),%,$(TARGET_PLATFORM)) --rhel%: ARTIFACTS_DIR = $(DIST_DIR)/rhel$(VERSION)/$(ARCH) @@ -131,6 +140,7 @@ docker-build-%: --build-arg PKG_NAME="$(LIB_NAME)" \ --build-arg PKG_VERS="$(LIB_VERSION)" \ --build-arg PKG_REV="$(PKG_REV)" \ + --build-arg LIBNVIDIA_CONTAINER_TOOLS_VERSION="$(LIBNVIDIA_CONTAINER_TOOLS_VERSION)" \ --build-arg CONFIG_TOML_SUFFIX="$(CONFIG_TOML_SUFFIX)" \ --build-arg GIT_COMMIT="$(GIT_COMMIT)" \ --tag $(BUILDIMAGE) \ diff --git a/packaging/debian/control b/packaging/debian/control index f21c42e7..22d9d8fd 100644 --- a/packaging/debian/control +++ b/packaging/debian/control @@ -10,7 +10,7 @@ Build-Depends: debhelper (>= 9) Package: nvidia-container-toolkit Architecture: any -Depends: ${misc:Depends}, libnvidia-container-tools (>= @LIBNVIDIA_CONTAINER_VERSION@), libnvidia-container-tools (<< 2.0.0), libseccomp2 +Depends: ${misc:Depends}, libnvidia-container-tools (>= @LIBNVIDIA_CONTAINER_TOOLS_VERSION@), libnvidia-container-tools (<< 2.0.0), libseccomp2 Breaks: nvidia-container-runtime (<= 3.5.0-1), nvidia-container-runtime-hook Replaces: nvidia-container-runtime (<= 3.5.0-1), nvidia-container-runtime-hook Description: NVIDIA container runtime hook diff --git a/packaging/debian/prepare b/packaging/debian/prepare index edff676a..4dc5085d 100755 --- a/packaging/debian/prepare +++ b/packaging/debian/prepare @@ -3,7 +3,7 @@ set -e sed -i "s;@SECTION@;${SECTION:+$SECTION/};g" debian/control -sed -i "s;@LIBNVIDIA_CONTAINER_VERSION@;${LIBNVIDIA_CONTAINER_VERSION:+$LIBNVIDIA_CONTAINER_VERSION};g" debian/control +sed -i "s;@LIBNVIDIA_CONTAINER_TOOLS_VERSION@;${LIBNVIDIA_CONTAINER_TOOLS_VERSION:+$LIBNVIDIA_CONTAINER_TOOLS_VERSION};g" debian/control if [ -n "$DISTRIB" ]; then sed -i "s;UNRELEASED;$DISTRIB;" debian/changelog diff --git a/packaging/rpm/SPECS/nvidia-container-toolkit.spec b/packaging/rpm/SPECS/nvidia-container-toolkit.spec index e2f68fb1..3f682bde 100644 --- a/packaging/rpm/SPECS/nvidia-container-toolkit.spec +++ b/packaging/rpm/SPECS/nvidia-container-toolkit.spec @@ -21,7 +21,7 @@ Source6: LICENSE Obsoletes: nvidia-container-runtime <= 3.5.0-1, nvidia-container-runtime-hook Provides: nvidia-container-runtime Provides: nvidia-container-runtime-hook -Requires: libnvidia-container-tools >= %{libnvidia_container_version}, libnvidia-container-tools < 2.0.0 +Requires: libnvidia-container-tools >= %{libnvidia_container_tools_version}, libnvidia-container-tools < 2.0.0 %if 0%{?suse_version} Requires: libseccomp2 @@ -70,4 +70,4 @@ rm -f %{_bindir}/nvidia-container-runtime-hook # As of 1.10.0-1 we generate the release information automatically * %{release_date} NVIDIA CORPORATION %{version}-%{release} - See https://gitlab.com/nvidia/container-toolkit/container-toolkit/-/blob/%{git_commit}/CHANGELOG.md -- Bump libnvidia-container dependency to libnvidia-container-tools >= %{libnvidia_container_version} +- Bump libnvidia-container dependency to libnvidia-container-tools >= %{libnvidia_container_tools_version} diff --git a/scripts/build-all-components.sh b/scripts/build-all-components.sh index 97407a8b..81f3c2be 100755 --- a/scripts/build-all-components.sh +++ b/scripts/build-all-components.sh @@ -52,13 +52,16 @@ ${SCRIPTS_DIR}/get-component-versions.sh # Build libnvidia-container make -C ${LIBNVIDIA_CONTAINER_ROOT} -f mk/docker.mk ${TARGET} -# Build nvidia-container-toolkit -make -C ${NVIDIA_CONTAINER_TOOLKIT_ROOT} ${TARGET} - -if [[ -z ${NVIDIA_CONTAINER_TOOLKIT_VERSION} ]]; then +if [[ -z ${NVIDIA_CONTAINER_TOOLKIT_VERSION} || -z ${LIBNVIDIA_CONTAINER_VERSION} ]]; then eval $(${SCRIPTS_DIR}/get-component-versions.sh) fi +# Build nvidia-container-toolkit +make -C ${NVIDIA_CONTAINER_TOOLKIT_ROOT} \ + LIBNVIDIA_CONTAINER_VERSION="${LIBNVIDIA_CONTAINER_VERSION}" \ + LIBNVIDIA_CONTAINER_TAG="${LIBNVIDIA_CONTAINER_TAG}" \ + ${TARGET} + # We set the TOOLKIT_VERSION, TOOLKIT_TAG for the nvidia-container-runtime and nvidia-docker targets # The LIB_TAG is also overridden to match the TOOLKIT_TAG. # Build nvidia-container-runtime diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh index ea2a9549..9d64fece 100755 --- a/scripts/build-packages.sh +++ b/scripts/build-packages.sh @@ -61,6 +61,12 @@ fi eval $(${SCRIPTS_DIR}/get-component-versions.sh) + +if [[ -n ${NVIDIA_CONTAINER_TOOLKIT_TAG} ]]; then +echo "Allowing mismatched versions for release candidate " +: ${ALLOW_VERSION_MISMATCH:=true} +fi + if [[ "${NVIDIA_CONTAINER_TOOLKIT_PACKAGE_VERSION}" != "${LIBNVIDIA_CONTAINER_PACKAGE_VERSION}" ]]; then set +x echo "The libnvidia-container and nvidia-container-toolkit versions do not match." @@ -68,10 +74,13 @@ if [[ "${NVIDIA_CONTAINER_TOOLKIT_PACKAGE_VERSION}" != "${LIBNVIDIA_CONTAINER_PA echo "toolkit: '${NVIDIA_CONTAINER_TOOLKIT_PACKAGE_VERSION}'" set -x [[ ${ALLOW_VERSION_MISMATCH} == "true" ]] || exit 1 + echo "Continuing with mismatched version" fi export NVIDIA_CONTAINER_TOOLKIT_VERSION export NVIDIA_CONTAINER_TOOLKIT_TAG +export LIBNVIDIA_CONTAINER_VERSION +export LIBNVIDIA_CONTAINER_TAG export NVIDIA_CONTAINER_RUNTIME_VERSION export NVIDIA_DOCKER_VERSION