2 #define APP_VERSION
'%APPVERSION%'
3 #define APP_URL
'http://code.google.com/p/msysgit/'
4 #define APP_BUILTINS
'etc\fileList-builtins.txt'
8 InternalCompressLevel
=max
9 OutputBaseFilename
={#emit APP_NAME+'-'+APP_VERSION}
15 AppName
={#emit APP_NAME}
16 AppPublisherURL
={#emit APP_URL}
17 AppVersion
={#emit APP_VERSION}
18 AppVerName
={#emit APP_NAME+' '+APP_VERSION}
19 ChangesEnvironment
=yes
20 DefaultDirName
={pf}\
{#emit APP_NAME}
21 DefaultGroupName
={#emit APP_NAME}
23 LicenseFile
=gpl
-2.0.txt
24 UninstallDisplayIcon
=etc\git
.ico
27 SetupIconFile
=etc\git
.ico
28 WizardSmallImageFile
=git
.bmp
31 Name
: quicklaunchicon; Description
: "Create a &Quick Launch icon"; GroupDescription
: "Additional icons:"; Flags
: checkedonce
32 Name
: desktopicon; Description
: "Create a &Desktop icon"; GroupDescription
: "Additional icons:"; Flags
: checkedonce
33 Name
: shellextension
; Description
: "Add ""Git &Bash Here"""; GroupDescription
: "Windows Explorer integration:"; Flags
: checkedonce
34 Name
: guiextension
; Description
: "Add ""Git &GUI Here"""; GroupDescription
: "Windows Explorer integration:"; Flags
: checkedonce
37 Source
: "*"; DestDir
: "{app}"; Excludes
: "\*.txt, \install.*, \tmp.*, \bin\*install*"; Flags
: recursesubdirs
40 Name
: "{group}\Git GUI"; Filename
: "{app}\bin\wish.exe"; Parameters
: """{app}\bin\git-gui"""; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"
41 Name
: "{group}\Git Bash"; Filename
: "{app}\bin\sh.exe"; Parameters
: "--login -i"; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"
42 Name
: "{group}\Uninstall Git"; Filename
: "{uninstallexe}"
43 Name
: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Git Bash"; Filename
: "{app}\bin\sh.exe"; Parameters
: "--login -i"; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"; Tasks
: quicklaunchicon
44 Name
: "{userdesktop}\Git Bash"; Filename
: "{app}\bin\sh.exe"; Parameters
: "--login -i"; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"; Tasks
: desktopicon
47 BeveledLabel
={#emit APP_URL}
50 Root
: HKLM
; Subkey
: "SOFTWARE\Classes\Directory\shell\git_shell"; ValueType
: string; ValueData
: "Git &Shell Here"; Flags
: uninsdeletevalue uninsdeletekeyifempty; Tasks
: shellextension
51 Root
: HKLM
; Subkey
: "SOFTWARE\Classes\Directory\shell\git_shell\command"; ValueType
: string; ValueData
: "cmd.exe /c ""pushd ""%1"" && ""{app}\bin\sh.exe"" --login -i"""; Flags
: uninsdeletevalue uninsdeletekeyifempty; Tasks
: shellextension
52 Root
: HKLM
; Subkey
: "SOFTWARE\Classes\Directory\shell\git_gui"; ValueType
: string; ValueData
: "Git &GUI Here"; Flags
: uninsdeletevalue uninsdeletekeyifempty; Tasks
: guiextension
53 Root
: HKLM
; Subkey
: "SOFTWARE\Classes\Directory\shell\git_gui\command"; ValueType
: string; ValueData
: """{app}\bin\wish.exe"" ""{app}\bin\git-gui"" ""--working-dir"" ""%1"""; Flags
: uninsdeletevalue uninsdeletekeyifempty; Tasks
: guiextension
56 Type: files; Name
: "{app}\bin\git-*.exe"
57 Type: dirifempty; Name
: "{app}\home\{username}"
58 Type: dirifempty; Name
: "{app}\home"
63 RdbGitBash
,RdbGitCmd
,RdbGitCmdTools
:TRadioButton
;
65 procedure InitializeWizard
;
67 LblGitBash
,LblGitCmd
,LblGitCmdTools
,LblGitCmdToolsWarn
:TLabel
;
69 // Use a mono spaced font
in the license dialog
. NOTE
: This might be too small
.
70 WizardForm
.LicenseMemo
.Font
.Name
:='Lucida Console';
71 WizardForm
.LicenseMemo
.Font
.Size
:=7;
73 // Create a custom page
for modifying the environment
.
74 EnvPage
:=CreateCustomPage(
76 'Adjusting your PATH environment',
77 'How would you like to use Git from the command line?'
81 RdbGitBash
:=TRadioButton
.Create(EnvPage
);
82 with RdbGitBash
do begin
83 Parent
:=EnvPage
.Surface
;
84 Caption
:='Use Git Bash only';
93 LblGitBash
:=TLabel
.Create(EnvPage
);
94 with LblGitBash
do begin
95 Parent
:=EnvPage
.Surface
;
97 'This is the most conservative choice if you are concerned about the' + #
13 +
98 'stability of your system. Your PATH will not be modified.';
106 RdbGitCmd
:=TRadioButton
.Create(EnvPage
);
107 with RdbGitCmd
do begin
108 Parent
:=EnvPage
.Surface
;
109 Caption
:='Run Git from the Windows Command Prompt';
114 Font
.Style
:=[fsBold
];
117 LblGitCmd
:=TLabel
.Create(EnvPage
);
118 with LblGitCmd
do begin
119 Parent
:=EnvPage
.Surface
;
121 'This option is considered safe and no conflicts with other tools are' + #
13 +
122 'known. Only Git will be added to your PATH.';
130 RdbGitCmdTools
:=TRadioButton
.Create(EnvPage
);
131 with RdbGitCmdTools
do begin
132 Parent
:=EnvPage
.Surface
;
133 Caption
:='Run Git and included Unix tools from the Windows Command Prompt';
138 Font
.Style
:=[fsBold
];
141 LblGitCmdTools
:=TLabel
.Create(EnvPage
);
142 with LblGitCmdTools
do begin
143 Parent
:=EnvPage
.Surface
;
144 Caption
:='Both Git and the Unix tools will be added to your PATH.';
150 LblGitCmdToolsWarn
:=TLabel
.Create(EnvPage
);
151 with LblGitCmdToolsWarn
do begin
152 Parent
:=EnvPage
.Surface
;
154 'Warning: This will override Windows tools like find.exe and' + #
13 +
155 'sort.exe. Select this option only if you understand the implications.';
161 Font
.Style
:=[fsBold
];
165 function GetEnvPathStrings(CurrentUser
:Boolean):TArrayOfString
;
171 // See http
://www
.jrsoftware
.org
/isfaq
.php#env
172 if CurrentUser
then begin
173 RegQueryStringValue(HKEY_CURRENT_USER
,'Environment','Path',Path
);
175 RegQueryStringValue(HKEY_LOCAL_MACHINE
,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','Path',Path
);
178 // Make sure we have at least one semicolon
.
181 // Split the directories
in PATH into an
array of strings
.
185 SetArrayLength(Result
,i
+1);
187 Result
[i
]:=Copy(Path
,1,p
-1);
190 Path
:=Copy(Path
,p
+1,Length(Path
));
195 function SetEnvPathStrings(CurrentUser
:Boolean;DirStrings
:TArrayOfString
):Boolean;
200 // Merge all non
-empty directory strings into a PATH variable
.
202 for i
:=0 to GetArrayLength(DirStrings
)-1 do begin
203 if Length(DirStrings
[i
])>0 then begin
204 if Length(Path
)>0 then begin
205 Path
:=Path
+';'+DirStrings
[i
];
212 // See http
://www
.jrsoftware
.org
/isfaq
.php#env
213 if CurrentUser
then begin
214 Result
:=RegWriteStringValue(HKEY_CURRENT_USER
,'Environment','Path',Path
);
216 Result
:=RegWriteStringValue(HKEY_LOCAL_MACHINE
,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','Path',Path
);
220 function CreateHardLink(lpFileName
,lpExistingFileName
:string;lpSecurityAttributes
:Integer):Boolean;
221 external 'CreateHardLinkA@Kernel32.dll';
223 procedure CurStepChanged(CurStep
:TSetupStep
);
225 AppDir
,FileName
:string;
226 BuiltIns
,DirStrings
:TArrayOfString
;
230 if CurStep
<>ssPostInstall
then begin
234 AppDir
:=ExpandConstant('{app}');
240 // Load the built
-ins from a
text file.
241 FileName
:=ExpandConstant('{app}\'+'{#emit APP_BUILTINS}');
242 if not LoadStringsFromFile(FileName,BuiltIns) then begin
243 MsgBox('Unable
to read file "{#emit APP_BUILTINS}".',mbError,MB_OK);
247 // Check if we are running on NTFS.
249 if SetNTFSCompression(AppDir+'\bin\git
.exe
',true) then begin
250 IsNTFS:=SetNTFSCompression(AppDir+'\bin\git
.exe
',false);
253 Count:=GetArrayLength(BuiltIns)-1;
255 // Map the built-ins to git.exe.
257 for i:=0 to Count do begin
258 FileName:=AppDir+'\'+BuiltIns
[i
];
260 // On non
-NTFS partitions
, create hard links
.
261 CreateHardLink(FileName
,AppDir
+'\bin\git.exe',0);
264 for i
:=0 to GetArrayLength(BuiltIns
)-1 do begin
265 FileName
:=AppDir
+'\'+BuiltIns[i];
267 // On non-NTFS partitions, copy simply the files.
268 FileCopy(AppDir+'\bin\git
.exe
',FileName,false);
273 Modify the environment
275 This must happen no later than ssPostInstall to make
276 "ChangesEnvironment=yes" not happend before the change!
279 // Get the current user's directories
in PATH
.
280 DirStrings
:=GetEnvPathStrings(True);
282 // First
, remove the installation directory from PATH
in any
case.
283 for i
:=0 to GetArrayLength(DirStrings
)-1 do begin
284 if Pos(AppDir
,DirStrings
[i
])=1 then begin
289 // Modify the PATH variable
as requested by the user
.
290 if RdbGitCmd
.Checked
then begin
291 i
:=GetArrayLength(DirStrings
);
292 SetArrayLength(DirStrings
,i
+1);
293 DirStrings
[i
]:=ExpandConstant('{app}\cmd');
294 end else if RdbGitCmdTools
.Checked
then begin
295 i
:=GetArrayLength(DirStrings
);
296 SetArrayLength(DirStrings
,i
+2);
298 // List \cmd before
\bin so \cmd has higher priority
and programs
in
299 // there will be called
in favor
of those
in \bin
.
300 DirStrings
[i
]:=ExpandConstant('{app}\cmd');
301 DirStrings
[i
+1]:=ExpandConstant('{app}\bin');
304 // Set the current user
's directories in PATH.
305 SetEnvPathStrings(True,DirStrings);
308 procedure CurUninstallStepChanged(CurUninstallStep:TUninstallStep);
311 DirStrings:TArrayOfString;
314 if CurUninstallStep<>usUninstall then begin
319 Modify the environment
321 This must happen no later than usUninstall to make
322 "ChangesEnvironment=yes" not happend before the change!
325 AppDir:=ExpandConstant('{app}');
327 // Get the current user's directories
in PATH
.
328 DirStrings
:=GetEnvPathStrings(True);
330 // Remove the installation directory from PATH
in any
case, even
if it
331 // was
not added by the installer
.
332 for i
:=0 to GetArrayLength(DirStrings
)-1 do begin
333 if Pos(AppDir
,DirStrings
[i
])=1 then begin
338 // Set the current user
's directories in PATH.
339 if not SetEnvPathStrings(True,DirStrings) then begin
340 MsgBox('Unable
to revert any possible changes
to PATH
.',mbError,MB_OK);