Skip to content

Commit

Permalink
Merge branch 'dev/kupu/packman_update' into 'main'
Browse files Browse the repository at this point in the history
Update packman

See merge request lightspeedrtx/dxvk-remix-nv!1017
  • Loading branch information
nvzkupu committed Oct 1, 2024
2 parents fb5dcc9 + 84b0b25 commit 37886d2
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 13 deletions.
2 changes: 1 addition & 1 deletion scripts-common/packman/bootstrap/configure.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
:: See the License for the specific language governing permissions and
:: limitations under the License.

set PM_PACKMAN_VERSION=7.20
set PM_PACKMAN_VERSION=7.24.2

:: Specify where packman command is rooted
set PM_INSTALL_PATH=%~dp0..
Expand Down
8 changes: 5 additions & 3 deletions scripts-common/packman/bootstrap/install_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ def generate_sha256_for_file(file_path: Union[str, os.PathLike]) -> str:


def install_common_module(package_path, install_path):
COMMON_SHA256 = "0023d893d3fa3600496cdf7fad9c8e6e0d5d7ab80a35741b4e8520736cc0c375"
COMMON_SHA256 = "7397be5807841f6d6084e1fa77a4f7c8a9a29b4285b4440cf8c2865d1d9fd152"
package_sha256 = generate_sha256_for_file(package_path)
if package_sha256 != COMMON_SHA256:
raise RuntimeError(f"Package at '{package_path}' must have a sha256 of '{COMMON_SHA256}' "
f"but was found to have '{package_sha256}'")
raise RuntimeError(
f"Package at '{package_path}' must have a sha256 of '{COMMON_SHA256}' "
f"but was found to have '{package_sha256}'"
)
staging_path, version = os.path.split(install_path)
with StagingDirectory(staging_path) as staging_dir:
output_folder = staging_dir.get_temp_folder_path()
Expand Down
46 changes: 39 additions & 7 deletions scripts-common/packman/packman
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ else
PM_CURL_SILENT="-s -S"
PM_WGET_QUIET="--quiet"
fi
export PM_PACKMAN_VERSION=7.20
export PM_PACKMAN_VERSION=7.24.2

# This is necessary for newer macOS
if [ `uname` == 'Darwin' ]; then
Expand Down Expand Up @@ -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()
Expand Down
24 changes: 22 additions & 2 deletions scripts-common/packman/packmanconf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# Use this file to bootstrap packman into your Python environment (3.7.x). Simply
# Copyright 2021-2024 NVIDIA CORPORATION

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Use this file to bootstrap packman into your Python environment. Simply
# add the path by doing sys.insert to where packmanconf.py is located and then execute:
#
# >>> import packmanconf
Expand Down Expand Up @@ -84,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

Expand Down

0 comments on commit 37886d2

Please sign in to comment.