1 /**
2  * DMD 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.dmd;
15 
16 import std.array;
17 import std.conv;
18 import std.exception;
19 import std.file;
20 import std.string;
21 import std.path;
22 
23 import ae.sys.archive;
24 import ae.sys.file;
25 import ae.utils.meta : singleton, I;
26 
27 public import ae.sys.install.common;
28 
29 class DMDInstaller : Installer
30 {
31 	string dmdVersion;
32 
33 	this(string v = currentVersion)
34 	{
35 		dmdVersion = v;
36 	}
37 
38 	// Note: we can't get the dot-release version. Assume ".0".
39 	enum currentVersion = text(__VERSION__)[0] ~ "." ~ text(__VERSION__)[1..$] ~ ".0";
40 
41 	version (Windows)
42 		enum modelString = "";
43 	else
44 	version (OSX)
45 		enum modelString = "";
46 	else
47 	version (D_LP64)
48 		enum modelString = "64";
49 	else
50 		enum modelString = "32";
51 
52 	version (Windows)
53 	{
54 		enum platformDir = "windows";
55 		enum platformSuffix = "windows";
56 	}
57 	else version (linux)
58 	{
59 		enum platformDir = "linux";
60 		enum platformSuffix = "linux";
61 	}
62 	else	version (FreeBSD)
63 	{
64 		enum platformDir = "freebsd";
65 		enum platformSuffix = "freebsd-"~modelString;
66 	}
67 	else	version (OSX)
68 	{
69 		enum platformDir = "osx";
70 		enum platformSuffix = "osx";
71 	}
72 	else
73 		static assert(false, "Unknown platform");
74 
75 	@property override string name() { return "DigitalMars D compiler v" ~ dmdVersion; }
76 	@property override string subdirectory() { return "dmd-" ~ dmdVersion; }
77 
78 	@property override string[] requiredExecutables() { return ["dmd"]; }
79 	@property override string[] binPaths() { return ["dmd2/" ~ platformDir ~ "/bin" ~ modelString]; }
80 
81 	@property string url() { return "http://downloads.dlang.org/releases/%s.x/%s/dmd.%s.%s.zip".format(
82 		dmdVersion[0], dmdVersion, dmdVersion, platformSuffix); }
83 
84 	override void installImpl(string target)
85 	{
86 		url
87 			.I!save()
88 			.I!unpackTo(target);
89 	}
90 
91 	static this()
92 	{
93 		urlDigests["http://downloads.dlang.org/releases/2.x/2.065.0/dmd.2.065.0.windows.zip"   ] = "d79b92cf4c7ccb01ebbb5f7ded8e583081391781";
94 		urlDigests["http://downloads.dlang.org/releases/2.x/2.065.0/dmd.2.065.0.linux.zip"	   ] = "53c28075672aca183d6247a80a163e10084c9add";
95 		urlDigests["http://downloads.dlang.org/releases/2.x/2.065.0/dmd.2.065.0.freebsd-32.zip"] = "1df3915ea9ced62da504ec50de98148a1b22e4dc";
96 		urlDigests["http://downloads.dlang.org/releases/2.x/2.065.0/dmd.2.065.0.freebsd-64.zip"] = "bc7a41eb0cec3e766954010a873e8c414b210f40";
97 		urlDigests["http://downloads.dlang.org/releases/2.x/2.065.0/dmd.2.065.0.osx.zip"	   ] = "bf0f03a14b52ee964e8732200dd4d21064260a39";
98 		urlDigests["http://downloads.dlang.org/releases/2.x/2.066.0/dmd.2.066.0.windows.zip"   ] = "987b9a505c4598b204bee09f646eab571c6aaf00";
99 		urlDigests["http://downloads.dlang.org/releases/2.x/2.066.0/dmd.2.066.0.linux.zip"	   ] = "c63d4cb4c8ce704689249d5a81fd4d97d9c0084e";
100 		urlDigests["http://downloads.dlang.org/releases/2.x/2.066.0/dmd.2.066.0.freebsd-32.zip"] = "7d0d4e4e499a76ce1717f48ab7d781dd48a60260";
101 		urlDigests["http://downloads.dlang.org/releases/2.x/2.066.0/dmd.2.066.0.freebsd-64.zip"] = "e835228d7ad486623d2f491576ab2f0d0e9973a9";
102 		urlDigests["http://downloads.dlang.org/releases/2.x/2.066.0/dmd.2.066.0.osx.zip"	   ] = "063f984f7d23f24bc9096227431c38ed5f52dbe5";
103 		urlDigests["http://downloads.dlang.org/releases/2.x/2.066.1/dmd.2.066.1.windows.zip"   ] = "1e1c73f67e0a2c6de92d4644036692e07cab1346";
104 		urlDigests["http://downloads.dlang.org/releases/2.x/2.066.1/dmd.2.066.1.linux.zip"	   ] = "65debddc874c1be5ce99ec24fa6ed422eb52288e";
105 		urlDigests["http://downloads.dlang.org/releases/2.x/2.066.1/dmd.2.066.1.freebsd-32.zip"] = "de00c316b6500e47fe36de1b9790b448b773278a";
106 		urlDigests["http://downloads.dlang.org/releases/2.x/2.066.1/dmd.2.066.1.freebsd-64.zip"] = "4ab95f1e7af851808855fe0c89b5a3ac368f0640";
107 		urlDigests["http://downloads.dlang.org/releases/2.x/2.066.1/dmd.2.066.1.osx.zip"	   ] = "7e97fcf5f0d7b337e4c2bbfb5b9ad1438566c95d";
108 		urlDigests["http://downloads.dlang.org/releases/2.x/2.067.0/dmd.2.067.0.windows.zip"   ] = "2b7e9cf49dd80d59f68062f8d7e38d18c23a61e4";
109 		urlDigests["http://downloads.dlang.org/releases/2.x/2.067.0/dmd.2.067.0.linux.zip"	   ] = "11f6936121e49dabebd2ddcb84b06b8ffb999a98";
110 		urlDigests["http://downloads.dlang.org/releases/2.x/2.067.0/dmd.2.067.0.freebsd-32.zip"] = "189ed0d94b4440464ed9be2adc6ec901b84df204";
111 		urlDigests["http://downloads.dlang.org/releases/2.x/2.067.0/dmd.2.067.0.freebsd-64.zip"] = "ba572366e2720217a12862d91c171be6a6cabc9b";
112 		urlDigests["http://downloads.dlang.org/releases/2.x/2.067.0/dmd.2.067.0.osx.zip"	   ] = "41b6118cc1f9b7d2c671e4e3498d0b0f7e38ca8c";
113 		urlDigests["http://downloads.dlang.org/releases/2.x/2.067.1/dmd.2.067.1.windows.zip"   ] = "8ea799291320f61fbfc0618351af6adf10107334";
114 		urlDigests["http://downloads.dlang.org/releases/2.x/2.067.1/dmd.2.067.1.linux.zip"	   ] = "2c158da0ac406877b8934487518aded785ef3439";
115 		urlDigests["http://downloads.dlang.org/releases/2.x/2.067.1/dmd.2.067.1.freebsd-32.zip"] = "ea850992ad533b6709fe8bca8cf5d19fd6ddf698";
116 		urlDigests["http://downloads.dlang.org/releases/2.x/2.067.1/dmd.2.067.1.freebsd-64.zip"] = "68bde60035813c07958abb248accce48026ec081";
117 		urlDigests["http://downloads.dlang.org/releases/2.x/2.067.1/dmd.2.067.1.osx.zip"	   ] = "bb2beb054e6feb67288a912ab62acbc685132091";
118 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.0/dmd.2.068.0.windows.zip"   ] = "7f3ddcdc19df81780a255652d0559bbe1780572e";
119 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.0/dmd.2.068.0.linux.zip"	   ] = "dede88e477919a825713c95dede44690aa5fa46d";
120 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.0/dmd.2.068.0.freebsd-32.zip"] = "6daba7d8683df92c5a120ba8d61d7300c251d98a";
121 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.0/dmd.2.068.0.freebsd-64.zip"] = "ccb985ef933f99fd8620c197ecbbfc92541c4572";
122 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.0/dmd.2.068.0.osx.zip"	   ] = "2831b535909bd82ca2fe711fda4c35c34198ebcd";
123 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.1/dmd.2.068.1.windows.zip"   ] = "6ad214fab50a6d679bb0e847a6efbb6c95635ac5";
124 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.1/dmd.2.068.1.linux.zip"	   ] = "8b5237fd80c635859da36a673a6c52b357fdf26f";
125 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.1/dmd.2.068.1.freebsd-32.zip"] = "6387f3b70713a953b68c02b1b442098bd5eec354";
126 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.1/dmd.2.068.1.freebsd-64.zip"] = "ba65233459f97a2a2c2b4c02b1308e61350e7426";
127 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.1/dmd.2.068.1.osx.zip"	   ] = "2917fd6663f928e4523d952df29af1d86dddd9d0";
128 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.2/dmd.2.068.2.windows.zip"   ] = "747b5e805276a706d15f0d36c62be88830eab77a";
129 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.2/dmd.2.068.2.linux.zip"	   ] = "814640bb81665695e807d8b6e61acec2a0630bb8";
130 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.2/dmd.2.068.2.freebsd-32.zip"] = "e4a2eaf083bfb38f2c3d5450afd5af643c8bd39b";
131 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.2/dmd.2.068.2.freebsd-64.zip"] = "f561f6970924b4ace870e45b2300eceba21a2ffc";
132 		urlDigests["http://downloads.dlang.org/releases/2.x/2.068.2/dmd.2.068.2.osx.zip"	   ] = "db7b9be84ee2413b82c26db415df099422c8c867";
133 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.0/dmd.2.069.0.windows.zip"   ] = "4fa12a1ee224b0400bd6a3c969f461019848dd8c";
134 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.0/dmd.2.069.0.linux.zip"	   ] = "2368cd7c98bdd7aa147cfee790223190eea9a2fb";
135 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.0/dmd.2.069.0.freebsd-32.zip"] = "b05f367b2169fdc07fbdfe0a7a305e2c3b702832";
136 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.0/dmd.2.069.0.freebsd-64.zip"] = "72c249e35cd2fb55d5f3f79f6211e1c798336250";
137 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.0/dmd.2.069.0.osx.zip"	   ] = "f4306fe519d6752e1879477cae6b0637a0bafca2";
138 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.1/dmd.2.069.1.windows.zip"   ] = "0e4630114b17971608cdf961eae6680d4b1b0b9a";
139 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.1/dmd.2.069.1.linux.zip"	   ] = "982f5d2063d6f9cf242c4c8e38b001a4c0b5d4db";
140 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.1/dmd.2.069.1.freebsd-32.zip"] = "c3268a4aefe7406c5b31ed56065d56e7401fb32d";
141 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.1/dmd.2.069.1.freebsd-64.zip"] = "7fd2c1dbadcf123665251aee3a24d3741989da12";
142 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.1/dmd.2.069.1.osx.zip"	   ] = "244e0b374c17e13d81e596174467a8166c30ee06";
143 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.2/dmd.2.069.2.windows.zip"   ] = "dd95c861bad2ce3bbd0d6882b92d75442550e28c";
144 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.2/dmd.2.069.2.linux.zip"	   ] = "84e7f58ead856c3ca06b885ac04a4f466154a0d0";
145 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.2/dmd.2.069.2.freebsd-32.zip"] = "affbca67d6a57d4a5f18d6c119a5cf47f72f9f81";
146 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.2/dmd.2.069.2.freebsd-64.zip"] = "caaefacc577e4d5c845a6566d6aeace4905b04a7";
147 		urlDigests["http://downloads.dlang.org/releases/2.x/2.069.2/dmd.2.069.2.osx.zip"	   ] = "222ffcfe59480c9883d7419d9a8a50754d4edcb6";
148 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.0/dmd.2.070.0.windows.zip"   ] = "6365e2138840035b4c1df9bcffd6126124675dcb";
149 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.0/dmd.2.070.0.linux.zip"	   ] = "780101d03d089befad5d6975312deda2428b8ebf";
150 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.0/dmd.2.070.0.freebsd-32.zip"] = "7622975da880a5006c1201d546af6173b7868727";
151 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.0/dmd.2.070.0.freebsd-64.zip"] = "c38bd62116a3bd5daa2ffb515ccad7c1b816bfb1";
152 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.0/dmd.2.070.0.osx.zip"	   ] = "f1b712cbcf9753e6320c318093c96be37141ae0b";
153 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.1/dmd.2.070.1.windows.zip"   ] = "26044ebcfade1051b53dd1c0e14744f661e1acd6";
154 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.1/dmd.2.070.1.linux.zip"	   ] = "7ce6142279fa8f0240d7f9b6f11fbc83bb7f10b4";
155 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.1/dmd.2.070.1.freebsd-32.zip"] = "494c8c70d2565661f2414639af42325ef164602b";
156 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.1/dmd.2.070.1.freebsd-64.zip"] = "b046449663d25179b0eb8eb703a9c0942529b9e8";
157 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.1/dmd.2.070.1.osx.zip"	   ] = "0b128a5f50167bc1943a7272eca0eda086cb87fd";
158 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.2/dmd.2.070.2.windows.zip"   ] = "bfa0348c85174657ff2f7b0e8370b36d8e7f0a76";
159 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.2/dmd.2.070.2.linux.zip"	   ] = "4eeca47bc5a1bc1a38f91615218e05aa6dad7711";
160 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.2/dmd.2.070.2.freebsd-32.zip"] = "bc60574bd392bb7b42ec10282e2fa33491ba9d56";
161 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.2/dmd.2.070.2.freebsd-64.zip"] = "e0bd7c727d8bc5a3df3b5a70402dba24ce16c5ab";
162 		urlDigests["http://downloads.dlang.org/releases/2.x/2.070.2/dmd.2.070.2.osx.zip"	   ] = "578114de8ae5f89cfd9275f340be26494fa05a38";
163 		urlDigests["http://downloads.dlang.org/releases/2.x/2.071.0/dmd.2.071.0.windows.zip"   ] = "ac8b4167b077f6d09701d5135a5f061788587310";
164 		urlDigests["http://downloads.dlang.org/releases/2.x/2.071.0/dmd.2.071.0.linux.zip"	   ] = "8ee9713be14ef2fe6024b3f93e24667d8a2a3d47";
165 		urlDigests["http://downloads.dlang.org/releases/2.x/2.071.0/dmd.2.071.0.freebsd-32.zip"] = "6a9e57384c4afbe9888dcb44c9878320ab9be15e";
166 		urlDigests["http://downloads.dlang.org/releases/2.x/2.071.0/dmd.2.071.0.freebsd-64.zip"] = "76cfe16e1c617aba360a5d855a85d42b7c9f7072";
167 		urlDigests["http://downloads.dlang.org/releases/2.x/2.071.0/dmd.2.071.0.osx.zip"	   ] = "ac8cf92505414858d5a9b91d03bae9eebc8c58c8";
168 	}
169 }
170 
171 alias dmdInstaller = singleton!DMDInstaller;