zed/script/install.sh
0x2CA c8709978a1
Dealing with missing arm architectures (#13349)
![image](https://github.com/zed-industries/zed/assets/19868292/341bf8c6-4586-4d51-8889-2c706dc98f6f)

"AArch64" and "ARM64" refer to the same thing.

AArch64 is the 64-bit state introduced in the [Armv8-A
architecture](https://en.wikipedia.org/wiki/ARM_architecture_family#Armv8-A).
The 32-bit state which is backwards compatible with Armv7-A and previous
32-bit Arm architectures is referred to as AArch32. Therefore the GNU
triplet for the 64-bit ISA is aarch64. The Linux kernel community
[chose](https://lkml.org/lkml/2012/7/6/624) to call their port of the
kernel to this architecture arm64 rather than aarch64, so that's where
some of the arm64 usage comes from.

The Apple-developed backend for AArch64 was called "ARM64" whereas the
LLVM community-developed backend was called "AArch64" (as it is the
canonical name for the 64-bit ISA). The two were merged [in
2014](https://www.phoronix.com/news/MTY5ODk) and the backend now is
called "AArch64".

Remote Normal


![image](https://github.com/zed-industries/zed/assets/19868292/f8c5505a-f455-45a6-83bd-230054f8aebd)


Release Notes:

- N/A
2024-06-21 10:46:25 +03:00

144 lines
4.1 KiB
Bash
Executable File

#!/usr/bin/env sh
set -eu
main() {
platform="$(uname -s)"
arch="$(uname -m)"
channel="${ZED_CHANNEL:-stable}"
temp="$(mktemp -d "/tmp/zed-XXXXX")"
if [ "$platform" = "Darwin" ]; then
platform="macos"
elif [ "$platform" = "Linux" ]; then
platform="linux"
channel="${ZED_CHANNEL:-preview}"
else
echo "Unsupported platform $platform"
exit 1
fi
case "$platform-$arch" in
macos-arm64* | linux-arm64* | linux-armhf | linux-aarch64)
arch="aarch64"
;;
macos-x86* | linux-x86* | linux-i686*)
arch="x86_64"
;;
*)
echo "Unsupported platform or architecture"
exit 1
;;
esac
if which curl >/dev/null 2>&1; then
curl () {
command curl -fL "$@"
}
elif which wget >/dev/null 2>&1; then
curl () {
wget -O- "$@"
}
else
echo "Could not find 'curl' or 'wget' in your path"
exit 1
fi
"$platform" "$@"
}
linux() {
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
suffix="-$channel"
fi
appid=""
case "$channel" in
stable)
appid="dev.zed.Zed"
;;
nightly)
appid="dev.zed.Zed-Nightly"
;;
preview)
appid="dev.zed.Zed-Preview"
;;
dev)
appid="dev.zed.Zed-Dev"
;;
*)
echo "Unknown release channel: ${channel}. Using stable app ID."
appid="dev.zed.Zed"
;;
esac
# Unpack
rm -rf "$HOME/.local/zed$suffix.app"
mkdir -p "$HOME/.local/zed$suffix.app"
tar -xzf "$temp/zed-linux-$arch.tar.gz" -C "$HOME/.local/"
# Setup ~/.local directories
mkdir -p "$HOME/.local/bin" "$HOME/.local/share/applications"
# Link the binary
if [ -f "$HOME/.local/zed$suffix.app/bin/zed" ]; then
ln -sf "$HOME/.local/zed$suffix.app/bin/zed" "$HOME/.local/bin/zed"
else
# support for versions before 0.139.x.
ln -sf "$HOME/.local/zed$suffix.app/bin/cli" "$HOME/.local/bin/zed"
fi
# Copy .desktop file
desktop_file_path="$HOME/.local/share/applications/${appid}.desktop"
cp "$HOME/.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/libexec/zed-editor|g" "${desktop_file_path}"
if which "zed" >/dev/null 2>&1; then
echo "Zed has been installed. Run with 'zed'"
else
echo "To run Zed from your terminal, you must add ~/.local/bin to your PATH"
echo "Run:"
echo " echo 'export PATH=\$HOME/.local/bin:\$PATH' >> ~/.bashrc"
echo " source ~/.bashrc"
echo "To run Zed now, '~/.local/bin/zed'"
fi
}
macos() {
echo "Downloading Zed"
curl "https://zed.dev/api/releases/$channel/latest/Zed-$arch.dmg" > "$temp/Zed-$arch.dmg"
hdiutil attach -quiet "$temp/Zed-$arch.dmg" -mountpoint "$temp/mount"
app="$(cd "$temp/mount/"; echo *.app)"
echo "Installing $app"
if [ -d "/Applications/$app" ]; then
echo "Removing existing $app"
rm -rf "/Applications/$app"
fi
ditto "$temp/mount/$app" "/Applications/$app"
hdiutil detach -quiet "$temp/mount"
mkdir -p "$HOME/.local/bin"
# Link the binary
ln -sf "/Applications/$app/Contents/MacOS/cli" "$HOME/.local/bin/zed"
if which "zed" >/dev/null 2>&1; then
echo "Zed has been installed. Run with 'zed'"
else
echo "To run Zed from your terminal, you must add ~/.local/bin to your PATH"
echo "Run:"
echo " echo 'export PATH=\$HOME/.local/bin:\$PATH' >> ~/.bashrc"
echo " source ~/.bashrc"
echo "To run Zed now, '~/.local/bin/zed'"
fi
}
main "$@"