This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 218
/
setup.iss.skel
151 lines (124 loc) · 4.36 KB
/
setup.iss.skel
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
; Syncany Inno Setup SKELETON Script
;
; PLEASE NOTE:
;
; 1. This script is a SKELETON and is meant to be parsed by the Gradle
; task "innosetup" before handing it to the Inno Setup compiler (ISCC)
;
; 2. All VARIABLES with a dollar sign and curly brackets are replaced
; by Gradle, e.g. "applicationVersion" below
;
; 3. The script is COPIED to build/innosetup before its run,
; so all relative paths refer to this path!
;
; 4. All BACKSLASHES must be escaped
;
[Setup]
AppName=Syncany
AppId=Syncany
AppVersion=${applicationVersionFull}
AppVerName=Syncany ${applicationVersion}
AppPublisher=Philipp Heckel
AppPublisherURL=https://www.syncany.org/
AppCopyright=Copyright (C) 2011-2014 Philipp Heckel
DefaultDirName={pf}\\Syncany
DefaultGroupName=Syncany
PrivilegesRequired=none
DisableProgramGroupPage=yes
UninstallDisplayIcon={uninstallexe}
ChangesEnvironment=yes
SourceDir=..\\install\\syncany
OutputDir=..\\..\\innosetup
OutputBaseFilename=syncany-${applicationVersionFull}
SetupIconFile=..\\..\\innosetup\\setup-icon.ico
WizardImageFile=..\\..\\innosetup\\setup-left.bmp
WizardSmallImageFile=..\\..\\innosetup\\setup-top.bmp
InfoBeforeFile=..\\..\\innosetup\\setup-info-before.rtf
InfoAfterFile=..\\..\\innosetup\\setup-info-after.rtf
[Files]
Source: "*"; DestDir: "{app}"
Source: "bin\\*"; DestDir: "{app}\\bin"; Excludes: "syncany,syncanyd,sy,syd"
Source: "lib\\*"; DestDir: "{app}\\lib"
[Tasks]
Name: modifypath; Description: Add Syncany to PATH environment variable (recommended)
Name: setjavahome; Description: Set JAVA_HOME environment variable if not set (recommended)
[Icons]
Name: "{group}\\Syncany Quick How-To"; Filename: "https://www.syncany.org/r/howto"
Name: "{group}\\Syncany User Guide and Wiki"; Filename: "https://www.syncany.org/r/wiki"
Name: "{group}\\Uninstall Syncany"; Filename: "{uninstallexe}"
[Code]
// 1. Set JAVA_HOME env. variable ///////////
const
ModPathName = 'modifypath';
ModPathType = 'user';
SetJavaHomeTaskName = 'setjavahome';
var
JavaHome: String;
JavaHomeSet: Boolean;
RegRootSearchPaths: TArrayOfString;
function InitializeSetup(): Boolean;
var
RegRootKey, i: Integer;
RegRootPath: String;
JavaVersion: String;
begin
SetArrayLength(RegRootSearchPaths, 4);
RegRootSearchPaths[0] := 'SOFTWARE\\JavaSoft\\Java Development Kit';
RegRootSearchPaths[1] := 'SOFTWARE\\JavaSoft\\Java Runtime Environment';
RegRootSearchPaths[2] := 'SOFTWARE\\Wow6432Node\\JavaSoft\\Java Development Kit';
RegRootSearchPaths[3] := 'SOFTWARE\\Wow6432Node\\JavaSoft\\Java Runtime Environment';
if IsWin64 then begin
RegRootKey := HKLM64;
end
else begin
RegRootKey := HKLM;
end;
JavaHome := GetEnv('JAVA_HOME');
if JavaHome <> '' then begin
JavaHomeSet := True;
Result := True;
end
else begin
JavaHomeSet := False;
Result := False;
for i := 0 to GetArrayLength(RegRootSearchPaths)-1 do begin
RegRootPath := RegRootSearchPaths[i];
if RegValueExists(RegRootKey, RegRootPath, 'CurrentVersion') then begin
RegQueryStringValue(RegRootKey, RegRootPath, 'CurrentVersion', JavaVersion);
if RegValueExists(RegRootKey, RegRootPath + '\\' + JavaVersion, 'JavaHome') then begin
RegQueryStringValue(RegRootKey, RegRootPath + '\\' + JavaVersion, 'JavaHome', JavaHome);
Result := True;
break;
end
end
end
if Result = false then begin
MsgBox('Java is not installed on your computer.'#13'Please install Java from java.com try again.', MbError, Mb_Ok);
end
end
end;
procedure SetJavaHome();
begin
if not JavaHomeSet then begin
RegWriteStringValue(HKEY_CURRENT_USER, 'Environment', 'JAVA_HOME', JavaHome);
end
end;
// 2. Set PATH variable (if ticked) ////////
function ModPathDir(): TArrayOfString;
begin
setArrayLength(Result, 1)
Result[0] := ExpandConstant('{app}\\bin');
end;
#include "modpath.iss"
// 3. Trigger post-install (taken from modpath.iss) /////////
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then begin
if IsTaskSelected(ModPathName) then begin
ModPath(); // In 'modpath.iss', calls 'ModPathDir()'
end
if IsTaskSelected(SetJavaHomeTaskName) then begin
SetJavaHome();
end
end
end;