File cuda-setup of Package cuda-library-container
#!/bin/bash
#set -x
PACKAGE_LIST=(
cuda-libraries
)
UPDATE=false
_update_package_cache() {
echo "Updating the package cache..."
FLAVOR="$(echo ${KERNEL_VERSION} | cut -d- -f3)"
if [ "$FLAVOR" == "azure" ]; then
# consumed by container-suseconnect when calling `zypper refresh`
export ADDITIONAL_MODULES="sle-module-public-cloud"
fi
if [ -n "${CUDA_REPO_FINGERPRINT}" ]; then
fpr_tail=${CUDA_REPO_FINGERPRINT: -8:8}
if ! rpm --quiet -q gpg-pubkey-${fpr_tail,,*}; then
filename=${fpr_tail}.pub
eval $(grep baseurl /etc/zypp/repos.d/CUDA.repo)
if ! curl -fsS ${baseurl}/$filename > /tmp/$filename; then
echo "FATAL: CUDA Repo Key not found!"
exit 1;
fi
fpr=$(gpg --with-colons --import-options show-only --import --fingerprint < /tmp/${filename} | grep "^fpr:" | cut -d: -f 10)
if [ "$fpr" != "$CUDA_REPO_FINGERPRINT" ]; then
echo "FATAL: CUDA Repo Key Fingerprint does not match known one!"
exit 1
fi
if [ -x /usr/bin/rpmkeys ]; then
/usr/bin/rpmkeys --import /tmp/${filename}
else
rpm --import /tmp/$filename
fi
if [ $? -ne 0 ]; then
echo "FATAL: Import of CUDA Repo Key failed!"
exit 1
fi
else UPDATE=true
fi
else
echo "FATAL: Fingerprint of CUDA Repo Key unknown!"
exit 1
fi
if ! zypper --non-interactive refresh CUDA || ! zypper refresh; then
echo "FATAL: failed to reach SUSE package repositories. "\
"Ensure that the cluster can access the proper networks."
exit 1
fi
}
_cleanup_package_cache() {
echo "Cleaning up the package cache..."
zypper clean
}
install_update_cuda_components() {
local package_list
if $UPDATE; then echo "Installing:"; else echo "Updating:"; fi
for i in ${PACKAGE_LIST[@]}; do
echo "$i-${CUDA_VERSION/./-}"
package_list+="$i-${CUDA_VERSION/./-} "
done
if $UPDATE; then
zypper --non-interactive update -y $package_list
else
zypper --non-interactive install -y $package_list
fi
echo "Done"
}
_update_package_cache
install_update_cuda_components
_cleanup_package_cache