From e862df276c2f99dbe8a66a1733d590fa498e9b1b Mon Sep 17 00:00:00 2001 From: David Herman Date: Mon, 11 Feb 2019 10:49:50 -0800 Subject: [PATCH 1/2] Update the bootstrap installer (ie the https://get.notionjs.com script) to choose between multiple Linux builds for Notion >= 0.2. --- dev/unix/boot-install.sh | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/dev/unix/boot-install.sh b/dev/unix/boot-install.sh index 5a1238b6c..fb12aa247 100755 --- a/dev/unix/boot-install.sh +++ b/dev/unix/boot-install.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +# This is the bootstrap Unix installer served by `https://get.notionjs.com`. +# Its responsibility is to query the system to determine what OS (and in the +# case of Linux, what OpenSSL version) the system has, and then proceed to +# fetch and install the appropriate build of Notion. + notion_get_latest_release() { curl --silent https://www.notionjs.com/latest-version } @@ -28,20 +33,29 @@ notion_warning() { notion_eprintf '' } -notion_exit() { - notion_cleanup - exit $1 -} - -notion_cleanup() { - unset -f notion_get_latest_release notion_eprintf notion_info notion_error notion_warning notion_exit notion_cleanup +# determines the major and minor version of OpenSSL on the system +notion_get_openssl_version() { + local LIB + local FULLVERSION + local MAJOR + local MINOR + # By default, we'll guess OpenSSL 1.0.1. + LIB="$(openssl version 2>/dev/null || echo 'OpenSSL 1.0.1')" + FULLVERSION="$(echo $LIB | awk '{print $2;}')" + MAJOR="$(echo ${FULLVERSION} | cut -d. -f1)" + MINOR="$(echo ${FULLVERSION} | cut -d. -f2)" + echo "${MAJOR}.${MINOR}" } NOTION_LATEST_VERSION=$(notion_get_latest_release) case $(uname) in Linux) - NOTION_OS=linux + if [[ "$NOTION_LATEST_VERSION" == 0.1* ]]; then + NOTION_OS=linux + else + NOTION_OS="linux-openssl-$(notion_get_openssl_version)" + fi NOTION_PRETTY_OS=Linux ;; Darwin) @@ -50,7 +64,7 @@ case $(uname) in ;; *) notion_error "The current operating system does not appear to be supported by Notion." - notion_exit 1 + exit 1 esac NOTION_INSTALLER="https://github.com/notion-cli/notion/releases/download/v${NOTION_LATEST_VERSION}/notion-${NOTION_LATEST_VERSION}-${NOTION_OS}.sh" @@ -60,4 +74,4 @@ notion_info 'Fetching' "${NOTION_PRETTY_OS} installer" curl -sSLf ${NOTION_INSTALLER} | bash STATUS=$? -notion_exit $STATUS +exit $STATUS From 581c5b95d07ce828c59ebf8365fa30ca8011cc4a Mon Sep 17 00:00:00 2001 From: David Herman Date: Mon, 11 Feb 2019 13:42:06 -0800 Subject: [PATCH 2/2] Fail fast if the system SSL library on Linux is anything other than OpenSSL. --- dev/unix/boot-install.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dev/unix/boot-install.sh b/dev/unix/boot-install.sh index fb12aa247..332d959d0 100755 --- a/dev/unix/boot-install.sh +++ b/dev/unix/boot-install.sh @@ -36,11 +36,21 @@ notion_warning() { # determines the major and minor version of OpenSSL on the system notion_get_openssl_version() { local LIB + local LIBNAME local FULLVERSION local MAJOR local MINOR + # By default, we'll guess OpenSSL 1.0.1. LIB="$(openssl version 2>/dev/null || echo 'OpenSSL 1.0.1')" + + LIBNAME="$(echo $LIB | awk '{print $1;}')" + + if [[ "$LIBNAME" != "OpenSSL" ]]; then + notion_error "Your system SSL library ($LIBNAME) is not currently supported on this OS." + #exit 1 + fi + FULLVERSION="$(echo $LIB | awk '{print $2;}')" MAJOR="$(echo ${FULLVERSION} | cut -d. -f1)" MINOR="$(echo ${FULLVERSION} | cut -d. -f2)"