From 912963bd0856239828253af8d04e4f62e75cafd7 Mon Sep 17 00:00:00 2001
From: Chris Denton <christophersdenton@gmail.com>
Date: Mon, 25 May 2020 13:53:02 +0100
Subject: [PATCH] Remove legacy InnoSetup GUI installer

On Windows the InnoSetup installer was superseded by the MSI installer. It's no longer needed.
---
 .github/workflows/ci.yml             |   9 --
 src/bootstrap/dist.rs                |  21 ---
 src/ci/azure-pipelines/steps/run.yml |   4 -
 src/ci/github-actions/ci.yml         |   4 -
 src/ci/scripts/install-innosetup.sh  |  18 ---
 src/etc/installer/exe/modpath.iss    | 219 ---------------------------
 src/etc/installer/exe/rust.iss       |  87 -----------
 src/etc/installer/exe/upgrade.iss    |  61 --------
 8 files changed, 423 deletions(-)
 delete mode 100755 src/ci/scripts/install-innosetup.sh
 delete mode 100644 src/etc/installer/exe/modpath.iss
 delete mode 100644 src/etc/installer/exe/rust.iss
 delete mode 100644 src/etc/installer/exe/upgrade.iss

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 291dbf60361..6383cbdc139 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -90,9 +90,6 @@ jobs:
       - name: install WIX
         run: src/ci/scripts/install-wix.sh
         if: success() && !env.SKIP_JOB
-      - name: install InnoSetup
-        run: src/ci/scripts/install-innosetup.sh
-        if: success() && !env.SKIP_JOB
       - name: ensure the build happens on a partition with enough space
         run: src/ci/scripts/symlink-build-dir.sh
         if: success() && !env.SKIP_JOB
@@ -200,9 +197,6 @@ jobs:
       - name: install WIX
         run: src/ci/scripts/install-wix.sh
         if: success() && !env.SKIP_JOB
-      - name: install InnoSetup
-        run: src/ci/scripts/install-innosetup.sh
-        if: success() && !env.SKIP_JOB
       - name: ensure the build happens on a partition with enough space
         run: src/ci/scripts/symlink-build-dir.sh
         if: success() && !env.SKIP_JOB
@@ -552,9 +546,6 @@ jobs:
       - name: install WIX
         run: src/ci/scripts/install-wix.sh
         if: success() && !env.SKIP_JOB
-      - name: install InnoSetup
-        run: src/ci/scripts/install-innosetup.sh
-        if: success() && !env.SKIP_JOB
       - name: ensure the build happens on a partition with enough space
         run: src/ci/scripts/symlink-build-dir.sh
         if: success() && !env.SKIP_JOB
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 5e966d7055b..b6c8e0652d1 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -1859,28 +1859,7 @@ impl Step for Extended {
                 prepare("rust-mingw");
             }
 
-            builder.install(&xform(&etc.join("exe/rust.iss")), &exe, 0o644);
-            builder.install(&etc.join("exe/modpath.iss"), &exe, 0o644);
-            builder.install(&etc.join("exe/upgrade.iss"), &exe, 0o644);
             builder.install(&etc.join("gfx/rust-logo.ico"), &exe, 0o644);
-            builder.create(&exe.join("LICENSE.txt"), &license);
-
-            // Generate exe installer
-            builder.info("building `exe` installer with `iscc`");
-            let mut cmd = Command::new("iscc");
-            cmd.arg("rust.iss").arg("/Q").current_dir(&exe);
-            if target.contains("windows-gnu") {
-                cmd.arg("/dMINGW");
-            }
-            add_env(builder, &mut cmd, target);
-            let time = timeit(builder);
-            builder.run(&mut cmd);
-            drop(time);
-            builder.install(
-                &exe.join(format!("{}-{}.exe", pkgname(builder, "rust"), target)),
-                &distdir(builder),
-                0o755,
-            );
 
             // Generate msi installer
             let wix = PathBuf::from(env::var_os("WIX").unwrap());
