mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
build.sh and the releases/ scripts wrote all over the machine: temporary files to /tmp and macOS's /var/folders, downloads and release zips to ~/Downloads or ~/Lataukset, Meteor to ~/.meteor, Node.js to /usr/local (sudo n) or ~/.nvm, the npm cache to ~/.npm, Volta to ~/.volta, the Sandstorm toolchain to ~/projects, and PATH lines into ~/.zshrc and ~/.bashrc. A sandboxed editor (Flatpak on Linux, sandbox-exec on macOS) can reach only the checkout, and a container's own /tmp is a few hundred megabytes. Everything is in .tools/ now, which git and Meteor ignore: - releases/tools-env.sh, sourced by build.sh and every script that writes files, sets TMPDIR/TMP/TEMP to .tools/tmp (also downloads and release zips), NVM_DIR, npm_config_cache, VOLTA_HOME and the meteor-spk directory to .tools/, METEOR_WAREHOUSE_DIR to .tools/.meteor once Meteor is installed there, and puts those tools first on PATH, so no shell rc file is edited. HOME is not moved: git needs ~/.gitconfig and ~/.ssh. A TMPDIR already inside a .tools/ is kept, so a test's own directory there stays its own; without a writable one it stops rather than fall back to /tmp. It never fails a caller running set -euo pipefail. - macOS's mktemp ignores TMPDIR when given no template, so every mktemp names one: mktemp "$TMPDIR/name.XXXXXX". Fixed /tmp files are in $TMPDIR. - build.sh installs Node.js on Linux into .tools/n (N_PREFIX, no sudo), nvm on macOS into .tools/nvm (PROFILE=/dev/null: no rc file edited), and Meteor with HOME=.tools for the installer only, into .tools/.meteor. build.sh is replaced, not edited in place, while it may be running. - Containers get this checkout's .tools/tmp as their /tmp: every db-conformance database (MariaDB's temporary tables were verified to land there, and MongoDB's socket) and the repack container, which empty it themselves before they are removed. install-node-for-arch.sh requires the mounted TMPDIR. - tests/run-node-suites.cjs gives every suite TMPDIR in .tools/tmp, and the tests that copied a script into a fixture copy tools-env.sh too; tests that pinned ~/.meteor, the rc file edits, sudo n or /tmp/manifest.json pin the .tools/ places now and say why. tests/toolsDirOnly.test.cjs runs tools-env.sh against a TMPDIR already set elsewhere and under set -euo pipefail, and fails on any script that makes a temporary file without naming .tools/tmp, writes to the home directory, or edits a shell rc file, or on a container whose /tmp is its own. Thanks to xet7 !
73 lines
2.2 KiB
Bash
Executable File
73 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
if [ -n "${ZSH_VERSION:-}" ]; then exec /bin/bash "$0" "$@"; fi
|
|
. "$(dirname "${BASH_SOURCE[0]}")/tools-env.sh" # temporary files and downloads go to .tools/tmp
|
|
|
|
# Update node version.
|
|
|
|
# Check that there is only one parameter
|
|
# of Wekan version number:
|
|
|
|
if [ $# -ne 2 ]
|
|
then
|
|
echo "Syntax with Node old and new version number:"
|
|
echo " ./node-update-local.sh 12.21.0 12.22.0"
|
|
exit 1
|
|
fi
|
|
|
|
NODE_VERSION=$(node -v)
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
. "$SCRIPT_DIR/ensure-tools.sh"
|
|
if [ "$(_et_os)" = macos ]; then
|
|
_et_brew_ensure
|
|
command -v volta >/dev/null 2>&1 || brew install volta
|
|
else
|
|
ensure_tools curl
|
|
if ! command -v volta >/dev/null 2>&1; then
|
|
echo "volta not found. Installing Volta with its official installer..."
|
|
curl -fsSL https://get.volta.sh | bash -s -- --skip-setup
|
|
fi
|
|
export VOLTA_HOME="${VOLTA_HOME:-$WEKAN_TOOLS_DIR/volta}"
|
|
export PATH="$VOLTA_HOME/bin:$PATH"
|
|
fi
|
|
if [ $NODE_VERSION != v$2 ]; then
|
|
echo "8) Upgrading installed node to newest version"
|
|
volta install node@12
|
|
else
|
|
echo "8) Installed node is already newest version"
|
|
fi
|
|
|
|
# If Sandstorm node does not exist
|
|
SANDSTORM_NODE="$WEKAN_METEOR_SPK_DIR/meteor-spk-0.5.1/meteor-spk.deps/bin/node"
|
|
|
|
#if [[ -f "$SANDSTORM_NODE" ]]; then
|
|
# echo "9) Installing local Sandstorm develoment version"
|
|
# "$(dirname "$0")/install-sandstorm.sh"
|
|
#else
|
|
# echo "9) Local Sandstorm is already installed"
|
|
#fi
|
|
|
|
SANDSTORM_NODE_VERSION=$($SANDSTORM_NODE -v)
|
|
PROJECTS_ARCHIVE="$WEKAN_TOOLS_DIR/projects.7z"
|
|
|
|
# If installed Sandstorm node is not newest version
|
|
if [ $SANDSTORM_NODE != v$2 ]; then
|
|
echo "9) Copy previously updated local node to Sandstorm node"
|
|
cp "$VOLTA_HOME/bin/node" "$WEKAN_METEOR_SPK_DIR/meteor-spk-0.5.1/meteor-spk.deps/bin/"
|
|
# echo "11) Install 7zip"
|
|
# sudo apt-get -y install p7zip-full
|
|
# # If projects.7z exists, delete it
|
|
# if [[ -f "$PROJECTS_ARCHIVE" ]] then;
|
|
# echo "12) Deleting existing project.7z archive"
|
|
# rm $PROJECTS_ARCHIVE
|
|
# else
|
|
# echo "12) There is no existin project.7z archive"
|
|
# fi
|
|
# echo "13) Archive projects.7z directory"
|
|
# 7z a projects.7z projects
|
|
# echo "14) Upload projects.7z archive to webserver"
|
|
# scp projects.7z x2:/var/snap/wekan/common/releases.wekan.team/meteor-spk/
|
|
fi
|
|
|
|
echo "Done."
|