mirror of https://github.com/coder/code-server.git
Support recursive symlinks in release script
See https://github.com/cdr/code-server/issues/1746#issuecomment-637830396
This commit is contained in:
parent
206f195c1c
commit
02a77b528b
|
@ -1,26 +1,40 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
# This script is intended to be bundled into the standalone releases.
|
# This script is intended to be bundled into the standalone releases.
|
||||||
# Runs code-server with the bundled node binary.
|
# Runs code-server with the bundled node binary.
|
||||||
|
|
||||||
# More complicated than readlink -f or realpath to support macOS.
|
_realpath() {
|
||||||
# See https://github.com/cdr/code-server/issues/1537
|
if [ "$(uname)" = "Linux" ]; then
|
||||||
root_dir() {
|
readlink -f "$1"
|
||||||
# We read the symlink, which may be relative from $0.
|
return
|
||||||
dst="$(readlink "$0")"
|
fi
|
||||||
# We cd into the $0 directory.
|
|
||||||
cd "$(dirname "$0")" || exit 1
|
# See https://github.com/cdr/code-server/issues/1537
|
||||||
# Now we can cd into the directory above the dst directory which is the root
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
# of the release.
|
# We read the symlink, which may be relative from $1.
|
||||||
cd "$(dirname "$dst")/.." || exit 1
|
script="$1"
|
||||||
# Finally we use pwd -P to print the absolute path the root.
|
if [ -L "$script" ]; then
|
||||||
pwd -P || exit 1
|
while [ -L "$script" ]; do
|
||||||
|
script="$(readlink "$script")"
|
||||||
|
cd "$(dirname "$script")"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
cd "$(dirname "$script")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$PWD/$(basename "$script")"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Unsupported OS $(uname)" >&2
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
ROOT="$(root_dir)"
|
ROOT="$(dirname "$(dirname "$(_realpath "$0")")")"
|
||||||
if [ "$(uname)" = "Linux" ]; then
|
if [ "$(uname)" = "Linux" ]; then
|
||||||
export LD_LIBRARY_PATH="$ROOT/lib:$LD_LIBRARY_PATH"
|
export LD_LIBRARY_PATH="$ROOT/lib:${LD_LIBRARY_PATH-}"
|
||||||
elif [ "$(uname)" = "Darwin" ]; then
|
elif [ "$(uname)" = "Darwin" ]; then
|
||||||
export DYLD_LIBRARY_PATH="$ROOT/lib:$DYLD_LIBRARY_PATH"
|
export DYLD_LIBRARY_PATH="$ROOT/lib:${DYLD_LIBRARY_PATH-}"
|
||||||
fi
|
fi
|
||||||
exec "$ROOT/lib/node" "$ROOT" "$@"
|
exec "$ROOT/lib/node" "$ROOT" "$@"
|
||||||
|
|
Loading…
Reference in New Issue