diff --git a/src/ci/azure-pipelines/steps/run.yml b/src/ci/azure-pipelines/steps/run.yml
index 85ff3e52a84..5ceb280953a 100644
--- a/src/ci/azure-pipelines/steps/run.yml
+++ b/src/ci/azure-pipelines/steps/run.yml
@@ -66,10 +66,6 @@ steps:
   displayName: Install wix
   condition: and(succeeded(), not(variables.SKIP_JOB))
 
-- bash: src/ci/scripts/install-innosetup.sh
-  displayName: Install InnoSetup
-  condition: and(succeeded(), not(variables.SKIP_JOB))
-
 - bash: src/ci/scripts/symlink-build-dir.sh
   displayName: Ensure the build happens on a partition with enough space
   condition: and(succeeded(), not(variables.SKIP_JOB))
diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml
index 1c120f81634..7a0cd760059 100644
--- a/src/ci/github-actions/ci.yml
+++ b/src/ci/github-actions/ci.yml
@@ -131,10 +131,6 @@ x--expand-yaml-anchors--remove:
         run: src/ci/scripts/install-wix.sh
         <<: *step
 
-      - name: install InnoSetup
-        run: src/ci/scripts/install-innosetup.sh
-        <<: *step
-
       - name: ensure the build happens on a partition with enough space
         run: src/ci/scripts/symlink-build-dir.sh
         <<: *step
