Skip to content

Commit 0bf9929

Browse files
committed
Merge pull request #1669 from graydon/inno-setup
Add Inno Setup installer script rather than NSIS
2 parents a06850c + fe57a7e commit 0bf9929

File tree

7 files changed

+300
-16
lines changed

7 files changed

+300
-16
lines changed

LICENSE.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,17 @@ included:
186186
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
187187
OF SUCH DAMAGE.
188188

189+
* The auxiliary file src/etc/pkg/modpath.iss contains a
190+
library routine compiled, by Inno Setup, into the Windows
191+
installer binary. This file is licensed under the LGPL,
192+
but, in our legal interpretation, this does not affect the
193+
aggregate "collected work" license of the Rust
194+
distribution (MIT) nor any other components of it. We
195+
believe that the terms governing distribution of the
196+
binary Windows installer built from modpath.iss are
197+
therefore LGPL, but not the terms governing distribution
198+
of any of the files installed by such an installer (such
199+
as the Rust compiler or runtime libraries themselves).
189200

190201
* The libuv asynchronous I/O library. Code for this package
191202
is found in the src/rt/libuv directory, within this

Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ LIBRUSTC_GLOB :=$(call CFG_LIB_GLOB,rustc)
114114

115115
# version-string calculation
116116
CFG_GIT_DIR := $(CFG_SRC_DIR).git
117-
CFG_RELEASE = 0.2pre
117+
CFG_RELEASE = 0.1.1
118118
CFG_VERSION = $(CFG_RELEASE)
119119

120120
ifneq ($(wildcard $(CFG_GIT)),)

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ probe CFG_GCC gcc
289289
probe CFG_LLVM_CONFIG llvm-config
290290
probe CFG_VALGRIND valgrind
291291
probe CFG_PERF perf
292-
probe CFG_MAKENSIS makensis
292+
probe CFG_ISCC iscc
293293
probe CFG_NATURALDOCS NaturalDocs naturaldocs
294294
probe CFG_LLNEXTGEN LLnextgen
295295
probe CFG_PANDOC pandoc

mk/dist.mk

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ PKG_NAME := rust
66
PKG_DIR = $(PKG_NAME)-$(CFG_RELEASE)
77
PKG_TAR = $(PKG_DIR).tar.gz
88

