1 /**
2  * 7-Zip command-line 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.sevenzip;
15 
16 import ae.utils.meta : singleton, I;
17 
18 public import ae.sys.install.common;
19 
20 /// Installs the 7-Zip archiving tool.
21 /// Windows-only.
22 class SevenZipInstaller : Installer
23 {
24 	string url = "http://downloads.sourceforge.net/sevenzip/7za920.zip"; /// Download URL.
25 
26 	/// "7za" or "7z", depending on which is available.
27 	@property string exe()
28 	{
29 		if (haveExecutable("7za"))
30 			return "7za";
31 		else
32 			return "7z";
33 	}
34 
35 protected:
36 	@property override string name() { return "7-Zip"; }
37 	@property override string subdirectory() { return "7z"; }
38 
39 	@property override string[] requiredExecutables() { assert(false); }
40 
41 	import ae.utils.path : haveExecutable;
42 
43 	override void installImpl(string target)
44 	{
45 		windowsOnly();
46 		url
47 			.I!save()
48 			.I!unpackTo(target);
49 	}
50 
51 	@property override bool availableOnSystem()
52 	{
53 		return haveExecutable("7z") || haveExecutable("7za");
54 	}
55 
56 	static this()
57 	{
58 		urlDigests["http://downloads.sourceforge.net/sevenzip/7za920.zip"] = "9ce9ce89ebc070fea5d679936f21f9dde25faae0";
59 	}
60 }
61 
62 alias sevenZip = singleton!SevenZipInstaller;