Skip to content

Add auto install script #1701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
96eeb9f
Fix install instructions for SUSE
nhooyr May 20, 2020
3b11733
Add auto install script
nhooyr May 20, 2020
0129e00
Add install.sh into README.md
nhooyr May 20, 2020
510d848
install.sh: Add our own flag parser
nhooyr May 21, 2020
c80b274
install.sh: Fixes from @code-asher's review
nhooyr May 21, 2020
e0172d0
Minor fixes for install.sh and bundle in libstdc++
nhooyr May 21, 2020
a40dabb
Add install script to docs
nhooyr May 21, 2020
f117475
install.md: Add https://github.com/linuxserver/docker-code-server
nhooyr May 21, 2020
ac9b57c
Properly bundle in libstdc++
nhooyr May 21, 2020
e55d3e4
Bundle in libicu on macOS
nhooyr May 22, 2020
15cd727
Replace gif with screenshot
nhooyr May 22, 2020
7dcfde7
Documentation fixes
nhooyr May 22, 2020
42b5152
Further documentation cleanup
nhooyr May 22, 2020
7ef82d8
Improved install.sh flags
nhooyr May 22, 2020
e9101a2
Improve formatting
nhooyr May 27, 2020
c51d94d
Document PWA
nhooyr May 27, 2020
eb17a29
Document Microsoft's Remote extensions
nhooyr May 27, 2020
33bca2d
Adjust nfpm config for bindir removal
nhooyr May 27, 2020
665ca01
Fixes from @code-asher's godly review
nhooyr May 27, 2020
fa45fd0
Rename static releases to binary releases
nhooyr May 27, 2020
06c26a2
Improve aur installation clarity
nhooyr May 27, 2020
f71d887
Rename binary release to standalone
nhooyr May 27, 2020
29e5c4a
Clarify npm docs in install.md
nhooyr May 27, 2020
af398c4
Workaround lack of builtin in /bin/sh
nhooyr May 27, 2020
30e9c51
Further improve AUR installation
nhooyr May 27, 2020
fbd8564
Fix CI
nhooyr May 27, 2020
69ad529
v3.4.0
nhooyr May 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename binary release to standalone
  • Loading branch information
