Skip to content
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

Parse Windows' version correctly in post-install script #506

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions post-install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
@REM <percent>~fI Expands <percent>I to a fully qualified path name.
@FOR /F "delims=" %%D IN ("%~dp0") DO @CD %%~fD

@FOR /F "tokens=4 delims=.[XP " %%i IN ('ver') DO @SET ver=%%i
@SET /A "version=0" & FOR /F "tokens=2 delims=[]" %%i IN ('"VER"') DO @(
@FOR /F "tokens=2 delims=. " %%v IN ("%%~i") DO @(
@SET /A "version=%%~v + 0"
)
)

@REM If this is a 32-bit Git for Windows, adjust the DLL address ranges.
@REM We cannot use %PROCESSOR_ARCHITECTURE% for this test because it is
@REM allowed to install a 32-bit Git for Windows into a 64-bit system.
@IF EXIST mingw32\bin\git.exe @(
@REM We need to rebase just to make sure that it still works even with
@REM 32-bit Windows 10
@IF 10 LEQ %ver% @(
@IF %version% GEQ 10 @(
@REM We copy `rebase.exe` because it links to `msys-2.0.dll`
@REM (and @REM thus prevents modifying it). It is okay to
@REM execute `rebase.exe`, though, because the DLL base address
Expand All @@ -42,5 +46,8 @@
@REM Run the post-install scripts
@usr\bin\bash.exe --norc -c "export PATH=/usr/bin:$PATH; export SYSCONFDIR=/etc; for p in $(export LC_COLLATE=C; echo /etc/post-install/*.post); do test -e \"$p\" && . \"$p\"; done"

@REM Unset environment variables set by this script
@SET "version="

@REM Remove this script
@DEL post-install.bat