From 22c71785618a4c08a66eaed01c38041983bdd858 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 26 Apr 2023 16:33:56 +0200 Subject: [PATCH] Build meta-packages before others Signed-off-by: Evan Lezar --- .gitlab-ci.yml | 22 ++++++++++++++++++++++ scripts/build-all-components.sh | 19 ++++++++++++++----- scripts/utils.sh | 14 +++++++++++++- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7a338002..4e606398 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -102,8 +102,30 @@ unit-tests: name: ${ARTIFACTS_NAME} paths: - ${ARTIFACTS_ROOT} + needs: + - job: package-meta-packages + artifacts: true # Define the package build targets +package-meta-packages: + extends: + - .package-artifacts + stage: package-build + variables: + SKIP_LIBNVIDIA_CONTAINER: "yes" + SKIP_NVIDIA_CONTAINER_TOOLKIT: "yes" + parallel: + matrix: + - PACKAGING: [deb, rpm] + before_script: + - apk add --no-cache coreutils build-base sed git bash make + script: + - ./scripts/build-packages.sh ${PACKAGING} + artifacts: + name: ${ARTIFACTS_NAME} + paths: + - ${ARTIFACTS_ROOT} + package-amazonlinux2-aarch64: extends: - .package-build diff --git a/scripts/build-all-components.sh b/scripts/build-all-components.sh index c728e425..8c51ec9d 100755 --- a/scripts/build-all-components.sh +++ b/scripts/build-all-components.sh @@ -51,18 +51,22 @@ echo "Building ${TARGET} for all packages to ${DIST_DIR}" "${SCRIPTS_DIR}/get-component-versions.sh" -# Build libnvidia-container -make -C "${LIBNVIDIA_CONTAINER_ROOT}" -f mk/docker.mk "${TARGET}" - if [[ -z "${NVIDIA_CONTAINER_TOOLKIT_VERSION}" || -z "${LIBNVIDIA_CONTAINER_VERSION}" ]]; then eval $(${SCRIPTS_DIR}/get-component-versions.sh) fi +# Build libnvidia-container +if [[ -z ${SKIP_LIBNVIDIA_CONTAINER} ]]; then + make -C "${LIBNVIDIA_CONTAINER_ROOT}" -f mk/docker.mk "${TARGET}" +fi + +if [[ -z ${SKIP_NVIDIA_CONTAINER_TOOLKIT} ]]; then # Build nvidia-container-toolkit make -C "${NVIDIA_CONTAINER_TOOLKIT_ROOT}" \ LIBNVIDIA_CONTAINER_VERSION="${LIBNVIDIA_CONTAINER_VERSION}" \ LIBNVIDIA_CONTAINER_TAG="${LIBNVIDIA_CONTAINER_TAG}" \ "${TARGET}" +fi # If required we also build the nvidia-container-runtime and nvidia-docker packages. # Since these are essentially meta packages intended to allow for users to @@ -71,6 +75,7 @@ make -C "${NVIDIA_CONTAINER_TOOLKIT_ROOT}" \ # version of 0. if [[ -n ${FORCE_META_PACKAGES} || -z ${NVIDIA_CONTAINER_TOOLKIT_TAG} && "${NVIDIA_CONTAINER_TOOLKIT_VERSION%.0}" != "${NVIDIA_CONTAINER_TOOLKIT_VERSION}" ]]; then package_format=$(package_type ${TARGET}) + package_target=$(get_package_target ${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. @@ -89,7 +94,9 @@ if [[ -n ${FORCE_META_PACKAGES} || -z ${NVIDIA_CONTAINER_TOOLKIT_TAG} && "${NVID TOOLKIT_TAG="${NVIDIA_CONTAINER_TOOLKIT_TAG}" \ ${TARGET} fi - cp ${package_pattern} ${DIST_DIR}/$(get_package_target ${TARGET})/ + if [[ -n ${package_target} ]]; then + cp ${package_pattern} ${DIST_DIR}/${package_target}/ + fi # Build nvidia-docker2 if required package_name="nvidia-docker2" @@ -105,7 +112,9 @@ if [[ -n ${FORCE_META_PACKAGES} || -z ${NVIDIA_CONTAINER_TOOLKIT_TAG} && "${NVID TOOLKIT_TAG="${NVIDIA_CONTAINER_TOOLKIT_TAG}" \ ${TARGET} fi - cp ${package_pattern} ${DIST_DIR}/$(get_package_target ${TARGET})/ + if [[ -n ${package_target} ]]; then + cp ${package_pattern} ${DIST_DIR}/${package_target}/ + fi else echo "Skipping nvidia-container-runtime and nvidia-docker builds." diff --git a/scripts/utils.sh b/scripts/utils.sh index dd3b1c14..56438f49 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -16,6 +16,10 @@ function package_type() { ;; ubuntu*) pkg_type=deb ;; + deb) pkg_type=deb + ;; + rpm) pkg_type=rpm + ;; *) exit 1 ;; esac @@ -39,5 +43,13 @@ function get_package_target() { local target=$1 local dist=${target%-*} local arch=${target##*-} - echo "${dist}/${arch}" + + case ${target} in + deb) echo "" + ;; + rpm) echo "" + ;; + *) echo "${dist}/${arch}" + ;; + esac }