1 #define APP_NAME
'git-cola'
2 #define APP_LONGNAME
'git-cola - A highly caffeinated git GUI'
3 #define APP_VERSION
'%APPVERSION%'
4 #define APP_URL
'http://cola.tuxfamily.org/'
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
: "{app}\bin\git-cola.pyw"; Parameters
: "--git-path ""{code:GetGitExe}"""; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"
42 Name
: "{group}\License"; Filename
: "{app}\etc\gpl-2.0.rtf"; WorkingDir
: "%USERPROFILE%";
43 Name
: "{group}\Release Notes"; Filename
: "{app}\etc\ReleaseNotes.txt"; WorkingDir
: "%USERPROFILE%";
44 Name
: "{group}\Git Cola Homepage"; Filename
: "{#emit APP_URL}"; WorkingDir
: "%USERPROFILE%";
45 Name
: "{group}\Uninstall Git Cola"; Filename
: "{uninstallexe}"
46 Name
: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Git Cola"; Filename
: "{app}\bin\git-cola.pyw"; Parameters
: "--git-path ""{code:GetGitExe}"""; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"; Tasks
: quicklaunchicon
47 Name
: "{code:GetShellFolder|desktop}\Git Cola"; Filename
: "{app}\bin\git-cola.pyw"; Parameters
: "--git-path ""{code:GetGitExe}"""; WorkingDir
: "%USERPROFILE%"; IconFilename
: "{app}\etc\git.ico"; Tasks
: desktopicon
50 BeveledLabel
={#emit APP_URL}
51 SetupAppTitle
={#emit APP_NAME} Setup
52 SetupWindowTitle
={#emit APP_NAME} Setup
55 Type: files; Name
: "{app}\bin\*"
56 Type: files; Name
: "{app}\etc\*"
57 Type: files; Name
: "{app}\share\git-cola\bin\*"
58 Type: files; Name
: "{app}\share\git-cola\lib\cola\*"
59 Type: files; Name
: "{app}\share\git-cola\lib\cola\models\*"
60 Type: files; Name
: "{app}\share\git-cola\lib\cola\controllers\*"
61 Type: files; Name
: "{app}\share\git-cola\lib\cola\views\*"
62 Type: files; Name
: "{app}\share\git-cola\lib\jsonpickle\*"
63 Type: files; Name
: "{app}\share\git-cola\lib\simplejson\*"
64 Type: dirifempty; Name
: "{app}\share\git-cola\lib\cola\models"
65 Type: dirifempty; Name
: "{app}\share\git-cola\lib\cola\controllers"
66 Type: dirifempty; Name
: "{app}\share\git-cola\lib\cola\views"
67 Type: dirifempty; Name
: "{app}\share\git-cola\lib\cola"
68 Type: dirifempty; Name
: "{app}\share\git-cola\lib\simplejson"
69 Type: dirifempty; Name
: "{app}\share\git-cola\lib\jsonpickle"
70 Type: dirifempty; Name
: "{app}\share\git-cola\lib"
71 Type: dirifempty; Name
: "{app}\share\git-cola\bin"
72 Type: dirifempty; Name
: "{app}\etc"
73 Type: dirifempty; Name
: "{app}\bin"
81 PythonPage
:TWizardPage
;
86 function GetEnvStrings(VarName
:string;AllUsers
:Boolean):TArrayOfString
;
94 // See http
://www
.jrsoftware
.org
/isfaq
.php#env
95 if AllUsers
then begin
96 // We ignore errors here
. The resulting
array of strings will be empty
.
97 RegQueryStringValue(HKEY_LOCAL_MACHINE
,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',VarName
,Path
);
99 // We ignore errors here
. The resulting
array of strings will be empty
.
100 RegQueryStringValue(HKEY_CURRENT_USER
,'Environment',VarName
,Path
);
103 // Make sure we have at least one semicolon
.
106 // Split the directories
in PATH into an
array of strings
.
108 SetArrayLength(Result
,0);
112 SetArrayLength(Result
,i
+1);
114 Result
[i
]:=Copy(Path
,1,p
-1);
117 Path
:=Copy(Path
,p
+1,Length(Path
));
122 function SetEnvStrings(VarName
:string;AllUsers
,DeleteIfEmpty
:Boolean;DirStrings
:TArrayOfString
):Boolean;
127 // Merge all non
-empty directory strings into a PATH variable
.
129 for i
:=0 to GetArrayLength(DirStrings
)-1 do begin
130 if Length(DirStrings
[i
])>0 then begin
131 if Length(Path
)>0 then begin
132 Path
:=Path
+';'+DirStrings
[i
];
139 // See http
://www
.jrsoftware
.org
/isfaq
.php#env
140 if AllUsers
then begin
141 KeyName
:='SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
142 if DeleteIfEmpty
and (Length(Path
)=0) then begin
143 Result
:=(not RegValueExists(HKEY_LOCAL_MACHINE
,KeyName
,VarName
))
144 or RegDeleteValue(HKEY_LOCAL_MACHINE
,KeyName
,VarName
);
146 Result
:=RegWriteStringValue(HKEY_LOCAL_MACHINE
,KeyName
,VarName
,Path
);
149 KeyName
:='Environment';
150 if DeleteIfEmpty
and (Length(Path
)=0) then begin
151 Result
:=(not RegValueExists(HKEY_CURRENT_USER
,KeyName
,VarName
))
152 or RegDeleteValue(HKEY_CURRENT_USER
,KeyName
,VarName
);
154 Result
:=RegWriteStringValue(HKEY_CURRENT_USER
,KeyName
,VarName
,Path
);
160 procedure BrowseForPythonFolder(Sender
:TObject
);
164 Path
:=GetPreviousData('PythonPath', 'C:\Python26');
165 EdtPython
.Text:=Path
;
166 Path
:=ExtractFilePath(EdtPython
.Text);
167 BrowseForFolder('Please select the Python folder:',Path
,False);
168 Path
:=Path
+'\pythonw.exe';
169 if FileExists(Path
) then begin
170 EdtPython
.Text:=Path
;
172 MsgBox('Please enter a valid path to pythonw.exe.',mbError
,MB_OK
);
176 function GetPythonExe(Param
: String): String;
178 Result
:=EdtPython
.Text;
181 procedure BrowseForGitFolder(Sender
:TObject
);
186 Path
:=GetPreviousData('GitPath', 'C:\Program Files\Git');
188 Path
:=ExtractFilePath(EdtGit
.Text);
189 BrowseForFolder('Please select the Git folder:',Path
,False);
193 Check for both $DIR\git.exe and $DIR\bin\git.exe
196 Path
:=OldPath
+'\bin\git.exe';
197 if FileExists(Path
) then begin
202 Path
:=OldPath
+'\git.exe';
203 if FileExists(Path
) then begin
206 MsgBox('Please enter a valid path to git.exe.',mbError
,MB_OK
);
211 function GetGitExe(Param
: String): String;
216 procedure RegisterPreviousData(PreviousDataKey
:Integer);
220 Path
:=ExtractFilePath(EdtPython
.Text);
221 SetPreviousData(PreviousDataKey
, 'PythonPath', Path
);
223 Path
:=ExtractFilePath(ExtractFilePath(EdtGit
.Text));
224 SetPreviousData(PreviousDataKey
, 'GitPath', Path
);
232 procedure InitializeWizard
;
239 // Create a custom page
for finding Python
240 PythonPage
:=CreateCustomPage(
243 'Where is your Python folder?'
246 LblPython
:=TLabel
.Create(PythonPage
);
247 with LblPython
do begin
248 Parent
:=PythonPage
.Surface
;
249 Caption
:= 'Please provide the path to pythonw.exe.';
256 EdtPython
:=TEdit
.Create(PythonPage
);
257 with EdtPython
do begin
258 Parent
:=PythonPage
.Surface
;
259 Text:='C:\Python26\pythonw.exe';
260 if not FileExists(Text) then begin
269 BtnPython
:=TButton
.Create(PythonPage
);
270 with BtnPython
do begin
271 Parent
:=PythonPage
.Surface
;
273 OnClick
:=@BrowseForPythonFolder
;
280 // Create a custom page
for finding Git
281 GitPage
:=CreateCustomPage(
284 'Where is your Git folder?'
287 LblGit
:=TLabel
.Create(GitPage
);
289 Parent
:=GitPage
.Surface
;
290 Caption
:= 'Please provide the path to git.exe.';
297 EdtGit
:=TEdit
.Create(GitPage
);
299 Parent
:=GitPage
.Surface
;
300 Text:='C:\Program Files\Git\bin\git.exe';
301 if not FileExists(Text) then begin
310 BtnGit
:=TButton
.Create(GitPage
);
312 Parent
:=GitPage
.Surface
;
314 OnClick
:=@BrowseForGitFolder
;
322 function NextButtonClick(CurPageID
:Integer):Boolean;
324 if CurPageID
= PythonPage
.ID
then begin
325 Result
:=FileExists(EdtPython
.Text);
327 if not Result
then begin
328 MsgBox('Please enter a valid path to pythonw.exe.',mbError
,MB_OK
);
333 if CurPageID
= GitPage
.ID
then begin
334 Result
:=FileExists(EdtGit
.Text);
336 if not Result
then begin
337 MsgBox('Please enter a valid path to git.exe.',mbError
,MB_OK
);
345 procedure CurStepChanged(CurStep
:TSetupStep
);
347 AppDir
,BinDir
,Msg
:string;
348 EnvPath
:TArrayOfString
;
352 if CurStep
<>ssPostInstall
then begin
356 AppDir
:=ExpandConstant('{app}');
357 BinDir
:=ExpandConstant('{app}\bin');
360 Modify the environment
362 This must happen no later than ssPostInstall to make
363 "ChangesEnvironment=yes" not happend before the change!
366 // Get the current user
's directories in PATH.
367 EnvPath:=GetEnvStrings('PATH
',IsAdminLoggedOn);
369 // First, remove the installation directory from PATH in any case.
370 for i:=0 to GetArrayLength(EnvPath)-1 do begin
371 if Pos(AppDir,EnvPath[i])=1 then begin
376 // Modify the PATH variable as requested by the user.
377 i:=GetArrayLength(EnvPath);
378 SetArrayLength(EnvPath,i+1);
380 // Add \bin to the path
383 // Set the current user's PATH directories
.
384 if not SetEnvStrings('PATH',IsAdminLoggedOn
,True,EnvPath
) then begin
385 Msg
:='Line {#emit __LINE__}: Unable to set the PATH environment variable.';
386 MsgBox(Msg
,mbError
,MB_OK
);
388 // This
is not a critical error
, the user can probably fix it manually
,
393 Create the Windows Explorer shell extensions
396 if IsAdminLoggedOn
then begin
397 RootKey
:=HKEY_LOCAL_MACHINE
;
399 RootKey
:=HKEY_CURRENT_USER
;
402 if IsTaskSelected('guiextension') then begin
403 if (not RegWriteStringValue(RootKey
,'SOFTWARE\Classes\Directory\shell\git_cola','','Git &Cola Here'))
404 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
405 Msg
:='Line {#emit __LINE__}: Unable to create "Git Cola Here" shell extension.';
406 MsgBox(Msg
,mbError
,MB_OK
);
408 // This
is not a critical error
, the user can probably fix it manually
,
418 function InitializeUninstall
:Boolean;
423 procedure CurUninstallStepChanged(CurUninstallStep
:TUninstallStep
);
425 AppDir
,Command
,Msg
:string;
426 EnvPath
:TArrayOfString
;
430 if CurUninstallStep
<>usUninstall
then begin
435 Modify the environment
437 This must happen no later than usUninstall to make
438 "ChangesEnvironment=yes" not happend before the change!
441 AppDir
:=ExpandConstant('{app}');
442 Command
:=AppDir
+'\setup.ini';
444 // Get the current user
's directories in PATH.
445 EnvPath:=GetEnvStrings('PATH
',IsAdminLoggedOn);
447 // Remove the installation directory from PATH in any case, even if it
448 // was not added by the installer.
449 for i:=0 to GetArrayLength(EnvPath)-1 do begin
450 if Pos(AppDir,EnvPath[i])=1 then begin
455 // Reset the current user's directories
in PATH
.
456 if not SetEnvStrings('PATH',IsAdminLoggedOn
,True,EnvPath
) then begin
457 Msg
:='Line {#emit __LINE__}: Unable to revert any possible changes to PATH.';
458 MsgBox(Msg
,mbError
,MB_OK
);
460 // This
is not a critical error
, the user can probably fix it manually
,
464 if (FileExists(Command
) and (not DeleteFile(Command
))) then begin
465 Msg
:='Line {#emit __LINE__}: Unable to delete file "'+Command
+'".';
466 MsgBox(Msg
,mbError
,MB_OK
);
468 // This
is not a critical error
, the user can probably fix it manually
,
473 Delete the Windows Explorer shell extensions
476 if IsAdminLoggedOn
then begin
477 RootKey
:=HKEY_LOCAL_MACHINE
;
479 RootKey
:=HKEY_CURRENT_USER
;
483 RegQueryStringValue(RootKey
,'SOFTWARE\Classes\Directory\shell\git_cola\command','',Command
);
484 if Pos(AppDir
,Command
)>0 then begin
485 if not RegDeleteKeyIncludingSubkeys(RootKey
,'SOFTWARE\Classes\Directory\shell\git_cola') then begin
486 Msg
:='Line {#emit __LINE__}: Unable to remove "Git Cola Here" shell extension.';
487 MsgBox(Msg
,mbError
,MB_OK
);
489 // This
is not a critical error
, the user can probably fix it manually
,
495 function GetShellFolder(Param
:string):string;
497 if IsAdminLoggedOn
then begin
498 Param
:='{common'+Param
+'}';
500 Param
:='{user'+Param
+'}';
502 Result
:=ExpandConstant(Param
);