diff --git a/api/src/job.js b/api/src/job.js index d46120b..8c3fa79 100644 --- a/api/src/job.js +++ b/api/src/job.js @@ -156,7 +156,11 @@ class Job { '-s', '-c', '/box/submission', - '-e', + '-E', + 'HOME=/tmp', + ...this.runtime.env_vars.flat_map(v => ['-E', v]), + '-E', + `PISTON_LANGUAGE=${this.runtime.language}`, `--dir=${this.runtime.pkgdir}`, `--dir=/etc:noexec`, `--processes=${this.runtime.max_process_count}`, @@ -175,10 +179,6 @@ class Job { ...args, ], { - env: { - ...this.runtime.env_vars, - PISTON_LANGUAGE: this.runtime.language, - }, stdio: 'pipe', } ); diff --git a/api/src/runtime.js b/api/src/runtime.js index 9a2adf4..90a2225 100644 --- a/api/src/runtime.js +++ b/api/src/runtime.js @@ -178,15 +178,7 @@ class Runtime { const env_file = path.join(this.pkgdir, '.env'); const env_content = fss.read_file_sync(env_file).toString(); - this._env_vars = {}; - - env_content - .trim() - .split('\n') - .map(line => line.split('=', 2)) - .forEach(([key, val]) => { - this._env_vars[key.trim()] = val.trim(); - }); + this._env_vars = env_content.trim().split('\n'); } return this._env_vars; diff --git a/packages/node/22.4.0/build.sh b/packages/node/22.4.0/build.sh new file mode 100644 index 0000000..958f46f --- /dev/null +++ b/packages/node/22.4.0/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash +curl "https://nodejs.org/dist/v22.4.0/node-v22.4.0-linux-x64.tar.xz" -o node.tar.xz +tar xf node.tar.xz --strip-components=1 +rm node.tar.xz \ No newline at end of file diff --git a/packages/node/22.4.0/environment b/packages/node/22.4.0/environment new file mode 100644 index 0000000..bd0ff98 --- /dev/null +++ b/packages/node/22.4.0/environment @@ -0,0 +1 @@ +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/node/22.4.0/metadata.json b/packages/node/22.4.0/metadata.json new file mode 100644 index 0000000..de73d3c --- /dev/null +++ b/packages/node/22.4.0/metadata.json @@ -0,0 +1,10 @@ +{ + "language": "node", + "version": "22.4.0", + "provides": [ + { + "language": "javascript", + "aliases": ["node-javascript", "node-js", "javascript", "js"] + } + ] +} \ No newline at end of file diff --git a/packages/node/22.4.0/run b/packages/node/22.4.0/run new file mode 100644 index 0000000..6d1fdee --- /dev/null +++ b/packages/node/22.4.0/run @@ -0,0 +1,3 @@ +#!/bin/bash + +node "$@" \ No newline at end of file diff --git a/packages/node/22.4.0/test.js b/packages/node/22.4.0/test.js new file mode 100644 index 0000000..c963843 --- /dev/null +++ b/packages/node/22.4.0/test.js @@ -0,0 +1 @@ +console.log('OK'); \ No newline at end of file diff --git a/packages/typescript/5.5.3/build.sh b/packages/typescript/5.5.3/build.sh new file mode 100644 index 0000000..9eedc54 --- /dev/null +++ b/packages/typescript/5.5.3/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source ../../node/22.4.0/build.sh + +source ./environment + +bin/npm install -g typescript@5.5.3 \ No newline at end of file diff --git a/packages/typescript/5.5.3/compile b/packages/typescript/5.5.3/compile new file mode 100644 index 0000000..d674bb0 --- /dev/null +++ b/packages/typescript/5.5.3/compile @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# Put instructions to compile source code, remove this file if the language does not require this stage + +rename 's/$/\.ts/' "$@" # Add .ts extension + +tsc *.ts \ No newline at end of file diff --git a/packages/typescript/5.5.3/environment b/packages/typescript/5.5.3/environment new file mode 100644 index 0000000..c6ab089 --- /dev/null +++ b/packages/typescript/5.5.3/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Put 'export' statements here for environment variables +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/typescript/5.5.3/metadata.json b/packages/typescript/5.5.3/metadata.json new file mode 100644 index 0000000..94013bf --- /dev/null +++ b/packages/typescript/5.5.3/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "typescript", + "version": "5.5.3", + "aliases": ["ts", "node-ts", "tsc", "typescript5", "ts5"] +} \ No newline at end of file diff --git a/packages/typescript/5.5.3/run b/packages/typescript/5.5.3/run new file mode 100644 index 0000000..4ce91c5 --- /dev/null +++ b/packages/typescript/5.5.3/run @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# Put instructions to run the runtime + +CODE=$1.js +shift + +node $CODE "$@" \ No newline at end of file diff --git a/packages/typescript/5.5.3/test.ts b/packages/typescript/5.5.3/test.ts new file mode 100644 index 0000000..c963843 --- /dev/null +++ b/packages/typescript/5.5.3/test.ts @@ -0,0 +1 @@ +console.log('OK'); \ No newline at end of file