diff options
author | Nik Reist <zeroability@tutanota.com> | 2021-01-10 04:02:10 +0300 |
---|---|---|
committer | Davide Beatrici <git@davidebeatrici.dev> | 2021-01-10 04:02:12 +0300 |
commit | e845f51220f4942f314295a4f0a35e5578031856 (patch) | |
tree | 0549936235b179e17778a6164e0ad62d31c27a1c /installer | |
parent | 41bbab9e8b9014bcb5925c102c5d9e62c856b70b (diff) |
FEAT(installer): Add support for snapshot builds
This commit:
- Adds null checks and error messages for "--arch" and "--version" to WixSharp projects.
- Sets cabinet file name to "Mumble.cab", for consistency with our previous installers.
- Cleans up ClientInstaller.
- Fixes regex patterns for string input safety and to simplify conditions.
Diffstat (limited to 'installer')
-rw-r--r-- | installer/ClientInstaller.cs | 44 | ||||
-rw-r--r-- | installer/ServerInstaller.cs | 37 |
2 files changed, 44 insertions, 37 deletions
diff --git a/installer/ClientInstaller.cs b/installer/ClientInstaller.cs index 918345cdb..5257247d1 100644 --- a/installer/ClientInstaller.cs +++ b/installer/ClientInstaller.cs @@ -7,6 +7,7 @@ //css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll; using System; +using System.Linq; using System.Text.RegularExpressions; using System.Windows.Forms; using Microsoft.Deployment.WindowsInstaller; @@ -65,7 +66,7 @@ public class ClientInstaller : MumbleInstall { "wow.dll", "wow_x64.dll" }; - + string[] licenses = { "qt.txt", "portaudio.txt", @@ -74,7 +75,7 @@ public class ClientInstaller : MumbleInstall { "lgpl.txt", "Mumble.rtf" }; - + if (arch == "x64") { // 64 bit this.Platform = WixSharp.Platform.x64; @@ -104,12 +105,13 @@ public class ClientInstaller : MumbleInstall { "mumble_ol_helper.exe" }; } - + this.Name = "Mumble (client)"; this.UpgradeCode = Guid.Parse(upgradeGuid); this.Version = new Version(version); this.OutFileName = "mumble_client-" + this.Version + "-" + arch; - + this.Media.First().Cabinet = "Mumble.cab"; + var progsDir = new Dir(@"%ProgramFiles%"); var productDir = new Dir("Mumble"); var installDir = new Dir("client"); @@ -160,17 +162,6 @@ public class ClientInstaller : MumbleInstall { } } -public class CustomActions -{ - [CustomAction] - public static ActionResult InstallDeskShortcut(Session session) { - if (DialogResult.Yes == MessageBox.Show("Would you like to create a shortcut on the Desktop?", "Desktop Shortcut", MessageBoxButtons.YesNo)) { - session["INSTALLDESKTOPSHORTCUT"] = "yes"; - } - return ActionResult.Success; - } -} - class BuildInstaller { public static void Main(string[] args) { @@ -179,24 +170,31 @@ class BuildInstaller bool isAllLangs = false; for (int i = 0; i < args.Length; i++) { - if (args[i] == "--version" && Regex.Match(args[i + 1], @"^\d+$.^\d+$.^\d+$", RegexOptions.None) != null) { + if (args[i] == "--version" && Regex.IsMatch(args[i + 1], @"^[0-9]\.[0-9]\.[0-9]\.[0-9]$")) { version = args[i + 1]; } - + if (args[i] == "--arch" && (args[i + 1] == "x64" || args[i + 1] == "x86")) { arch = args[i + 1]; } - + if (args[i] == "--all-languages") { isAllLangs = true; } } - - var clInstaller = new ClientInstaller(version, arch); - if (isAllLangs) { - clInstaller.BuildMultilanguageMsi(); + + if (version != null && arch != null) { + var clInstaller = new ClientInstaller(version, arch); + clInstaller.Version = new Version(version); + + if (isAllLangs) { + clInstaller.BuildMultilanguageMsi(); + } else { + clInstaller.BuildMsi(); + } } else { - clInstaller.BuildMsi(); + Console.WriteLine("ERROR - Values for arch or version are null or incorrect!"); + Environment.ExitCode = 0xA0; // Bad argument } } } diff --git a/installer/ServerInstaller.cs b/installer/ServerInstaller.cs index 033514590..75f5c5a54 100644 --- a/installer/ServerInstaller.cs +++ b/installer/ServerInstaller.cs @@ -7,6 +7,7 @@ //css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll; using System; +using System.Linq; using System.Text.RegularExpressions; using Microsoft.Deployment.WindowsInstaller; using WixSharp; @@ -19,7 +20,7 @@ public class ServerInstaller : MumbleInstall { "murmur.exe", "Murmur.ice" }; - + string[] licenses = { "qt.txt", "gpl.txt", @@ -27,7 +28,7 @@ public class ServerInstaller : MumbleInstall { "lgpl.txt", "Mumble.rtf" }; - + if (arch == "x64") { // 64 bit this.Platform = WixSharp.Platform.x64; @@ -36,12 +37,13 @@ public class ServerInstaller : MumbleInstall { // 32 bit this.Platform = WixSharp.Platform.x86; } - + this.Name = "Mumble (server)"; this.UpgradeCode = Guid.Parse(upgradeGuid); this.Version = new Version(version); - this.OutFileName = "mumble_server-" + this.Version + "-" + arch; - + this.OutFileName = "mumble_server-" + this.Version + "-" + arch; + this.Media.First().Cabinet = "Mumble.cab"; + var progsDir = new Dir(@"%ProgramFiles%"); var productDir = new Dir("Mumble"); var installDir = new Dir("server"); @@ -62,7 +64,7 @@ public class ServerInstaller : MumbleInstall { for (int i = 0; i < licenses.Length; i++) { licenseFiles[i] = new File(@"..\..\licenses\" + licenses[i]); } - + installDir.Files = binaryFiles; licenseDir.Files = licenseFiles; @@ -86,24 +88,31 @@ class BuildInstaller bool isAllLangs = false; for (int i = 0; i < args.Length; i++) { - if (args[i] == "--version" && Regex.Match(args[i + 1], @"^\d+$.^\d+$.^\d+$", RegexOptions.None) != null) { + if (args[i] == "--version" && Regex.IsMatch(args[i + 1], @"^[0-9]\.[0-9]\.[0-9]\.[0-9]$")) { version = args[i + 1]; } - + if (args[i] == "--arch" && (args[i + 1] == "x64" || args[i + 1] == "x86")) { arch = args[i + 1]; } - + if (args[i] == "--all-languages") { isAllLangs = true; } } - - var srvInstaller = new ServerInstaller(version, arch); - if (isAllLangs) { - srvInstaller.BuildMultilanguageMsi(); + + if (version != null && arch != null) { + var srvInstaller = new ServerInstaller(version, arch); + srvInstaller.Version = new Version(version); + + if (isAllLangs) { + srvInstaller.BuildMultilanguageMsi(); + } else { + srvInstaller.BuildMsi(); + } } else { - srvInstaller.BuildMsi(); + Console.WriteLine("ERROR - Values for arch or version are null or incorrect!"); + Environment.ExitCode = 0xA0; // Bad argument } } } |