nhooyr committed May 27, 2020
commit f71d8875d0bd26ae15eaf20a0daf5cd99eaf7f21
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dist*
out*
release/
release-npm-package/
release-binary/
release-standalone/
release-packages/
release-gcp/
release-images/
Expand Down
18 changes: 9 additions & 9 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ You can disable minification by setting `MINIFY=`.
- Builds vscode into `./lib/vscode/out-vscode`.
- [./ci/build/build-release.sh](./build/build-release.sh) (`yarn release`)
- Bundles the output of the above two scripts into a single node module at `./release`.
- [./ci/build/build-binary-release.sh](./build/build-binary-release.sh) (`yarn release:binary`)
- [./ci/build/build-standalone-release.sh](./build/build-standalone-release.sh) (`yarn release:standalone`)
- Requires a node module already built into `./release` with the above script.
- Will build a binary release with node and node_modules bundled into `./release-binary`.
- Will build a standalone release with node and node_modules bundled into `./release-standalone`.
- [./ci/build/clean.sh](./build/clean.sh) (`yarn clean`)
- Removes all build artifacts.
- Will also `git reset --hard lib/vscode`.
- Useful to do a clean build.
- [./ci/build/code-server.sh](./build/code-server.sh)
- Copied into binary releases to run code-server with the bundled node binary.
- [./ci/build/test-binary-release.sh](./build/test-binary-release.sh) (`yarn test:binary-release`)
- Ensures code-server in the `./release-binary` directory works by installing an extension.
- Copied into standalone releases to run code-server with the bundled node binary.
- [./ci/build/test-standalone-release.sh](./build/test-standalone-release.sh) (`yarn test:standalone-release`)
- Ensures code-server in the `./release-standalone` directory works by installing an extension.
- [./ci/build/build-packages.sh](./build/build-packages.sh) (`yarn package`)
- Packages `./release-binary` into a `.tar.gz` archive in `./release-packages`.
- Packages `./release-standalone` into a `.tar.gz` archive in `./release-packages`.
- If on linux, [nfpm](https://github.com/goreleaser/nfpm) is used to generate `.deb` and `.rpm`.
- [./ci/build/nfpm.yaml](./build/nfpm.yaml)
- Used to configure [nfpm](https://github.com/goreleaser/nfpm) to generate `.deb` and `.rpm`.
Expand Down Expand Up @@ -131,9 +131,9 @@ Helps avoid clobbering the CI configuration.
- [./steps/release.sh](./steps/release.sh)
- Runs the release process.
- Generates the npm package at `./release`.
- [./steps/release-binary.sh](./steps/release-binary.sh)
- Takes the output of the previous script and generates a binary release and
release packages into `release-packages`.
- [./steps/release-packages.sh](./steps/release-packages.sh)
- Takes the output of the previous script and generates a standalone release and
release packages into `./release-packages`.
- [./steps/publish-npm.sh](./steps/publish-npm.sh)
- Grabs the `npm-package` release artifact for the current commit and publishes it on npm.
- [./steps/build-docker-image.sh](./steps/build-docker-image.sh)
Expand Down
6 changes: 3 additions & 3 deletions ci/build/build-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail

# Packages code-server for the current OS and architecture into ./release-packages.
# This script assumes that a binary release is built already into ./release-binary
# This script assumes that a standalone release is built already into ./release-standalone

main() {
cd "$(dirname "${0}")/../.."
Expand All @@ -29,9 +29,9 @@ main() {
release_archive() {
local release_name="code-server-$VERSION-$OS-$ARCH"
if [[ $OS == "linux" ]]; then
tar -czf "release-packages/$release_name.tar.gz" --transform "s/^\.\/release-binary/$release_name/" ./release-binary
tar -czf "release-packages/$release_name.tar.gz" --transform "s/^\.\/release-standalone/$release_name/" ./release-standalone
else
tar -czf "release-packages/$release_name.tar.gz" -s "/^release-binary/$release_name/" release-binary
tar -czf "release-packages/$release_name.tar.gz" -s "/^release-standalone/$release_name/" ./release-standalone
fi
echo "done (release-packages/$release_name)"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ main() {
cd "$(dirname "${0}")/../.."
source ./ci/lib.sh

rsync "$RELEASE_PATH/" "$RELEASE_PATH-binary"
RELEASE_PATH+=-binary
rsync "$RELEASE_PATH/" "$RELEASE_PATH-standalone"
RELEASE_PATH+=-standalone

# We cannot find the path to node from $PATH because yarn shims a script to ensure
# we use the same version it's using so we instead run a script with yarn that
Expand Down
2 changes: 1 addition & 1 deletion ci/build/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ main() {
rm -Rf \
out \
release \
release-binary \
release-standalone \
release-packages \
release-gcp \
release-images/ \
Expand Down
4 changes: 2 additions & 2 deletions ci/build/code-server.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

# This script is intended to be bundled into the binary releases.
# Runs code-server with the bundled Node binary.
# This script is intended to be bundled into the standalone releases.
# Runs code-server with the bundled node binary.

# More complicated than readlink -f or realpath to support macOS.
# See https://github.com/cdr/code-server/issues/1537
Expand Down
2 changes: 1 addition & 1 deletion ci/build/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ license: "MIT"
files:
./ci/build/code-server-nfpm.sh: /usr/bin/code-server
./ci/build/code-server.service: /usr/lib/systemd/user/code-server.service
./release-binary/**/*: "/usr/lib/code-server/"
./release-standalone/**/*: "/usr/lib/code-server/"
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ main() {
local EXTENSIONS_DIR
EXTENSIONS_DIR="$(mktemp -d)"

echo "Testing binary release"
echo "Testing standalone release."

./release-binary/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --install-extension ms-python.python
./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --install-extension ms-python.python
local installed_extensions
installed_extensions="$(./release-binary/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --list-extensions 2>&1)"
installed_extensions="$(./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --list-extensions 2>&1)"
if [[ $installed_extensions != "ms-python.python" ]]; then
echo "Unexpected output from listing extensions:"
echo "$installed_extensions"
exit 1
fi

echo "Binary release works correctly"
echo "Standalone release works correctly."
}

main "$@"
4 changes: 2 additions & 2 deletions ci/steps/release-binary.sh → ci/steps/release-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ main() {
# https://github.com/actions/upload-artifact/issues/38
tar -xzf release-npm-package/package.tar.gz

yarn release:binary
yarn test:binary-release
yarn release:standalone
yarn test:standalone-release
yarn package
}

Expand Down
10 changes: 5 additions & 5 deletions doc/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ yarn --production
node .
```

Now you can build binary packages with:
Now you can build the packages with:

```
yarn release:binary
yarn test:binary-release
yarn release:standalone
yarn test:standalone-release
yarn package
# The binary release is in ./release-binary
# .deb, .rpm and the binary archive are in ./release-packages
# The standalone release is in ./release-standalone
# .deb, .rpm and the standalone archive are in ./release-packages
```

## Structure
Expand Down
20 changes: 10 additions & 10 deletions doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- [Arch Linux](#arch-linux)
- [yarn, npm](#yarn-npm)
- [macOS](#macos)
- [Binary Releases](#binary-releases)
- [Standalone Releases](#standalone-releases)
- [Docker](#docker)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -50,9 +50,9 @@ commands presented in the rest of this document.

- `--dry-run` to echo the commands for the install process without running them.
- `--method` to choose the installation method.
- `--method=detect` to detect the package manager but fallback to `--method=archive`.
- `--method=archive` to install a binary release archive into `~/.local`.
- `--prefix=/usr/local` to install a binary release archive system wide.
- `--method=detect` to detect the package manager but fallback to `--method=standalone`.
- `--method=standalone` to install a standalone release archive into `~/.local`.
- `--prefix=/usr/local` to install a standalone release archive system wide.
- `--version=X.X.X` to install version `X.X.X` instead of latest.
- `--help` to see full usage docs.

Expand All @@ -61,17 +61,17 @@ commands presented in the rest of this document.
- For Debian, Ubuntu and Raspbian it will install the latest deb package.
- For Fedora, CentOS, RHEL and openSUSE it will install the latest rpm package.
- For Arch Linux it will install the AUR package.
- For any unrecognized Linux operating system it will install the latest binary release into `~/.local`.
- For any unrecognized Linux operating system it will install the latest standalone release into `~/.local`.

- Add `~/.local/bin` to your `$PATH` to run code-server.

- For macOS it will install the Homebrew package.

- If Homebrew is not installed it will install the latest binary release into `~/.local`.
- If Homebrew is not installed it will install the latest standalone release into `~/.local`.
- Add `~/.local/bin` to your `$PATH` to run code-server.

- If ran on an architecture with no binary releases, it will install the npm package with `yarn` or `npm`.
- We only have binary releases for amd64 and arm64 presently.
- If ran on an architecture with no releases, it will install the npm package with `yarn` or `npm`.
- We only have releases for amd64 and arm64 presently.

## Debian, Ubuntu

Expand Down Expand Up @@ -136,7 +136,7 @@ brew services start code-server
# Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml
```

## Binary Releases
## Standalone Releases

We publish self contained `.tar.gz` archives for every release on [github](https://github.com/cdr/code-server/releases).
They bundle the node binary and `node_modules`.
Expand All @@ -148,7 +148,7 @@ They bundle the node binary and `node_modules`.
You can add the code-server `bin` directory to your `$PATH` to easily execute `code-server`
without the full path every time.

Here is an example script for installing and using a binary `code-server` release on Linux:
Here is an example script for installing and using a standalone `code-server` release on Linux:

```bash
mkdir -p ~/.local/lib ~/.local/bin
Expand Down
64 changes: 32 additions & 32 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ Usage:
Echo the commands for the install process without running them.
--version X.X.X
Install a specific version instead of the latest.
--method [detect | archive]
--method [detect | standalone]
Choose the installation method. Defaults to detect.
- detect detects the system package manager and tries to use it.
Full reference on the process is further below.
- archive installs a binary release archive into ~/.local
- standalone installs a standalone release archive into ~/.local
Add ~/.local/bin to your \$PATH to use it.
--prefix <dir>
Sets the prefix used by binary release archives. Defaults to ~/.local
Sets the prefix used by standalone release archives. Defaults to ~/.local
The release is unarchived into ~/.local/lib/code-server-X.X.X
and the binary symlinked into ~/.local/bin/code-server
To install system wide pass ---prefix=/usr/local

- For Debian, Ubuntu and Raspbian it will install the latest deb package.
- For Fedora, CentOS, RHEL and openSUSE it will install the latest rpm package.
- For Arch Linux it will install the AUR package.
- For any unrecognized Linux operating system it will install the latest binary
- For any unrecognized Linux operating system it will install the latest standalone
release into ~/.local

- For macOS it will install the Homebrew package.
- If Homebrew is not installed it will install the latest binary release
- If Homebrew is not installed it will install the latest standalone release
into ~/.local

- If ran on an architecture with no binary releases, it will install the
- If ran on an architecture with no releases, it will install the
npm package with yarn or npm.
- We only have binary releases for amd64 and arm64 presently.
- We only have releases for amd64 and arm64 presently.

It will cache all downloaded assets into ~/.cache/code-server

Expand All @@ -65,12 +65,12 @@ echo_latest_version() {
echo "$version"
}

echo_archive_postinstall() {
echo_standalone_postinstall() {
echo
cat << EOF
Binary release has been installed into $ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION
Standalone release has been installed into $STANDALONE_INSTALL_PREFIX/lib/code-server-$VERSION
Please extend your path to use code-server:
PATH="$ARCHIVE_INSTALL_PREFIX/bin:\$PATH"
PATH="$STANDALONE_INSTALL_PREFIX/bin:\$PATH"
Then you can run:
code-server
EOF
Expand All @@ -94,7 +94,7 @@ main() {
unset \
DRY_RUN \
METHOD \
ARCHIVE_INSTALL_PREFIX \
STANDALONE_INSTALL_PREFIX \
VERSION \
OPTIONAL

Expand All @@ -111,11 +111,11 @@ main() {
METHOD="$(parse_arg "$@")"
;;
--prefix)
ARCHIVE_INSTALL_PREFIX="$(parse_arg "$@")"
STANDALONE_INSTALL_PREFIX="$(parse_arg "$@")"
shift
;;
--prefix=*)
ARCHIVE_INSTALL_PREFIX="$(parse_arg "$@")"
STANDALONE_INSTALL_PREFIX="$(parse_arg "$@")"
;;
--version)
VERSION="$(parse_arg "$@")"
Expand All @@ -140,12 +140,12 @@ main() {

VERSION="${VERSION-$(echo_latest_version)}"
METHOD="${METHOD-detect}"
if [ "$METHOD" != detect ] && [ "$METHOD" != archive ]; then
if [ "$METHOD" != detect ] && [ "$METHOD" != standalone ]; then
echoerr "Unknown install method \"$METHOD\""
echoerr "Run with --help to see usage."
exit 1
fi
ARCHIVE_INSTALL_PREFIX="${ARCHIVE_INSTALL_PREFIX-$HOME/.local}"
STANDALONE_INSTALL_PREFIX="${STANDALONE_INSTALL_PREFIX-$HOME/.local}"

OS="$(os)"
if [ ! "$OS" ]; then
Expand All @@ -157,9 +157,9 @@ main() {

ARCH="$(arch)"
if [ ! "$ARCH" ]; then
if [ "$METHOD" = archive ]; then
echoerr "No binary releases available for the architecture $(uname -m)."
echoerr 'Please rerun without the "--method archive" flag to install from npm.'
if [ "$METHOD" = standalone ]; then
echoerr "No releases available for the architecture $(uname -m)."
echoerr 'Please rerun without the "--method standalone" flag to install from npm.'
exit 1
fi
echo "No precompiled releases for $(uname -m)."
Expand All @@ -170,8 +170,8 @@ main() {
CACHE_DIR="$(echo_cache_dir)"
mkdir -p "$CACHE_DIR"

if [ "$METHOD" = archive ]; then
install_archive
if [ "$METHOD" = standalone ]; then
install_standalone
return
fi

Expand All @@ -190,7 +190,7 @@ main() {
;;
*)
echo "Unsupported package manager."
install_archive
install_standalone
;;
esac
}
Expand Down Expand Up @@ -256,7 +256,7 @@ install_macos() {

echo "Homebrew not installed."

install_archive
install_standalone
}

install_deb() {
Expand Down Expand Up @@ -300,31 +300,31 @@ install_aur() {
echo_systemd_postinstall
}

install_archive() {
echo "Installing binary release archive v$VERSION"
install_standalone() {
echo "Installing standalone release archive v$VERSION"
echo

fetch "https://github.com/cdr/code-server/releases/download/v$VERSION/code-server-$VERSION-$OS-$ARCH.tar.gz" \
"$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz"

sh_c="sh_c"
if [ ! -w "$ARCHIVE_INSTALL_PREFIX" ]; then
if [ ! -w "$STANDALONE_INSTALL_PREFIX" ]; then
sh_c="sudo_sh_c"
fi

if [ -e "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION" ]; then
if [ -e "$STANDALONE_INSTALL_PREFIX/lib/code-server-$VERSION" ]; then
echo
echo "code-server-$VERSION is already installed at $ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION"
echo "code-server-$VERSION is already installed at $STANDALONE_INSTALL_PREFIX/lib/code-server-$VERSION"
echo "Remove it to reinstall."
exit 0
fi

"$sh_c" mkdir -p "$ARCHIVE_INSTALL_PREFIX/lib" "$ARCHIVE_INSTALL_PREFIX/bin"
"$sh_c" tar -C "$ARCHIVE_INSTALL_PREFIX/lib" -xzf "$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz"
"$sh_c" mv -f "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION-$OS-$ARCH" "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION"
"$sh_c" ln -fs "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION/bin/code-server" "$ARCHIVE_INSTALL_PREFIX/bin/code-server"
"$sh_c" mkdir -p "$STANDALONE_INSTALL_PREFIX/lib" "$STANDALONE_INSTALL_PREFIX/bin"
"$sh_c" tar -C "$STANDALONE_INSTALL_PREFIX/lib" -xzf "$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz"
"$sh_c" mv -f "$STANDALONE_INSTALL_PREFIX/lib/code-server-$VERSION-$OS-$ARCH" "$STANDALONE_INSTALL_PREFIX/lib/code-server-$VERSION"
"$sh_c" ln -fs "$STANDALONE_INSTALL_PREFIX/lib/code-server-$VERSION/bin/code-server" "$STANDALONE_INSTALL_PREFIX/bin/code-server"

echo_archive_postinstall
echo_standalone_postinstall
}

install_npm() {
Expand Down
Loading