forked from sagemath/sage-windows-cygwin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gap.iss
executable file
·228 lines (185 loc) · 7.71 KB
/
gap.iss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "GAP"
#ifndef SageVersion
#error SageVersion must be defined--pass /DSageVersion=<version> to InnoSetup with the correct version
#endif
#ifndef InstallerVersion
#error InstallerVersion must be defined--pass /DInstallerVersion=<version> to InnoSetup with the correct version
#endif
#ifndef SageName
#error SageName must be defined--pass /DSageName=<name> to InnoSetup with the correct version
#endif
#ifndef SageArch
#define SageArch "x86_64"
#endif
#if SageArch == "x86_64"
#define MyArchitecturesAllowed "x64"
#else
#define MyArchitecturesAllowed "x86 x64"
#endif
#define MyAppVersion SageVersion
#define MyAppPublisher "The GAP Group"
#define MyAppURL "https://www.gap-system.org"
#define MyAppExeName "gap-mintty.bat"
#define SageGroupName MyAppName + "-" + MyAppVersion
#ifndef EnvsDir
#define EnvsDir "envs"
#endif
#ifndef OutputDir
#define OutputDir "dist"
#endif
#define Source EnvsDir + "\runtime-" + SageVersion + "-" + SageArch
#define Runtime "{app}\runtime"
#define Bin Runtime + "\bin"
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={#MyAppName}-{#MyAppVersion}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
ArchitecturesAllowed={#MyArchitecturesAllowed}
ArchitecturesInstallIn64BitMode=x64
ChangesEnvironment=true
DefaultDirName={autopf}\{#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=dialog
OutputBaseFilename=gap-{#MyAppVersion}-{#SageArch}
Compression=lzma2
LZMANumBlockThreads=6
SolidCompression=yes
WizardStyle=modern
LicenseFile="{#Source}\opt\gap-{#MyAppVersion}\LICENSE"
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "gap_resources\gap.bat"; DestDir: "{app}"; Flags: ignoreversion
Source: "gap_resources\gap-mintty.bat"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#Source}\*"; DestDir: "{#Runtime}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{#Source}\gapicon.ico"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall: PostInstall;
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
; InnoSetup will not create empty directories found when including files
; recursively in the [Files] section, so any directories that must exist
; (but start out empty) in the cygwin distribution must be created
;
; /etc/fstab.d is where user-specific mount tables go--this is used in
; sage for windows by /etc/sagerc to set up the /dot_sage mount point for
; each user's DOT_SAGE directory, since the actual path name might contain
; spaces and other special characters not handled well by some software that
; uses DOT_SAGE
;
; /dev/shm and /dev/mqueue are used by the system for POSIX semaphores, shared
; memory, and message queues and must be created world-writeable
[Dirs]
Name: "{#Runtime}\etc\fstab.d"; Permissions: users-modify
Name: "{#Runtime}\dev\shm"; Permissions: users-modify
Name: "{#Runtime}\dev\mqueue"; Permissions: users-modify
; Name: "{#Runtime}\home\sage"; Permissions: users-modify
[Icons]
Name: "{autoprograms}\{#MyAppName}-{#SageVersion}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\gapicon.ico"
Name: "{autodesktop}\{#MyAppName}-{#SageVersion}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\gapicon.ico" ; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: shellexec postinstall skipifsilent
[UninstallDelete]
Type: filesandordirs; Name: "{app}"
[Code]
var
UserInstall: Boolean;
InstallModeSelectPageID: Integer;
// This function is used above in the [Icons] section to get the correct
// installation path for desktop icons depending on what installation mode
// was selected
function GetDesktopPath(Param: String): String;
begin
if UserInstall then
begin
Result := ExpandConstant('{userdesktop}');
end
else begin
Result := ExpandConstant('{commondesktop}');
end;
end;
// ******************* Custom Install Wizard Pages ***************************
function ProcessInstallModeSelectPage(Page: TWizardPage): Boolean;
begin
if TInputOptionWizardPage(Page).CheckListBox.Checked[0] then
begin
WizardForm.DirEdit.Text := ExpandConstant('{localappdata}\{#SageGroupName}');
UserInstall := True;
end
else begin
WizardForm.DirEdit.Text := ExpandConstant('{pf}\{#SageGroupName}');
UserInstall := False;
end;
Result := True;
end;
procedure CreateInstallModeSelectPage();
var
Page: TInputOptionWizardPage;
begin
Page := CreateInputOptionPage(wpUserInfo, 'Install Mode Select',
'Install either for a single user or for all users on the system (requires Administrator privileges).', '', True, False);
InstallModeSelectPageID := Page.ID;
Page.Add('Install just for the current user');
Page.Add('Install for all users (installer must be run with Administrator privileges)');
UserInstall := Boolean(
StrToInt(
GetPreviousData('UserInstall', IntToStr(Integer(not IsAdminLoggedOn())))));
with Page do
begin
CheckListBox.Checked[0] := UserInstall;
CheckListBox.Checked[1] := (not UserInstall);
CheckListBox.ItemEnabled[1] := IsAdminLoggedOn();
OnNextButtonClick := @ProcessInstallModeSelectPage;
end;
end;
procedure InitializeWizard();
begin
UserInstall := not IsAdminLoggedOn();
CreateInstallModeSelectPage();
end;
// Symlinks from the Cygwin runtime are stored in the .lnk file format
// which is one of the different ways of storing symlinks supported by Cygwin;
// for this to work they must have the READ ONLY attribute set on them.
// When the files are compressed by InnoSetup they lose this attribute, so
// we must have a list of files that are supposed to by symlinks, which is
// created by the Makefile as <runtime-env>/etc/symlinks.lst and included in
// the installer. This procedure loops over all the files in this list and
// applies the READ ONLY attribute to them so they can once again be recognized
// by Cygwin as symlinks.
procedure FixupSymlinks();
var
n: Integer;
i: Integer;
resultCode: Integer;
filenames: TArrayOfString;
filenam: String;
begin
LoadStringsFromFile(ExpandConstant('{#Runtime}\etc\symlinks.lst'), filenames);
n := GetArrayLength(filenames);
WizardForm.ProgressGauge.Min := 0;
WizardForm.ProgressGauge.Max := n - 1;
WizardForm.ProgressGauge.Position := 0;
WizardForm.StatusLabel.Caption := 'Fixing up symlinks...';
for i := 0 to n - 1 do
begin
filenam := filenames[i] + '.lnk';
WizardForm.FilenameLabel.Caption := Copy(filenam, 2, Length(filenam));
WizardForm.ProgressGauge.Position := i;
Exec(ExpandConstant('{sys}\attrib.exe'), '+R ' + filenam,
ExpandConstant('{#Runtime}'), SW_HIDE, ewNoWait, resultCode);
end;
end;
procedure PostInstall();
begin
FixupSymlinks();
end;