aboutsummaryrefslogtreecommitdiff
path: root/buildtools/packman
diff options
context:
space:
mode:
authorBryan Galdrikian <[email protected]>2018-01-22 14:04:16 -0800
committerBryan Galdrikian <[email protected]>2018-01-22 14:04:16 -0800
commit1dc1a87fba520bb45c1ce8165e8ea2c83c0a308d (patch)
tree5f8ca75a6b92c60fb5cf3b14282fc4cc1c127eb2 /buildtools/packman
parentUpdating readme.md to show updated UE4 Blast integration branches (diff)
downloadblast-1dc1a87fba520bb45c1ce8165e8ea2c83c0a308d.tar.xz
blast-1dc1a87fba520bb45c1ce8165e8ea2c83c0a308d.zip
Changes for 1.1.2 release candidate
See README.md, docs/release_notes.txt
Diffstat (limited to 'buildtools/packman')
-rwxr-xr-xbuildtools/packman/packman25
-rw-r--r--buildtools/packman/packman.cmd20
-rw-r--r--buildtools/packman/packmanapi.py2
-rw-r--r--buildtools/packman/win-bootstrap/configure.bat6
-rw-r--r--buildtools/packman/win-bootstrap/fetch_file_from_s3.cmd (renamed from buildtools/packman/win-bootstrap/fetch_file.cmd)16
-rw-r--r--buildtools/packman/win-bootstrap/fetch_file_from_s3.ps175
6 files changed, 99 insertions, 45 deletions
diff --git a/buildtools/packman/packman b/buildtools/packman/packman
index 6ab322c..a423f8a 100755
--- a/buildtools/packman/packman
+++ b/buildtools/packman/packman
@@ -1,12 +1,15 @@
-#!/bin/sh
+#!/bin/bash
-PM_PACKMAN_VERSION=4.0-rc3
+PM_PACKMAN_VERSION=4.0.1
# Specify where configuration file could exist
-export PM_CONFIG_PATH=$(dirname "$0")/packman_config.txt
+export PM_CONFIG_PATH=$(dirname ${BASH_SOURCE})/packman_config.txt
# 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
export PM_PACKAGES_ROOT="${HOME}/packman-repo"
fi
@@ -54,4 +57,18 @@ if [ ! -f "$PM_MODULE" ]; then
fi
fi
-python "$PM_MODULE" $*
+# Generate temporary file name for environment variables:
+PM_VAR_PATH=`mktemp -u -t tmp.XXXXX.$$.pmvars`
+
+python "$PM_MODULE" $* --var-path="$PM_VAR_PATH"
+
+# Export the variables if the file was used and remove the file:
+if [ -f "$PM_VAR_PATH" ]; then
+ while read -r line
+ do
+ if [ ${#line} -gt 0 ]; then
+ export "$line"
+ fi
+ done < "$PM_VAR_PATH"
+ rm -f "$PM_VAR_PATH"
+fi
diff --git a/buildtools/packman/packman.cmd b/buildtools/packman/packman.cmd
index a17027e..03e2cf8 100644
--- a/buildtools/packman/packman.cmd
+++ b/buildtools/packman/packman.cmd
@@ -7,7 +7,21 @@
@if not defined PM_PYTHON goto :PYTHON_ENV_ERROR
@if not defined PM_MODULE goto :MODULE_ENV_ERROR
-@"%PM_PYTHON%" "%PM_MODULE%" %*
+:: Generate temporary path for variable file
+:TEMP_VAR_PATH_LOOP
+@set "PM_VAR_PATH=%tmp%\tmp.%RANDOM%.pmvars"
+@if exist "%PM_VAR_PATH%" goto :TEMP_VAR_PATH_LOOP
+
+@"%PM_PYTHON%" "%PM_MODULE%" %* --var-path="%PM_VAR_PATH%"
+@if errorlevel 1 goto :eof
+
+:: Marshall environment variables into the current environment if they have been generated and remove temporary file
+@if exist "%PM_VAR_PATH%" (
+ @for /F "usebackq tokens=*" %%A in ("%PM_VAR_PATH%") do @set "%%A"
+ @if errorlevel 1 goto :VAR_ERROR
+ @del /F "%PM_VAR_PATH%"
+)
+@set PM_VAR_PATH=
@goto :eof
:: Subroutines below
@@ -19,5 +33,9 @@
@echo User environment variable PM_MODULE is not set! Please configure machine for packman or call configure.bat.
@exit /b 1
+:VAR_ERROR
+@echo Error while processing and setting environment variables!
+@exit /b 1
+
:RESET_ERROR
@exit /b 0 \ No newline at end of file
diff --git a/buildtools/packman/packmanapi.py b/buildtools/packman/packmanapi.py
index 45ea711..6475f9d 100644
--- a/buildtools/packman/packmanapi.py
+++ b/buildtools/packman/packmanapi.py
@@ -4,7 +4,7 @@ import sys
def get_packman_module_dir():
root_dir = os.environ['PM_PACKAGES_ROOT']
- common_dir = '4.0-rc3-common'
+ common_dir = '4.0.1-common'
module_dir = os.path.join(root_dir, 'packman', common_dir)
return module_dir
diff --git a/buildtools/packman/win-bootstrap/configure.bat b/buildtools/packman/win-bootstrap/configure.bat
index 8f3d7b8..7963ac2 100644
--- a/buildtools/packman/win-bootstrap/configure.bat
+++ b/buildtools/packman/win-bootstrap/configure.bat
@@ -1,4 +1,4 @@
-@set PM_PACKMAN_VERSION=4.0-rc3
+@set PM_PACKMAN_VERSION=4.0.1
:: Specify where config file could exist
@set PM_CONFIG_PATH=%~dp0..\packman_config.txt
@@ -45,7 +45,7 @@
@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
-@call "%~dp0fetch_file.cmd" s3 %PM_PYTHON_PACKAGE% UNUSED_BOGUS_GUID %TARGET%
+@call "%~dp0fetch_file_from_s3.cmd" %PM_PYTHON_PACKAGE% %TARGET%
@if errorlevel 1 goto ERROR
@echo Unpacking ...
@@ -69,7 +69,7 @@
@set PM_MODULE_PACKAGE=packman@%PM_PACKMAN_VERSION%-common.zip
@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%
-@call "%~dp0fetch_file.cmd" s3 %PM_MODULE_PACKAGE% UNUSED_BOGUS_GUID %TARGET%
+@call "%~dp0fetch_file_from_s3.cmd" %PM_MODULE_PACKAGE% %TARGET%
@if errorlevel 1 goto ERROR
@echo Unpacking ...
diff --git a/buildtools/packman/win-bootstrap/fetch_file.cmd b/buildtools/packman/win-bootstrap/fetch_file_from_s3.cmd
index 298b6a0..974d5ec 100644
--- a/buildtools/packman/win-bootstrap/fetch_file.cmd
+++ b/buildtools/packman/win-bootstrap/fetch_file_from_s3.cmd
@@ -1,19 +1,15 @@
-:: You need to specify <package-source> <package-name> <package-guid> <target-name> as input to this command
+:: You need to specify <package-name> <target-name> as input to this command
-@set PACKAGE_NAME=%2
-@set PACKAGE_GUID=%3
-@set TARGET=%4
+@set PACKAGE_NAME=%1
+@set TARGET=%2
-@echo Fetching %PACKAGE_NAME% from %1 ...
+@echo Fetching %PACKAGE_NAME% from s3 ...
-@if ["%1"] EQU ["s3"] set SOURCE_OPT=-sourceName %PACKAGE_NAME%
-@if ["%1"] EQU ["gtl"] set SOURCE_OPT=-sourceGUID %PACKAGE_GUID%
-
-@powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0fetch_file_from_%1.ps1" %SOURCE_OPT% -output %TARGET%
+@powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0fetch_file_from_s3.ps1" -sourceName %PACKAGE_NAME% -output %TARGET%
:: A bug in powershell prevents the errorlevel code from being set when using the -File execution option
:: We must therefore do our own failure analysis, basically make sure the file exists and is larger than 0 bytes:
@if not exist %TARGET% goto ERROR_DOWNLOAD_FAILED
-@if %~z4==0 goto ERROR_DOWNLOAD_FAILED
+@if %~z2==0 goto ERROR_DOWNLOAD_FAILED
@exit /b 0
diff --git a/buildtools/packman/win-bootstrap/fetch_file_from_s3.ps1 b/buildtools/packman/win-bootstrap/fetch_file_from_s3.ps1
index e424058..fc588d9 100644
--- a/buildtools/packman/win-bootstrap/fetch_file_from_s3.ps1
+++ b/buildtools/packman/win-bootstrap/fetch_file_from_s3.ps1
@@ -5,33 +5,56 @@ param(
$source = "http://packman.s3.amazonaws.com/" + $sourceName
$filename = $output
-$req = [System.Net.httpwebrequest]::Create($source)
-$req.cookiecontainer = New-Object System.net.CookieContainer
+$triesLeft = 3
-Write-Host "Connecting to S3 ..."
-$res = $req.GetResponse()
+do
+{
+ $triesLeft -= 1
+ $req = [System.Net.httpwebrequest]::Create($source)
+ $req.cookiecontainer = New-Object System.net.CookieContainer
-if($res.StatusCode -eq "OK") {
- Write-Host "Downloading ..."
- [int]$goal = $res.ContentLength
- $reader = $res.GetResponseStream()
- $writer = new-object System.IO.FileStream $fileName, "Create"
- [byte[]]$buffer = new-object byte[] 4096
- [int]$total = [int]$count = 0
- do
- {
- $count = $reader.Read($buffer, 0, $buffer.Length);
- $writer.Write($buffer, 0, $count);
- $total += $count
- if($goal -gt 0) {
- Write-Progress "Downloading $url" "Saving $total of $goal" -id 0 -percentComplete (($total/$goal)*100)
- } else {
- Write-Progress "Downloading $url" "Saving $total bytes..." -id 0
+ try
+ {
+ Write-Host "Connecting to S3 ..."
+ $res = $req.GetResponse()
+ if($res.StatusCode -eq "OK") {
+ Write-Host "Downloading ..."
+ [int]$goal = $res.ContentLength
+ $reader = $res.GetResponseStream()
+ $writer = new-object System.IO.FileStream $fileName, "Create"
+ [byte[]]$buffer = new-object byte[] 4096
+ [int]$total = [int]$count = 0
+ do
+ {
+ $count = $reader.Read($buffer, 0, $buffer.Length);
+ $writer.Write($buffer, 0, $count);
+ $total += $count
+ if($goal -gt 0) {
+ Write-Progress "Downloading $url" "Saving $total of $goal" -id 0 -percentComplete (($total/$goal)*100)
+ } else {
+ Write-Progress "Downloading $url" "Saving $total bytes..." -id 0
+ }
+ } while ($count -gt 0)
+
+ $triesLeft = 0
+ }
}
- } while ($count -gt 0)
-
- $reader.Close()
- $writer.Flush()
- $writer.Close()
-}
+ catch
+ {
+ Write-Host "Error connecting to S3!"
+ Write-Host $_.Exception|format-list -force
+ }
+ finally
+ {
+ if ($reader)
+ {
+ $reader.Close()
+ }
+ if ($writer)
+ {
+ $writer.Flush()
+ $writer.Close()
+ }
+ }
+} while ($triesLeft -gt 0)