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 procedure SetEnvPathStrings(CurrentUser
:Boolean;DirStrings
:TArrayOfString
);
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 RegWriteStringValue(HKEY_CURRENT_USER
,'Environment','Path',Path
);
216 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 DirStrings
:TArrayOfString
;
227 LinkOrCopy
:TOutputProgressWizardPage
;
228 FileName
,AppDir
:string;
229 BuiltIns
:TArrayOfString
;
233 AppDir
:=ExpandConstant('{app}');
235 if CurStep
=ssPostInstall
then begin
236 LinkOrCopy
:=CreateOutputProgressPage('Creating Build-Ins','Please wait while Setup creates built-in command files.');
239 // Load the built
-ins from a
text file.
240 FileName
:=ExpandConstant('{app}\'+'{#emit APP_BUILTINS}');
241 if not LoadStringsFromFile(FileName,BuiltIns) then begin
242 MsgBox('Unable
to read file "{#emit APP_BUILTINS}".', mbError, MB_OK);
246 // Check if we are running on NTFS.
248 if SetNTFSCompression(AppDir+'\bin\git
.exe
',true) then begin
249 IsNTFS:=SetNTFSCompression(AppDir+'\bin\git
.exe
',false);
252 Count:=GetArrayLength(BuiltIns)-1;
254 // Map the built-ins to git.exe.
256 for i:=0 to Count do begin
257 FileName:=AppDir+'\'+BuiltIns
[i
];
259 // On non
-NTFS partitions
, create hard links
.
260 LinkOrCopy
.SetText('Creating hard link...',FileName
);
261 LinkOrCopy
.SetProgress(i
,Count
);
262 CreateHardLink(FileName
,AppDir
+'\bin\git.exe',0);
265 for i
:=0 to GetArrayLength(BuiltIns
)-1 do begin
266 FileName
:=AppDir
+'\'+BuiltIns[i];
268 // On non-NTFS partitions, copy simply the files.
269 LinkOrCopy.SetText('Copying
file...',FileName);
270 LinkOrCopy.SetProgress(i,Count);
271 FileCopy(AppDir+'\bin\git
.exe
',FileName,false);
276 end else if CurStep=ssDone then begin
277 // Get the current user's directories
in PATH
.
278 DirStrings
:=GetEnvPathStrings(True);
280 // First
, remove the installation directory from PATH
in any
case.
281 for i
:=0 to GetArrayLength(DirStrings
)-1 do begin
282 if Pos(AppDir
,DirStrings
[i
])=1 then begin
287 // Modify the PATH variable
as requested by the user
.
288 if RdbGitCmd
.Checked
then begin
289 i
:=GetArrayLength(DirStrings
);
290 SetArrayLength(DirStrings
,i
+1);
291 DirStrings
[i
]:=ExpandConstant('{app}\cmd');
292 end else if RdbGitCmdTools
.Checked
then begin
293 i
:=GetArrayLength(DirStrings
);
294 SetArrayLength(DirStrings
,i
+2);
295 DirStrings
[i
]:=ExpandConstant('{app}\cmd');
296 DirStrings
[i
+1]:=ExpandConstant('{app}\bin');
299 // Set the current user
's directories in PATH.
300 SetEnvPathStrings(True,DirStrings);
304 procedure CurUninstallStepChanged(CurUninstallStep:TUninstallStep);
307 DirStrings:TArrayOfString;
310 if CurUninstallStep=usDone then begin
311 AppDir:=ExpandConstant('{app}');
313 // Get the current user's directories
in PATH
.
314 DirStrings
:=GetEnvPathStrings(True);
316 // Remove the installation directory from PATH
in any
case, even
if it
317 // was
not added by the installer
.
318 for i
:=0 to GetArrayLength(DirStrings
)-1 do begin
319 if Pos(AppDir
,DirStrings
[i
])=1 then begin
324 // Set the current user
's directories in PATH.
325 SetEnvPathStrings(True,DirStrings);