9-
ifdef CFG_MAKENSIS
10-
PKG_NSI = $(S)src/etc/pkg/rust.nsi
9+
ifdef CFG_ISCC
10+
PKG_ISS = $(wildcard $(S)src/etc/pkg/*.iss)
11+
PKG_ICO = $(S)src/etc/pkg/rust-logo.ico
1112
PKG_EXE = $(PKG_DIR)-install.exe
1213
endif
1314

@@ -38,18 +39,23 @@ PKG_FILES := \
3839

3940
UNROOTED_PKG_FILES := $(patsubst $(S)%,./%,$(PKG_FILES))
4041

41-
lic.txt: $(S)LICENSE.txt
42-
@$(call E, crlf: $@)
43-
@$(Q)perl -pe 's@\r\n|\n@\r\n@go' <$< >$@
42+
ifdef CFG_ISCC
43+
LICENSE.txt: $(S)LICENSE.txt
44+
cp $< $@
4445

45-
ifdef CFG_MAKENSIS
46-
$(PKG_EXE): $(PKG_NSI) $(PKG_FILES) all rustc-stage3 lic.txt
47-
@$(call E, makensis: $@)
48-
$(Q)"$(CFG_MAKENSIS)" -NOCD -V1 "-XOutFile $@" \
49-
"-XLicenseData lic.txt" $<
50-
$(Q)rm -f lic.txt
46+
%.iss: $(S)src/etc/pkg/%.iss
47+
cp $< $@
48+
49+
%.ico: $(S)src/etc/pkg/%.ico
50+
cp $< $@
51+
52+
$(PKG_EXE): rust.iss modpath.iss LICENSE.txt rust-logo.ico \
53+
$(PKG_FILES) all rustc-stage3
54+
@$(call E, ISCC: $@)
55+
$(Q)"$(CFG_ISCC)" $<
5156
endif
5257

58+
5359
$(PKG_TAR): $(PKG_FILES)
5460
@$(call E, making dist dir)
5561
$(Q)rm -Rf dist
@@ -68,7 +74,7 @@ $(PKG_TAR): $(PKG_FILES)
6874
$(Q)tar -czf $(PKG_TAR) -C dist $(PKG_DIR)
6975
$(Q)rm -Rf dist
7076

71-
.PHONY: dist nsis-dist distcheck
77+
.PHONY: dist distcheck
7278

7379
ifdef CFG_WINDOWSY
7480

@@ -84,8 +90,6 @@ else
8490

8591
dist: $(PKG_TAR)
8692

87-
nsis-dist: $(PKG_EXE)
88-
8993
distcheck: $(PKG_TAR)
9094
$(Q)rm -Rf dist
9195
$(Q)mkdir -p dist

src/etc/pkg/modpath.iss

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// Inno Setup Ver: 5.4.2
4+
// Script Version: 1.4.1
5+
// Author: Jared Breland <[email protected]>
6+
// Homepage: http://www.legroom.net/software
7+
// License: GNU Lesser General Public License (LGPL), version 3
8+
// http://www.gnu.org/licenses/lgpl.html
9+
//
10+
// Script Function:
11+
// Allow modification of environmental path directly from Inno Setup installers
12+
//
13+
// Instructions:
14+
// Copy modpath.iss to the same directory as your setup script
15+
//
16+
// Add this statement to your [Setup] section
17+
// ChangesEnvironment=true
18+
//
19+
// Add this statement to your [Tasks] section
20+
// You can change the Description or Flags
21+
// You can change the Name, but it must match the ModPathName setting below
22+
// Name: modifypath; Description: &Add application directory to your environmental path; Flags: unchecked
23+
//
24+
// Add the following to the end of your [Code] section
25+
// ModPathName defines the name of the task defined above
26+
// ModPathType defines whether the 'user' or 'system' path will be modified;
27+
// this will default to user if anything other than system is set
28+
// setArrayLength must specify the total number of dirs to be added
29+
// Result[0] contains first directory, Result[1] contains second, etc.
30+
// const
31+
// ModPathName = 'modifypath';
32+
// ModPathType = 'user';
33+
//
34+
// function ModPathDir(): TArrayOfString;
35+
// begin
36+
// setArrayLength(Result, 1);
37+
// Result[0] := ExpandConstant('{app}');
38+
// end;
39+
// #include "modpath.iss"
40+
// ----------------------------------------------------------------------------
41+
42+
procedure ModPath();
43+
var
44+
oldpath: String;
45+
newpath: String;
46+
updatepath: Boolean;
47+
pathArr: TArrayOfString;
48+
aExecFile: String;
49+
aExecArr: TArrayOfString;
50+
i, d: Integer;
51+
pathdir: TArrayOfString;
52+
regroot: Integer;
53+
regpath: String;
54+
55+
begin
56+
// Get constants from main script and adjust behavior accordingly
57+
// ModPathType MUST be 'system' or 'user'; force 'user' if invalid
58+
if ModPathType = 'system' then begin
59+
regroot := HKEY_LOCAL_MACHINE;
60+
regpath := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
61+
end else begin
62+
regroot := HKEY_CURRENT_USER;
63+
regpath := 'Environment';
64+
end;
65+
66+
// Get array of new directories and act on each individually
67+
pathdir := ModPathDir();
68+
for d := 0 to GetArrayLength(pathdir)-1 do begin
69+
updatepath := true;
70+
71+
// Modify WinNT path
72+
if UsingWinNT() = true then begin
73+
74+
// Get current path, split into an array
75+
RegQueryStringValue(regroot, regpath, 'Path', oldpath);
76+
oldpath := oldpath + ';';
77+
i := 0;
78+
79+
while (Pos(';', oldpath) > 0) do begin
80+
SetArrayLength(pathArr, i+1);
81+
pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath)-1);
82+
oldpath := Copy(oldpath, Pos(';', oldpath)+1, Length(oldpath));
83+
i := i + 1;
84+
85+
// Check if current directory matches app dir
86+
if pathdir[d] = pathArr[i-1] then begin
87+
// if uninstalling, remove dir from path
88+
if IsUninstaller() = true then begin
89+
continue;
90+
// if installing, flag that dir already exists in path
91+
end else begin
92+
updatepath := false;
93+
end;
94+
end;
95+
96+
// Add current directory to new path
97+
if i = 1 then begin
98+
newpath := pathArr[i-1];
99+
end else begin
100+
newpath := newpath + ';' + pathArr[i-1];
101+
end;
102+
end;
103+
104+
// Append app dir to path if not already included
105+
if (IsUninstaller() = false) AND (updatepath = true) then
106+
newpath := newpath + ';' + pathdir[d];
107+
108+
// Write new path
109+
RegWriteStringValue(regroot, regpath, 'Path', newpath);
110+
111+
// Modify Win9x path
112+
end else begin
113+
114+
// Convert to shortened dirname
115+
pathdir[d] := GetShortName(pathdir[d]);
116+
117+
// If autoexec.bat exists, check if app dir already exists in path
118+
aExecFile := 'C:\AUTOEXEC.BAT';
119+
if FileExists(aExecFile) then begin
120+
LoadStringsFromFile(aExecFile, aExecArr);
121+
for i := 0 to GetArrayLength(aExecArr)-1 do begin
122+
if IsUninstaller() = false then begin
123+
// If app dir already exists while installing, skip add
124+
if (Pos(pathdir[d], aExecArr[i]) > 0) then
125+
updatepath := false;
126+
break;
127+
end else begin
128+
// If app dir exists and = what we originally set, then delete at uninstall
129+
if aExecArr[i] = 'SET PATH=%PATH%;' + pathdir[d] then
130+
aExecArr[i] := '';
131+
end;
132+
end;
133+
end;
134+
135+
// If app dir not found, or autoexec.bat didn't exist, then (create and) append to current path
136+
if (IsUninstaller() = false) AND (updatepath = true) then begin
137+
SaveStringToFile(aExecFile, #13#10 + 'SET PATH=%PATH%;' + pathdir[d], True);
138+
139+
// If uninstalling, write the full autoexec out
140+
end else begin
141+
SaveStringsToFile(aExecFile, aExecArr, False);
142+
end;
143+
end;
144+
end;
145+
end;
146+
147+
// Split a string into an array using passed delimeter
148+
procedure Explode(var Dest: TArrayOfString; Text: String; Separator: String);
149+
var
150+
i: Integer;
151+
begin
152+
i := 0;
153+
repeat
154+
SetArrayLength(Dest, i+1);
155+
if Pos(Separator,Text) > 0 then begin
156+
Dest[i] := Copy(Text, 1, Pos(Separator, Text)-1);
157+
Text := Copy(Text, Pos(Separator,Text) + Length(Separator), Length(Text));
158+
i := i + 1;
159+
end else begin
160+
Dest[i] := Text;
161+
Text := '';
162+
end;
163+
until Length(Text)=0;
164+
end;
165+
166+
167+
procedure CurStepChanged(CurStep: TSetupStep);
168+
var
169+
taskname: String;
170+
begin
171+
taskname := ModPathName;
172+
if CurStep = ssPostInstall then
173+
if IsTaskSelected(taskname) then
174+
ModPath();
175+
end;
176+
177+
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
178+
var
179+
aSelectedTasks: TArrayOfString;
180+
i: Integer;
181+
taskname: String;
182+
regpath: String;
183+
regstring: String;
184+
appid: String;
185+
begin
186+
// only run during actual uninstall
187+
if CurUninstallStep = usUninstall then begin
188+
// get list of selected tasks saved in registry at install time
189+
appid := '{#emit SetupSetting("AppId")}';
190+
if appid = '' then appid := '{#emit SetupSetting("AppName")}';
191+
regpath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\'+appid+'_is1');
192+
RegQueryStringValue(HKLM, regpath, 'Inno Setup: Selected Tasks', regstring);
193+
if regstring = '' then RegQueryStringValue(HKCU, regpath, 'Inno Setup: Selected Tasks', regstring);
194+
195+
// check each task; if matches modpath taskname, trigger patch removal
196+
if regstring <> '' then begin
197+
taskname := ModPathName;
198+
Explode(aSelectedTasks, regstring, ',');
199+
if GetArrayLength(aSelectedTasks) > 0 then begin
200+
for i := 0 to GetArrayLength(aSelectedTasks)-1 do begin
201+
if comparetext(aSelectedTasks[i], taskname) = 0 then
202+
ModPath();
203+
end;
204+
end;
205+
end;
206+
end;
207+
end;
208+
209+
function NeedRestart(): Boolean;
210+
var
211+
taskname: String;
212+
begin
213+
taskname := ModPathName;
214+
if IsTaskSelected(taskname) and not UsingWinNT() then begin
215+
Result := True;
216+
end else begin
217+
Result := False;
218+
end;
219+
end;

src/etc/pkg/rust-logo.ico

92.1 KB
Binary file not shown.

src/etc/pkg/rust.iss

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#define CFG_VERSION GetEnv("CFG_VERSION")
2+
3+
[Setup]
4+
5+
SetupIconFile=rust-logo.ico
6+
AppName=Rust
7+
AppVersion={#CFG_VERSION}
8+
AppCopyright=Copyright (C) 2006-2011 Mozilla Foundation, MIT license
9+
AppPublisher=Mozilla Foundation
10+
AppPublisherURL=http://www.rust-lang.org
11+
VersionInfoVersion={#CFG_VERSION}
12+
LicenseFile=LICENSE.txt
13+
14+
DisableWelcomePage=true
15+
DisableProgramGroupPage=true
16+
DisableReadyPage=true
17+
DisableStartupPrompt=true
18+
19+
OutputDir=.\
20+
SourceDir=.\
21+
OutputBaseFilename=rust-{#CFG_VERSION}-install
22+
DefaultDirName={pf32}\Rust
23+
24+
Compression=lzma2/ultra
25+
InternalCompressLevel=ultra
26+
SolidCompression=true
27+
28+
ChangesEnvironment=true
29+
ChangesAssociations=no
30+
AllowUNCPath=false
31+
AllowNoIcons=true
32+
Uninstallable=yes
33+
34+
[Tasks]
35+
Name: modifypath; Description: &Add {app}\bin to your PATH (recommended)
36+
37+
[Files]
38+
Source: "i686-pc-mingw32/stage3/*.*" ; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
39+
40+
[Code]
41+
const
42+
ModPathName = 'modifypath';
43+
ModPathType = 'user';
44+
45+
function ModPathDir(): TArrayOfString;
46+
begin
47+
setArrayLength(Result, 1)
48+
Result[0] := ExpandConstant('{app}\bin');
49+
end;
50+
#include "modpath.iss"

0 commit comments

Comments
 (0)