Skip to content

Commit 80050d0

Browse files
committed
Detect target automatically
This removes the potential for a bad build because the native Node modules currently can only be built on the target system, so specifying a target for something other than the system your are building on will not work.
1 parent c2be0ec commit 80050d0

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

scripts/ci.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function docker-build() {
2626

2727
function docker-exec() {
2828
local command="${1}" ; shift
29-
local args="'${vscodeVersion}' '${codeServerVersion}' '${target}'"
29+
local args="'${vscodeVersion}' '${codeServerVersion}'"
3030
docker exec "${containerId}" \
3131
bash -c "cd /src && CI=true GITHUB_TOKEN=${token} MINIFY=${minify} yarn ${command} ${args}"
3232
}

scripts/tasks.bash

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function in-vscode () {
212212
if [[ ! -f "${maybeVsCode}/package.json" ]] ; then
213213
return 1
214214
fi
215-
if ! grep '"name": "code-oss-dev"' "${maybeVsCode}/package.json" --quiet ; then
215+
if ! grep '"name": "code-oss-dev"' "${maybeVsCode}/package.json" -q ; then
216216
return 1
217217
fi
218218
return 0
@@ -264,17 +264,24 @@ function main() {
264264
local codeServerVersion="${1}" ; shift
265265
local ci="${CI:-}"
266266
local minify="${MINIFY:-}"
267+
267268
local arch
268269
arch=$(uname -m)
269-
local target="${1:-}"
270-
if [[ -z "${target}" ]] ; then
271-
local ostype="${OSTYPE:-}"
272-
if [[ "${ostype}" == "darwin"* ]] ; then
273-
target="darwin"
274-
else
275-
target="linux"
270+
271+
local target="linux"
272+
local ostype="${OSTYPE:-}"
273+
if [[ "${ostype}" == "darwin"* ]] ; then
274+
target="darwin"
275+
else
276+
# On Alpine there seems no way to get the version except to use an invalid
277+
# command which will output the version to stderr and exit with 1.
278+
local output
279+
output=$(ldd --version 2>&1 || :)
280+
if [[ "${output}" == "musl"* ]] ; then
281+
target="alpine"
276282
fi
277283
fi
284+
278285
local binaryName="code-server${codeServerVersion}-vsc${vscodeVersion}-${target}-${arch}"
279286
local buildPath="${stagingPath}/${binaryName}-built"
280287

src/update.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ export class UpdateService extends AbstractUpdateService {
124124
private async buildReleaseName(release: string): Promise<string> {
125125
let target: string = os.platform();
126126
if (target === "linux") {
127-
const result = await util.promisify(cp.exec)("ldd --version");
128-
if (result.stderr) {
129-
throw new Error(result.stderr);
130-
}
131-
if (result.stdout.indexOf("musl") !== -1) {
127+
const result = await util.promisify(cp.exec)("ldd --version").catch((error) => ({
128+
stderr: error.message,
129+
stdout: "",
130+
}));
131+
if (result.stderr.indexOf("musl") !== -1 || result.stdout.indexOf("musl") !== -1) {
132132
target = "alpine";
133133
}
134134
}

0 commit comments

Comments
 (0)