-
Notifications
You must be signed in to change notification settings - Fork 0
Add jinja templating, payload as tar, tests #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
109693f
5e97190
2019d4f
b80642e
8aebd7c
e4bc141
313f7f2
e642b75
839e290
3327439
3df7843
2566f73
938e027
b2d2025
81a75b4
3300636
a813e17
d64e6ab
0f4d68d
d64a807
c3d51fd
d9fa4f8
1d40e95
f39a787
60f85bb
2ad0d23
8a32292
84b0136
b501aab
c5237a3
2c40ad5
6c542cd
26ebcb3
8c8cc7b
621a545
6312aa7
3c91055
556705a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| @echo {{ 'on' if add_debug else 'off' }} | ||
| setlocal | ||
|
|
||
| {% macro error_block(message, code) %} | ||
| echo [ERROR] {{ message }} | ||
| >> "%LOG%" echo [ERROR] {{ message }} | ||
| exit /b {{ code }} | ||
| {% endmacro %} | ||
|
|
||
| rem Assign INSTDIR and normalize the path | ||
| set "INSTDIR=%~dp0.." | ||
| for %%I in ("%INSTDIR%") do set "INSTDIR=%%~fI" | ||
|
|
||
| set "BASE_PATH=%INSTDIR%\base" | ||
| set "PREFIX=%BASE_PATH%" | ||
| set "CONDA_EXE=%INSTDIR%\{{ conda_exe_name }}" | ||
| set "PAYLOAD_TAR=%INSTDIR%\{{ archive_name }}" | ||
|
|
||
| rem Get the name of the install directory | ||
| for %%I in ("%INSTDIR%") do set "APPNAME=%%~nxI" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has this been tested with
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, all of the tests actually contain spaces because the install directory is set as "name versionnumber-buildnumber" |
||
| set "LOG=%INSTDIR%\uninstall.log" | ||
|
|
||
| {%- if add_debug %} | ||
| echo ==== pre_uninstall start ==== >> "%LOG%" | ||
| echo SCRIPT=%~f0 >> "%LOG%" | ||
| echo CWD=%CD% >> "%LOG%" | ||
| echo INSTDIR=%INSTDIR% >> "%LOG%" | ||
| echo BASE_PATH=%BASE_PATH% >> "%LOG%" | ||
| echo CONDA_EXE=%CONDA_EXE% >> "%LOG%" | ||
| echo PAYLOAD_TAR=%PAYLOAD_TAR% >> "%LOG%" | ||
| "%CONDA_EXE%" --version >> "%LOG%" 2>&1 | ||
| {%- endif %} | ||
|
|
||
| rem Consistency checks | ||
| if not exist "%CONDA_EXE%" ( | ||
| {{ error_block('CONDA_EXE not found: "%CONDA_EXE%"', 10) }} | ||
| ) | ||
|
|
||
| rem Recreate an empty payload tar. This file was deleted during installation but the | ||
| rem MSI installer expects it to exist. | ||
| type nul > "%PAYLOAD_TAR%" | ||
| if errorlevel 1 ( | ||
| {{ error_block('Failed to create "%PAYLOAD_TAR%"', '%errorlevel%') }} | ||
| ) | ||
|
|
||
| "%CONDA_EXE%" --log-file "%LOG%" constructor uninstall --prefix "%BASE_PATH%" | ||
| if errorlevel 1 ( exit /b %errorlevel% ) | ||
|
|
||
| rem If we reached this far without any errors, remove any log-files. | ||
| if exist "%INSTDIR%\install.log" del "%INSTDIR%\install.log" | ||
| if exist "%INSTDIR%\uninstall.log" del "%INSTDIR%\uninstall.log" | ||
|
|
||
| exit /b 0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,68 @@ | ||
| set "INSTDIR=%cd%" | ||
| @echo {{ 'on' if add_debug else 'off' }} | ||
| setlocal | ||
|
|
||
| {% macro error_block(message, code) %} | ||
| echo [ERROR] {{ message }} | ||
| >> "%LOG%" echo [ERROR] {{ message }} | ||
| exit /b {{ code }} | ||
| {% endmacro %} | ||
|
|
||
| rem Assign INSTDIR and normalize the path | ||
| set "INSTDIR=%~dp0.." | ||
| for %%I in ("%INSTDIR%") do set "INSTDIR=%%~fI" | ||
|
|
||
| set "BASE_PATH=%INSTDIR%\base" | ||
| set "PREFIX=%BASE_PATH%" | ||
| set "CONDA_EXE=%INSTDIR%\_conda.exe" | ||
|
|
||
| "%INSTDIR%\_conda.exe" constructor --prefix "%BASE_PATH%" --extract-conda-pkgs | ||
| set "CONDA_EXE=%INSTDIR%\{{ conda_exe_name }}" | ||
| set "PAYLOAD_TAR=%INSTDIR%\{{ archive_name }}" | ||
|
|
||
| set CONDA_EXTRA_SAFETY_CHECKS=no | ||
| set CONDA_PROTECT_FROZEN_ENVS=0 | ||
| set "CONDA_ROOT_PREFIX=%BASE_PATH%" | ||
| set CONDA_REGISTER_ENVS={{ register_envs }} | ||
| set CONDA_SAFETY_CHECKS=disabled | ||
| set CONDA_EXTRA_SAFETY_CHECKS=no | ||
| set "CONDA_ROOT_PREFIX=%BASE_PATH%" | ||
| set "CONDA_PKGS_DIRS=%BASE_PATH%\pkgs" | ||
|
|
||
| "%INSTDIR%\_conda.exe" install --offline --file "%BASE_PATH%\conda-meta\initial-state.explicit.txt" -yp "%BASE_PATH%" | ||
| rem Get the name of the install directory | ||
| for %%I in ("%INSTDIR%") do set "APPNAME=%%~nxI" | ||
| set "LOG=%INSTDIR%\install.log" | ||
|
|
||
| {%- if add_debug %} | ||
| echo ==== run_installation start ==== >> "%LOG%" | ||
| echo SCRIPT=%~f0 >> "%LOG%" | ||
| echo CWD=%CD% >> "%LOG%" | ||
| echo INSTDIR=%INSTDIR% >> "%LOG%" | ||
| echo BASE_PATH=%BASE_PATH% >> "%LOG%" | ||
| echo CONDA_EXE=%CONDA_EXE% >> "%LOG%" | ||
| echo PAYLOAD_TAR=%PAYLOAD_TAR% >> "%LOG%" | ||
| {%- endif %} | ||
|
|
||
| rem Consistency checks | ||
| if not exist "%CONDA_EXE%" ( | ||
| {{ error_block('CONDA_EXE not found: "%CONDA_EXE%"', 10) }} | ||
| ) | ||
| if not exist "%PAYLOAD_TAR%" ( | ||
| {{ error_block('PAYLOAD_TAR not found: "%PAYLOAD_TAR%"', 11) }} | ||
| ) | ||
|
|
||
| echo Unpacking payload... | ||
| "%CONDA_EXE%" --log-file "%LOG%" constructor extract --prefix "%INSTDIR%" --tar-from-stdin < "%PAYLOAD_TAR%" | ||
| if errorlevel 1 ( exit /b %errorlevel% ) | ||
|
|
||
| "%CONDA_EXE%" --log-file "%LOG%" constructor extract --prefix "%BASE_PATH%" --conda-pkgs | ||
| if errorlevel 1 ( exit /b %errorlevel% ) | ||
|
|
||
| if not exist "%BASE_PATH%" ( | ||
| {{ error_block('"%BASE_PATH%" not found!', 12) }} | ||
| ) | ||
|
|
||
| "%CONDA_EXE%" --log-file "%LOG%" install --offline --file "%BASE_PATH%\conda-meta\initial-state.explicit.txt" -yp "%BASE_PATH%" | ||
| if errorlevel 1 ( exit /b %errorlevel% ) | ||
|
|
||
| rem Delete the payload to save disk space. | ||
| rem A truncated placeholder of 0 bytes is recreated during uninstall | ||
| rem because MSI expects the file to be there to clean the registry. | ||
| del "%PAYLOAD_TAR%" | ||
| if errorlevel 1 ( exit /b %errorlevel% ) | ||
|
|
||
| exit /b 0 |
Uh oh!
There was an error while loading. Please reload this page.