From e0b09c77076d02e839260b90dd6a4cca69baadb1 Mon Sep 17 00:00:00 2001 From: Eric Shi Date: Fri, 30 Aug 2024 15:05:57 -0700 Subject: [PATCH] Update Packman to 7.24.1 --- tools/packman/bootstrap/configure.bat | 2 +- tools/packman/bootstrap/install_package.py | 2 +- tools/packman/packman | 46 ++++++++++++++++++---- tools/packman/packmanconf.py | 8 +++- 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/tools/packman/bootstrap/configure.bat b/tools/packman/bootstrap/configure.bat index 33fb44138..8887b1c45 100755 --- a/tools/packman/bootstrap/configure.bat +++ b/tools/packman/bootstrap/configure.bat @@ -12,7 +12,7 @@ :: See the License for the specific language governing permissions and :: limitations under the License. -set PM_PACKMAN_VERSION=7.23.1 +set PM_PACKMAN_VERSION=7.24.1 :: Specify where packman command is rooted set PM_INSTALL_PATH=%~dp0.. diff --git a/tools/packman/bootstrap/install_package.py b/tools/packman/bootstrap/install_package.py index 4542c4bef..8735a0ec8 100644 --- a/tools/packman/bootstrap/install_package.py +++ b/tools/packman/bootstrap/install_package.py @@ -142,7 +142,7 @@ def generate_sha256_for_file(file_path: Union[str, os.PathLike]) -> str: def install_common_module(package_path, install_path): - COMMON_SHA256 = "0a2064434cca0170411c86f23349f9618556dc380d3589a2361db38ffeea9cac" + COMMON_SHA256 = "ce46783c5a938082514e796a014f8cca5870d6466c6a7147c35e230911dff143" package_sha256 = generate_sha256_for_file(package_path) if package_sha256 != COMMON_SHA256: raise RuntimeError( diff --git a/tools/packman/packman b/tools/packman/packman index b222d307a..03d297d35 100755 --- a/tools/packman/packman +++ b/tools/packman/packman @@ -24,7 +24,7 @@ else PM_CURL_SILENT="-s -S" PM_WGET_QUIET="--quiet" fi -export PM_PACKMAN_VERSION=7.23.1 +export PM_PACKMAN_VERSION=7.24.1 # This is necessary for newer macOS if [ `uname` == 'Darwin' ]; then @@ -60,17 +60,49 @@ if [ ! -d "$PM_PACKAGES_ROOT" ]; then mkdir -p -m a+rwx "$PM_PACKAGES_ROOT" fi +execute_with_retry() +{ + # Don't exit on error, we need to handle them + set +e + + local CMD="$1" + local MAX_TRIES=4 + local DELAY=2 + local TRIES=0 + local exit_code + + while [ $TRIES -lt $MAX_TRIES ] + do + ((TRIES++)) + eval $CMD + exit_code=$? + if [ $exit_code -eq 0 ]; then + return 0 + fi + + if [ $TRIES -lt $MAX_TRIES ]; then + echo "Attempt $TRIES failed. Retrying in $DELAY seconds ..." + sleep $DELAY + DELAY=$((DELAY * DELAY)) + echo "Retrying ..." + fi + done + + echo "Command failed after $MAX_TRIES attempts: $CMD" + return $exit_code +} + fetch_file_from_s3() { - SOURCE=$1 - SOURCE_URL=http://bootstrap.packman.nvidia.com/$SOURCE - TARGET=$2 + local SOURCE=$1 + local SOURCE_URL=http://bootstrap.packman.nvidia.com/$SOURCE + local TARGET=$2 echo "Fetching $SOURCE from bootstrap.packman.nvidia.com ..." + local CMD="curl -o $TARGET $SOURCE_URL $PM_CURL_SILENT" if command -v wget >/dev/null 2>&1; then - wget $PM_WGET_QUIET -O$TARGET $SOURCE_URL - else - curl -o $TARGET $SOURCE_URL $PM_CURL_SILENT + CMD="wget $PM_WGET_QUIET -O$TARGET $SOURCE_URL" fi + execute_with_retry "$CMD" } generate_temp_file_name() diff --git a/tools/packman/packmanconf.py b/tools/packman/packmanconf.py index db220d27e..f2dca9e3b 100644 --- a/tools/packman/packmanconf.py +++ b/tools/packman/packmanconf.py @@ -98,7 +98,13 @@ def get_module_dir(conf_dir, packages_root: str, version: str) -> str: tf = tempfile.NamedTemporaryFile(delete=False) target_name = tf.name tf.close() - url = f"http://bootstrap.packman.nvidia.com/packman-common@{version}.zip" + # Using http here and not https is by design. Unfortunately SSL keeps getting revised + # which breaks old clients when servers are forced to upgrade to newer version of TLS + # and refuse to downgrade when asked. Instead of relying on SSL for transport security + # packman does SHA256 verification of the downloaded package in the `install_package` + # method. We therefore inform SonarQube to stop complaining about the line below. + # See issue #367 for more detail. + url = f"http://bootstrap.packman.nvidia.com/packman-common@{version}.zip" # NOSONAR print(f"Downloading '{url}' ...") import urllib.request