diff --git a/src/ci/scripts/install-innosetup.sh b/src/ci/scripts/install-innosetup.sh
deleted file mode 100755
index 04ca249777a..00000000000
--- a/src/ci/scripts/install-innosetup.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-# We use InnoSetup and its `iscc` program to also create combined installers.
-# Honestly at this point WIX above and `iscc` are just holdovers from
-# oh-so-long-ago and are required for creating installers on Windows. I think
-# one is MSI installers and one is EXE, but they're not used so frequently at
-# this point anyway so perhaps it's a wash!
-
-set -euo pipefail
-IFS=$'\n\t'
-
-source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
-
-if isWindows; then
-    curl.exe -o is-install.exe "${MIRRORS_BASE}/2017-08-22-is.exe"
-    cmd.exe //c "is-install.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"
-
-    ciCommandAddPath "C:\\Program Files (x86)\\Inno Setup 5"
-fi
diff --git a/src/etc/installer/exe/modpath.iss b/src/etc/installer/exe/modpath.iss
deleted file mode 100644
index 2cfc8698c4b..00000000000
--- a/src/etc/installer/exe/modpath.iss
+++ /dev/null
@@ -1,219 +0,0 @@
-// ----------------------------------------------------------------------------
-//
-// Inno Setup Ver:	5.4.2
-// Script Version:	1.4.1
-// Author:			Jared Breland <jbreland@legroom.net>
-// Homepage:		http://www.legroom.net/software
-// License:			GNU Lesser General Public License (LGPL), version 3
-//						http://www.gnu.org/licenses/lgpl.html
-//
-// Script Function:
-//	Allow modification of environmental path directly from Inno Setup installers
-//
-// Instructions:
-//	Copy modpath.iss to the same directory as your setup script
-//
-//	Add this statement to your [Setup] section
-//		ChangesEnvironment=true
-//
-//	Add this statement to your [Tasks] section
-//	You can change the Description or Flags
-//	You can change the Name, but it must match the ModPathName setting below
-//		Name: modifypath; Description: &Add application directory to your environmental path; Flags: unchecked
-//
-//	Add the following to the end of your [Code] section
-//	ModPathName defines the name of the task defined above
-//	ModPathType defines whether the 'user' or 'system' path will be modified;
-//		this will default to user if anything other than system is set
-//	setArrayLength must specify the total number of dirs to be added
-//	Result[0] contains first directory, Result[1] contains second, etc.
-//		const
-//			ModPathName = 'modifypath';
-//			ModPathType = 'user';
-//
-//		function ModPathDir(): TArrayOfString;
-//		begin
-//			setArrayLength(Result, 1);
-//			Result[0] := ExpandConstant('{app}');
-//		end;
-//		#include "modpath.iss"
-// ----------------------------------------------------------------------------
-
-procedure ModPath();
-var
-	oldpath:	String;
-	newpath:	String;
-	updatepath:	Boolean;
-	pathArr:	TArrayOfString;
-	aExecFile:	String;
-	aExecArr:	TArrayOfString;
-	i, d:		Integer;
-	pathdir:	TArrayOfString;
-	regroot:	Integer;
-	regpath:	String;
-
-begin
-	// Get constants from main script and adjust behavior accordingly
-	// ModPathType MUST be 'system' or 'user'; force 'user' if invalid
-	if ModPathType = 'system' then begin
-		regroot := HKEY_LOCAL_MACHINE;
-		regpath := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
-	end else begin
-		regroot := HKEY_CURRENT_USER;
-		regpath := 'Environment';
-	end;
-
-	// Get array of new directories and act on each individually
-	pathdir := ModPathDir();
-	for d := 0 to GetArrayLength(pathdir)-1 do begin
-		updatepath := true;
-
-		// Modify WinNT path
-		if UsingWinNT() = true then begin
-
-			// Get current path, split into an array
-			RegQueryStringValue(regroot, regpath, 'Path', oldpath);
-			oldpath := oldpath + ';';
-			i := 0;
-
-			while (Pos(';', oldpath) > 0) do begin
-				SetArrayLength(pathArr, i+1);
-				pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath)-1);
-				oldpath := Copy(oldpath, Pos(';', oldpath)+1, Length(oldpath));
-				i := i + 1;
-
-				// Check if current directory matches app dir
-				if pathdir[d] = pathArr[i-1] then begin
-					// if uninstalling, remove dir from path
-					if IsUninstaller() = true then begin
-						continue;
-					// if installing, flag that dir already exists in path
-					end else begin
-						updatepath := false;
-					end;
-				end;
-
-				// Add current directory to new path
-				if i = 1 then begin
-					newpath := pathArr[i-1];
-				end else begin
-					newpath := newpath + ';' + pathArr[i-1];
-				end;
-			end;
-
-			// Append app dir to path if not already included
-			if (IsUninstaller() = false) AND (updatepath = true) then
-				newpath := newpath + ';' + pathdir[d];
-
-			// Write new path
-			RegWriteStringValue(regroot, regpath, 'Path', newpath);
-
-		// Modify Win9x path
-		end else begin
-
-			// Convert to shortened dirname
-			pathdir[d] := GetShortName(pathdir[d]);
-
-			// If autoexec.bat exists, check if app dir already exists in path
-			aExecFile := 'C:\AUTOEXEC.BAT';
-			if FileExists(aExecFile) then begin
-				LoadStringsFromFile(aExecFile, aExecArr);
-				for i := 0 to GetArrayLength(aExecArr)-1 do begin
-					if IsUninstaller() = false then begin
-						// If app dir already exists while installing, skip add
-						if (Pos(pathdir[d], aExecArr[i]) > 0) then
-							updatepath := false;
-							break;
-					end else begin
-						// If app dir exists and = what we originally set, then delete at uninstall
-						if aExecArr[i] = 'SET PATH=%PATH%;' + pathdir[d] then
-							aExecArr[i] := '';
-					end;
-				end;
-			end;
-
-			// If app dir not found, or autoexec.bat didn't exist, then (create and) append to current path
-			if (IsUninstaller() = false) AND (updatepath = true) then begin
-				SaveStringToFile(aExecFile, #13#10 + 'SET PATH=%PATH%;' + pathdir[d], True);
-
-			// If uninstalling, write the full autoexec out
-			end else begin
-				SaveStringsToFile(aExecFile, aExecArr, False);
-			end;
-		end;
-	end;
-end;
-
-// Split a string into an array using passed delimiter
-procedure Explode(var Dest: TArrayOfString; Text: String; Separator: String);
-var
-	i: Integer;
-begin
-	i := 0;
-	repeat
-		SetArrayLength(Dest, i+1);
-		if Pos(Separator,Text) > 0 then	begin
-			Dest[i] := Copy(Text, 1, Pos(Separator, Text)-1);
-			Text := Copy(Text, Pos(Separator,Text) + Length(Separator), Length(Text));
-			i := i + 1;
-		end else begin
-			 Dest[i] := Text;
-			 Text := '';
-		end;
-	until Length(Text)=0;
-end;
-
-
-procedure ModPathCurStepChanged(CurStep: TSetupStep);
-var
-	taskname:	String;
-begin
-	taskname := ModPathName;
-	if CurStep = ssPostInstall then
-		if IsTaskSelected(taskname) then
-			ModPath();
-end;
-
-procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
-var
-	aSelectedTasks:	TArrayOfString;
-	i:				Integer;
-	taskname:		String;
-	regpath:		String;
-	regstring:		String;
-	appid:			String;
-begin
-	// only run during actual uninstall
-	if CurUninstallStep = usUninstall then begin
-		// get list of selected tasks saved in registry at install time
-		appid := '{#emit SetupSetting("AppId")}';
-		if appid = '' then appid := '{#emit SetupSetting("AppName")}';
-		regpath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\'+appid+'_is1');
-		RegQueryStringValue(HKLM, regpath, 'Inno Setup: Selected Tasks', regstring);
-		if regstring = '' then RegQueryStringValue(HKCU, regpath, 'Inno Setup: Selected Tasks', regstring);
-
-		// check each task; if matches modpath taskname, trigger patch removal
-		if regstring <> '' then begin
-			taskname := ModPathName;
-			Explode(aSelectedTasks, regstring, ',');
-			if GetArrayLength(aSelectedTasks) > 0 then begin
-				for i := 0 to GetArrayLength(aSelectedTasks)-1 do begin
-					if comparetext(aSelectedTasks[i], taskname) = 0 then
-						ModPath();
-				end;
-			end;
-		end;
-	end;
-end;
-
-function NeedRestart(): Boolean;
-var
-	taskname:	String;
-begin
-	taskname := ModPathName;
-	if IsTaskSelected(taskname) and not UsingWinNT() then begin
-		Result := True;
-	end else begin
-		Result := False;
-	end;
-end;
diff --git a/src/etc/installer/exe/rust.iss b/src/etc/installer/exe/rust.iss
deleted file mode 100644
index 70648beac38..00000000000
--- a/src/etc/installer/exe/rust.iss
+++ /dev/null
@@ -1,87 +0,0 @@
-#define CFG_RELEASE_NUM GetEnv("CFG_RELEASE_NUM")
-#define CFG_RELEASE GetEnv("CFG_RELEASE")
-#define CFG_PACKAGE_NAME GetEnv("CFG_PACKAGE_NAME")
-#define CFG_BUILD GetEnv("CFG_BUILD")
-
-[Setup]
-
-SetupIconFile=rust-logo.ico
-AppName=Rust
-AppVersion={#CFG_RELEASE}
-AppCopyright=Copyright (C) 2006-2014 Mozilla Foundation, MIT license
-AppPublisher=Mozilla Foundation
-AppPublisherURL=http://www.rust-lang.org
-VersionInfoVersion={#CFG_RELEASE_NUM}
-LicenseFile=LICENSE.txt
-
-PrivilegesRequired=lowest
-DisableWelcomePage=true
-DisableProgramGroupPage=true
-DisableReadyPage=true
-DisableStartupPrompt=true
-
-OutputDir=.\
-SourceDir=.\
-OutputBaseFilename={#CFG_PACKAGE_NAME}-{#CFG_BUILD}
-DefaultDirName={sd}\Rust
-
-Compression=lzma2/normal
-InternalCompressLevel=normal
-SolidCompression=no
-
-ChangesEnvironment=true
-ChangesAssociations=no
-AllowUNCPath=false
-AllowNoIcons=true
-Uninstallable=yes
-
-[Tasks]
-Name: modifypath; Description: &Add {app}\bin to your PATH (recommended)
-
-[Components]
-Name: rust; Description: "Rust compiler and standard crates"; Types: full compact custom; Flags: fixed
-#ifdef MINGW
-Name: gcc; Description: "Linker and platform libraries"; Types: full
-#endif
-Name: docs; Description: "HTML documentation"; Types: full
-Name: cargo; Description: "Cargo, the Rust package manager"; Types: full
-Name: std; Description: "The Rust Standard Library"; Types: full
-// tool-rls-start
-Name: rls; Description: "RLS, the Rust Language Server"
-// tool-rls-end
-
-[Files]
-Source: "rustc/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: rust
-#ifdef MINGW
-Source: "rust-mingw/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: gcc
-#endif
-Source: "rust-docs/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: docs
-Source: "cargo/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: cargo
-Source: "rust-std/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: std
-// tool-rls-start
-Source: "rls/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: rls
-Source: "rust-analysis/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: rls
-// tool-rls-end
-
-[Code]
-const
-	ModPathName = 'modifypath';
-	ModPathType = 'user';
-
-function ModPathDir(): TArrayOfString;
-begin
-	setArrayLength(Result, 1)
-	Result[0] := ExpandConstant('{app}\bin');
-end;
-
-#include "modpath.iss"
-#include "upgrade.iss"
-
-// Both modpath.iss and upgrade.iss want to overload CurStepChanged.
-// This version does the overload then delegates to each.
-
-procedure CurStepChanged(CurStep: TSetupStep);
-begin
-  UpgradeCurStepChanged(CurStep);
-  ModPathCurStepChanged(CurStep);
-end;
diff --git a/src/etc/installer/exe/upgrade.iss b/src/etc/installer/exe/upgrade.iss
deleted file mode 100644
index 29da7c333bb..00000000000
--- a/src/etc/installer/exe/upgrade.iss
+++ /dev/null
@@ -1,61 +0,0 @@
-// The following code taken from https://stackoverflow.com/questions/2000296/innosetup-how-to-automatically-uninstall-previous-installed-version
-// It performs upgrades by running the uninstaller before the install
-
-/////////////////////////////////////////////////////////////////////
-function GetUninstallString(): String;
-var
-  sUnInstPath: String;
-  sUnInstallString: String;
-begin
-  sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\Rust_is1');
-  sUnInstallString := '';
-  if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
-    RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
-  Result := sUnInstallString;
-end;
-
-
-/////////////////////////////////////////////////////////////////////
-function IsUpgrade(): Boolean;
-begin
-  Result := (GetUninstallString() <> '');
-end;
-
-
-/////////////////////////////////////////////////////////////////////
-function UnInstallOldVersion(): Integer;
-var
-  sUnInstallString: String;
-  iResultCode: Integer;
-begin
-// Return Values:
-// 1 - uninstall string is empty
-// 2 - error executing the UnInstallString
-// 3 - successfully executed the UnInstallString
-
-  // default return value
-  Result := 0;
-
-  // get the uninstall string of the old app
-  sUnInstallString := GetUninstallString();
-  if sUnInstallString <> '' then begin
-    sUnInstallString := RemoveQuotes(sUnInstallString);
-    if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
-      Result := 3
-    else
-      Result := 2;
-  end else
-    Result := 1;
-end;
-
-/////////////////////////////////////////////////////////////////////
-procedure UpgradeCurStepChanged(CurStep: TSetupStep);
-begin
-  if (CurStep=ssInstall) then
-  begin
-    if (IsUpgrade()) then
-    begin
-      UnInstallOldVersion();
-    end;
-  end;
-end;