Repository: NVIDIA/hpc-container-maker

Issue:
Replace use of deprecated apt-key
The use of apt-key has been deprecated for two years, so it would be good to update. Debian's official advice is [here](https://wiki.debian.org/DebianRepository/UseThirdParty).

See for example https://askubuntu.com/questions/1328806/how-to-solve-apt-key-deprecated for an approach that I think should work well for Ubuntu.

The apt commands written to the hppcm Docker build file need to be changed accordingly.

Hints from issue comments:
@samcmill: Agreed.  The `_apt_key` parameter default should be changed from True to False and all the test cases will need to be updated.

Solution patch:
diff --git a/docs/building_blocks.md b/docs/building_blocks.md
index d60819e4..e2d4a37b 100644
--- a/docs/building_blocks.md
+++ b/docs/building_blocks.md
@@ -3335,7 +3335,7 @@ they are not available.  For Ubuntu 16.04 and ppc64le processors,
 the `libibcm1` and `libibcm-dev` packages are not installed
 because they are not available.
 
-For Ubuntu 18.04, the following packages are installed:
+For Ubuntu 18.04 and later, the following packages are installed:
 `dapl2-utils`, `ibutils`, `ibverbs-providers`, `ibverbs-utils`,
 `infiniband-diags`, `libdapl2`, `libdapl-dev`, `libibmad5`,
 `libibmad-dev`, `libibverbs1`, `libibverbs-dev`, `librdmacm1`,
@@ -3347,7 +3347,7 @@ installed: `dapl`, `dapl-devel`, `ibutils`, `libibcm`, `libibmad`,
 `libibverbs-utils`, `librdmacm`, `rdma-core`, and
 `rdma-core-devel`.
 
-For RHEL-based 8.x distributions, the following packages are
+For RHEL-based 8.x distributions and later, the following packages are
 installed: `libibmad`, `libibmad-devel`, `libmlx5`, `libibumad`,
 `libibverbs`, `libibverbs-utils`, `librdmacm`, `rdma-core`, and
 `rdma-core-devel`.
diff --git a/hpccm/building_blocks/apt_get.py b/hpccm/building_blocks/apt_get.py
index 1e2fa0a2..a1664db3 100644
--- a/hpccm/building_blocks/apt_get.py
+++ b/hpccm/building_blocks/apt_get.py
@@ -83,7 +83,7 @@ def __init__(self, **kwargs):
 
         super(apt_get, self).__init__()
 
-        self.__apt_key = kwargs.get('_apt_key', True)
+        self.__apt_key = kwargs.get('_apt_key', False)
         self.__aptitude = kwargs.get('aptitude', False)
         self.__commands = []
         self.__download = kwargs.get('download', False)
