From ef84ce76e36e5b9ee440fea612028b5b2f21258a Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 10 Jun 2024 20:43:13 -0600 Subject: [PATCH] linux make install (#12870) Release Notes: - N/A --- .github/workflows/ci.yml | 3 --- docs/src/development/linux.md | 26 ++++++++++++++++++-------- script/bundle-linux | 6 ++---- script/install-linux | 26 ++++++++++++++++++++++++++ script/install.sh | 10 +++++++--- 5 files changed, 53 insertions(+), 18 deletions(-) create mode 100755 script/install-linux diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea552eaddd015b4be9b84d64017120c638199b91..3f03bd55250ea7491a7045fc4bed4d33f3dc8dee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -305,9 +305,6 @@ jobs: exit 1 fi - - name: Generate license file - run: script/generate-licenses - - name: Create and upload Linux .tar.gz bundle run: script/bundle-linux diff --git a/docs/src/development/linux.md b/docs/src/development/linux.md index 1a12a8e05d1a68ee56b86ee970507e6b486c1913..7f6bc3ac88bf02b5d1aa893cea8322db6c976d2e 100644 --- a/docs/src/development/linux.md +++ b/docs/src/development/linux.md @@ -40,31 +40,41 @@ docker compose up -d Once you have the dependencies installed, you can build Zed using [Cargo](https://doc.rust-lang.org/cargo/). -For a debug build: +For a debug build of the editor: ``` cargo run ``` -For a release build: +And to run the tests: ``` -cargo run --release +cargo test --workspace ``` -For a release package: +In release mode, the primary user interface is the `cli` crate. You can run it in development with: ``` -cargo build --release +cargo run -p cli ``` -the binary can be found in `target/release` folder. +## Installing a development build -And to run the tests: +You can install a local build on your machine with: ``` -cargo test --workspace +./script/install-linux +``` + +This will build zed and the cli in release mode and make them available at `~/.local/bin/zed`, installing .desktop files to `~/.local/share`. + +If you'd like to install things to a different prefix you can use: + ``` +./script/install-linux /usr/ +``` + +In this case the binary will be `/usr/bin/zed` and the `.desktop` file in `/usr/share`. The script should prompt for sudo as required so that the rust build runs as the current user. ## Wayland & X11 diff --git a/script/bundle-linux b/script/bundle-linux index 67879fea3998785cc56697f12cf09804dc27cd7b..25eb97093bb2ef71cbbde7a82bcf63b82918cadc 100755 --- a/script/bundle-linux +++ b/script/bundle-linux @@ -95,14 +95,12 @@ mkdir -p "${zed_dir}/share/applications" envsubst < "crates/zed/resources/zed.desktop.in" > "${zed_dir}/share/applications/zed$suffix.desktop" # Licenses +script/generate-licenses cp "assets/licenses.md" "${zed_dir}/licenses.md" # Create archive out of everything that's in the temp directory target="linux-$(uname -m)" - -if [[ "$channel" == "nightly" ]]; then - archive="zed-${target}.tar.gz" -elif [[ "$channel" == "dev" ]]; then +if [[ "$channel" == "dev" ]]; then archive="zed-${commit}-${target}.tar.gz" else archive="zed-${target}.tar.gz" diff --git a/script/install-linux b/script/install-linux new file mode 100755 index 0000000000000000000000000000000000000000..3e9c0ae4bed3612c15579c28f18d140dff88a8aa --- /dev/null +++ b/script/install-linux @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +if [[ $# -gt 0 ]]; then + echo " + Usage: ${0##*/} + Builds and installs zed onto your system into ~/.local, making it available as ~/.local/bin/zed. + + Before running this you should ensure you have all the build dependencies installed with `./script/linux`. + " + exit 1 +fi +export ZED_CHANNEL=$( "$temp/zed-linux-$arch.tar.gz" + if [[ -n "${ZED_BUNDLE_PATH:-}" ]]; then + cp "$ZED_BUNDLE_PATH" "$temp/zed-linux-$arch.tar.gz" + else + echo "Downloading Zed" + curl "https://zed.dev/api/releases/$channel/latest/zed-linux-$arch.tar.gz" > "$temp/zed-linux-$arch.tar.gz" + fi suffix="" if [[ $channel != "stable" ]]; then @@ -91,7 +95,7 @@ linux() { desktop_file_path="$HOME/.local/share/applications/${appid}.desktop" cp ~/.local/zed$suffix.app/share/applications/zed$suffix.desktop "${desktop_file_path}" sed -i "s|Icon=zed|Icon=$HOME/.local/zed$suffix.app/share/icons/hicolor/512x512/apps/zed.png|g" "${desktop_file_path}" - sed -i "s|Exec=zed|Exec=$HOME/.local/zed$suffix.app/bin/zed|g" "${desktop_file_path}" + sed -i "s|Exec=zed|Exec=$HOME/.local/zed$suffix.app/libexec/zed-editor|g" "${desktop_file_path}" if which "zed" >/dev/null 2>&1; then echo "Zed has been installed. Run with 'zed'"