WinGit(Inno): Make installer optionally modify PATH
[msysgit/mtrensch.git] / share / WinGit-InnoSetup / install.iss
blob8ef2a13a472de1f72b999665fe25e372822fa608
1 #define APP_NAME 'Git'
2 #define APP_VERSION '%APPVERSION%'
3 #define APP_URL 'http://code.google.com/p/msysgit/'
4 #define APP_BUILTINS 'etc\fileList-builtins.txt'
6 [Setup]
7 ; Compiler-related
8 InternalCompressLevel=max
9 OutputBaseFilename={#emit APP_NAME+'-'+APP_VERSION}
10 OutputDir=%OUTPUTDIR%
11 SolidCompression=yes
13 ; Installer-related
14 AllowNoIcons=yes
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}
22 DisableReadyPage=yes
23 LicenseFile=gpl-2.0.txt
24 UninstallDisplayIcon=etc\git.ico
26 ; Cosmetic
27 SetupIconFile=etc\git.ico
28 WizardSmallImageFile=install.bmp
30 [Tasks]
31 Name: modifypath; Description: "Modify &PATH environment variable"; Flags: checkedonce
32 Name: modifypath\git; Description: "Add &only Git"; Flags: exclusive
33 Name: modifypath\tools; Description: "Add Git and UNIX &tools"; Flags: exclusive unchecked
35 Name: shellextension; Description: "Add ""Git &Bash Here"" to Windows Explorer"; Flags: checkedonce
36 Name: guiextension; Description: "Add ""Git &GUI Here"" to Windows Explorer"; Flags: checkedonce
38 Name: quicklaunchicon; Description: "Create a &Quick Launch icon"; GroupDescription: "Additional icons:"; Flags: checkedonce
39 Name: desktopicon; Description: "Create a &Desktop icon"; GroupDescription: "Additional icons:"; Flags: checkedonce
41 [Files]
42 Source: "*"; DestDir: "{app}"; Excludes: "\*.txt, \install.*, \tmp.*, \bin\*install*"; Flags: recursesubdirs
44 [Icons]
45 Name: "{group}\Git GUI"; Filename: "{app}\bin\wish.exe"; Parameters: """{app}\bin\git-gui"""; WorkingDir: "%USERPROFILE%"; IconFilename: "{app}\etc\git.ico"
46 Name: "{group}\Git Bash"; Filename: "{app}\bin\sh.exe"; Parameters: "--login -i"; WorkingDir: "%USERPROFILE%"; IconFilename: "{app}\etc\git.ico"
47 Name: "{group}\Uninstall Git"; Filename: "{uninstallexe}"
48 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
49 Name: "{userdesktop}\Git Bash"; Filename: "{app}\bin\sh.exe"; Parameters: "--login -i"; WorkingDir: "%USERPROFILE%"; IconFilename: "{app}\etc\git.ico"; Tasks: desktopicon
51 [Messages]
52 BeveledLabel={#emit APP_URL}
54 [Registry]
55 Root: HKLM; Subkey: "SOFTWARE\Classes\Directory\shell\git_shell"; ValueType: string; ValueData: "Git &Shell Here"; Flags: uninsdeletevalue uninsdeletekeyifempty; Tasks: shellextension
56 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
57 Root: HKLM; Subkey: "SOFTWARE\Classes\Directory\shell\git_gui"; ValueType: string; ValueData: "Git &GUI Here"; Flags: uninsdeletevalue uninsdeletekeyifempty; Tasks: guiextension
58 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
60 [UninstallDelete]
61 Type: files; Name: "{app}\bin\git-*.exe"
62 Type: dirifempty; Name: "{app}\home\{username}"
63 Type: dirifempty; Name: "{app}\home"
65 [Code]
66 function ModPathDir:TArrayOfString;
67 var
68 IsModifyPathGit,IsModifyPathTools:Boolean;
69 SelectedTasks:String;
70 begin
71 if IsUninstaller then begin
72 if LoadStringFromFile(ExpandConstant('{app}')+'\uninsTasks.txt',SelectedTasks) then begin
73 IsModifyPathGit:=Pos('modifypath\git',SelectedTasks)>0;
74 IsModifyPathTools:=Pos('modifypath\tools',SelectedTasks)>0;
75 end else begin
76 IsModifyPathGit:=False;
77 IsModifyPathTools:=False;
78 end;
79 end else begin
80 IsModifyPathGit:=IsTaskSelected('modifypath\git');
81 IsModifyPathTools:=IsTaskSelected('modifypath\tools');
82 end;
84 if IsModifyPathGit then begin
85 setArrayLength(Result,1);
86 Result[0]:=ExpandConstant('{app}\cmd');
87 end else if IsModifyPathTools then begin
88 setArrayLength(Result,2);
89 Result[0]:=ExpandConstant('{app}\bin');
90 Result[1]:=ExpandConstant('{app}\mingw\bin');
91 end;
92 end;
93 #include "modpath.iss"
95 procedure InitializeWizard;
96 begin
97 // Use a mono spaced font in the license dialog. NOTE: This might be too small.
98 WizardForm.LicenseMemo.Font.Name:='Lucida Console';
99 WizardForm.LicenseMemo.Font.Size:=7;
100 end;
102 function CreateHardLink(lpFileName,lpExistingFileName:string;lpSecurityAttributes:Integer):Boolean;
103 external 'CreateHardLinkA@Kernel32.dll';
105 procedure CurStepChanged(CurStep:TSetupStep);
107 ListFile,AppDir:string;
108 BuiltIns:TArrayOfString;
109 i:Longint;
110 IsNTFS:Boolean;
111 begin
112 if CurStep=ssPostInstall then begin
113 if IsTaskSelected('modifypath') then begin
114 ModPath();
115 end;
116 end else if CurStep=ssDone then begin
117 // Load the built-ins from a text file.
118 ListFile:=ExpandConstant('{app}\'+'{#emit APP_BUILTINS}');
119 if not LoadStringsFromFile(ListFile,BuiltIns) then begin
120 MsgBox('Unable to read file "{#emit APP_BUILTINS}".', mbError, MB_OK);
121 Exit;
122 end;
124 AppDir:=ExpandConstant('{app}');
126 // Check if we are running on NTFS.
127 IsNTFS:=False;
128 if SetNTFSCompression(AppDir+'\bin\git.exe',true) then begin
129 IsNTFS:=SetNTFSCompression(AppDir+'\bin\git.exe',false);
130 end;
132 // Map the built-ins to git.exe.
133 if IsNTFS then begin
134 for i:=0 to GetArrayLength(BuiltIns)-1 do begin
135 // On non-NTFS partitions, create hard links.
136 CreateHardLink(AppDir+'\'+BuiltIns[i],AppDir+'\bin\git.exe',0);
137 end;
138 end else begin
139 for i:=0 to GetArrayLength(BuiltIns)-1 do begin
140 // On non-NTFS partitions, copy simply the files.
141 FileCopy(AppDir+'\bin\git.exe',AppDir+'\'+BuiltIns[i],false);
142 end;
143 end;
144 end;
145 end;