File: ServerInstaller.cs

package info (click to toggle)
mumble 1.5.857-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 90,180 kB
  • sloc: cpp: 556,939; ansic: 81,662; python: 3,607; sh: 659; makefile: 506; cs: 389; asm: 371; sql: 228; javascript: 143; xml: 88; perl: 80
file content (143 lines) | stat: -rw-r--r-- 4,141 bytes parent folder | download
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
// Copyright 2020-2023 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

//css_ref MumbleInstall.dll
//css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll;

using System;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Deployment.WindowsInstaller;
using WixSharp;
using WixSharp.CommonTasks;

public class ServerInstaller : MumbleInstall {

	public const string s_Name = "Mumble Server";
	public const string s_UpgradeGuid = "03E9476F-0F75-4661-BFC9-A9DAEB23D3A0";

	public static string GetMSIPath(string version, string arch) {
		return System.IO.Path.GetFullPath(System.IO.Path.Combine(Environment.CurrentDirectory, "mumble_server-" + new Version(version) + "-" + arch) + ".msi");
	}

	public ServerInstaller(string version, string arch) {
		string[] binaries = {
			"mumble-server.exe",
			"MumbleServer.ice"
		};

		string[] licenses = {
			"qt.txt",
			"gpl.txt",
			"speex.txt",
			"lgpl.txt",
			"Mumble.rtf"
		};

		if (arch == "x64") {
			// 64 bit
			this.Platform = WixSharp.Platform.x64;
			
		} else if (arch == "x86") {
			// 32 bit
			this.Platform = WixSharp.Platform.x86;
		}

		this.Name = ServerInstaller.s_Name;
		this.UpgradeCode = Guid.Parse(ServerInstaller.s_UpgradeGuid);
		this.Version = new Version(version);
		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");
		var licenseDir = new Dir("licenses");
		var menuDir = new Dir(@"%ProgramMenu%");
		var shortcutDir = new Dir("Mumble");
		var menuShortcut = new ExeFileShortcut("Mumble Server", "[INSTALLDIR]mumble-server.exe", arguments: "");
		menuShortcut.IconFile = @"..\icons\murmur.ico";
		shortcutDir.Shortcuts = new ExeFileShortcut[] { menuShortcut };
		
		var binaryFiles = new File[binaries.Length];
		var licenseFiles = new File[licenses.Length];
		
		for (int i = 0; i < binaries.Length; i++) {
			binaryFiles[i] = new File(@"..\..\" + binaries[i]);
		}
		
		for (int i = 0; i < licenses.Length; i++) {
			licenseFiles[i] = new File(@"..\..\licenses\" + licenses[i]);
		}

		installDir.Files = binaryFiles;
		licenseDir.Files = licenseFiles;
		
		menuDir.Dirs = new Dir[] { shortcutDir };
		installDir.Dirs = new Dir[] { licenseDir };
		productDir.Dirs = new Dir[] { installDir };
		progsDir.Dirs = new Dir[] { productDir };
		
		this.Dirs = new Dir[] {
			progsDir,
			menuDir
		};
	}
}

class BuildInstaller 
{
	public static void Main(string[] args) {
		string version = "";
		string arch = "";
		string vcRedistRequired = "";
		bool isAllLangs = false;
		bool skipMSIRebuild = false;

		for (int i = 0; i < args.Length; i++) {
			if (args[i] == "--version" && Regex.IsMatch(args[i + 1], @"^([0-9]+\.){2}[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;
			}

			if (args[i] == "--vc-redist-required") {
				vcRedistRequired = args[i + 1];
			}

			if (args[i] == "--skip-msi-rebuild") {
				skipMSIRebuild = true;
			}
		}

		if (version != null && arch != null) {
			string msiPath;

			if (!skipMSIRebuild) {
				var srvInstaller = new ServerInstaller(version, arch);
				srvInstaller.Version = new Version(version);
				msiPath = isAllLangs
							? srvInstaller.BuildMultilanguageMsi()
							: srvInstaller.BuildMsi();
			} else {
				Console.WriteLine("INFO - Skipping MSI rebuild.");
				msiPath = ServerInstaller.GetMSIPath(version, arch);
			}

			MumbleInstall.BundleMsi(ServerInstaller.s_Name, Guid.Parse(ServerInstaller.s_UpgradeGuid), msiPath, vcRedistRequired)
			            .Build(msiPath.PathChangeExtension(".exe"));

		} else {
			Console.WriteLine("ERROR - Values for arch or version are null or incorrect!");
			Environment.ExitCode = 0xA0; // Bad argument
		}
	}
}