Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions scripts/bootstrap_prerequisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,31 @@ echo "Building prerequisites in $PREREQS_BUILD_DIR"
# Remove below if you wish to debug pre-req build failures
trap "rm -rf $PREREQS_BUILD_DIR" EXIT

# Retry a command, clearing package-manager metadata between attempts. The CUDA
# yum repo CDN intermittently serves a stale repomd.xml that points at rotated
# repodata files, producing 404s; clearing metadata forces a fresh fetch.
function retry {
local n=0 max=5 delay=15
until "$@"; do
n=$((n+1))
if [ "$n" -ge "$max" ]; then
echo "Command failed after $max attempts: $*" >&2
return 1
fi
echo "Attempt $n/$max failed; clearing repo metadata and retrying in ${delay}s..." >&2
if [ -x "$(command -v dnf)" ]; then dnf clean all || true
elif [ -x "$(command -v apt-get)" ]; then apt-get clean || true; fi
sleep "$delay"
done
}

function temp_install_if_command_unknown {
if [ ! -x "$(command -v $1)" ]; then
if [ -x "$(command -v apt-get)" ]; then
if [ -z "$PKG_UNINSTALL" ]; then apt-get update; fi
apt-get install -y --no-install-recommends $2
if [ -z "$PKG_UNINSTALL" ]; then retry apt-get update; fi
retry apt-get install -y --no-install-recommends $2
elif [ -x "$(command -v dnf)" ]; then
dnf install -y --nobest --setopt=install_weak_deps=False $2
retry dnf install -y --nobest --setopt=install_weak_deps=False $2
elif [ -x "$(command -v brew)" ]; then
HOMEBREW_NO_AUTO_UPDATE=1 brew install $2
else
Expand Down
24 changes: 21 additions & 3 deletions scripts/install_prerequisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,31 @@ echo "Building prerequisites in $PREREQS_BUILD_DIR"
# Remove below if you wish to debug pre-req build failures
trap "rm -rf $PREREQS_BUILD_DIR" EXIT

# Retry a command, clearing package-manager metadata between attempts. The CUDA
# yum repo CDN intermittently serves a stale repomd.xml that points at rotated
# repodata files, producing 404s; clearing metadata forces a fresh fetch.
function retry {
local n=0 max=5 delay=15
until "$@"; do
n=$((n+1))
if [ "$n" -ge "$max" ]; then
echo "Command failed after $max attempts: $*" >&2
return 1
fi
echo "Attempt $n/$max failed; clearing repo metadata and retrying in ${delay}s..." >&2
if [ -x "$(command -v dnf)" ]; then dnf clean all || true
elif [ -x "$(command -v apt-get)" ]; then apt-get clean || true; fi
sleep "$delay"
done
}

function temp_install_if_command_unknown {
if [ ! -x "$(command -v $1)" ]; then
if [ -x "$(command -v apt-get)" ]; then
if [ -z "$PKG_UNINSTALL" ]; then apt-get update; fi
apt-get install -y --no-install-recommends $2
if [ -z "$PKG_UNINSTALL" ]; then retry apt-get update; fi
retry apt-get install -y --no-install-recommends $2
elif [ -x "$(command -v dnf)" ]; then
dnf install -y --nobest --setopt=install_weak_deps=False $2
retry dnf install -y --nobest --setopt=install_weak_deps=False $2
elif [ -x "$(command -v brew)" ]; then
HOMEBREW_NO_AUTO_UPDATE=1 brew install $2
else
Expand Down
Loading