From 247a431e9255cbdcabd8324853bcafb6a504e755 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Fri, 30 Apr 2021 14:19:40 -0500 Subject: [PATCH] feat(binstall): error on missing glibc --- installers/binstall/scripts/nix/install.sh | 11 +- .../binstall/scripts/nix/local-install.sh | 150 ------------------ .../binstall/scripts/windows/install.ps1 | 16 +- .../scripts/windows/local-install.ps1 | 2 - 4 files changed, 19 insertions(+), 160 deletions(-) delete mode 100755 installers/binstall/scripts/nix/local-install.sh delete mode 100644 installers/binstall/scripts/windows/local-install.ps1 diff --git a/installers/binstall/scripts/nix/install.sh b/installers/binstall/scripts/nix/install.sh index 64947f4f31..965e9888ca 100755 --- a/installers/binstall/scripts/nix/install.sh +++ b/installers/binstall/scripts/nix/install.sh @@ -51,6 +51,9 @@ download_binary_and_run_installer() { *windows*) _ext=".exe" ;; + *linux*) + need_glibc + ;; esac local _tardir="rover-$DOWNLOAD_VERSION-${_arch}" @@ -104,7 +107,7 @@ get_architecture() { if [ "$_ostype" = Darwin -a "$_cputype" = arm64 ]; then # Darwin `uname -s` doesn't seem to lie on Big Sur - # but we want to serve x86_64 binaries anyway that they can + # but we want to serve x86_64 binaries anyway so that they can # then run in x86_64 emulation mode on their arm64 devices local _cputype=x86_64 fi @@ -154,6 +157,12 @@ err() { exit 1 } +need_glibc() { + if ! check_cmd "/lib/x86_64-linux-gnu/libc.so.6" + then err "could not link against 'glibc'" + fi +} + need_cmd() { if ! check_cmd "$1" then err "need '$1' (command not found)" diff --git a/installers/binstall/scripts/nix/local-install.sh b/installers/binstall/scripts/nix/local-install.sh deleted file mode 100755 index a8e3fcd355..0000000000 --- a/installers/binstall/scripts/nix/local-install.sh +++ /dev/null @@ -1,150 +0,0 @@ -#!/bin/bash -# -# Licensed under the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -# This script is like install.sh except it uses binaries from -# your local machine so it's easier to test/develop. - -set -u - -copy_binary_and_run_installer() { - need_cmd uname - need_cmd mktemp - need_cmd chmod - need_cmd mkdir - need_cmd rm - need_cmd rmdir - need_cmd tar - need_cmd which - need_cmd dirname - need_cmd cargo - - say "building rover" - ensure cargo build --workspace - say "build complete" - - get_architecture || return 1 - local _arch="$RETVAL" - assert_nz "$_arch" "arch" - - say "$_arch" - - local _ext="" - case "$_arch" in - *windows*) - _ext=".exe" - ;; - esac - - local _dir="./target/debug" - local _rover="$_dir/rover$_ext" - - # The installer may want to ask for confirmation on stdin for various - # operations. We were piped through `sh` though so we probably don't have - # access to a tty naturally. If it looks like we're attached to a terminal - # (`-t 1`) then pass the tty down to the installer explicitly. - if [ -t 1 ]; then - "$_rover" "install" "$@" < /dev/tty - else - "$_rover" "install" "$@" - fi - - local _retval=$? - - return "$_retval" -} - -get_architecture() { - local _ostype="$(uname -s)" - local _cputype="$(uname -m)" - - if [ "$_ostype" = Darwin -a "$_cputype" = i386 ]; then - # Darwin `uname -s` lies - if sysctl hw.optional.x86_64 | grep -q ': 1'; then - local _cputype=x86_64 - fi - fi - - case "$_ostype" in - Linux) - local _ostype=unknown-linux-gnu - ;; - - Darwin) - local _ostype=apple-darwin - ;; - - MINGW* | MSYS* | CYGWIN*) - local _ostype=pc-windows-msvc - ;; - - *) - err "no precompiled binaries available for OS: $_ostype" - ;; - esac - - case "$_cputype" in - x86_64 | x86-64 | x64 | amd64) - local _cputype=x86_64 - ;; - *) - err "no precompiled binaries available for CPU architecture: $_cputype" - - esac - - local _arch="$_cputype-$_ostype" - - RETVAL="$_arch" -} - -say() { - local green=`tput setaf 2 2>/dev/null || echo ''` - local reset=`tput sgr0 2>/dev/null || echo ''` - echo " ${green}INFO${reset} sh::wrapper: $1" -} - -err() { - local red=`tput setaf 1 2>/dev/null || echo ''` - local reset=`tput sgr0 2>/dev/null || echo ''` - say " ${red}ERROR${reset} sh::wrapper: $1" >&2 - exit 1 -} - -need_cmd() { - if ! check_cmd "$1" - then err "need '$1' (command not found)" - fi -} - -check_cmd() { - command -v "$1" > /dev/null 2>&1 - return $? -} - -need_ok() { - if [ $? != 0 ]; then err "$1"; fi -} - -assert_nz() { - if [ -z "$1" ]; then err "assert_nz $2"; fi -} - -# Run a command that should never fail. If the command fails execution -# will immediately terminate with an error showing the failing -# command. -ensure() { - "$@" - need_ok "command failed: $*" -} - -# This is just for indicating that commands' results are being -# intentionally ignored. Usually, because it's being executed -# as part of error handling. -ignore() { - "$@" -} - -copy_binary_and_run_installer "$@" || exit 1 diff --git a/installers/binstall/scripts/windows/install.ps1 b/installers/binstall/scripts/windows/install.ps1 index 7749c2bacd..a00ac4cf31 100644 --- a/installers/binstall/scripts/windows/install.ps1 +++ b/installers/binstall/scripts/windows/install.ps1 @@ -1,3 +1,11 @@ +# Licensed under the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +# This is just a little script that can be downloaded from the internet to +# install rover. It just downloads the installer and runs it. + # version found in Rover's Cargo.toml # Note: this line is built automatically # in build.rs. Don't touch it! @@ -65,14 +73,8 @@ function Initialize-Environment() { break } - If (-Not (Get-Command 'curl')) { - Write-Error "The curl command is not installed on this machine. Please install curl before installing Rover" - # don't abort if invoked with iex that would close the PS session - If ($myinvocation.mycommand.commandtype -eq 'Script') { return } else { exit 1 } - } - If (-Not (Get-Command 'tar')) { - Write-Error "The tar command is not installed on this machine. Please install curl before installing Rover" + Write-Error "The tar command is not installed on this machine. Please install tar before installing Rover" # don't abort if invoked with iex that would close the PS session If ($myinvocation.mycommand.commandtype -eq 'Script') { return } else { exit 1 } } diff --git a/installers/binstall/scripts/windows/local-install.ps1 b/installers/binstall/scripts/windows/local-install.ps1 deleted file mode 100644 index c8e4d60278..0000000000 --- a/installers/binstall/scripts/windows/local-install.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -cargo build --workspace -..\..\..\..\..\target\debug\rover.exe install \ No newline at end of file