From 89a9aa5e160d8d243064f2ca71f06c842a766023 Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Fri, 1 Apr 2022 15:52:14 -0400 Subject: [PATCH 1/6] Add a script for installing all the software mentioned in the README --- tools/install_prerequisites.sh | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 tools/install_prerequisites.sh diff --git a/tools/install_prerequisites.sh b/tools/install_prerequisites.sh new file mode 100755 index 00000000000..05dd34100ff --- /dev/null +++ b/tools/install_prerequisites.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +set -eu + +# Set the CWD to Omicron's source. +SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd "${SOURCE_DIR}/.." + +HOST_OS=$(uname -s) +if [[ "${HOST_OS}" == "Linux" ]]; then + echo "Linux" + sudo apt-get install libpq-dev + sudo apt-get install pkg-config +elif [[ "${HOST_OS}" == "SunOS" ]]; then + echo "illumos" + need=( + 'build-essential' + 'library/postgresql-13' + 'pkg-config' + 'brand/omicron1/tools' + 'pkg:/package/pkg' + ) + missing=() + for (( i = 0; i < ${#need[@]}; i++ )); do + p=${need[$i]} + if ! pkg info -q "$p"; then + missing+=( "$p" ) + fi + done + if (( ${#missing[@]} > 0 )); then + pfexec pkg install -v "${missing[@]}" + fi + pkg list -v "${need[@]}" +elif [[ "${HOST_OS}" == "Darwin" ]]; then + echo "Mac" + brew install postgresql + brew install pkg-config +else + echo "Unsupported OS" + exit -1 +fi + +./tools/ci_download_cockroachdb +./tools/ci_download_clickhouse From 147c97c2df680a035775950b54ca452a3b30076f Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Fri, 1 Apr 2022 16:00:14 -0400 Subject: [PATCH 2/6] Update Readme --- README.adoc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index ef6e5d40f65..c63d6043171 100644 --- a/README.adoc +++ b/README.adoc @@ -33,7 +33,15 @@ You can **format the code** using `cargo fmt`. Make sure to run this before pus You can **run the https://github.com/rust-lang/rust-clippy[Clippy linter]** using `cargo clippy \-- -D warnings -A clippy::style`. Make sure to run this before pushing changes. The CI checks that the code is clippy-clean. -**Prerequisites:** +=== Installing Prerequisite Software + +The following software may be installed automatically with the following scripts: + +---- +$ ./tools/install_prerequisites.sh +---- + +Alternatively, the manual installation steps as follows: Both normal execution and the test suite expect certain binaries (described below) on your PATH. @@ -83,6 +91,10 @@ pkg install pkg:/package/pkg pkg update ---- +=== Running (Simulated) Omicron + +NOTE: If you'd like to run on Helios, refer to <> below. + To **run Omicron** you need to run four programs: * a CockroachDB cluster. For development, you can use the `omicron-dev` tool in this repository to start a single-node CockroachDB cluster **that will delete the database when you shut it down.** From 0e5d9846f1f2e29d3d5e60c6c3551ea5a2c7bb35 Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Sat, 2 Apr 2022 22:28:12 -0400 Subject: [PATCH 3/6] Merge update and install --- tools/install_prerequisites.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tools/install_prerequisites.sh b/tools/install_prerequisites.sh index 05dd34100ff..390094b4ef5 100755 --- a/tools/install_prerequisites.sh +++ b/tools/install_prerequisites.sh @@ -8,35 +8,34 @@ cd "${SOURCE_DIR}/.." HOST_OS=$(uname -s) if [[ "${HOST_OS}" == "Linux" ]]; then - echo "Linux" sudo apt-get install libpq-dev sudo apt-get install pkg-config elif [[ "${HOST_OS}" == "SunOS" ]]; then - echo "illumos" need=( + 'pkg:/package/pkg' 'build-essential' 'library/postgresql-13' 'pkg-config' 'brand/omicron1/tools' - 'pkg:/package/pkg' ) - missing=() - for (( i = 0; i < ${#need[@]}; i++ )); do - p=${need[$i]} - if ! pkg info -q "$p"; then - missing+=( "$p" ) + + # Perform updates + if (( ${#need[@]} > 0 )); then + pfexec pkg install -v "${need[@]}" && rc=$? || rc=$? + # Return codes: + # 0: Normal Success + # 4: Failure because we're already up-to-date. Also acceptable. + if [ "$rc" -ne 4 ] && [ "$rc" -ne 0 ]; then + exit "$rc" fi - done - if (( ${#missing[@]} > 0 )); then - pfexec pkg install -v "${missing[@]}" fi + pkg list -v "${need[@]}" elif [[ "${HOST_OS}" == "Darwin" ]]; then - echo "Mac" brew install postgresql brew install pkg-config else - echo "Unsupported OS" + echo "Unsupported OS: ${HOST_OS}" exit -1 fi From 3de53f182027f6030f1ec907d611ecc688b5960a Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Mon, 4 Apr 2022 14:33:58 -0400 Subject: [PATCH 4/6] More docs, hopefully more clear rc usage --- tools/install_prerequisites.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/install_prerequisites.sh b/tools/install_prerequisites.sh index 390094b4ef5..a42cca50e19 100755 --- a/tools/install_prerequisites.sh +++ b/tools/install_prerequisites.sh @@ -11,7 +11,7 @@ if [[ "${HOST_OS}" == "Linux" ]]; then sudo apt-get install libpq-dev sudo apt-get install pkg-config elif [[ "${HOST_OS}" == "SunOS" ]]; then - need=( + packages=( 'pkg:/package/pkg' 'build-essential' 'library/postgresql-13' @@ -19,18 +19,19 @@ elif [[ "${HOST_OS}" == "SunOS" ]]; then 'brand/omicron1/tools' ) - # Perform updates - if (( ${#need[@]} > 0 )); then - pfexec pkg install -v "${need[@]}" && rc=$? || rc=$? - # Return codes: - # 0: Normal Success - # 4: Failure because we're already up-to-date. Also acceptable. - if [ "$rc" -ne 4 ] && [ "$rc" -ne 0 ]; then - exit "$rc" - fi + # Install/update the set of packages. + # Explicitly manage the return code using "rc" to observe the result of this + # command without exiting the script entirely (due to bash's "errexit"). + rc=0 + pfexec pkg install -v "${packages[@]}" || rc=$? + # Return codes: + # 0: Normal Success + # 4: Failure because we're already up-to-date. Also acceptable. + if [[ "$rc" -ne 4 ]] && [[ "$rc" -ne 0 ]]; then + exit "$rc" fi - pkg list -v "${need[@]}" + pkg list -v "${packages[@]}" elif [[ "${HOST_OS}" == "Darwin" ]]; then brew install postgresql brew install pkg-config From fd77f51bd0606b910e3fcf4af2912fd02d9e5835 Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Mon, 4 Apr 2022 15:52:18 -0400 Subject: [PATCH 5/6] Idempotency message on error --- tools/install_prerequisites.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/install_prerequisites.sh b/tools/install_prerequisites.sh index a42cca50e19..9cc47afb389 100755 --- a/tools/install_prerequisites.sh +++ b/tools/install_prerequisites.sh @@ -2,6 +2,12 @@ set -eu +on_exit () { + echo "Something went wrong, but this script is idempotent - If you can fix the issue, try re-running" +} + +trap on_exit ERR + # Set the CWD to Omicron's source. SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd "${SOURCE_DIR}/.." From 8d7aa809055605b22926e9dd85a855cbaed84cf9 Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Mon, 4 Apr 2022 18:37:55 -0400 Subject: [PATCH 6/6] Add confirmation prompt --- tools/install_prerequisites.sh | 44 ++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/tools/install_prerequisites.sh b/tools/install_prerequisites.sh index 9cc47afb389..b8a09f856cf 100755 --- a/tools/install_prerequisites.sh +++ b/tools/install_prerequisites.sh @@ -2,20 +2,41 @@ set -eu -on_exit () { - echo "Something went wrong, but this script is idempotent - If you can fix the issue, try re-running" +# Set the CWD to Omicron's source. +SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd "${SOURCE_DIR}/.." + +function on_exit +{ + echo "Something went wrong, but this script is idempotent - If you can fix the issue, try re-running" } trap on_exit ERR -# Set the CWD to Omicron's source. -SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -cd "${SOURCE_DIR}/.." +# Offers a confirmation prompt. +# +# Args: +# $1: Text to be displayed +function confirm +{ + read -r -p "$1 (y/n): " response + case $response in + [yY]) + true + ;; + *) + false + ;; + esac +} HOST_OS=$(uname -s) if [[ "${HOST_OS}" == "Linux" ]]; then - sudo apt-get install libpq-dev - sudo apt-get install pkg-config + packages=( + 'libpq-dev' + 'pkg-config' + ) + confirm "Install (or update) [${packages[*]}]?" && sudo apt-get install ${packages[@]} elif [[ "${HOST_OS}" == "SunOS" ]]; then packages=( 'pkg:/package/pkg' @@ -29,7 +50,7 @@ elif [[ "${HOST_OS}" == "SunOS" ]]; then # Explicitly manage the return code using "rc" to observe the result of this # command without exiting the script entirely (due to bash's "errexit"). rc=0 - pfexec pkg install -v "${packages[@]}" || rc=$? + confirm "Install (or update) [${packages[*]}]?" && { pfexec pkg install -v "${packages[@]}" || rc=$?; } # Return codes: # 0: Normal Success # 4: Failure because we're already up-to-date. Also acceptable. @@ -39,8 +60,11 @@ elif [[ "${HOST_OS}" == "SunOS" ]]; then pkg list -v "${packages[@]}" elif [[ "${HOST_OS}" == "Darwin" ]]; then - brew install postgresql - brew install pkg-config + packages=( + 'postgresql' + 'pkg-config' + ) + confirm "Install (or update) [${packages[*]}]?" && brew install ${packages[@]} else echo "Unsupported OS: ${HOST_OS}" exit -1