Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit 1e0842b

Browse files
committed
support actually setting the home directory selected by the user in the installer
getting this working right was suprisingly messy and I'm still not happy with any of it. For now I'm just happy that it appears to work, and will find a cleaner way later.
1 parent 79f7863 commit 1e0842b

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

Diff for: SageMath.iss

+41-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Name: desktop; Description: "Create &desktop icons"; GroupDescription: "Addition
100100
[Files]
101101
Source: "dot_sage\*"; DestDir: "{#SageRootWin}\dot_sage"; Flags: recursesubdirs ignoreversion
102102
Source: "{#Source}\*"; DestDir: "{#Runtime}"; Excludes: "{#SageExcludes}"; Flags: recursesubdirs ignoreversion
103-
Source: "resources\sagemath.ico"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall: FixupSymlinks
103+
Source: "resources\sagemath.ico"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall: PostInstall
104104

105105
; InnoSetup will not create empty directories found when including files
106106
; recursively in the [Files] section, so any directories that must exist
@@ -232,7 +232,7 @@ var
232232
begin
233233
Page := CreateInputDirPage(InstallModeSelectPageID, 'Select Sage home directory',
234234
'Select the default directory that Sage will start in', '', False, '');
235-
Page.Add('');
235+
Page.Add('Sage will start with this folder as your working directory by default; you can also change this after installation using the sage-sethome command:');
236236
UserHomeDirSelectPageID := Page.ID;
237237
with Page do
238238
begin
@@ -284,7 +284,44 @@ begin
284284
WizardForm.FilenameLabel.Caption := Copy(filenam, 2, Length(filenam));
285285
WizardForm.ProgressGauge.Position := i;
286286
Exec(ExpandConstant('{sys}\attrib.exe'), '+S ' + filenam,
287-
ExpandConstant('{#Runtime}'), SW_HIDE,
288-
ewNoWait, resultCode);
287+
ExpandConstant('{#Runtime}'), SW_HIDE, ewNoWait, resultCode);
289288
end;
290289
end;
290+
291+
292+
// In principle we should be able to run the sage-sethome script with the
293+
// just-installed bash.exe, but this seems to encounter insurmountable
294+
// problems with quoting or I'm not sure what else, so we essentially
295+
// reimplement that script here to write the appropriate /etc/fstab.d file.
296+
procedure SetHome();
297+
var
298+
resultCode: Integer;
299+
userHome: String;
300+
fstabdFile: String;
301+
fstabLine: String;
302+
fstabLines: TArrayOfString;
303+
begin
304+
fstabdFile := ExpandConstant('{#Runtime}\etc\fstab.d\') + GetUserNameString();
305+
userHome := Copy(UserHomeDir, 1, Length(UserHomeDir));
306+
StringChangeEx(userHome, ' ', '\040', True)
307+
fstabLine := userHome + ' /home/sage ntfs binary,posix=1,user,acl 0 0';
308+
SetArrayLength(fstabLines, 1);
309+
fstabLines[0] := fstabLine;
310+
SaveStringsToUTF8File(fstabdFile, fstabLines, False);
311+
// The above nevertheless writes the file with a bunch of stupid
312+
// ideosyncracies (most notably, a useless UTF-8 BOM) which confuse
313+
// Cygwin; we run this final cleanup script to fix everything, ugh.
314+
Exec(ExpandConstant('{#Bin}\dash.exe'),
315+
'/usr/local/bin/_sage-complete-install.sh',
316+
ExpandConstant('{#Runtime}'),
317+
SW_HIDE, ewNoWait, resultCode);
318+
MsgBox(IntToStr(resultCode), mbInformation, MB_OK);
319+
end;
320+
321+
322+
procedure PostInstall();
323+
begin
324+
FixupSymlinks();
325+
if UserInstall then
326+
SetHome();
327+
end;

Diff for: cygwin-sage-runtime.list

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ base-files 4.2-3
22
bash 4.3.42-4
33
cygutils 1.4.15-2
44
cygwin 2.6.0-1
5+
dos2unix 7.4.0-1
56
gcc-core 5.3.0-5
67
gcc-fortran 5.3.0-5
78
gcc-g++ 5.3.0-5
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
export PATH=/usr/bin:/bin
3+
for filename in /etc/fstab.d/*; do
4+
dos2unix "$filename"
5+
chmod 600 "$filename"
6+
done
7+
8+
rm -f /usr/local/bin/_sage-complete-install.sh

0 commit comments

Comments
 (0)