1 #define APP_NAME
'git-cola'
2 #define APP_LONGNAME
'git-cola - The highly caffeinated git GUI'
3 #define APP_VERSION
'%APPVERSION%'
4 #define APP_URL
'http://git-cola.github.io/'
8 InternalCompressLevel
=max
9 OutputBaseFilename
={#emit APP_NAME+'-'+APP_VERSION}
15 AppName
={#emit APP_LONGNAME}
16 AppPublisherURL
={#emit APP_URL}
17 AppVersion
={#emit APP_VERSION}
18 AppVerName
={#emit APP_LONGNAME+' '+APP_VERSION}
19 ChangesEnvironment
=yes
20 DefaultDirName
={pf}\
{#emit APP_NAME}
21 DefaultGroupName
={#emit APP_LONGNAME}
23 InfoBeforeFile
=etc\gpl
-2.0.rtf
24 PrivilegesRequired
=none
25 UninstallDisplayIcon
=etc\git
.ico
28 SetupIconFile
=etc\git
.ico
29 WizardSmallImageFile
=etc\git
.bmp
32 Name
: quicklaunchicon; Description
: "Create a &Quick Launch icon"; GroupDescription
: "Additional icons:"; Flags
: checkedonce
33 Name
: desktopicon; Description
: "Create a &Desktop icon"; GroupDescription
: "Additional icons:"; Flags
: checkedonce
34 Name
: guiextension
; Description
: "Add ""Git &Cola Here"""; GroupDescription
: "Windows Explorer integration:"; Flags
: checkedonce
37 Source
: "*"; DestDir
: "{app}"; Excludes
: "\*.bmp, \install.*, \tmp.*, \bin\*install*"; Flags
: recursesubdirs
38 Source
: "etc\ReleaseNotes.txt"; DestDir
: "{app}\etc"; Flags
: isreadme
41 Name
: "{group}\git-cola"; Filename
: "{code:GetPythonExe}"; Parameters
: """{app}\bin\git-cola.pyw"" --prompt --git-path ""{code:GetGitExe}"""; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"
42 Name
: "{group}\git-dag"; Filename
: "{code:GetPythonExe}"; Parameters
: """{app}\bin\git-dag.pyw"" --prompt --git-path ""{code:GetGitExe}"""; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"
43 Name
: "{group}\git-cola Homepage"; Filename
: "{#emit APP_URL}"; WorkingDir
: "%USERPROFILE%";
44 Name
: "{group}\Release Notes"; Filename
: "{app}\etc\ReleaseNotes.txt"; WorkingDir
: "%USERPROFILE%";
45 Name
: "{group}\License"; Filename
: "{app}\etc\gpl-2.0.rtf"; WorkingDir
: "%USERPROFILE%";
46 Name
: "{group}\Uninstall git-cola"; Filename
: "{uninstallexe}"
47 Name
: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\git-cola"; Filename
: "{code:GetPythonExe}"; Parameters
: """{app}\bin\git-cola.pyw"" --prompt --git-path ""{code:GetGitExe}"""; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"; Tasks
: quicklaunchicon
48 Name
: "{code:GetShellFolder|desktop}\git-cola"; Filename
: "{code:GetPythonExe}"; Parameters
: """{app}\bin\git-cola.pyw"" --prompt --git-path ""{code:GetGitExe}"""; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"; Tasks
: desktopicon
49 Name
: "{code:GetShellFolder|desktop}\git-dag"; Filename
: "{code:GetPythonExe}"; Parameters
: """{app}\bin\git-dag.pyw"" --prompt --git-path ""{code:GetGitExe}"""; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"; Tasks
: desktopicon
52 BeveledLabel
={#emit APP_URL}
53 SetupAppTitle
={#emit APP_NAME} Setup
54 SetupWindowTitle
={#emit APP_NAME} Setup
57 Type: files; Name
: "{app}\bin\*"
58 Type: files; Name
: "{app}\etc\*"
59 Type: files; Name
: "{app}\share\git-cola\bin\*"
60 Type: files; Name
: "{app}\share\git-cola\icons\*"
61 Type: files; Name
: "{app}\share\git-cola\lib\cola\*"
62 Type: files; Name
: "{app}\share\git-cola\lib\cola\classic\*"
63 Type: files; Name
: "{app}\share\git-cola\lib\cola\main\*"
64 Type: files; Name
: "{app}\share\git-cola\lib\cola\merge\*"
65 Type: files; Name
: "{app}\share\git-cola\lib\cola\models\*"
66 Type: files; Name
: "{app}\share\git-cola\lib\cola\stash\*"
67 Type: files; Name
: "{app}\share\git-cola\lib\cola\widgets\*"
68 Type: dirifempty; Name
: "{app}\share\git-cola\lib\cola\classic"
69 Type: dirifempty; Name
: "{app}\share\git-cola\lib\cola\main"
70 Type: dirifempty; Name
: "{app}\share\git-cola\lib\cola\merge"
71 Type: dirifempty; Name
: "{app}\share\git-cola\lib\cola\models"
72 Type: dirifempty; Name
: "{app}\share\git-cola\lib\cola\stash"
73 Type: dirifempty; Name
: "{app}\share\git-cola\lib\cola\widgets"
74 Type: dirifempty; Name
: "{app}\share\git-cola\lib\cola"
75 Type: dirifempty; Name
: "{app}\share\git-cola\lib"
76 Type: dirifempty; Name
: "{app}\share\git-cola\icons"
77 Type: dirifempty; Name
: "{app}\share\git-cola\bin"
78 Type: dirifempty; Name
: "{app}\etc"
79 Type: dirifempty; Name
: "{app}\bin"
87 PythonPage
:TWizardPage
;
92 function GetEnvStrings(VarName
:string;AllUsers
:Boolean):TArrayOfString
;
100 // See http
://www
.jrsoftware
.org
/isfaq
.php#env
101 if AllUsers
then begin
102 // We ignore errors here
. The resulting
array of strings will be empty
.
103 RegQueryStringValue(HKEY_LOCAL_MACHINE
,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',VarName
,Path
);
105 // We ignore errors here
. The resulting
array of strings will be empty
.
106 RegQueryStringValue(HKEY_CURRENT_USER
,'Environment',VarName
,Path
);
109 // Make sure we have at least one semicolon
.
112 // Split the directories
in PATH into an
array of strings
.
114 SetArrayLength(Result
,0);
118 SetArrayLength(Result
,i
+1);
120 Result
[i
]:=Copy(Path
,1,p
-1);
123 Path
:=Copy(Path
,p
+1,Length(Path
));
128 function SetEnvStrings(VarName
:string;AllUsers
,DeleteIfEmpty
:Boolean;DirStrings
:TArrayOfString
):Boolean;
133 // Merge all non
-empty directory strings into a PATH variable
.
135 for i
:=0 to GetArrayLength(DirStrings
)-1 do begin
136 if Length(DirStrings
[i
])>0 then begin
137 if Length(Path
)>0 then begin
138 Path
:=Path
+';'+DirStrings
[i
];
145 // See http
://www
.jrsoftware
.org
/isfaq
.php#env
146 if AllUsers
then begin
147 KeyName
:='SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
148 if DeleteIfEmpty
and (Length(Path
)=0) then begin
149 Result
:=(not RegValueExists(HKEY_LOCAL_MACHINE
,KeyName
,VarName
))
150 or RegDeleteValue(HKEY_LOCAL_MACHINE
,KeyName
,VarName
);
152 Result
:=RegWriteStringValue(HKEY_LOCAL_MACHINE
,KeyName
,VarName
,Path
);
155 KeyName
:='Environment';
156 if DeleteIfEmpty
and (Length(Path
)=0) then begin
157 Result
:=(not RegValueExists(HKEY_CURRENT_USER
,KeyName
,VarName
))
158 or RegDeleteValue(HKEY_CURRENT_USER
,KeyName
,VarName
);
160 Result
:=RegWriteStringValue(HKEY_CURRENT_USER
,KeyName
,VarName
,Path
);
166 procedure BrowseForPythonFolder(Sender
:TObject
);
170 Path
:=GetPreviousData('PythonPath', 'C:\Python27');
171 EdtPython
.Text:=Path
;
172 Path
:=ExtractFilePath(EdtPython
.Text);
173 BrowseForFolder('Please select the Python folder:',Path
,False);
174 Path
:=Path
+'\pythonw.exe';
175 if FileExists(Path
) then begin
176 EdtPython
.Text:=Path
;
178 MsgBox('Please enter a valid path to pythonw.exe.',mbError
,MB_OK
);
182 function GetPythonExe(Param
: String): String;
184 Result
:=EdtPython
.Text;
187 procedure BrowseForGitFolder(Sender
:TObject
);
192 Path
:=GetPreviousData('GitPath', 'C:\Program Files\Git');
194 Path
:=ExtractFilePath(EdtGit
.Text);
195 BrowseForFolder('Please select the Git folder:',Path
,False);
199 Check for both $DIR\git.exe and $DIR\bin\git.exe
202 Path
:=OldPath
+'\bin\git.exe';
203 if FileExists(Path
) then begin
208 Path
:=OldPath
+'\git.exe';
209 if FileExists(Path
) then begin
212 MsgBox('Please enter a valid path to git.exe.',mbError
,MB_OK
);
217 function GetGitExe(Param
: String): String;
222 procedure RegisterPreviousData(PreviousDataKey
:Integer);
226 Path
:=ExtractFilePath(EdtPython
.Text);
227 SetPreviousData(PreviousDataKey
, 'PythonPath', Path
);
229 Path
:=ExtractFilePath(ExtractFilePath(EdtGit
.Text));
230 SetPreviousData(PreviousDataKey
, 'GitPath', Path
);
238 procedure InitializeWizard
;
245 // Create a custom page
for finding Python
246 PythonPage
:=CreateCustomPage(
249 'Where is your Python folder?'
252 LblPython
:=TLabel
.Create(PythonPage
);
253 with LblPython
do begin
254 Parent
:=PythonPage
.Surface
;
255 Caption
:= 'Please provide the path to pythonw.exe.';
262 EdtPython
:=TEdit
.Create(PythonPage
);
263 with EdtPython
do begin
264 Parent
:=PythonPage
.Surface
;
265 Text:=GetPreviousData('PythonPath', 'C:\Python26');
266 Text:=Text+'pythonw.exe';
267 if not FileExists(Text) then begin
276 BtnPython
:=TButton
.Create(PythonPage
);
277 with BtnPython
do begin
278 Parent
:=PythonPage
.Surface
;
280 OnClick
:=@BrowseForPythonFolder
;
287 // Create a custom page
for finding Git
288 GitPage
:=CreateCustomPage(
291 'Where is your Git folder?'
294 LblGit
:=TLabel
.Create(GitPage
);
296 Parent
:=GitPage
.Surface
;
297 Caption
:= 'Please provide the path to git.exe.';
304 EdtGit
:=TEdit
.Create(GitPage
);
306 Parent
:=GitPage
.Surface
;
307 Text:=GetPreviousData('GitPath', 'C:\Program Files\Git');
308 Text:=Text+'git.exe';
309 if not FileExists(Text) then begin
318 BtnGit
:=TButton
.Create(GitPage
);
320 Parent
:=GitPage
.Surface
;
322 OnClick
:=@BrowseForGitFolder
;
330 function NextButtonClick(CurPageID
:Integer):Boolean;
332 if CurPageID
= PythonPage
.ID
then begin
333 Result
:=FileExists(EdtPython
.Text);
335 if not Result
then begin
336 MsgBox('Please enter a valid path to pythonw.exe.',mbError
,MB_OK
);
341 if CurPageID
= GitPage
.ID
then begin
342 Result
:=FileExists(EdtGit
.Text);
344 if not Result
then begin
345 MsgBox('Please enter a valid path to git.exe.',mbError
,MB_OK
);
353 procedure CurStepChanged(CurStep
:TSetupStep
);
355 AppDir
,BinDir
,Msg
:string;
356 EnvPath
:TArrayOfString
;
360 if CurStep
<>ssPostInstall
then begin
364 AppDir
:=ExpandConstant('{app}');
365 BinDir
:=ExpandConstant('{app}\bin');
368 Modify the environment
370 This must happen no later than ssPostInstall to make
371 "ChangesEnvironment=yes" not happend before the change!
374 // Get the current user
's directories in PATH.
375 EnvPath:=GetEnvStrings('PATH
',IsAdminLoggedOn);
377 // First, remove the installation directory from PATH in any case.
378 for i:=0 to GetArrayLength(EnvPath)-1 do begin
379 if Pos(AppDir,EnvPath[i])=1 then begin
384 // Modify the PATH variable as requested by the user.
385 i:=GetArrayLength(EnvPath);
386 SetArrayLength(EnvPath,i+1);
388 // Add \bin to the path
391 // Set the current user's PATH directories
.
392 if not SetEnvStrings('PATH',IsAdminLoggedOn
,True,EnvPath
) then begin
393 Msg
:='Line {#emit __LINE__}: Unable to set the PATH environment variable.';
394 MsgBox(Msg
,mbError
,MB_OK
);
396 // This
is not a critical error
, the user can probably fix it manually
,
401 Create the Windows Explorer shell extensions
404 if IsAdminLoggedOn
then begin
405 RootKey
:=HKEY_LOCAL_MACHINE
;
407 RootKey
:=HKEY_CURRENT_USER
;
410 if IsTaskSelected('guiextension') then begin
411 if (not RegWriteStringValue(RootKey
,'SOFTWARE\Classes\Directory\shell\git_cola','','Git &Cola Here'))
412 or (not RegWriteStringValue(RootKey
,'SOFTWARE\Classes\Directory\shell\git_cola\command','','"'+EdtPython
.Text+'" "'+AppDir
+'\bin\git-cola.pyw" "--repo" "%1" "--git-path" "'+EdtGit
.Text+'"')) then begin
413 Msg
:='Line {#emit __LINE__}: Unable to create "Git Cola Here" shell extension.';
414 MsgBox(Msg
,mbError
,MB_OK
);
416 // This
is not a critical error
, the user can probably fix it manually
,
426 function InitializeUninstall
:Boolean;
431 procedure CurUninstallStepChanged(CurUninstallStep
:TUninstallStep
);
433 AppDir
,Command
,Msg
:string;
434 EnvPath
:TArrayOfString
;
438 if CurUninstallStep
<>usUninstall
then begin
443 Modify the environment
445 This must happen no later than usUninstall to make
446 "ChangesEnvironment=yes" not happend before the change!
449 AppDir
:=ExpandConstant('{app}');
450 Command
:=AppDir
+'\setup.ini';
452 // Get the current user
's directories in PATH.
453 EnvPath:=GetEnvStrings('PATH
',IsAdminLoggedOn);
455 // Remove the installation directory from PATH in any case, even if it
456 // was not added by the installer.
457 for i:=0 to GetArrayLength(EnvPath)-1 do begin
458 if Pos(AppDir,EnvPath[i])=1 then begin
463 // Reset the current user's directories
in PATH
.
464 if not SetEnvStrings('PATH',IsAdminLoggedOn
,True,EnvPath
) then begin
465 Msg
:='Line {#emit __LINE__}: Unable to revert any possible changes to PATH.';
466 MsgBox(Msg
,mbError
,MB_OK
);
468 // This
is not a critical error
, the user can probably fix it manually
,
472 if (FileExists(Command
) and (not DeleteFile(Command
))) then begin
473 Msg
:='Line {#emit __LINE__}: Unable to delete file "'+Command
+'".';
474 MsgBox(Msg
,mbError
,MB_OK
);
476 // This
is not a critical error
, the user can probably fix it manually
,
481 Delete the Windows Explorer shell extensions
484 if IsAdminLoggedOn
then begin
485 RootKey
:=HKEY_LOCAL_MACHINE
;
487 RootKey
:=HKEY_CURRENT_USER
;
491 RegQueryStringValue(RootKey
,'SOFTWARE\Classes\Directory\shell\git_cola\command','',Command
);
492 if Pos(AppDir
,Command
)>0 then begin
493 if not RegDeleteKeyIncludingSubkeys(RootKey
,'SOFTWARE\Classes\Directory\shell\git_cola') then begin
494 Msg
:='Line {#emit __LINE__}: Unable to remove "Git Cola Here" shell extension.';
495 MsgBox(Msg
,mbError
,MB_OK
);
497 // This
is not a critical error
, the user can probably fix it manually
,
503 function GetShellFolder(Param
:string):string;
505 if IsAdminLoggedOn
then begin
506 Param
:='{common'+Param
+'}';
508 Param
:='{user'+Param
+'}';
510 Result
:=ExpandConstant(Param
);