Make install.sh sh-compatible (#12899)
Co-Authored-By: Max <max@zed.dev> Release Notes: - N/A --------- Co-authored-by: Max <max@zed.dev> Co-authored-by: Shyim <github@shyim.de>
This commit is contained in:
parent
ab41eddd8b
commit
e16bbe048f
1 changed files with 24 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
set -euo pipefail
|
set -eu
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
platform="$(uname -s)"
|
platform="$(uname -s)"
|
||||||
|
@ -7,9 +7,9 @@ main() {
|
||||||
channel="${ZED_CHANNEL:-stable}"
|
channel="${ZED_CHANNEL:-stable}"
|
||||||
temp="$(mktemp -d "/tmp/zed-XXXXX")"
|
temp="$(mktemp -d "/tmp/zed-XXXXX")"
|
||||||
|
|
||||||
if [[ $platform == "Darwin" ]]; then
|
if [ "$platform" = "Darwin" ]; then
|
||||||
platform="macos"
|
platform="macos"
|
||||||
elif [[ $platform == "Linux" ]]; then
|
elif [ "$platform" = "Linux" ]; then
|
||||||
platform="linux"
|
platform="linux"
|
||||||
channel="${ZED_CHANNEL:-preview}"
|
channel="${ZED_CHANNEL:-preview}"
|
||||||
else
|
else
|
||||||
|
@ -17,14 +17,18 @@ main() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $platform == "macos" ]] && [[ $arch == arm64* ]]; then
|
case "$platform-$arch" in
|
||||||
arch="aarch64"
|
macos-arm64*)
|
||||||
elif [[ $arch = x86* || $arch == i686* ]]; then
|
arch="aarch64"
|
||||||
arch="x86_64"
|
;;
|
||||||
else
|
macos-x86* | linux-x86* | linux-i686*)
|
||||||
echo "Unsupported architecture $arch"
|
arch="x86_64"
|
||||||
exit 1
|
;;
|
||||||
fi
|
*)
|
||||||
|
echo "Unsupported platform or architecture"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if which curl >/dev/null 2>&1; then
|
if which curl >/dev/null 2>&1; then
|
||||||
curl () {
|
curl () {
|
||||||
|
@ -33,7 +37,7 @@ main() {
|
||||||
elif which wget >/dev/null 2>&1; then
|
elif which wget >/dev/null 2>&1; then
|
||||||
curl () {
|
curl () {
|
||||||
wget -O- "$@"
|
wget -O- "$@"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
echo "Could not find 'curl' or 'wget' in your path"
|
echo "Could not find 'curl' or 'wget' in your path"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -51,7 +55,7 @@ linux() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
suffix=""
|
suffix=""
|
||||||
if [[ $channel != "stable" ]]; then
|
if [ "$channel" != "stable" ]; then
|
||||||
suffix="-$channel"
|
suffix="-$channel"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -84,16 +88,16 @@ linux() {
|
||||||
mkdir -p "$HOME/.local/bin" "$HOME/.local/share/applications"
|
mkdir -p "$HOME/.local/bin" "$HOME/.local/share/applications"
|
||||||
|
|
||||||
# Link the binary
|
# Link the binary
|
||||||
if [ -f ~/.local/zed$suffix.app/bin/zed ]; then
|
if [ -f "$HOME/.local/zed$suffix.app/bin/zed" ]; then
|
||||||
ln -sf ~/.local/zed$suffix.app/bin/zed "$HOME/.local/bin/zed"
|
ln -sf "$HOME/.local/zed$suffix.app/bin/zed" "$HOME/.local/bin/zed"
|
||||||
else
|
else
|
||||||
# support for versions before 0.139.x.
|
# support for versions before 0.139.x.
|
||||||
ln -sf ~/.local/zed$suffix.app/bin/cli "$HOME/.local/bin/zed"
|
ln -sf "$HOME/.local/zed$suffix.app/bin/cli" "$HOME/.local/bin/zed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy .desktop file
|
# Copy .desktop file
|
||||||
desktop_file_path="$HOME/.local/share/applications/${appid}.desktop"
|
desktop_file_path="$HOME/.local/share/applications/${appid}.desktop"
|
||||||
cp ~/.local/zed$suffix.app/share/applications/zed$suffix.desktop "${desktop_file_path}"
|
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|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}"
|
sed -i "s|Exec=zed|Exec=$HOME/.local/zed$suffix.app/libexec/zed-editor|g" "${desktop_file_path}"
|
||||||
|
|
||||||
|
@ -114,7 +118,7 @@ macos() {
|
||||||
hdiutil attach -quiet "$temp/Zed-$arch.dmg" -mountpoint "$temp/mount"
|
hdiutil attach -quiet "$temp/Zed-$arch.dmg" -mountpoint "$temp/mount"
|
||||||
app="$(cd "$temp/mount/"; echo *.app)"
|
app="$(cd "$temp/mount/"; echo *.app)"
|
||||||
echo "Installing $app"
|
echo "Installing $app"
|
||||||
if [[ -d "/Applications/$app" ]]; then
|
if [ -d "/Applications/$app" ]; then
|
||||||
echo "Removing existing $app"
|
echo "Removing existing $app"
|
||||||
rm -rf "/Applications/$app"
|
rm -rf "/Applications/$app"
|
||||||
fi
|
fi
|
||||||
|
@ -123,7 +127,7 @@ macos() {
|
||||||
|
|
||||||
mkdir -p "$HOME/.local/bin"
|
mkdir -p "$HOME/.local/bin"
|
||||||
# Link the binary
|
# Link the binary
|
||||||
ln -sf /Applications/$app/Contents/MacOS/cli "$HOME/.local/bin/zed"
|
ln -sf "/Applications/$app/Contents/MacOS/cli" "$HOME/.local/bin/zed"
|
||||||
|
|
||||||
if which "zed" >/dev/null 2>&1; then
|
if which "zed" >/dev/null 2>&1; then
|
||||||
echo "Zed has been installed. Run with 'zed'"
|
echo "Zed has been installed. Run with 'zed'"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue