Skip to content

Commit db3521c

Browse files
committed
installer: test for more in-use files
The recently-added "blocked-file-util" is now being put to good use: we enumerate the process IDs of the processes that use .exe or .dll files from the installation location to skip the installation if the /SKIPIFINUSE=1 option was specified. This catches scenarios where users call non-Git executables directly (e.g. C:\Program Files\Git\mingw64\bin\openssl.exe) and a silent installation wants to just make sure that Git is installed. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent ad3d6a5 commit db3521c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

installer/install.iss

+20
Original file line numberDiff line numberDiff line change
@@ -1502,9 +1502,29 @@ begin
15021502
end;
15031503
15041504
function ShouldSkipPage(PageID:Integer):Boolean;
1505+
var
1506+
AppDir,Msg,Cmd,LogPath:String;
1507+
Res:Longint;
15051508
begin
15061509
if (ProcessesPage<>NIL) and (PageID=ProcessesPage.ID) then begin
15071510
// This page is only reached forward (by pressing "Next", never by pressing "Back").
1511+
if (ParamIsSet('SKIPIFINUSE') or ParamIsSet('VSNOTICE')) then begin
1512+
AppDir:=ExpandConstant('{app}');
1513+
if DirExists(AppDir) then begin
1514+
if not FileExists(ExpandConstant('{tmp}\blocked-file-util.exe')) then
1515+
ExtractTemporaryFile('blocked-file-util.exe');
1516+
LogPath:=ExpandConstant('{tmp}\blocking-pids.log');
1517+
Cmd:='/C ""'+ExpandConstant('{tmp}\blocked-file-util.exe')+'" blocking-pids "'+AppDir+'" 2>"'+LogPath+'""';
1518+
if not Exec(ExpandConstant('{sys}\cmd.exe'),Cmd,'',SW_HIDE,ewWaitUntilTerminated,Res) or (Res<>0) then begin
1519+
Msg:='Skipping installation because '+AppDir+' is still in use:'+#13+#10+ReadFileAsString(LogPath);
1520+
if ParamIsSet('SKIPIFINUSE') or (ExpandConstant('{log}')='') then
1521+
LogError(Msg)
1522+
else
1523+
Log(Msg);
1524+
ExitEarlyWithSuccess();
1525+
end;
1526+
end;
1527+
end;
15081528
RefreshProcessList(NIL);
15091529
Result:=(GetArrayLength(Processes)=0);
15101530
end else begin

installer/release.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ else
108108
die "Could not generate file list"
109109
fi
110110

111-
printf "; List of files\n%s\n%s\n%s\n%s\n%s\n" \
111+
printf '; List of files\n%s\n%s\n%s\n%s\n%s\n%s\n' \
112+
"Source: \"mingw$BITNESS\\bin\\blocked-file-util.exe\"; Flags: dontcopy" \
112113
"Source: \"{#SourcePath}\\package-versions.txt\"; DestDir: {app}\\etc; Flags: replacesameversion; AfterInstall: DeleteFromVirtualStore" \
113114
"Source: \"{#SourcePath}\\..\\ReleaseNotes.css\"; DestDir: {app}\\usr\\share\\git; Flags: replacesameversion; AfterInstall: DeleteFromVirtualStore" \
114115
"Source: \"cmd\\git.exe\"; DestDir: {app}\\bin; Flags: replacesameversion; AfterInstall: DeleteFromVirtualStore" \

0 commit comments

Comments
 (0)