diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2021-11-21 15:49:21 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2021-11-21 15:49:37 -0500 |
| commit | 59acf85c7371b5a955e420a02f469d43116d2a0c (patch) | |
| tree | 3b794f30f5ba65ddcd95793709f755b9e6dd3363 /tezos/install.sh | |
| parent | 58c3c4c8fb2de308fe5b99b22b1b1449186dcffe (diff) | |
| download | dotfiles-59acf85c7371b5a955e420a02f469d43116d2a0c.tar.gz dotfiles-59acf85c7371b5a955e420a02f469d43116d2a0c.tar.xz | |
Build tezos from source code. Allow version to be specified in start script.
Diffstat (limited to 'tezos/install.sh')
| -rw-r--r-- | tezos/install.sh | 111 |
1 files changed, 92 insertions, 19 deletions
diff --git a/tezos/install.sh b/tezos/install.sh index 0d55472..bcfb39e 100644 --- a/tezos/install.sh +++ b/tezos/install.sh @@ -13,9 +13,64 @@ set -e # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -ocaml_compiler="4.09.1" +# Add a given path to the start of your $PATH if it doesn't already +# exist +path_preappend() { + if [ -z "$1" ] ; then echo "need something to preappend" ; return ; fi + pth="$1"; shift + if ! echo "$PATH" | grep -qF "$pth" ; then + export PATH="$pth:$PATH" + fi +} + +ubuntuOpam() { +if grep -qi ubuntu /etc/os-release ; then + # Check and see if we have the ppa already, if not let's go ahead and add it + if ! apt policy 2>/dev/null | grep -q avsm/ppa ; then + sudo add-apt-repository ppa:avsm/ppa + sudo apt update + fi + sudo apt install opam +fi +} + +otherOpam() { +if ! grep -qi ubuntu /etc/os-release ; then + mkdir -p ~/bin + checksum="b727fa6c91b8a8d261dbbad3b16687db8364b49f57c934d2d751c8ee7153cb88" + curl -L -sS \ + "https://github.com/ocaml/opam/releases/download/2.0.10/opam-2.0.10-x86_64-linux" \ + > ~/bin/opam + + if ! sha256sum ~/bin/opam | grep -qi "$checksum" ; then + printf "\033[1;31m%s\033[0m\n" "Invalid checksum for ~/bin/opam" + exit 1 + fi + chmod +x ~/bin/opam +fi +} + +path_preappend "$HOME/bin" + +ocaml_version="4.12.1" # overridden later ocaml_switch_name="for_tezos" +envvars="$(curl -sS \ + 'https://gitlab.com/tezos/tezos/raw/latest-release/scripts/version.sh' \ + | sed -e '/^#/d' -e '/^$/d' )" + +printf "\033[1;33m" +printf "Fetched environment vars: \n%s\n" "$envvars" +printf "\033[0m" +printf "Does this look okay? [Yy]: " +read -r resp +case $resp in + [Yy]*) ;; + *) exit 0 ;; +esac + +eval "$(echo "$envvars")" + printf "\033[1;31m" echo "**********************************************************************" echo "* Short install script for tezos from source code, loosely based on: *" @@ -24,7 +79,9 @@ echo "* *" echo "* This script was created on 09-12-2020 and may need some checking *" echo "* over for updates in the future *" echo "* *" -echo "* ocaml_compiler: $ocaml_compiler *" +printf "* ocaml_version: %-51s *\n" "$ocaml_version" +printf "* ocaml_switch_name: %-47s *\n" "$ocaml_switch_name" +printf "* recommended_rust_version: %-40s *\n" "$recommended_rust_version" echo "**********************************************************************" echo printf "\033[0m" @@ -32,9 +89,7 @@ printf "\033[0m" set -x # Check and see if cargo is in the path, if not let's add it -if ! echo "$PATH"| grep -q cargo ; then - export PATH="$HOME/.cargo/bin:$PATH" -fi +path_preappend "$HOME/.cargo/bin" # Check and see if rustc is available, if not we're going to go ahead # and try to install it from their main source @@ -44,25 +99,43 @@ if ! stat "$(which rustc | sed 1q)" >/dev/null 2>&1 ; then fi rustup set profile minimal -rustup toolchain install 1.39.0 -rustup default 1.39.0 +rustup toolchain install "$recommended_rust_version" +rustup default "$recommended_rust_version" . $HOME/.cargo/env -# Check and see if we have the ppa already, if not let's go ahead and add it -if ! apt policy 2>/dev/null | grep -q avsm/ppa ; then - sudo add-apt-repository ppa:avsm/ppa - sudo apt update +if ! [ -x "$(command -v opam)" ] ; then + otherOpam ; ubuntuOpam +fi + +err=0 +for cmd in unzip ocamlc ; do +if ! [ -x "$(command -v $cmd)" ] ; then + echo "You need '$cmd' to continue" + err=1 +fi +done +if [ $err -ne 0 ] ; then + exit 1 +fi + +if ! [ -x "$(command -v opam)" ] ; then + printf "\033[1;31m" + printf "You need 'opam' installed in order to continue\n" + printf "\033[0m" fi -sudo apt install opam -# Only run if the switch for our tezos install does not currently exist -if ! opam switch list 2>/dev/null | grep -q "$ocaml_switch_name" ; then - opam switch create "$ocaml_switch_name" "$ocaml_compiler" +if ! [ -d "$HOME/tezos" ] ; then + git clone https://gitlab.com/tezos/tezos.git "$HOME/tezos" fi -opam switch "$ocaml_switch_name" + +cd "$HOME/tezos" + +git checkout latest-release + +make build-deps + eval $(opam env) -opam install depext -opam depext tezos +make -opam install tezos +cp -vf ~/tezos/tezos-* ~/bin/ |
