aboutsummaryrefslogtreecommitdiff
path: root/buildtools/packman5
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools/packman5')
-rwxr-xr-xbuildtools/packman5/config.packman.xml2
-rwxr-xr-xbuildtools/packman5/packman49
-rwxr-xr-xbuildtools/packman5/packman.cmd2
-rwxr-xr-xbuildtools/packman5/win-bootstrap/configure.bat64
-rwxr-xr-xbuildtools/packman5/win-bootstrap/fetch_file_from_s3.cmd2
-rwxr-xr-xbuildtools/packman5/win-bootstrap/fetch_file_from_s3.ps12
-rw-r--r--buildtools/packman5/win-bootstrap/generate_temp_folder.ps17
7 files changed, 92 insertions, 36 deletions
diff --git a/buildtools/packman5/config.packman.xml b/buildtools/packman5/config.packman.xml
index 6a6da46..a3b89aa 100755
--- a/buildtools/packman5/config.packman.xml
+++ b/buildtools/packman5/config.packman.xml
@@ -1,3 +1,3 @@
<config remotes="cloudfront">
<remote name="cloudfront" packageLocation="d4i3qtqj3r0z5.cloudfront.net/${name}@${version}" type="https" />
- </config> \ No newline at end of file
+</config> \ No newline at end of file
diff --git a/buildtools/packman5/packman b/buildtools/packman5/packman
index c16a2a7..a2fb94f 100755
--- a/buildtools/packman5/packman
+++ b/buildtools/packman5/packman
@@ -1,15 +1,27 @@
#!/bin/bash
-PM_PACKMAN_VERSION=5.2.1
+PM_PACKMAN_VERSION=5.7.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
@@ -20,17 +32,17 @@ if [ ! -d "$PM_PACKAGES_ROOT" ]; then
fi
# The packman module may be externally configured
-if [ -z "$PM_MODULE_EXT" ]; then
+if [ -z "$PM_MODULE_DIR_EXT" ]; then
PM_MODULE_DIR="$PM_PACKAGES_ROOT/packman-common/$PM_PACKMAN_VERSION"
- export PM_MODULE="$PM_MODULE_DIR/packman.py"
else
- export PM_MODULE="$PM_MODULE_EXT"
+ PM_MODULE_DIR="$PM_MODULE_DIR_EXT"
fi
+export PM_MODULE="$PM_MODULE_DIR/packman.py"
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
@@ -67,20 +79,23 @@ else
fi
# Ensure 7za package exists:
-PM_7za_VERSION=16.02.2
-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.4
+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 -s -u -E "$PM_MODULE" pull "$PM_MODULE_DIR/deps.packman.xml"
+ 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"
+$PM_PYTHON -s -u -E "$PM_MODULE" "$@" --var-path="$PM_VAR_PATH"
exit_code=$?
# Export the variables if the file was used and remove the file:
if [ -f "$PM_VAR_PATH" ]; then
diff --git a/buildtools/packman5/packman.cmd b/buildtools/packman5/packman.cmd
index ae7b495..b06f6dc 100755
--- a/buildtools/packman5/packman.cmd
+++ b/buildtools/packman5/packman.cmd
@@ -11,7 +11,7 @@
@for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile ^
-File "%~dp0win-bootstrap\generate_temp_file_name.ps1"') do @set PM_VAR_PATH=%%a
-@"%PM_PYTHON%" -u "%PM_MODULE%" %* --var-path="%PM_VAR_PATH%"
+@"%PM_PYTHON%" -s -u -E "%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
diff --git a/buildtools/packman5/win-bootstrap/configure.bat b/buildtools/packman5/win-bootstrap/configure.bat
index a38f697..223a839 100755
--- a/buildtools/packman5/win-bootstrap/configure.bat
+++ b/buildtools/packman5/win-bootstrap/configure.bat
@@ -1,4 +1,4 @@
-@set PM_PACKMAN_VERSION=5.2.1
+@set PM_PACKMAN_VERSION=5.7.2
:: Specify where packman command is rooted
@set PM_INSTALL_PATH=%~dp0..
@@ -45,31 +45,54 @@
@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
-@if defined PM_MODULE_EXT (
- @set PM_MODULE=%PM_MODULE_EXT%
- @goto ENSURE_7za
+@if defined PM_MODULE_DIR_EXT (
+ @set PM_MODULE_DIR=%PM_MODULE_DIR_EXT%
+) else (
+ @set PM_MODULE_DIR=%PM_PACKAGES_ROOT%\packman-common\%PM_PACKMAN_VERSION%
)
-@set PM_MODULE_DIR=%PM_PACKAGES_ROOT%\packman-common\%PM_PACKMAN_VERSION%
@set PM_MODULE=%PM_MODULE_DIR%\packman.py
@if exist "%PM_MODULE%" goto ENSURE_7ZA
@@ -81,17 +104,19 @@
@if errorlevel 1 goto ERROR
@echo Unpacking ...
-@"%PM_PYTHON%" "%~dp0\install_package.py" "%TARGET%" "%PM_MODULE_DIR%"
+@"%PM_PYTHON%" -s -u -E "%~dp0\install_package.py" "%TARGET%" "%PM_MODULE_DIR%"
@if errorlevel 1 goto ERROR
@del "%TARGET%"
:ENSURE_7ZA
-@set PM_7Za_VERSION=16.02.2
+@set PM_7Za_VERSION=16.02.4
+@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%" -s -u -E "%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/buildtools/packman5/win-bootstrap/fetch_file_from_s3.cmd b/buildtools/packman5/win-bootstrap/fetch_file_from_s3.cmd
index 90f717a..4e31293 100755
--- a/buildtools/packman5/win-bootstrap/fetch_file_from_s3.cmd
+++ b/buildtools/packman5/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/buildtools/packman5/win-bootstrap/fetch_file_from_s3.ps1 b/buildtools/packman5/win-bootstrap/fetch_file_from_s3.ps1
index 132fe0d..96db7f2 100755
--- a/buildtools/packman5/win-bootstrap/fetch_file_from_s3.ps1
+++ b/buildtools/packman5/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/buildtools/packman5/win-bootstrap/generate_temp_folder.ps1 b/buildtools/packman5/win-bootstrap/generate_temp_folder.ps1
new file mode 100644
index 0000000..b24a654
--- /dev/null
+++ b/buildtools/packman5/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