Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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 <<Deploying Omicron>> 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.**
Expand Down
74 changes: 74 additions & 0 deletions tools/install_prerequisites.sh
Original file line number Diff line number Diff line change
@@ -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