Skip to content

Add FreeBSD support to install script #1806

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 1 commit into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For a full setup and walkthrough, please see [./doc/guide.md](./doc/guide.md).

### Quick Install

We have a [script](./install.sh) to install code-server for Linux and macOS.
We have a [script](./install.sh) to install code-server for Linux, macOS and FreeBSD.

It tries to use the system package manager if possible.

Expand Down
2 changes: 1 addition & 1 deletion doc/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ to avoid the slow dashboard.

## 2. Install code-server

We have a [script](../install.sh) to install `code-server` for Linux and macOS.
We have a [script](../install.sh) to install `code-server` for Linux, macOS and FreeBSD.

It tries to use the system package manager if possible.

Expand Down
4 changes: 3 additions & 1 deletion doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ various distros and operating systems.

## install.sh

We have a [script](../install.sh) to install code-server for Linux and macOS.
We have a [script](../install.sh) to install code-server for Linux, macOS and FreeBSD.

It tries to use the system package manager if possible.

Expand Down Expand Up @@ -70,6 +70,8 @@ commands presented in the rest of this document.
- If Homebrew is not installed it will install the latest standalone release into `~/.local`.
- Add `~/.local/bin` to your `$PATH` to run code-server.

- For FreeBSD, it will install the [npm package](#yarn-npm) with `yarn` or `npm`.

- If ran on an architecture with no releases, it will install the [npm package](#yarn-npm) with `yarn` or `npm`.
- We only have releases for amd64 and arm64 presently.
- The [npm package](#yarn-npm) builds the native modules on postinstall.
Expand Down
28 changes: 24 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ usage() {
fi

cath << EOF
Installs code-server for Linux and macOS.
Installs code-server for Linux, macOS and FreeBSD.
It tries to use the system package manager if possible.
After successful installation it explains how to start using code-server.
${not_curl_usage-}
Expand Down Expand Up @@ -48,6 +48,8 @@ Usage:
- If Homebrew is not installed it will install the latest standalone release
into ~/.local

- For FreeBSD, it will install the npm package with yarn or npm.

- 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.
Expand Down Expand Up @@ -160,7 +162,7 @@ main() {
ARCH="$(arch)"
if [ ! "$ARCH" ]; then
if [ "$METHOD" = standalone ]; then
echoerr "No releases available for the architecture $(uname -m)."
echoerr "No precompiled releases for $(uname -m)."
echoerr 'Please rerun without the "--method standalone" flag to install from npm.'
exit 1
fi
Expand All @@ -169,6 +171,17 @@ main() {
return
fi

if [ "$OS" = "freebsd" ]; then
if [ "$METHOD" = standalone ]; then
echoerr "No precompiled releases available for $OS."
echoerr 'Please rerun without the "--method standalone" flag to install from npm.'
exit 1
fi
echoh "No precompiled releases available for $OS."
install_npm
return
fi

CACHE_DIR="$(echo_cache_dir)"

if [ "$METHOD" = standalone ]; then
Expand Down Expand Up @@ -360,6 +373,9 @@ os() {
Darwin)
echo macos
;;
FreeBSD)
echo freebsd
;;
esac
}

Expand All @@ -371,11 +387,12 @@ os() {
# - centos, fedora, rhel, opensuse
# - alpine
# - arch
# - freebsd
#
# Inspired by https://github.com/docker/docker-install/blob/26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c/install.sh#L111-L120.
distro() {
if [ "$(uname)" = "Darwin" ]; then
echo "macos"
if [ "$OS" = "macos" ] || [ "$OS" = "freebsd" ]; then
echo "$OS"
return
fi

Expand Down Expand Up @@ -422,6 +439,9 @@ arch() {
x86_64)
echo amd64
;;
amd64) # FreeBSD.
echo amd64
;;
esac
}

Expand Down