aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarijn Tamis <[email protected]>2018-07-06 17:26:27 +0200
committerMarijn Tamis <[email protected]>2018-07-06 17:26:27 +0200
commitc3ac1004e49545ad0e92c6a1bc6a0a2b8c2ad3d9 (patch)
tree08b85c3d9bcbfec3ee2340e9625b10a5bc1e3dbc
parentFix cmake.packman.xml using an advice from Halldor, so it should work for non... (diff)
downloadnvcloth-c3ac1004e49545ad0e92c6a1bc6a0a2b8c2ad3d9.tar.xz
nvcloth-c3ac1004e49545ad0e92c6a1bc6a0a2b8c2ad3d9.zip
Fixed packman issues. 2447985
-rw-r--r--NvCloth/scripts/packman/config.packman.xml13
-rw-r--r--NvCloth/scripts/packman/packman.sh47
-rw-r--r--NvCloth/scripts/packman/win-bootstrap/configure.bat54
-rw-r--r--NvCloth/scripts/packman/win-bootstrap/fetch_file_from_s3.cmd2
-rw-r--r--NvCloth/scripts/packman/win-bootstrap/fetch_file_from_s3.ps12
-rw-r--r--NvCloth/scripts/packman/win-bootstrap/generate_temp_folder.ps17
6 files changed, 88 insertions, 37 deletions
diff --git a/NvCloth/scripts/packman/config.packman.xml b/NvCloth/scripts/packman/config.packman.xml
index 8c61e70..a3b89aa 100644
--- a/NvCloth/scripts/packman/config.packman.xml
+++ b/NvCloth/scripts/packman/config.packman.xml
@@ -1,10 +1,3 @@
-<config remotes="s3 gtl">
- <remote name="s3" type="s3" packageLocation="packman">
- <credentials id="AKIAJHPSPBMWMTZS6TJA" key="vK3d0lHiQjEW9krFfvKA4OLpuHGxi2L4/Q4r4IuT"
- errorUrl="https://gtl-gitlab.nvidia.com/halldor/packman/wikis/credentials/failure-using-s3-packman-read-access"/>
- </remote>
- <remote name="gtl" type="gtl">
- <credentials id="svcgtlautomate" key="QHV0ME1AdDNHVEwkY3IxcHQk"/>
- </remote>
- <remote name="cloudfront" type="https" packageLocation="d2bmww5yym6ce8.cloudfront.net/${name}@${version}" />
-</config>
+<config remotes="cloudfront">
+ <remote name="cloudfront" packageLocation="d4i3qtqj3r0z5.cloudfront.net/${name}@${version}" type="https" />
+</config> \ No newline at end of file
diff --git a/NvCloth/scripts/packman/packman.sh b/NvCloth/scripts/packman/packman.sh
index a892def..95bb161 100644
--- a/NvCloth/scripts/packman/packman.sh
+++ b/NvCloth/scripts/packman/packman.sh
@@ -1,15 +1,27 @@
#!/bin/bash
-PM_PACKMAN_VERSION=5.1
+PM_PACKMAN_VERSION=5.4.2
# Specify where packman command exists
export PM_INSTALL_PATH=$(dirname ${BASH_SOURCE})
+add_packages_root_to_file()
+{
+ FILE_PATH=$1
+ if [ -f "$FILE_PATH" ]; then
+ if ! grep -Fq "PM_PACKAGES_ROOT" $FILE_PATH ; then
+ echo "Adjusting $FILE_PATH"
+ echo -e "export PM_PACKAGES_ROOT=\$HOME/packman-repo\n" >> $FILE_PATH
+ fi
+ fi
+}
+
# The packages root may already be configured by the user
if [ -z "$PM_PACKAGES_ROOT" ]; then
- # Set variable permanently using .profile for this user
- echo "export PM_PACKAGES_ROOT=\$HOME/packman-repo" >> ~/.profile
- # Set variable temporarily in this process so that the following execution will work
+ # Set variable permanently using .profile for this user (if exists)
+ add_packages_root_to_file ~/.profile
+ add_packages_root_to_file ~/.bashrc
+ # Set variable temporarily in this process so that the following execution will work
export PM_PACKAGES_ROOT="${HOME}/packman-repo"
fi
@@ -30,7 +42,7 @@ fi
fetch_file_from_s3()
{
SOURCE=$1
- SOURCE_URL=http://packman.s3.amazonaws.com/$SOURCE
+ SOURCE_URL=http://packman-bootstrap.s3.amazonaws.com/$SOURCE
TARGET=$2
echo "Fetching $SOURCE from S3 ..."
if command -v wget >/dev/null 2>&1; then
@@ -58,25 +70,30 @@ if [ ! -f "$PM_MODULE" ]; then
fi
# For now assume python is installed on the box and we just need to find it
-if command -v python2 >/dev/null 2>&1; then
- export PM_PYTHON=python2
+if command -v python2.7 >/dev/null 2>&1; then
+ export PM_PYTHON=python2.7
+elif command -v python2 >/dev/null 2>&1; then
+ export PM_PYTHON=python2
else
export PM_PYTHON=python
fi
# Ensure 7za package exists:
-PM_7za_VERSION=16.02
-export PM_7za_PATH="$PM_PACKAGES_ROOT/chk/7za/$PM_7za_VERSION"
-if [ ! -f "$PM_7za_PATH" ]; then
- $PM_PYTHON "$PM_MODULE" install 7za $PM_7za_VERSION -r packman:cloudfront
- if [ "$?" -ne 0 ]; then
- echo "Failure while installing required 7za package"
- exit 1
+PM_7za_VERSION=16.02.2
+export PM_7za_PATH="$PM_PACKAGES_ROOT/7za/$PM_7za_VERSION"
+if [ ! -d "$PM_7za_PATH" ]; then
+ export PM_7za_PATH="$PM_PACKAGES_ROOT/chk/7za/$PM_7za_VERSION"
+ if [ ! -d "$PM_7za_PATH" ]; then
+ $PM_PYTHON "$PM_MODULE" install 7za $PM_7za_VERSION -r packman:cloudfront
+ if [ "$?" -ne 0 ]; then
+ echo "Failure while installing required 7za package"
+ exit 1
+ fi
fi
fi
# Generate temporary file name for environment variables:
-PM_VAR_PATH=`mktemp -u -t tmp.XXXXX.$$.pmvars`
+PM_VAR_PATH=`mktemp -u -t tmp.$$.pmvars.XXXXXX`
$PM_PYTHON -u "$PM_MODULE" $* --var-path="$PM_VAR_PATH"
exit_code=$?
diff --git a/NvCloth/scripts/packman/win-bootstrap/configure.bat b/NvCloth/scripts/packman/win-bootstrap/configure.bat
index e2781c4..dc94ca6 100644
--- a/NvCloth/scripts/packman/win-bootstrap/configure.bat
+++ b/NvCloth/scripts/packman/win-bootstrap/configure.bat
@@ -1,4 +1,4 @@
-@set PM_PACKMAN_VERSION=5.1
+@set PM_PACKMAN_VERSION=5.4.2
:: Specify where packman command is rooted
@set PM_INSTALL_PATH=%~dp0..
@@ -45,22 +45,45 @@
@goto PACKMAN
)
-@set PM_PYTHON_DIR=%PM_PACKAGES_ROOT%\python\2.7.6-windows-x86
+@set PM_PYTHON_VERSION=2.7.14-windows-x86_32
+@set PM_PYTHON_BASE_DIR=%PM_PACKAGES_ROOT%\python
+@set PM_PYTHON_DIR=%PM_PYTHON_BASE_DIR%\%PM_PYTHON_VERSION%
@set PM_PYTHON=%PM_PYTHON_DIR%\python.exe
@if exist "%PM_PYTHON%" goto PACKMAN
+@if not exist "%PM_PYTHON_BASE_DIR%" call :CREATE_PYTHON_BASE_DIR
+@set PM_PYTHON_PACKAGE=python@%PM_PYTHON_VERSION%.cab
@for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do @set TEMP_FILE_NAME=%%a
-@set TARGET=%TEMP_FILE_NAME%.exe
+@set TARGET=%TEMP_FILE_NAME%.zip
@call "%~dp0fetch_file_from_s3.cmd" %PM_PYTHON_PACKAGE% "%TARGET%"
@if errorlevel 1 goto ERROR
-@echo Unpacking ...
-@"%TARGET%" -o"%PM_PYTHON_DIR%" -y 1> nul
-@if errorlevel 1 goto ERROR
-
+@for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_folder.ps1" -parentPath "%PM_PYTHON_BASE_DIR%"') do @set TEMP_FOLDER_NAME=%%a
+@echo Unpacking Python interpreter ...
+@expand -F:* "%TARGET%" "%TEMP_FOLDER_NAME%" 1> nul
@del "%TARGET%"
+:: Failure during extraction to temp folder name, need to clean up and abort
+@if errorlevel 1 (
+ @call :CLEAN_UP_TEMP_FOLDER
+ @goto ERROR
+)
+
+:: If python has now been installed by a concurrent process we need to clean up and then continue
+@if exist "%PM_PYTHON%" (
+ @call :CLEAN_UP_TEMP_FOLDER
+ @goto PACKMAN
+) else (
+ @if exist "%PM_PYTHON_DIR%" ( @rd /s /q "%PM_PYTHON_DIR%" > nul )
+)
+
+:: Perform atomic rename
+@rename "%TEMP_FOLDER_NAME%" "%PM_PYTHON_VERSION%" 1> nul
+:: Failure during move, need to clean up and abort
+@if errorlevel 1 (
+ @call :CLEAN_UP_TEMP_FOLDER
+ @goto ERROR
+)
:PACKMAN
:: The packman module may already be externally configured
@@ -87,11 +110,13 @@
@del "%TARGET%"
:ENSURE_7ZA
-@set PM_7Za_VERSION=16.02
+@set PM_7Za_VERSION=16.02.2
+@set PM_7Za_PATH=%PM_PACKAGES_ROOT%\7za\%PM_7ZA_VERSION%
+@if exist "%PM_7Za_PATH%" goto END
@set PM_7Za_PATH=%PM_PACKAGES_ROOT%\chk\7za\%PM_7ZA_VERSION%
@if exist "%PM_7Za_PATH%" goto END
-@"%PM_PYTHON%" "%PM_MODULE%" install 7za %PM_7za_VERSION% -r packman:cloudfront
+@"%PM_PYTHON%" "%PM_MODULE%" pull "%PM_MODULE_DIR%\deps.packman.xml"
@if errorlevel 1 goto ERROR
@goto END
@@ -109,4 +134,13 @@
@echo !!! Failure while configuring local machine :( !!!
@exit /B 1
+:CLEAN_UP_TEMP_FOLDER
+@rd /S /Q "%TEMP_FOLDER_NAME%"
+@exit /B
+
+:CREATE_PYTHON_BASE_DIR
+:: We ignore errors and clean error state - if two processes create the directory one will fail which is fine
+@md "%PM_PYTHON_BASE_DIR%" > nul 2>&1
+@exit /B 0
+
:END
diff --git a/NvCloth/scripts/packman/win-bootstrap/fetch_file_from_s3.cmd b/NvCloth/scripts/packman/win-bootstrap/fetch_file_from_s3.cmd
index 0d0a440..61a70fa 100644
--- a/NvCloth/scripts/packman/win-bootstrap/fetch_file_from_s3.cmd
+++ b/NvCloth/scripts/packman/win-bootstrap/fetch_file_from_s3.cmd
@@ -3,7 +3,7 @@
@set PACKAGE_NAME=%1
@set TARGET_PATH=%2
-@echo Fetching %PACKAGE_NAME% from S3 ...
+@echo Fetching %PACKAGE_NAME% from packman-bootstrap over HTTP ...
@powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0fetch_file_from_s3.ps1" -sourceName %PACKAGE_NAME% ^
-output %TARGET_PATH%
diff --git a/NvCloth/scripts/packman/win-bootstrap/fetch_file_from_s3.ps1 b/NvCloth/scripts/packman/win-bootstrap/fetch_file_from_s3.ps1
index fc588d9..c679ec2 100644
--- a/NvCloth/scripts/packman/win-bootstrap/fetch_file_from_s3.ps1
+++ b/NvCloth/scripts/packman/win-bootstrap/fetch_file_from_s3.ps1
@@ -2,7 +2,7 @@ param(
[Parameter(Mandatory=$true)][string]$sourceName=$null,
[string]$output="out.exe"
)
-$source = "http://packman.s3.amazonaws.com/" + $sourceName
+$source = "http://packman-bootstrap.s3.amazonaws.com/" + $sourceName
$filename = $output
$triesLeft = 3
diff --git a/NvCloth/scripts/packman/win-bootstrap/generate_temp_folder.ps1 b/NvCloth/scripts/packman/win-bootstrap/generate_temp_folder.ps1
new file mode 100644
index 0000000..b24a654
--- /dev/null
+++ b/NvCloth/scripts/packman/win-bootstrap/generate_temp_folder.ps1
@@ -0,0 +1,7 @@
+param(
+[Parameter(Mandatory=$true)][string]$parentPath=$null
+)
+[string] $name = [System.Guid]::NewGuid()
+$out = Join-Path $parentPath $name
+New-Item -ItemType Directory -Path ($out) | Out-Null
+Write-Host $out