summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Knaack <davidkna@users.noreply.github.com>2021-01-13 19:39:39 +0100
committerGitHub <noreply@github.com>2021-01-13 19:39:39 +0100
commit89b5772699a90599d0a36745a8cfad95eaef365a (patch)
tree632b6537948e71dde44bf7942b3a03d658de6c34
parentf640db87a428577eba256e7c320691b17220f362 (diff)
fix(install): improve supported target detection (#2121)
* fix(install): improve supported target detection * move supported target list into top level variable
-rwxr-xr-xinstall/install.sh40
1 files changed, 32 insertions, 8 deletions
diff --git a/install/install.sh b/install/install.sh
index 2713d29ee..a9ff0f8fe 100755
--- a/install/install.sh
+++ b/install/install.sh
@@ -33,6 +33,8 @@ BLUE="$(tput setaf 4 2>/dev/null || echo '')"
MAGENTA="$(tput setaf 5 2>/dev/null || echo '')"
NO_COLOR="$(tput sgr0 2>/dev/null || echo '')"
+SUPPORTED_TARGETS="x86_64-unknown-linux-gnu x86_64-unknown-linux-musl i686-unknown-linux-musl x86_64-apple-darwin x86_64-pc-windows-msvc"
+
info() {
printf "%s\n" "${BOLD}${GREY}>${NO_COLOR} $*"
}
@@ -192,7 +194,7 @@ detect_arch() {
# `uname -m` in some cases mis-reports 32-bit OS as 64-bit, so double check
if [ "${arch}" = "x64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then
- arch=i386
+ arch=i686
fi
echo "${arch}"
@@ -242,6 +244,34 @@ check_bin_dir() {
fi
}
+is_build_available() {
+ local arch="$1"
+ local platform="$2"
+
+ local target="${arch}-${platform}"
+ local good
+
+ good=$(
+ IFS=" "
+ for t in $SUPPORTED_TARGETS; do
+ if [ "${t}" == "${target}" ]; then
+ echo 1
+ break
+ fi
+ done
+ )
+
+ if [ "${good}" != "1" ]; then
+ error "${arch} builds for ${platform} are not yet available for Starship"
+ printf "\n" >&2
+ info "If you would like to see a build for your configuration,"
+ info "please create an issue requesting a build for ${MAGENTA}${target}${NO_COLOR}:"
+ info "${BOLD}${UNDERLINE}https://github.com/starship/starship/issues/new/${NO_COLOR}"
+ printf "\n"
+ exit 1
+ fi
+}
+
# defaults
if [ -z "${PLATFORM-}" ]; then
PLATFORM="$(detect_platform)"
@@ -320,13 +350,7 @@ while [ "$#" -gt 0 ]; do
esac
done
-if [ "${ARCH}" = "i386" ]; then
- error "i386 builds are not yet available for Starship\n"
- info "If you would like to see a build for your configuration,"
- info "please create an issue requesting a build for ${MAGENTA}${ARCH}-${PLATFORM}${NO_COLOR}:"
- info "${BOLD}${UNDERLINE}https://github.com/starship/starship/issues/new/${NO_COLOR}\n"
- exit 1
-fi
+is_build_available "${ARCH}" "${PLATFORM}"
printf " %s\n" "${UNDERLINE}Configuration${NO_COLOR}"
info "${BOLD}Bin directory${NO_COLOR}: ${GREEN}${BIN_DIR}${NO_COLOR}"