1 /**
2  * KindleGen installer
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.kindlegen;
15 
16 import std.exception;
17 
18 import ae.utils.meta : singleton, I;
19 
20 public import ae.sys.install.common;
21 
22 class KindleGenInstaller : Installer
23 {
24 	version (Windows)
25 		enum defaultUrl = "https://dump.cy.md/d4be194f848da73ea09742bc3a787f1b/kindlegen_win32_v2_9.zip";
26 	else
27 	version (linux)
28 		enum defaultUrl = "https://dump.cy.md/21aef3c8846946203e178c83a37beba1/kindlegen_linux_2.6_i386_v2_9.tar.gz";
29 	else
30 	version (OSX)
31 		enum defaultUrl = "https://dump.cy.md/204a2a4cc3e95e1a0dbbb9e52a7bc482/KindleGen_Mac_i386_v2_9.zip";
32 	else
33 		enum defaultUrl = null;
34 
35 	string url = defaultUrl;
36 
37 	static this()
38 	{
39 		urlDigests["https://dump.cy.md/d4be194f848da73ea09742bc3a787f1b/kindlegen_win32_v2_9.zip"            ] = "8b5540f12e291b4031ad5197e11c0c9f576ad1e5";
40 		urlDigests["https://dump.cy.md/21aef3c8846946203e178c83a37beba1/kindlegen_linux_2.6_i386_v2_9.tar.gz"] = "2e46cce099aba2725b5ba9ac9d1b1ecdc9dd77e2";
41 		urlDigests["https://dump.cy.md/204a2a4cc3e95e1a0dbbb9e52a7bc482/KindleGen_Mac_i386_v2_9.zip"         ] = "efa5ad0b05650f7f71543535ea2b232bb5fec571";
42 	}
43 
44 	@property override string[] requiredExecutables() { return ["kindlegen"]; }
45 
46 	override void installImpl(string target)
47 	{
48 		enforce(url, "KindleGen: No URL or platform not supported");
49 		url
50 			.I!save()
51 			.I!unpackTo(target);
52 	}
53 }
54 
55 alias kindleGenInstaller = singleton!KindleGenInstaller;