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.** diff --git a/tools/install_prerequisites.sh b/tools/install_prerequisites.sh new file mode 100755 index 00000000000..b8a09f856cf --- /dev/null +++ b/tools/install_prerequisites.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -eu + +# 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 + +# 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 + packages=( + 'libpq-dev' + 'pkg-config' + ) + confirm "Install (or update) [${packages[*]}]?" && sudo apt-get install ${packages[@]} +elif [[ "${HOST_OS}" == "SunOS" ]]; then + packages=( + 'pkg:/package/pkg' + 'build-essential' + 'library/postgresql-13' + 'pkg-config' + 'brand/omicron1/tools' + ) + + # 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 + 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. + if [[ "$rc" -ne 4 ]] && [[ "$rc" -ne 0 ]]; then + exit "$rc" + fi + + pkg list -v "${packages[@]}" +elif [[ "${HOST_OS}" == "Darwin" ]]; then + packages=( + 'postgresql' + 'pkg-config' + ) + confirm "Install (or update) [${packages[*]}]?" && brew install ${packages[@]} +else + echo "Unsupported OS: ${HOST_OS}" + exit -1 +fi + +./tools/ci_download_cockroachdb +./tools/ci_download_clickhouse