diff --git a/hpccm/building_blocks/intel_mpi.py b/hpccm/building_blocks/intel_mpi.py
index d95c1737..983893c5 100644
--- a/hpccm/building_blocks/intel_mpi.py
+++ b/hpccm/building_blocks/intel_mpi.py
@@ -126,6 +126,7 @@ def __instructions(self):
             raise RuntimeError('Intel EULA was not accepted.  To accept, see the documentation for this building block')
 
         self += packages(
+            _apt_key=True,
             apt_keys=['https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-{}.PUB'.format(self.__year)],
             apt_repositories=['deb https://apt.repos.intel.com/mpi all main'],
             ospackages=['intel-mpi-{}'.format(self.__version)],
diff --git a/hpccm/building_blocks/intel_psxe_runtime.py b/hpccm/building_blocks/intel_psxe_runtime.py
index 96c00917..371e7ad4 100644
--- a/hpccm/building_blocks/intel_psxe_runtime.py
+++ b/hpccm/building_blocks/intel_psxe_runtime.py
@@ -176,6 +176,7 @@ def __instructions(self):
 
         self += packages(
             apt=self.__apt,
+            _apt_key=True,
             apt_keys = ['https://apt.repos.intel.com/{0}/GPG-PUB-KEY-INTEL-PSXE-RUNTIME-{0}'.format(self.__year)],
             apt_repositories=apt_repositories,
             aptitude=True,
diff --git a/hpccm/building_blocks/llvm.py b/hpccm/building_blocks/llvm.py
index d276cef7..9e4d9228 100644
--- a/hpccm/building_blocks/llvm.py
+++ b/hpccm/building_blocks/llvm.py
@@ -381,8 +381,8 @@ def __upstream_package_repos(self):
             raise RuntimeError('Unsupported Ubuntu version')
 
         return [
-            'deb http://apt.llvm.org/{0}/ llvm-toolchain-{1} main'.format(codename, codename_ver),
-            'deb-src http://apt.llvm.org/{0}/ llvm-toolchain-{1} main'.format(codename, codename_ver)]
+            'deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/{0}/ llvm-toolchain-{1} main'.format(codename, codename_ver),
+            'deb-src [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/{0}/ llvm-toolchain-{1} main'.format(codename, codename_ver)]
 
     def runtime(self, _from='0'):
         """Generate the set of instructions to install the runtime specific
diff --git a/hpccm/building_blocks/mkl.py b/hpccm/building_blocks/mkl.py
index 0d7893db..dfbd39cc 100644
--- a/hpccm/building_blocks/mkl.py
+++ b/hpccm/building_blocks/mkl.py
@@ -118,6 +118,7 @@ def __instructions(self):
             raise RuntimeError('Intel EULA was not accepted.  To accept, see the documentation for this building block')
 
         self += packages(
+            _apt_key=True,
             apt_keys=['https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-{}.PUB'.format(self.__year)],
             apt_repositories=['deb https://apt.repos.intel.com/mkl all main'],
             ospackages=['intel-mkl-64bit-{}'.format(self.__version)],
diff --git a/hpccm/building_blocks/mlnx_ofed.py b/hpccm/building_blocks/mlnx_ofed.py
index 8f2f1707..993a43fd 100644
--- a/hpccm/building_blocks/mlnx_ofed.py
+++ b/hpccm/building_blocks/mlnx_ofed.py
@@ -133,6 +133,7 @@ def __instructions(self):
             self += packages(ospackages=self.__ospackages)
 
         self += packages(
+            _apt_key=True,
             apt_keys=[self.__key],
             apt_repositories=['https://linux.mellanox.com/public/repo/mlnx_ofed/{0}/{1}/mellanox_mlnx_ofed.list'.format(self.__version, self.__oslabel)],
             download=bool(self.__prefix),
diff --git a/hpccm/building_blocks/nccl.py b/hpccm/building_blocks/nccl.py
index be86250a..64bb2100 100644
--- a/hpccm/building_blocks/nccl.py
+++ b/hpccm/building_blocks/nccl.py
@@ -124,7 +124,7 @@ def __init__(self, **kwargs):
                      'libnccl-dev={0}+cuda{1}'.format(self.__version,
                                                       self.__cuda)],
                 apt_keys=['https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}/3bf863cc.pub'.format(self.__distro_label, get_cpu_architecture())],
-                apt_repositories=['deb https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1} /'.format(self.__distro_label, get_cpu_architecture())],
+                apt_repositories=['deb [signed-by=/usr/share/keyrings/3bf863cc.gpg] https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1} /'.format(self.__distro_label, get_cpu_architecture())],
                 yum=['libnccl-{0}+cuda{1}'.format(self.__version, self.__cuda),
                      'libnccl-devel-{0}+cuda{1}'.format(self.__version,
                                                         self.__cuda)],
@@ -247,7 +247,7 @@ def runtime(self, _from='0'):
                 apt=['libnccl2={0}+cuda{1}'.format(self.__version,
                                                    self.__cuda)],
                 apt_keys=['https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}/3bf863cc.pub'.format(self.__distro_label, get_cpu_architecture())],
-                apt_repositories=['deb https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1} /'.format(self.__distro_label, get_cpu_architecture())],
+                apt_repositories=['deb [signed-by=/usr/share/keyrings/3bf863cc.gpg] https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1} /'.format(self.__distro_label, get_cpu_architecture())],
                 yum=['libnccl-{0}+cuda{1}'.format(self.__version, self.__cuda)],
                 yum_keys=['https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}/3bf863cc.pub'.format(self.__distro_label, get_cpu_architecture())],
                 yum_repositories=['https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}'.format(self.__distro_label, get_cpu_architecture())])
diff --git a/hpccm/building_blocks/ofed.py b/hpccm/building_blocks/ofed.py
index a3b90b50..615ab5bf 100644
--- a/hpccm/building_blocks/ofed.py
+++ b/hpccm/building_blocks/ofed.py
@@ -48,7 +48,7 @@ class ofed(bb_base):
     the `libibcm1` and `libibcm-dev` packages are not installed
     because they are not available.
 
-    For Ubuntu 18.04, the following packages are installed:
+    For Ubuntu 18.04 and later, the following packages are installed:
     `dapl2-utils`, `ibutils`, `ibverbs-providers`, `ibverbs-utils`,
     `infiniband-diags`, `libdapl2`, `libdapl-dev`, `libibmad5`,
     `libibmad-dev`, `libibverbs1`, `libibverbs-dev`, `librdmacm1`,
@@ -60,7 +60,7 @@ class ofed(bb_base):
     `libibverbs-utils`, `librdmacm`, `rdma-core`, and
     `rdma-core-devel`.
 
-    For RHEL-based 8.x distributions, the following packages are
+    For RHEL-based 8.x distributions and later, the following packages are
     installed: `libibmad`, `libibmad-devel`, `libmlx5`, `libibumad`,
     `libibverbs`, `libibverbs-utils`, `librdmacm`, `rdma-core`, and
     `rdma-core-devel`.
@@ -113,7 +113,9 @@ def __distro(self):
             if hpccm.config.g_linux_version >= Version('18.0'):
                 # Give priority to packages from the Ubuntu repositories over
                 # vendor repositories
-                if hpccm.config.g_linux_version >= Version('22.0'):
+                if hpccm.config.g_linux_version >= Version('24.0'):
+                    self.__extra_opts = ['-t noble']
+                elif hpccm.config.g_linux_version >= Version('22.0'):
                     self.__extra_opts = ['-t jammy']
                 elif hpccm.config.g_linux_version >= Version('20.0'):
                     self.__extra_opts = ['-t focal']
@@ -165,7 +167,8 @@ def __distro(self):
                                      'libibverbs-utils', 'libmlx5',
                                      'librdmacm',
                                      'rdma-core', 'rdma-core-devel']
-                self.__powertools = True
+                if hpccm.config.g_linux_version < Version('9.0'):
+                    self.__powertools = True
             else:
                 self.__deppackages = ['libnl', 'libnl3', 'numactl-libs']
                 self.__ospackages = ['dapl', 'dapl-devel', 'ibutils',
diff --git a/hpccm/building_blocks/packages.py b/hpccm/building_blocks/packages.py
index ae8b7aae..b67ef87d 100644
--- a/hpccm/building_blocks/packages.py
+++ b/hpccm/building_blocks/packages.py
@@ -134,7 +134,7 @@ def __init__(self, **kwargs):
         super(packages, self).__init__()
 
         self.__apt = kwargs.get('apt', [])
-        self.__apt_key = kwargs.get('_apt_key', True)
+        self.__apt_key = kwargs.get('_apt_key', False)
         self.__apt_keys = kwargs.get('apt_keys', [])
         self.__apt_ppas = kwargs.get('apt_ppas', [])
         self.__apt_repositories = kwargs.get('apt_repositories', [])
diff --git a/hpccm/primitives/baseimage.py b/hpccm/primitives/baseimage.py
index 6c1efec9..a714f996 100644
--- a/hpccm/primitives/baseimage.py
+++ b/hpccm/primitives/baseimage.py
@@ -121,6 +121,8 @@ def __init__(self, **kwargs):
             hpccm.config.set_linux_distro('ubuntu20')
         elif self.__distro == 'ubuntu22':
             hpccm.config.set_linux_distro('ubuntu22')
+        elif self.__distro == 'ubuntu24':
+            hpccm.config.set_linux_distro('ubuntu24')
         elif self.__distro == 'centos':
             hpccm.config.set_linux_distro('centos')
         elif self.__distro == 'centos7':


Test patch:
diff --git a/test/helpers.py b/test/helpers.py
index 3a2819c8..2c33f6da 100644
--- a/test/helpers.py
+++ b/test/helpers.py
@@ -124,6 +124,15 @@ def wrapper(*args, **kwargs):
 
     return wrapper
 
+def rockylinux9(function):
+    """Decorator to set the Linux distribution to Rockylinux 9"""
+    def wrapper(*args, **kwargs):
+        hpccm.config.g_linux_distro = linux_distro.CENTOS
+        hpccm.config.g_linux_version = Version('9.0')
+        return function(*args, **kwargs)
+
+    return wrapper
+
 def singularity(function):
     """Decorator to set the global container type to singularity"""
     def wrapper(*args, **kwargs):
diff --git a/test/test_apt_get.py b/test/test_apt_get.py
index 639a82c7..2ec68c1e 100644
--- a/test/test_apt_get.py
+++ b/test/test_apt_get.py
@@ -44,27 +44,11 @@ def test_basic(self):
         gfortran && \
     rm -rf /var/lib/apt/lists/*''')
 
-    @ubuntu
-    @docker
-    def test_add_repo(self):
-        """Add repo and key"""
-        a = apt_get(keys=['https://www.example.com/key.pub'],
-                    ospackages=['example'],
-                    repositories=['deb http://www.example.com all main'])
-        self.assertEqual(str(a),
-r'''RUN wget -qO - https://www.example.com/key.pub | apt-key add - && \
-    echo "deb http://www.example.com all main" >> /etc/apt/sources.list.d/hpccm.list && \
-    apt-get update -y && \
-    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
-        example && \
-    rm -rf /var/lib/apt/lists/*''')
-
     @ubuntu
     @docker
     def test_add_repo_signed_by(self):
         """Add repo and key, using the signed-by method rather than apt-key"""
-        a = apt_get(_apt_key=False,
-                    keys=['https://www.example.com/key.pub'],
+        a = apt_get(keys=['https://www.example.com/key.pub'],
                     ospackages=['example'],
                     repositories=['deb [signed-by=/usr/share/keyrings/key.gpg] http://www.example.com all main'])
         self.assertEqual(str(a),
diff --git a/test/test_baseimage.py b/test/test_baseimage.py
index 4774f427..87362b52 100644
--- a/test/test_baseimage.py
+++ b/test/test_baseimage.py
@@ -188,6 +188,20 @@ def test_detect_ubuntu_20(self):
         self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU)
         self.assertEqual(hpccm.config.g_linux_version, Version('20.04'))
 
+    @docker
+    def test_detect_ubuntu_22(self):
+        """Base image Linux distribution detection"""
+        b = baseimage(image='ubuntu:22.04')
+        self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU)
+        self.assertEqual(hpccm.config.g_linux_version, Version('22.04'))
+
+    @docker
+    def test_detect_ubuntu_24(self):
+        """Base image Linux distribution detection"""
+        b = baseimage(image='ubuntu:24.04')
+        self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU)
+        self.assertEqual(hpccm.config.g_linux_version, Version('24.04'))
+
     @docker
     def test_detect_centos(self):
         """Base image Linux distribution detection"""
@@ -216,6 +230,13 @@ def test_detect_rockylinux_8(self):
         self.assertEqual(hpccm.config.g_linux_distro, linux_distro.ROCKYLINUX)
         self.assertEqual(hpccm.config.g_linux_version, Version('8.0'))
 
+    @docker
+    def test_detect_rockylinux_9(self):
+        """Base image Linux distribution detection"""
+        b = baseimage(image='rockylinux/rockylinux:9')
+        self.assertEqual(hpccm.config.g_linux_distro, linux_distro.ROCKYLINUX)
+        self.assertEqual(hpccm.config.g_linux_version, Version('9.0'))
+
     @docker
     def test_detect_ubi7(self):
         """Base image Linux distribution detection"""
@@ -274,6 +295,20 @@ def test_distro_ubuntu20(self):
         self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU)
         self.assertEqual(hpccm.config.g_linux_version, Version('20.04'))
 
+    @docker
+    def test_distro_ubuntu22(self):
+        """Base image Linux distribution specification"""
+        b = baseimage(image='foo', _distro='ubuntu22')
+        self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU)
+        self.assertEqual(hpccm.config.g_linux_version, Version('22.04'))
+
+    @docker
+    def test_distro_ubuntu24(self):
+        """Base image Linux distribution specification"""
+        b = baseimage(image='foo', _distro='ubuntu24')
+        self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU)
+        self.assertEqual(hpccm.config.g_linux_version, Version('24.04'))
+
     @docker
     def test_distro_centos(self):
         """Base image Linux distribution specification"""
@@ -295,6 +330,20 @@ def test_distro_centos8(self):
         self.assertEqual(hpccm.config.g_linux_distro, linux_distro.CENTOS)
         self.assertEqual(hpccm.config.g_linux_version, Version('8.0'))
 
+    @docker
+    def test_distro_rockylinux8(self):
+        """Base image Linux distribution specification"""
+        b = baseimage(image='foo', _distro='rockylinux8')
+        self.assertEqual(hpccm.config.g_linux_distro, linux_distro.CENTOS)
+        self.assertEqual(hpccm.config.g_linux_version, Version('8.0'))
+
+    @docker
+    def test_distro_rockylinux9(self):
+        """Base image Linux distribution specification"""
+        b = baseimage(image='foo', _distro='rockylinux9')
+        self.assertEqual(hpccm.config.g_linux_distro, linux_distro.CENTOS)
+        self.assertEqual(hpccm.config.g_linux_version, Version('9.0'))
+
     @docker
     def test_distro_nonexistent(self):
         """Base image Linux distribution specification"""
diff --git a/test/test_llvm.py b/test/test_llvm.py
index 0cccd65f..3e359353 100644
--- a/test/test_llvm.py
+++ b/test/test_llvm.py
@@ -330,9 +330,11 @@ def test_upstream_ubuntu16(self):
         gnupg \
         wget && \
     rm -rf /var/lib/apt/lists/*
-RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
-    echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main" >> /etc/apt/sources.list.d/hpccm.list && \
-    echo "deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main" >> /etc/apt/sources.list.d/hpccm.list && \
+RUN mkdir -p /usr/share/keyrings && \
+    rm -f /usr/share/keyrings/llvm-snapshot.gpg.gpg && \
+    wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-snapshot.gpg.gpg && \
+    echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main" >> /etc/apt/sources.list.d/hpccm.list && \
+    echo "deb-src [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main" >> /etc/apt/sources.list.d/hpccm.list && \
     apt-get update -y && \
     DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
         clang-10 \
@@ -356,9 +358,11 @@ def test_upstream_ubuntu18(self):
         gnupg \
         wget && \
     rm -rf /var/lib/apt/lists/*
-RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
-    echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" >> /etc/apt/sources.list.d/hpccm.list && \
-    echo "deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" >> /etc/apt/sources.list.d/hpccm.list && \
+RUN mkdir -p /usr/share/keyrings && \
+    rm -f /usr/share/keyrings/llvm-snapshot.gpg.gpg && \
+    wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-snapshot.gpg.gpg && \
+    echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" >> /etc/apt/sources.list.d/hpccm.list && \
+    echo "deb-src [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" >> /etc/apt/sources.list.d/hpccm.list && \
     apt-get update -y && \
     DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
         clang-18 \
@@ -386,9 +390,11 @@ def test_upstream_ubuntu24(self):
         gnupg \
         wget && \
     rm -rf /var/lib/apt/lists/*
-RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
-    echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble main" >> /etc/apt/sources.list.d/hpccm.list && \
-    echo "deb-src http://apt.llvm.org/noble/ llvm-toolchain-noble main" >> /etc/apt/sources.list.d/hpccm.list && \
+RUN mkdir -p /usr/share/keyrings && \
+    rm -f /usr/share/keyrings/llvm-snapshot.gpg.gpg && \
+    wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-snapshot.gpg.gpg && \
+    echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble main" >> /etc/apt/sources.list.d/hpccm.list && \
+    echo "deb-src [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble main" >> /etc/apt/sources.list.d/hpccm.list && \
     apt-get update -y && \
     DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
         clang-18 \
@@ -415,9 +421,11 @@ def test_upstream_ubuntu20(self):
         gnupg \
         wget && \
     rm -rf /var/lib/apt/lists/*
-RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
-    echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" >> /etc/apt/sources.list.d/hpccm.list && \
-    echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal main" >> /etc/apt/sources.list.d/hpccm.list && \
+RUN mkdir -p /usr/share/keyrings && \
+    rm -f /usr/share/keyrings/llvm-snapshot.gpg.gpg && \
+    wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-snapshot.gpg.gpg && \
+    echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/focal/ llvm-toolchain-focal main" >> /etc/apt/sources.list.d/hpccm.list && \
+    echo "deb-src [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/focal/ llvm-toolchain-focal main" >> /etc/apt/sources.list.d/hpccm.list && \
     apt-get update -y && \
     DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
         clang-18 \
@@ -445,9 +453,11 @@ def test_upstream_aarch64(self):
         gnupg \
         wget && \
     rm -rf /var/lib/apt/lists/*
-RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
-    echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main" >> /etc/apt/sources.list.d/hpccm.list && \
-    echo "deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main" >> /etc/apt/sources.list.d/hpccm.list && \
+RUN mkdir -p /usr/share/keyrings && \
+    rm -f /usr/share/keyrings/llvm-snapshot.gpg.gpg && \
+    wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-snapshot.gpg.gpg && \
+    echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main" >> /etc/apt/sources.list.d/hpccm.list && \
+    echo "deb-src [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.gpg] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main" >> /etc/apt/sources.list.d/hpccm.list && \
     apt-get update -y && \
     DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
         clang-11 \
diff --git a/test/test_nccl.py b/test/test_nccl.py
index df23c72c..da2ee91b 100644
--- a/test/test_nccl.py
+++ b/test/test_nccl.py
@@ -46,8 +46,10 @@ def test_defaults_ubuntu(self):
         gnupg \
         wget && \
     rm -rf /var/lib/apt/lists/*
-RUN wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/3bf863cc.pub | apt-key add - && \
-    echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" >> /etc/apt/sources.list.d/hpccm.list && \
+RUN mkdir -p /usr/share/keyrings && \
+    rm -f /usr/share/keyrings/3bf863cc.gpg && \
+    wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/3bf863cc.pub | gpg --dearmor -o /usr/share/keyrings/3bf863cc.gpg && \
+    echo "deb [signed-by=/usr/share/keyrings/3bf863cc.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" >> /etc/apt/sources.list.d/hpccm.list && \
     apt-get update -y && \
     DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
         libnccl-dev=2.12.10-1+cuda11.6 \
@@ -69,8 +71,10 @@ def test_defaults_ubuntu18(self):
         gnupg \
         wget && \
     rm -rf /var/lib/apt/lists/*
-RUN wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub | apt-key add - && \
-    echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" >> /etc/apt/sources.list.d/hpccm.list && \
+RUN mkdir -p /usr/share/keyrings && \
+    rm -f /usr/share/keyrings/3bf863cc.gpg && \
+    wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub | gpg --dearmor -o /usr/share/keyrings/3bf863cc.gpg && \
+    echo "deb [signed-by=/usr/share/keyrings/3bf863cc.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" >> /etc/apt/sources.list.d/hpccm.list && \
     apt-get update -y && \
     DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
         libnccl-dev=2.12.10-1+cuda11.6 \
@@ -92,8 +96,10 @@ def test_ubuntu_ppc64le(self):
         gnupg \
         wget && \
     rm -rf /var/lib/apt/lists/*
-RUN wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/ppc64el/3bf863cc.pub | apt-key add - && \
-    echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/ppc64el /" >> /etc/apt/sources.list.d/hpccm.list && \
+RUN mkdir -p /usr/share/keyrings && \
+    rm -f /usr/share/keyrings/3bf863cc.gpg && \
+    wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/ppc64el/3bf863cc.pub | gpg --dearmor -o /usr/share/keyrings/3bf863cc.gpg && \
+    echo "deb [signed-by=/usr/share/keyrings/3bf863cc.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/ppc64el /" >> /etc/apt/sources.list.d/hpccm.list && \
     apt-get update -y && \
     DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
         libnccl-dev=2.4.8-1+cuda9.2 \
@@ -217,8 +223,10 @@ def test_runtime(self):
         gnupg \
         wget && \
     rm -rf /var/lib/apt/lists/*
-RUN wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/3bf863cc.pub | apt-key add - && \
-    echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" >> /etc/apt/sources.list.d/hpccm.list && \
+RUN mkdir -p /usr/share/keyrings && \
+    rm -f /usr/share/keyrings/3bf863cc.gpg && \
+    wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/3bf863cc.pub | gpg --dearmor -o /usr/share/keyrings/3bf863cc.gpg && \
+    echo "deb [signed-by=/usr/share/keyrings/3bf863cc.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" >> /etc/apt/sources.list.d/hpccm.list && \
     apt-get update -y && \
     DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
         libnccl2=2.12.10-1+cuda11.6 && \
diff --git a/test/test_ofed.py b/test/test_ofed.py
index 77030707..08d0d4c5 100644
--- a/test/test_ofed.py
+++ b/test/test_ofed.py
@@ -22,7 +22,7 @@
 import logging # pylint: disable=unused-import
 import unittest
 
-from helpers import aarch64, centos, centos8, docker, ubuntu, ubuntu18, ubuntu20, ppc64le, x86_64
+from helpers import aarch64, centos, centos8, docker, rockylinux9, ubuntu, ubuntu18, ubuntu20, ubuntu22, ubuntu24, ppc64le, x86_64
 
 from hpccm.building_blocks.ofed import ofed
 
@@ -114,6 +114,58 @@ def test_defaults_ubuntu20(self):
         rdmacm-utils && \
     rm -rf /var/lib/apt/lists/*''')
 
+    @x86_64
+    @ubuntu22
+    @docker
+    def test_defaults_ubuntu22(self):
+        """Default ofed building block"""
+        o = ofed()
+        self.assertEqual(str(o),
+r'''# OFED
+RUN apt-get update -y && \
+    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends -t jammy \
+        dapl2-utils \
+        ibutils \
+        ibverbs-providers \
+        ibverbs-utils \
+        infiniband-diags \
+        libdapl-dev \
+        libdapl2 \
+        libibmad-dev \
+        libibmad5 \
+        libibverbs-dev \
+        libibverbs1 \
+        librdmacm-dev \
+        librdmacm1 \
+        rdmacm-utils && \
+    rm -rf /var/lib/apt/lists/*''')
+
+    @x86_64
+    @ubuntu24
+    @docker
+    def test_defaults_ubuntu24(self):
+        """Default ofed building block"""
+        o = ofed()
+        self.assertEqual(str(o),
+r'''# OFED
+RUN apt-get update -y && \
+    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends -t noble \
+        dapl2-utils \
+        ibutils \
+        ibverbs-providers \
+        ibverbs-utils \
+        infiniband-diags \
+        libdapl-dev \
+        libdapl2 \
+        libibmad-dev \
+        libibmad5 \
+        libibverbs-dev \
+        libibverbs1 \
+        librdmacm-dev \
+        librdmacm1 \
+        rdmacm-utils && \
+    rm -rf /var/lib/apt/lists/*''')
+
     @x86_64
     @centos
     @docker
@@ -160,6 +212,26 @@ def test_defaults_centos8(self):
         rdma-core-devel && \
     rm -rf /var/cache/yum/*''')
 
+    @x86_64
+    @rockylinux9
+    @docker
+    def test_defaults_rockylinux9(self):
+        """Default ofed building block"""
+        o = ofed()
+        self.assertEqual(str(o),
+r'''# OFED
+RUN yum install -y --disablerepo=mlnx\* \
+        libibmad \
+        libibmad-devel \
+        libibumad \
+        libibverbs \
+        libibverbs-utils \
+        libmlx5 \
+        librdmacm \
+        rdma-core \
+        rdma-core-devel && \
+    rm -rf /var/cache/yum/*''')
+
     @x86_64
     @ubuntu
     @docker