Skip to content

Commit eb84439

Browse files
committed
Replace repackaging using fpm with rpmrebuild
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 5f72b2e commit eb84439

File tree

4 files changed

+103
-30
lines changed

4 files changed

+103
-30
lines changed

deployments/container/Dockerfile

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,35 +53,6 @@ ARG VERSION="N/A"
5353
ARG GIT_COMMIT="unknown"
5454
RUN make PREFIX=/artifacts/bin cmd-nvidia-ctk-installer
5555

56-
# The rpmdigests stage updates the existing rpm packages to have 256bit digests.
57-
# This is done using fpm.
58-
FROM nvcr.io/nvidia/cuda:13.0.1-base-ubi9 AS rpmdigests
59-
60-
RUN dnf install -y \
61-
rubygems \
62-
ruby-devel \
63-
yum-utils \
64-
rpm-build \
65-
&& gem install --no-document fpm
66-
67-
ARG ARTIFACTS_ROOT
68-
COPY ${ARTIFACTS_ROOT}/centos7 /artifacts/packages/centos7-src
69-
70-
WORKDIR /artifacts/packages/centos7
71-
72-
# For each architecture from the source we find all packages and update the
73-
# digests.
74-
RUN for arch in $(ls /artifacts/packages/centos7-src/); do \
75-
mkdir -p /artifacts/packages/centos7/${arch}; \
76-
cd /artifacts/packages/centos7/${arch}; \
77-
# For each package in the source folder we recreate a package to update
78-
# the digests to 256-bit since we're running in a ubi9 container.
79-
for src_package in $(ls /artifacts/packages/centos7-src/${arch}/*.rpm); do \
80-
fpm -s rpm -t rpm --rpm-digest=sha256 ${src_package}; \
81-
done; \
82-
done; \
83-
rm -rf /artifacts/packages/centos7-src
84-
8556
# The packaging stage collects the deb and rpm packages built for
8657
# supported architectures.
8758
FROM nvcr.io/nvidia/distroless/go:v4.0.0-dev AS packaging
@@ -92,7 +63,7 @@ RUN ln -s /busybox/sh /bin/sh
9263

9364
ARG ARTIFACTS_ROOT
9465
COPY ${ARTIFACTS_ROOT}/ubuntu18.04 /artifacts/packages/ubuntu18.04
95-
COPY --from=rpmdigests /artifacts/packages/centos7 /artifacts/packages/centos7
66+
COPY ${ARTIFACTS_ROOT}/centos7 /artifacts/packages/centos7
9667

9768
# build-args are added to the manifest.txt file below.
9869
ARG PACKAGE_VERSION
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: Copyright (c) NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
FROM nvcr.io/nvidia/cuda:13.0.1-base-ubi9
17+
18+
RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
19+
&& \
20+
dnf install -y rpmrebuild
21+
22+
ARG arch
23+
ENV arch=${arch}
24+
CMD for src_package in $(ls *.rpm); do \
25+
rpmrebuild -pn --directory=/updated ${src_package}; \
26+
done; \
27+
cp -f /updated/${arch}/*.rpm /dist/

scripts/build-all-components.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,6 @@ make -C "${NVIDIA_CONTAINER_TOOLKIT_ROOT}" \
7171
LIBNVIDIA_CONTAINER_TAG="${NVIDIA_CONTAINER_TOOLKIT_TAG}" \
7272
"${TARGET}"
7373
fi
74+
75+
# Repackage RPMs if required.
76+
"${SCRIPTS_DIR}/repackage-rpms.sh" "${TARGET}"

scripts/repackage-rpms.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
function assert_usage() {
17+
echo "Missing argument $1"
18+
echo "$(basename "${BASH_SOURCE[0]}") TARGET"
19+
exit 1
20+
}
21+
22+
set -e
23+
24+
25+
if [ -n "${SKIP_REPACKAGE_RPMS}" ]; then
26+
exit 0
27+
fi
28+
29+
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../scripts && pwd )"
30+
PROJECT_ROOT="$( cd "${SCRIPTS_DIR}"/.. && pwd )"
31+
32+
if [[ $# -ne 1 ]]; then
33+
assert_usage "TARGET"
34+
fi
35+
36+
TARGET=$1
37+
38+
source "${SCRIPTS_DIR}"/utils.sh
39+
40+
: "${DIST_DIR:=${PROJECT_ROOT}/dist}"
41+
export DIST_DIR
42+
43+
case ${TARGET} in
44+
centos7-aarch64) platform="linux/aarch64"
45+
;;
46+
centos7-x86_64) platform="linux/x86_64"
47+
;;
48+
*) exit 0
49+
;;
50+
esac
51+
52+
arch="${TARGET/centos7-/}"
53+
platform="${TARGET/centos7-/linux/}"
54+
package_root="${DIST_DIR}/${TARGET/-//}"
55+
56+
# We build and rpmrebuild:${arch} image with no context.
57+
docker build \
58+
--platform=${platform} \
59+
--build-arg arch="${arch}" \
60+
--tag rpmrebuild:${arch} \
61+
- < ${PROJECT_ROOT}/deployments/container/Dockerfile.rpmrebuild
62+
63+
64+
updated=$(mktemp -d)
65+
echo "Repackaging RPMs from ${package_root} to ${updated}:"
66+
docker run \
67+
--platform=${platform} \
68+
--rm \
69+
-v ${package_root}:/dist \
70+
-v ${updated}:/updated \
71+
-w /dist \
72+
rpmrebuild:${arch}

0 commit comments

Comments
 (0)