From 8bab787804912306821e50747699ce25ba1d22e9 Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 8 Mar 2019 12:00:47 -0600 Subject: [PATCH] Move upx compression behind an env flag --- build/tasks.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build/tasks.ts b/build/tasks.ts index 6367d8957..bd316e374 100644 --- a/build/tasks.ts +++ b/build/tasks.ts @@ -40,22 +40,24 @@ const buildServerBinaryPackage = register("build:server:binary:package", async ( }); 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 targetBinaryName = `${os.platform()}-${os.arch()}-${process.version.substr(1)}`; const targetBinaryPath = path.join(nexeDir, targetBinaryName); if (!fs.existsSync(targetBinaryPath)) { - /** - * We create a binary with nexe - * so we can compress it - */ fse.mkdirpSync(nexeDir); runner.cwd = nexeDir; await runner.execute("wget", [`https://github.com/nexe/nexe/releases/download/v3.0.0-beta.15/${targetBinaryName}`]); await runner.execute("chmod", ["+x", targetBinaryPath]); } + // Compress with upx if it doesn't already look compressed. 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 upxBinary = path.join(upxFolder, "upx"); if (!fs.existsSync(upxBinary)) {