From 35226ae5146104d23db6f0fe31f73cee24fe47ca Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sun, 3 Dec 2023 15:28:21 +0100 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ README.txt | 4 ++++ build.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++ uncompressed_modules | 7 ++++++ unpacker.js | 13 +++++++++++ 5 files changed, 79 insertions(+) create mode 100644 .gitignore create mode 100644 README.txt create mode 100755 build.sh create mode 100644 uncompressed_modules create mode 100644 unpacker.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..52068d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +svrjs +svrjs-temp diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..dff4650 --- /dev/null +++ b/README.txt @@ -0,0 +1,4 @@ +How to build SVR.JS? +1. Clone SVR.JS git repository using "git clone -b stable https://git.svrjs.org/git/svrjs.git". You can also copy git repository contents into "svrjs" directory. +2. Run "bash build.sh" +3. You now have SVR.JS zip archive! You can install it using SVR.JS installer for GNU/Linux. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..0386dba --- /dev/null +++ b/build.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +GLOBIGNORE=".:.." + +if ! [ -d svrjs ]; then + echo '"svrjs" directory is missing. You can obtain SVR.JS source ("svrjs" directory) using "git clone -b https://git.svrjs.org/git/svrjs.git" (where "" is a branch you want to clone).' + exit 1 +fi + +rm svr.js.*.zip + +pushd $(dirname $0) + +cp -a svrjs svrjs-temp +rm -rf svrjs-temp/.git +find svrjs-temp -name '.gitignore' -exec rm -f {} \; + +mkdir svrjs-temp/node_modules_uncompressed + +mv svrjs-temp/node_modules/.bin svrjs-temp/node_modules_uncompressed +for module in $(cat uncompressed_modules); do + mv svrjs-temp/node_modules/$module svrjs-temp/node_modules_uncompressed +done + +cd svrjs-temp/node_modules +tar -czf ../modules.compressed * +tar -uzf ../modules.compressed .* 2>/dev/null + +cd .. +rm -rf node_modules +mv node_modules_uncompressed node_modules + +SVRJSVERSION=$(cat svr.js | grep -E '^[ \t]*(var|const|let) *version *= *(["'"'"'])' | grep -E -o '"([^"\\]|\\.)+"|'"'"'([^'"'"'\\]|\\.)+'"'"'' | head -n 1 | sed -E 's/^.|.$//g' | sed -E 's/\\(.)/\1/g') +if [ "$SVRJSVERSION" == "" ]; then + SVRJSVERSION=Unknown +fi +SVRJSFILENAME="svr.js.$(echo $SVRJSVERSION| tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z]+/./g').zip" + +gzip svr.js +mv svr.js.gz svr.compressed +cp ../unpacker.js svr.js + +echo $SVRJSFILENAME +zip -r ../$SVRJSFILENAME * +zip -r ../$SVRJSFILENAME .* 2>/dev/null +echo "SVR.JS $SVRJSVERSION" > zip -z ../$SVRJSFILENAME +cd .. + +rm -rf svrjs-temp + +popd + +echo "You have packed SVR.JS $SVRJSVERSION to \"$SVRJSFILENAME\" file." diff --git a/uncompressed_modules b/uncompressed_modules new file mode 100644 index 0000000..33a98f8 --- /dev/null +++ b/uncompressed_modules @@ -0,0 +1,7 @@ +chownr +fs-minipass +minipass +minizlib +mkdirp +tar +yallist diff --git a/unpacker.js b/unpacker.js new file mode 100644 index 0000000..76da0a5 --- /dev/null +++ b/unpacker.js @@ -0,0 +1,13 @@ +var zlib = require("zlib"); +var fs = require("fs"); +var tar = require("tar"); +console.log("Decompressing modules..."); +tar.x({file: './modules.compressed', C: './node_modules', sync: true}); +console.log("Deleting SVR.JS stub..."); +fs.unlinkSync("svr.js"); +fs.unlinkSync("modules.compressed"); +console.log("Decompressing SVR.JS..."); +var script = zlib.gunzipSync(fs.readFileSync("svr.compressed")); +fs.unlinkSync("svr.compressed"); +fs.writeFileSync("svr.js",script); +console.log("Restart SVR.JS to get server interface.");