WinGit(Inno): Add progress page for creating built-ins
[msysgit/mtrensch.git] / share / WinGit / install.iss
blob5fe35108f7c8ed5ba3a475004fd8cb755443a18d
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=git.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 LinkOrCopy:TOutputProgressWizardPage;
108 FileName,AppDir:string;
109 BuiltIns:TArrayOfString;
110 i,Count:Longint;
111 IsNTFS:Boolean;
112 begin
113 if CurStep=ssDone then begin
114 if IsTaskSelected('modifypath') then begin
115 ModPath();
116 end;
117 end else if CurStep=ssPostInstall then begin
118 LinkOrCopy:=CreateOutputProgressPage('Creating Build-Ins','Please wait while Setup creates built-in command files.');
119 LinkOrCopy.Show;
121 // Load the built-ins from a text file.
122 FileName:=ExpandConstant('{app}\'+'{#emit APP_BUILTINS}');
123 if not LoadStringsFromFile(FileName,BuiltIns) then begin
124 MsgBox('Unable to read file "{#emit APP_BUILTINS}".', mbError, MB_OK);
125 Exit;
126 end;
128 AppDir:=ExpandConstant('{app}');
130 // Check if we are running on NTFS.
131 IsNTFS:=False;
132 if SetNTFSCompression(AppDir+'\bin\git.exe',true) then begin
133 IsNTFS:=SetNTFSCompression(AppDir+'\bin\git.exe',false);
134 end;
136 Count:=GetArrayLength(BuiltIns)-1;
138 // Map the built-ins to git.exe.
139 if IsNTFS then begin
140 for i:=0 to Count do begin
141 FileName:=AppDir+'\'+BuiltIns[i];
143 // On non-NTFS partitions, create hard links.
144 LinkOrCopy.SetText('Creating hard link...',FileName);
145 LinkOrCopy.SetProgress(i,Count);
146 CreateHardLink(FileName,AppDir+'\bin\git.exe',0);
147 end;
148 end else begin
149 for i:=0 to GetArrayLength(BuiltIns)-1 do begin
150 FileName:=AppDir+'\'+BuiltIns[i];
152 // On non-NTFS partitions, copy simply the files.
153 LinkOrCopy.SetText('Copying file...',FileName);
154 LinkOrCopy.SetProgress(i,Count);
155 FileCopy(AppDir+'\bin\git.exe',FileName,false);
156 end;
157 end;
159 LinkOrCopy.Hide;
160 end;
161 end;