1 /**
2  * MSYS 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.msys;
15 
16 import std.file;
17 import std.path;
18 import std..string : format;
19 
20 import ae.utils.meta : singleton, I;
21 
22 public import ae.sys.install.common;
23 
24 /// Installs an MSYS component.
25 final class MSYSComponent : Installer
26 {
27 	this(string componentName, string testFile, string url) { this.componentName = componentName; this.testFile = testFile; this.url = url; } ///
28 
29 protected:
30 	string componentName, testFile, url;
31 
32 	@property override string name() { return "%s (MSYS)".format(componentName); }
33 	@property override string subdirectory() { return "msys"; }
34 	@property override string[] binPaths() { return ["bin"]; }
35 
36 	override @property bool installedLocally()
37 	{
38 		return directory.buildPath(testFile).exists;
39 	}
40 
41 	override void atomicInstallImpl()
42 	{
43 		windowsOnly();
44 		if (!directory.exists)
45 			directory.mkdir();
46 		url
47 			.I!save()
48 			.I!unpack()
49 			.atomicMoveInto(directory);
50 		assert(installedLocally);
51 	}
52 
53 	static this()
54 	{
55 		urlDigests["https://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.18-1/msysCORE-1.0.18-1-msys-1.0.18-bin.tar.lzma"                            ] = "36d52ca7066eb6ad0da68c6f31214416f4c9dcec";
56 		urlDigests["https://sourceforge.net/projects/mingw/files/MSYS/Base/gettext/gettext-0.18.1.1-1/libintl-0.18.1.1-1-msys-1.0.17-dll-8.tar.lzma"                      ] = "4000b935a5bc30b4c757fde69d27716fa3c2c269";
57 		urlDigests["https://sourceforge.net/projects/mingw/files/MSYS/Base/libiconv/libiconv-1.14-1/libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma"                           ] = "056d16bfb7a91c3e3b1acf8adb20edea6fceecdd";
58 		urlDigests["https://sourceforge.net/projects/mingw/files/MSYS/Base/termcap/termcap-0.20050421_1-2/libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma"           ] = "e4273ccfde8ecf3a7631446fb2b01971a24ff9f7";
59 		urlDigests["https://sourceforge.net/projects/mingw/files/MSYS/Base/regex/regex-1.20090805-2/libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma"                     ] = "d95faa144cf06625b3932a8e84ed1a6ab6bbe644";
60 		urlDigests["https://sourceforge.net/projects/mingw/files/MSYS/Base/coreutils/coreutils-5.97-3/coreutils-5.97-3-msys-1.0.13-bin.tar.lzma"                          ] = "54ac256a8f0c6a89f1b3c7758f3703b4e56382be";
61 		urlDigests["https://sourceforge.net/projects/mingw/files/MSYS/Base/bash/bash-3.1.23-1/bash-3.1.23-1-msys-1.0.18-bin.tar.xz"                                       ] = "b6ef3399b8d76b5fbbd0a88774ebc2a90e8af13a";
62 		urlDigests["https://sourceforge.net/projects/mingw/files/MSYS/Base/make/make-3.81-3/make-3.81-3-msys-1.0.13-bin.tar.lzma"                                         ] = "c7264eb13b05cf2e1a982a3c2619837b96203a27";
63 		urlDigests["https://sourceforge.net/projects/mingw/files/MSYS/Base/grep/grep-2.5.4-2/grep-2.5.4-2-msys-1.0.13-bin.tar.lzma"                                       ] = "69d03c4415c55b9617850a4991d0708fbe3788f6";
64 		urlDigests["https://sourceforge.net/projects/mingw/files/MSYS/Base/sed/sed-4.2.1-2/sed-4.2.1-2-msys-1.0.13-bin.tar.lzma"                                          ] = "ced60ab96ab3f713da0d0a570232f2a5f0ec5270";
65 		urlDigests["https://sourceforge.net/projects/mingw/files/MSYS/Base/diffutils/diffutils-2.8.7.20071206cvs-3/diffutils-2.8.7.20071206cvs-3-msys-1.0.13-bin.tar.lzma"] = "674d3e0be4c8ffe84290f48ed1dd8eb21bc3f805";
66 	}
67 }
68 
69 /// Definitions for some MSYS components.
70 struct MSYS
71 {
72 	alias msysCORE   = singleton!(MSYSComponent, "msysCORE"  , "bin/msys-1.0.dll"      , "https://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.18-1/msysCORE-1.0.18-1-msys-1.0.18-bin.tar.lzma"                             ); ///
73 	alias libintl    = singleton!(MSYSComponent, "libintl"   , "bin/msys-intl-8.dll"   , "https://sourceforge.net/projects/mingw/files/MSYS/Base/gettext/gettext-0.18.1.1-1/libintl-0.18.1.1-1-msys-1.0.17-dll-8.tar.lzma"                       ); ///
74 	alias libiconv   = singleton!(MSYSComponent, "libiconv"  , "bin/msys-iconv-2.dll"  , "https://sourceforge.net/projects/mingw/files/MSYS/Base/libiconv/libiconv-1.14-1/libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma"                            ); ///
75 	alias libtermcap = singleton!(MSYSComponent, "libtermcap", "bin/msys-termcap-0.dll", "https://sourceforge.net/projects/mingw/files/MSYS/Base/termcap/termcap-0.20050421_1-2/libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma"            ); ///
76 	alias libregex   = singleton!(MSYSComponent, "libregex"  , "bin/msys-regex-1.dll"  , "https://sourceforge.net/projects/mingw/files/MSYS/Base/regex/regex-1.20090805-2/libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma"                      ); ///
77 
78 	alias coreutils  = singleton!(MSYSComponent, "coreutils" , "bin/true.exe"          , "https://sourceforge.net/projects/mingw/files/MSYS/Base/coreutils/coreutils-5.97-3/coreutils-5.97-3-msys-1.0.13-bin.tar.lzma"                           ); ///
79 	alias bash       = singleton!(MSYSComponent, "bash"      , "bin/bash.exe"          , "https://sourceforge.net/projects/mingw/files/MSYS/Base/bash/bash-3.1.23-1/bash-3.1.23-1-msys-1.0.18-bin.tar.xz"                                        ); ///
80 	alias make       = singleton!(MSYSComponent, "make"      , "bin/make.exe"          , "https://sourceforge.net/projects/mingw/files/MSYS/Base/make/make-3.81-3/make-3.81-3-msys-1.0.13-bin.tar.lzma"                                          ); ///
81 	alias grep       = singleton!(MSYSComponent, "grep"      , "bin/grep.exe"          , "https://sourceforge.net/projects/mingw/files/MSYS/Base/grep/grep-2.5.4-2/grep-2.5.4-2-msys-1.0.13-bin.tar.lzma"                                        ); ///
82 	alias sed        = singleton!(MSYSComponent, "sed"       , "bin/sed.exe"           , "https://sourceforge.net/projects/mingw/files/MSYS/Base/sed/sed-4.2.1-2/sed-4.2.1-2-msys-1.0.13-bin.tar.lzma"                                           ); ///
83 	alias diffutils  = singleton!(MSYSComponent, "diffutils" , "bin/diff.exe"          , "https://sourceforge.net/projects/mingw/files/MSYS/Base/diffutils/diffutils-2.8.7.20071206cvs-3/diffutils-2.8.7.20071206cvs-3-msys-1.0.13-bin.tar.lzma" ); ///
84 }