1 /**
2  * WiX Toolset
3  *
4  * License:
5  *   This Source Code Form is subject to the terms of
6  *   the Mozilla Public License, v. 2.0. If a copy of
7  *   the MPL was not distributed with this file, You
8  *   can obtain one at http://mozilla.org/MPL/2.0/.
9  *
10  * Authors:
11  *   Vladimir Panteleev <vladimir@thecybershadow.net>
12  */
13 
14 module ae.sys.install.wix;
15 
16 import std.conv;
17 import std.file;
18 import std.regex;
19 import std.string;
20 
21 import ae.sys.archive;
22 import ae.sys.file;
23 import ae.utils.meta : singleton, I;
24 
25 public import ae.sys.install.common;
26 
27 class WixInstaller : Installer
28 {
29 	int downloadId = 762938;
30 	long fileTime = 130301249355530000;
31 
32 	@property override string[] requiredExecutables() { return ["candle", "dark", "heat", "light", "lit", "lux", "melt", "nit", "pyro", "retina", "shine", "smoke", "torch"]; }
33 
34 	override void installImpl(string target)
35 	{
36 		windowsOnly();
37 		// CodePlex does not have direct download URLs. Scrape it!
38 		"http://wix.codeplex.com/downloads/get/%d"
39 			.format(downloadId)
40 			.I!verify(null)
41 			.I!saveAs("wix-%d.html".format(downloadId))
42 			.readText()
43 			.match(regex(`<li>Version \d+\.\d+\.\d+\.(\d+)</li>`)).front[1]
44 			.to!int
45 			.I!buildZipUrl()
46 			.I!verify("82fb51e636df7e497fc224152759b9a6b95f19bc")
47 			.I!saveAs("wix-%d.zip".format(downloadId))
48 			.I!unpackTo(target);
49 	}
50 
51 	static string verify(string url, string hash)
52 	{
53 		urlDigests[url] = hash;
54 		return url;
55 	}
56 
57 	string buildZipUrl(int build)
58 	{
59 		return "http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=wix&DownloadId=%d&FileTime=%d&Build=%d"
60 			.format(downloadId, fileTime, build);
61 	}
62 }
63 
64 alias wixInstaller = singleton!WixInstaller;