-
Notifications
You must be signed in to change notification settings - Fork 176
MSI: Reorganize payload preparation #1164
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
13c2c05
8619a37
109693f
c4b11e8
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
68a527e
8a9be10
6af0910
56aa4a4
1ed9fe0
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" | ||
| 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%" | ||
|
Contributor
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. Since this assumes the
Contributor
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. Great idea, see 1ed9fe0 |
||
| 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 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example? And why is passing the appropriate course of action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few ways to look at it:
payload.remove()function here is intended to be called as the final step (currently insidecreate(...))It is likely that we could skip the entire
delattrshenanigan, but to me it looks more complete to avoid a reference to a directory that might not exist.I was also thinking of writing
Payloadto be used as a context-manager to achieve automatic clean-up but I thought it might be a bit overkill right now.