mirror of
https://git.tuxpa.in/a/code-server.git
synced 2024-12-27 20:55:25 +00:00
Move upx compression behind an env flag
This commit is contained in:
parent
3e9d86ee91
commit
8bab787804
@ -40,22 +40,24 @@ const buildServerBinaryPackage = register("build:server:binary:package", async (
|
|||||||
});
|
});
|
||||||
|
|
||||||
const dependencyNexeBinary = register("dependency:nexe", async (runner) => {
|
const dependencyNexeBinary = register("dependency:nexe", async (runner) => {
|
||||||
if (os.platform() === "linux") {
|
if (os.platform() === "linux" && process.env.COMPRESS === "true") {
|
||||||
|
// Download the nexe binary so we can compress it before nexe runs. If we
|
||||||
|
// don't want compression we don't need to do anything since nexe will take
|
||||||
|
// care of getting the binary.
|
||||||
const nexeDir = path.join(os.homedir(), ".nexe");
|
const nexeDir = path.join(os.homedir(), ".nexe");
|
||||||
const targetBinaryName = `${os.platform()}-${os.arch()}-${process.version.substr(1)}`;
|
const targetBinaryName = `${os.platform()}-${os.arch()}-${process.version.substr(1)}`;
|
||||||
const targetBinaryPath = path.join(nexeDir, targetBinaryName);
|
const targetBinaryPath = path.join(nexeDir, targetBinaryName);
|
||||||
if (!fs.existsSync(targetBinaryPath)) {
|
if (!fs.existsSync(targetBinaryPath)) {
|
||||||
/**
|
|
||||||
* We create a binary with nexe
|
|
||||||
* so we can compress it
|
|
||||||
*/
|
|
||||||
fse.mkdirpSync(nexeDir);
|
fse.mkdirpSync(nexeDir);
|
||||||
runner.cwd = nexeDir;
|
runner.cwd = nexeDir;
|
||||||
await runner.execute("wget", [`https://github.com/nexe/nexe/releases/download/v3.0.0-beta.15/${targetBinaryName}`]);
|
await runner.execute("wget", [`https://github.com/nexe/nexe/releases/download/v3.0.0-beta.15/${targetBinaryName}`]);
|
||||||
await runner.execute("chmod", ["+x", targetBinaryPath]);
|
await runner.execute("chmod", ["+x", targetBinaryPath]);
|
||||||
}
|
}
|
||||||
|
// Compress with upx if it doesn't already look compressed.
|
||||||
if (fs.statSync(targetBinaryPath).size >= 20000000) {
|
if (fs.statSync(targetBinaryPath).size >= 20000000) {
|
||||||
// Compress w/ upx
|
// It needs to be executable for upx to work, which it might not be if
|
||||||
|
// nexe downloaded it.
|
||||||
|
fs.chmodSync(targetBinaryPath, "755");
|
||||||
const upxFolder = path.join(os.tmpdir(), "upx");
|
const upxFolder = path.join(os.tmpdir(), "upx");
|
||||||
const upxBinary = path.join(upxFolder, "upx");
|
const upxBinary = path.join(upxFolder, "upx");
|
||||||
if (!fs.existsSync(upxBinary)) {
|
if (!fs.existsSync(upxBinary)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user