probbit 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install.js +28 -4
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -33,9 +33,28 @@ function binaryPath() {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
class ChecksumError extends Error {}
|
|
36
|
+
class UnsupportedError extends Error {}
|
|
37
|
+
|
|
38
|
+
// The x86_64 gnu build needs glibc >= 2.34 (release.yml); an older glibc (Debian 11, Ubuntu 20.04, RHEL 8) gets the static musl one
|
|
39
|
+
function glibcAtLeast(v, major, minor) {
|
|
40
|
+
const m = /^(\d+)\.(\d+)/.exec(String(v));
|
|
41
|
+
return !!m && (Number(m[1]) > major || (Number(m[1]) === major && Number(m[2]) >= minor));
|
|
42
|
+
}
|
|
36
43
|
|
|
37
44
|
async function get(url) {
|
|
38
|
-
|
|
45
|
+
let res;
|
|
46
|
+
try {
|
|
47
|
+
res = await fetch(url, { redirect: 'follow', signal: AbortSignal.timeout(30000) });
|
|
48
|
+
} catch (e) {
|
|
49
|
+
// Node's fetch goes direct unless NODE_USE_ENV_PROXY=1, even with HTTPS_PROXY set (npm's own proxy config does not apply)
|
|
50
|
+
const env = process.env;
|
|
51
|
+
const proxy = env.HTTPS_PROXY || env.https_proxy || env.HTTP_PROXY || env.http_proxy;
|
|
52
|
+
if (proxy && env.NODE_USE_ENV_PROXY !== '1') {
|
|
53
|
+
throw new Error(`${e.message}; a proxy is set but Node's fetch ignores it: retry with NODE_USE_ENV_PROXY=1 (recent Node releases), `
|
|
54
|
+
+ 'or download the archive yourself and reinstall with PROBBIT_BINARY=/path/to/probbit');
|
|
55
|
+
}
|
|
56
|
+
throw e;
|
|
57
|
+
}
|
|
39
58
|
if (!res.ok) throw new Error(`GET ${url}: HTTP ${res.status}`);
|
|
40
59
|
return Buffer.from(await res.arrayBuffer());
|
|
41
60
|
}
|
|
@@ -65,11 +84,11 @@ async function install(log = (m) => process.stderr.write(`${m}\n`)) {
|
|
|
65
84
|
return dest;
|
|
66
85
|
}
|
|
67
86
|
const glibc = process.platform === 'linux' && process.report && process.report.getReport().header.glibcVersionRuntime;
|
|
68
|
-
const detected = process.platform === 'linux' && process.arch === 'x64' && !glibc
|
|
87
|
+
const detected = process.platform === 'linux' && process.arch === 'x64' && !glibcAtLeast(glibc, 2, 34)
|
|
69
88
|
? 'x86_64-unknown-linux-musl' : TARGETS[`${process.platform}-${process.arch}`];
|
|
70
89
|
const target = env.PROBBIT_TARGET || detected;
|
|
71
90
|
if (!target) {
|
|
72
|
-
throw new
|
|
91
|
+
throw new UnsupportedError(`no prebuilt probbit for ${process.platform}-${process.arch}; build one (cargo build --release -p probbit-cli) `
|
|
73
92
|
+ 'and reinstall with PROBBIT_BINARY=/path/to/probbit');
|
|
74
93
|
}
|
|
75
94
|
let tag = env.PROBBIT_VERSION || `v${pkg.version}`;
|
|
@@ -105,10 +124,15 @@ async function install(log = (m) => process.stderr.write(`${m}\n`)) {
|
|
|
105
124
|
return dest;
|
|
106
125
|
}
|
|
107
126
|
|
|
108
|
-
module.exports = { install, binaryPath, ChecksumError };
|
|
127
|
+
module.exports = { install, binaryPath, ChecksumError, UnsupportedError };
|
|
109
128
|
|
|
110
129
|
if (require.main === module) {
|
|
111
130
|
install().catch((e) => {
|
|
131
|
+
if (e instanceof UnsupportedError) {
|
|
132
|
+
// not a network problem: a later run cannot fetch it either; npm install itself still succeeds
|
|
133
|
+
process.stderr.write(`probbit: ${e.message}\n`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
112
136
|
if (e instanceof ChecksumError) {
|
|
113
137
|
process.stderr.write(`probbit: ${e.message}; nothing was installed\n`);
|
|
114
138
|
process.exit(1);
|
package/package.json
CHANGED