Skip to content

Commit b51e4b5

Browse files
committed
install.sh: Add glibc check
1 parent e1c7d49 commit b51e4b5

File tree

4 files changed

+48
-20
lines changed

4 files changed

+48
-20
lines changed

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ curl -fsSL https://code-server.dev/install.sh | sh
2929
```
3030
$ curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run --help
3131
32+
$0 [--dry-run] [--version X.X.X] [--static <install-prefix>=~/.local]
33+
3234
Installs latest code-server on any macOS or Linux system preferring to use the OS package manager.
3335
3436
curl -fsSL https://code-server.dev/install.sh | sh -s --
@@ -37,29 +39,29 @@ Installs latest code-server on any macOS or Linux system preferring to use the O
3739
- For Fedora, CentOS, RHEL, openSUSE it will install the latest rpm package.
3840
- For Arch Linux it will install the AUR package.
3941
- For any unrecognized Linux operating system it will install the latest static release into ~/.local
40-
- Add ~/.local/bin to your $PATH to run code-server.
42+
- Add ~/.local/bin to your \$PATH to run code-server.
4143
4244
- For macOS it will install the Homebrew package.
4345
- If Homebrew is not installed it will install the latest static release into ~/.local
44-
- Add ~/.local/bin to your $PATH to run code-server.
46+
- Add ~/.local/bin to your \$PATH to run code-server.
4547
46-
- If ran on an architecture with no binary releases or outdated libc/libcxx, it will install the
48+
- If ran on an architecture with no binary releases or glibc < v2.17, it will install the
4749
npm package with yarn or npm.
4850
- We only have binary releases for amd64 and arm64 presently.
4951
5052
--dry-run Enables a dry run where where the steps that would have taken place
5153
are printed but do not actually execute.
5254
55+
--version Pass to install a specific version instead of the latest release.
56+
5357
--static Forces the installation of a static release into ~/.local
5458
5559
This flag takes an optional argument for the installation prefix which defaults to "~/.local".
5660
code-server will be unarchived into ~/.local/lib/code-server.X.X.X and the binary will be symlinked
57-
into "~/.local/bin/code-server". You will need to add ~/.local/bin to your $PATH to use it without
61+
into "~/.local/bin/code-server". You will need to add ~/.local/bin to your \$PATH to use it without
5862
the full path.
5963
6064
To install system wide set the prefix to /usr/local.
61-
62-
--version Pass to install a specific version instead of the latest release.
6365
```
6466

6567
If you still don't trust our install script, even with the above explaination and the dry run, we have

ci/build/build-static-release.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ main() {
1616

1717
mkdir -p "$RELEASE_PATH/bin"
1818
rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server"
19-
rsync "$node_path" "$RELEASE_PATH/lib/node"
19+
20+
g++ -Wl,--allow-multiple-definition "$node_path" -static-libstdc++ -static-libgcc -o "$RELEASE_PATH/lib/node"
2021

2122
ln -s "./bin/code-server" "$RELEASE_PATH/code-server"
2223
ln -s "./lib/node" "$RELEASE_PATH/node"

doc/install.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ systemctl --user enable --now code-server
6464
We recommend installing with `yarn` or `npm` if:
6565

6666
1. We don't have a precompiled release for your machine's platform or architecture.
67-
2. libc < v2.19
68-
3. libcxx < 3.4.20
67+
2. libc < v2.17
6968

7069
**note:** Installing via `yarn` or `npm` builds native modules on install and so requires C dependencies.
7170
See [./doc/npm.md](./doc/npm.md) for installing these dependencies.

install.sh

+37-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
#!/bin/sh
22
set -eu
33

4+
MINIMUM_LIBC=2.17
5+
46
usage() {
5-
cat << EOF
6-
$0 [--dry-run] [--version X.X.X] [--static <install-prefix>=~/.local]
7+
cli="$0"
8+
if [ "$0" = sh ]; then
9+
cli="curl -fsSL https://code-server.dev/install.sh | sh -s --"
10+
else
11+
curl_usage="$(cat <<EOF
12+
13+
To use latest:
714
8-
Installs latest code-server on any macOS or Linux system preferring to use the OS package manager.
15+
curl -fsSL https://code-server.dev/install.sh | sh -s -- <args>
16+
EOF)""
17+
"
18+
fi
19+
cat <<EOF
20+
Installs latest code-server on Linux or macOS preferring to use the system package manager.
21+
22+
Lives at https://code-server.dev/install.sh
923
10-
curl -fsSL https://code-server.dev/install.sh | sh -s --
24+
Usage:
1125
26+
$cli [--dry-run] [--version X.X.X] [--static <install-prefix>=~/.local]
27+
${curl_usage-}
1228
- For Debian, Ubuntu, Raspbian it will install the latest deb package.
1329
- For Fedora, CentOS, RHEL, openSUSE it will install the latest rpm package.
1430
- For Arch Linux it will install the AUR package.
@@ -19,7 +35,7 @@ Installs latest code-server on any macOS or Linux system preferring to use the O
1935
- If Homebrew is not installed it will install the latest static release into ~/.local
2036
- Add ~/.local/bin to your \$PATH to run code-server.
2137
22-
- If ran on an architecture with no binary releases or outdated libc/libcxx, it will install the
38+
- If ran on an architecture with no binary releases or glibc < v$MINIMUM_LIBC, it will install the
2339
npm package with yarn or npm.
2440
- We only have binary releases for amd64 and arm64 presently.
2541
@@ -40,15 +56,15 @@ EOF
4056
}
4157
4258
echo_latest_version() {
43-
version="$(curl -fsSL https://api.github.com/repos/cdr/code-server/releases/latest | jq -r .tag_name)"
44-
# Strip leading v.
45-
version="${version:1}"
59+
# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-2758860
60+
version="$(curl -fsSLI -o /dev/null -w %{url_effective} -o /dev/null -w %{url_effective} https://github.com/cdr/code-server/releases/latest)"
61+
version="${version#https://github.com/cdr/code-server/releases/tag/v}"
4662
echo "$version"
4763
}
4864
4965
echo_static_postinstall() {
5066
echo
51-
cat << EOF
67+
cat <<EOF
5268
Static release has been installed into $STATIC_INSTALL_PREFIX/lib/code-server-$VERSION
5369
Please extend your path to use code-server:
5470
PATH="$STATIC_INSTALL_PREFIX/bin:\$PATH"
@@ -59,7 +75,7 @@ EOF
5975
6076
echo_systemd_postinstall() {
6177
echo
62-
cat << EOF
78+
cat <<EOF
6379
To have systemd start code-server now and restart on boot:
6480
systemctl --user enable --now code-server
6581
Or, if you don't want/need a background service you can run:
@@ -147,6 +163,11 @@ main() {
147163
return
148164
fi
149165
166+
if [ "$OS" = "linux" ] && outdated_glibc; then
167+
install_static
168+
return
169+
fi
170+
150171
case "$(distro)" in
151172
macos)
152173
install_macos
@@ -386,7 +407,7 @@ arch() {
386407
}
387408
388409
command_exists() {
389-
command -v "$@" > /dev/null 2>&1
410+
command -v "$@" >/dev/null 2>&1
390411
}
391412
392413
sh_c() {
@@ -429,4 +450,9 @@ echoerr() {
429450
echo "$@" >&2
430451
}
431452
453+
outdated_glibc() {
454+
glibc_version="$(ldd --version | grep -m 1 -o '[0-9.]\+$')"
455+
echo "$glibc_version"
456+
}
457+
432458
main "$@"

0 commit comments

Comments
 (0)