Skip to content

Commit 49fc43b

Browse files
committed
Add script for discovering OpenSSL dependencies from Conan
1 parent 371c67e commit 49fc43b

File tree

4 files changed

+279
-1
lines changed

4 files changed

+279
-1
lines changed

lifecycleScripts/configureLibssh2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var rooted = function (dir) {
99
var isWin64 = function() {
1010
return process.platform === "win32" && (
1111
process.arch === "x64" ||
12-
process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")
12+
process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")
1313
);
1414
};
1515

package-lock.json

Lines changed: 116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"aws-sdk": "^2.3.19",
5050
"babel-cli": "^6.7.7",
5151
"babel-preset-es2015": "^6.6.0",
52+
"cheerio": "^1.0.0-rc.2",
5253
"clean-for-publish": "~1.0.2",
5354
"combyne": "~0.8.1",
5455
"coveralls": "^3.0.2",
@@ -57,6 +58,8 @@
5758
"jshint": "^2.9.6",
5859
"lcov-result-merger": "^3.1.0",
5960
"mocha": "^5.2.0",
61+
"ramda": "^0.25.0",
62+
"request-promise-native": "^1.0.5",
6063
"walk": "^2.3.9"
6164
},
6265
"vendorDependencies": {

utils/discoverOpenSSLDeps.js

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
const cheerio = require('cheerio');
2+
const fse = require('fs-extra');
3+
const path = require('path');
4+
const R = require('ramda');
5+
const request = require('request-promise-native');
6+
7+
const windowsCommonConditions = [
8+
R.test(/os=Windows$/gm),
9+
R.test(/shared=False$/gm)
10+
]
11+
12+
const macCommonConditions = [
13+
R.test(/arch=x86_64$/gm),
14+
R.test(/os=Macos$/gm),
15+
R.test(/compiler=apple-clang$/gm),
16+
R.test(/shared=False$/gm)
17+
];
18+
19+
const debugPairs = R.toPairs({
20+
'win32-vs12-static-debug': R.allPass([
21+
...windowsCommonConditions,
22+
R.test(/arch=x86$/gm),
23+
R.test(/build_type=Debug$/gm),
24+
R.test(/compiler\.version=12$/gm)
25+
]),
26+
'win32-vs14-static-debug': R.allPass([
27+
...windowsCommonConditions,
28+
R.test(/arch=x86$/gm),
29+
R.test(/build_type=Debug$/gm),
30+
R.test(/compiler\.version=14$/gm)
31+
]),
32+
'win32-vs15-static-debug': R.allPass([
33+
...windowsCommonConditions,
34+
R.test(/arch=x86$/gm),
35+
R.test(/build_type=Debug$/gm),
36+
R.test(/compiler\.version=15$/gm)
37+
]),
38+
39+
'win64-vs12-static-debug': R.allPass([
40+
...windowsCommonConditions,
41+
R.test(/arch=x86_64$/gm),
42+
R.test(/build_type=Debug$/gm),
43+
R.test(/compiler\.version=12$/gm)
44+
]),
45+
'win64-vs14-static-debug': R.allPass([
46+
...windowsCommonConditions,
47+
R.test(/arch=x86_64$/gm),
48+
R.test(/build_type=Debug$/gm),
49+
R.test(/compiler\.version=14$/gm)
50+
]),
51+
'win64-vs15-static-debug': R.allPass([
52+
...windowsCommonConditions,
53+
R.test(/arch=x86_64$/gm),
54+
R.test(/build_type=Debug$/gm),
55+
R.test(/compiler\.version=15$/gm)
56+
]),
57+
58+
'macOS-clang-9-static-debug': R.allPass([
59+
...macCommonConditions,
60+
R.test(/build_type=Debug$/gm),
61+
R.test(/compiler\.version=9.0$/gm)
62+
]),
63+
'macOS-clang-8.1-static-debug': R.allPass([
64+
...macCommonConditions,
65+
R.test(/build_type=Debug$/gm),
66+
R.test(/compiler\.version=8\.1$/gm)
67+
])
68+
})
69+
70+
const releasePairs = R.toPairs({
71+
'win32-vs12-static': R.allPass([
72+
...windowsCommonConditions,
73+
R.test(/arch=x86$/gm),
74+
R.test(/build_type=Release$/gm),
75+
R.test(/compiler\.version=12$/gm)
76+
]),
77+
'win32-vs14-static': R.allPass([
78+
...windowsCommonConditions,
79+
R.test(/arch=x86$/gm),
80+
R.test(/build_type=Release$/gm),
81+
R.test(/compiler\.version=14$/gm)
82+
]),
83+
'win32-vs15-static': R.allPass([
84+
...windowsCommonConditions,
85+
R.test(/arch=x86$/gm),
86+
R.test(/build_type=Release$/gm),
87+
R.test(/compiler\.version=15$/gm)
88+
]),
89+
90+
'win64-vs12-static': R.allPass([
91+
...windowsCommonConditions,
92+
R.test(/arch=x86_64$/gm),
93+
R.test(/build_type=Release$/gm),
94+
R.test(/compiler\.version=12$/gm)
95+
]),
96+
'win64-vs14-static': R.allPass([
97+
...windowsCommonConditions,
98+
R.test(/arch=x86_64$/gm),
99+
R.test(/build_type=Release$/gm),
100+
R.test(/compiler\.version=14$/gm)
101+
]),
102+
'win64-vs15-static': R.allPass([
103+
...windowsCommonConditions,
104+
R.test(/arch=x86_64$/gm),
105+
R.test(/build_type=Release$/gm),
106+
R.test(/compiler\.version=15$/gm)
107+
]),
108+
109+
'macOS-clang-9-static': R.allPass([
110+
...macCommonConditions,
111+
R.test(/build_type=Release$/gm),
112+
R.test(/compiler\.version=9.0$/gm)
113+
]),
114+
'macOS-clang-8.1-static': R.allPass([
115+
...macCommonConditions,
116+
R.test(/build_type=Release$/gm),
117+
R.test(/compiler\.version=8\.1$/gm)
118+
])
119+
});
120+
121+
const distributionPairs = [...debugPairs, ...releasePairs];
122+
123+
const detectDistributionPairFromConfig = (itemHash, body) => R.reduce(
124+
(acc, [releaseName, predicate]) => R.cond([
125+
[predicate, R.always([releaseName, itemHash])],
126+
[R.T, R.always(acc)]
127+
])(body),
128+
undefined,
129+
distributionPairs
130+
);
131+
132+
const getDistributionConfig = (itemHash) =>
133+
request.get(`https://bintray.com/conan-community/conan/download_file?file_path=conan%2FOpenSSL%2F1.1.0i%2Fstable%2Fpackage%2F${itemHash}%2Fconaninfo.txt`)
134+
.then((body) => detectDistributionPairFromConfig(itemHash, body));
135+
136+
const discoverDistributions = (treeHtml) => {
137+
const releaseHashes = [];
138+
139+
const $ = cheerio.load(treeHtml);
140+
const links = $('#treeBrowseTable > tbody > tr > td.nameCol > a');
141+
links.each((_, link) => {
142+
const releaseHash = link.children[0].data;
143+
if (!releaseHash) {
144+
return;
145+
}
146+
releaseHashes.push(releaseHash);
147+
});
148+
149+
return Promise.all(
150+
R.map(releaseHash => getDistributionConfig(releaseHash), releaseHashes)
151+
);
152+
}
153+
154+
request('https://bintray.com/package/files/conan-community/conan/OpenSSL%3Aconan?order=asc&sort=name&basePath=conan%2FOpenSSL%2F1.1.0i%2Fstable%2Fpackage&tab=files')
155+
.then(discoverDistributions)
156+
.then(R.filter(R.identity))
157+
.then(R.sortBy(R.prop(0)))
158+
.then(R.fromPairs)
159+
.then(distributions => fse.writeFile('openssl_distributions.json', JSON.stringify(distributions, null, 2)));

0 commit comments

Comments
 (0)