Add support for musl and centos
This commit is contained in:
42
build/platform.ts
Normal file
42
build/platform.ts
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Script that detects platform name and arch.
|
||||
* Cannot use os.platform() as that won't detect libc version
|
||||
*/
|
||||
import * as cp from "child_process";
|
||||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
|
||||
enum Lib {
|
||||
GLIBC,
|
||||
MUSL,
|
||||
}
|
||||
|
||||
const CLIB: Lib | undefined = ((): Lib | undefined => {
|
||||
if (os.platform() !== "linux") {
|
||||
return;
|
||||
}
|
||||
const glibc = cp.spawnSync("getconf", ["GNU_LIBC_VERSION"]);
|
||||
if (glibc.status === 0) {
|
||||
return Lib.GLIBC;
|
||||
}
|
||||
|
||||
const ldd = cp.spawnSync("ldd", ["--version"]);
|
||||
if (ldd.stdout && ldd.stdout.indexOf("musl") !== -1) {
|
||||
return Lib.MUSL;
|
||||
}
|
||||
|
||||
const muslFile = fs.readdirSync("/lib").find((value) => value.startsWith("libc.musl"));
|
||||
if (muslFile) {
|
||||
return Lib.MUSL;
|
||||
}
|
||||
|
||||
return Lib.GLIBC;
|
||||
})();
|
||||
|
||||
export const platform = (): NodeJS.Platform | "musl" => {
|
||||
if (CLIB === Lib.MUSL) {
|
||||
return "musl";
|
||||
}
|
||||
|
||||
return os.platform();
|
||||
};
|
@ -2,6 +2,7 @@ import { register, run } from "@coder/runner";
|
||||
import * as fs from "fs";
|
||||
import * as fse from "fs-extra";
|
||||
import * as os from "os";
|
||||
import { platform } from "./platform";
|
||||
import * as path from "path";
|
||||
import * as zlib from "zlib";
|
||||
import * as https from "https";
|
||||
@ -180,12 +181,12 @@ register("package", async (runner, releaseTag) => {
|
||||
|
||||
const releasePath = path.resolve(__dirname, "../release");
|
||||
|
||||
const archiveName = `code-server${releaseTag}-${os.platform()}-${os.arch()}`;
|
||||
const archiveName = `code-server${releaseTag}-${platform()}-${os.arch()}`;
|
||||
const archiveDir = path.join(releasePath, archiveName);
|
||||
fse.removeSync(archiveDir);
|
||||
fse.mkdirpSync(archiveDir);
|
||||
|
||||
const binaryPath = path.join(__dirname, `../packages/server/cli-${os.platform()}-${os.arch()}`);
|
||||
const binaryPath = path.join(__dirname, `../packages/server/cli-${platform()}-${os.arch()}`);
|
||||
const binaryDestination = path.join(archiveDir, "code-server");
|
||||
fse.copySync(binaryPath, binaryDestination);
|
||||
fs.chmodSync(binaryDestination, "755");
|
||||
|
Reference in New Issue
Block a user