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 <ae@cy.md>
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 /// Installs KindleGen, a compiler for Kindle-compatible e-books.
23 class KindleGenInstaller : Installer
24 {
25 	/// Download URL.
26 	version (Windows)
27 		enum defaultUrl = "https://dump.cy.md/d4be194f848da73ea09742bc3a787f1b/kindlegen_win32_v2_9.zip";
28 	else
29 	version (linux)
30 		enum defaultUrl = "https://dump.cy.md/21aef3c8846946203e178c83a37beba1/kindlegen_linux_2.6_i386_v2_9.tar.gz";
31 	else
32 	version (OSX)
33 		enum defaultUrl = "https://dump.cy.md/204a2a4cc3e95e1a0dbbb9e52a7bc482/KindleGen_Mac_i386_v2_9.zip";
34 	else
35 		enum defaultUrl = null;
36 
37 	string url = defaultUrl; /// ditto
38 
39 	static this()
40 	{
41 		urlDigests["https://dump.cy.md/d4be194f848da73ea09742bc3a787f1b/kindlegen_win32_v2_9.zip"            ] = "8b5540f12e291b4031ad5197e11c0c9f576ad1e5";
42 		urlDigests["https://dump.cy.md/21aef3c8846946203e178c83a37beba1/kindlegen_linux_2.6_i386_v2_9.tar.gz"] = "2e46cce099aba2725b5ba9ac9d1b1ecdc9dd77e2";
43 		urlDigests["https://dump.cy.md/204a2a4cc3e95e1a0dbbb9e52a7bc482/KindleGen_Mac_i386_v2_9.zip"         ] = "efa5ad0b05650f7f71543535ea2b232bb5fec571";
44 	} ///
45 
46 protected:
47 	@property override string[] requiredExecutables() { return ["kindlegen"]; }
48 
49 	override void installImpl(string target)
50 	{
51 		enforce(url, "KindleGen: No URL or platform not supported");
52 		url
53 			.I!save()
54 			.I!unpackTo(target);
55 	}
56 }
57 
58 alias kindleGenInstaller = singleton!KindleGenInstaller; /// ditto