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
|
; -- rakudo.iss --
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!
; using ISC 5.4.2(a)
[Setup]
AppName=Rakudo Star
AppVersion=2011.04
DefaultDirName=c:\rakudo
; Currently the installation path needs to be hard-coded
DisableDirPage=yes
DefaultGroupName=Rakudo Star
; UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma2
SolidCompression=yes
SourceDir=c:\rakudo
OutputDir=c:\output
OutputBaseFilename=rakudo-star
;AppComments=
AppContact=http://rakudo.org/
; AppCopyright=
AppId=Rakudo_Star
; AppMutex= TODO!
AppPublisherURL=http://rakudo.org/
; ChangesAssociations=yes
ChangesEnvironment=yes
;InfoAfterFile=README_FIRST.txt
[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
ValueName: "Path"; ValueType: expandsz; ValueData: "{olddata};{code:getPath}"; \
Check: NeedsAddPath('\rakudo\bin');
; Check: NeedsAddPath('\rakudo\install\bin');
; TODO: don't add the leading semi-colon to the Path if there is already a trailing one
[Files]
; Excludes: "cpan_sqlite_log*,cpan/build/*,cpan/sources/*,cpan/Bundle/*";
Source: "*"; DestDir: "{app}"; Flags: "recursesubdirs"
[Icons]
Name: "{group}\Rakudo REPL"; Filename: "{app}\bin\perl6.exe"; WorkingDir: "{app}"
Name: "{group}\Uninstall"; Filename: "{app}\unins000.exe"
; Name: "{group}\Rakudo README"; Filename: "{app}\share\doc\rakudo\README"
[Code]
function getPath(Param: String): string;
begin
// Result := ExpandConstant('{app}') + '\install\bin;'
Result := ExpandConstant('{app}') + '\bin;'
end;
// From http://stackoverflow.com/questions/3304463/how-do-i-modify-the-path-environment-variable-when-running-an-inno-setup-installe
function NeedsAddPath(Param: string): boolean;
var
OrigPath: string;
begin
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'Path', OrigPath)
then begin
Result := True;
exit;
end;
// look for the path with leading and trailing semicolon
// Pos() returns 0 if not found
//Result := Pos(';' + ExpandConstant('{app}') + Param + ';', OrigPath) = 0;
Result := Pos(getPath(''), OrigPath) = 0;
end;
function RemovePath(): boolean;
var
OrigPath: string;
start_pos: Longint;
end_pos: Longint;
new_str: string;
begin
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'Path', OrigPath)
then begin
Result := True;
exit;
end;
start_pos := Pos(getPath(''), OrigPath);
end_pos := start_pos + Length(getPath(''));
new_str := Copy(OrigPath, 0, start_pos-1) + Copy(OrigPath, end_pos, Length(OrigPath));
RegWriteExpandStringValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'Path', new_str);
Result := True;
end;
function InitializeUninstall(): Boolean;
begin
Result := True;
RemovePath();
end;
// Restrict the installation path to have no space
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result :=True;
case CurPageID of
wpSelectDir :
begin
if Pos(' ', ExpandConstant('{app}') ) <> 0 then
begin
MsgBox('You cannot install to a path containing spaces. Please select a different path.', mbError, mb_Ok);
Result := False;
end;
end;
end;
end;
|