aboutsummaryrefslogtreecommitdiff
path: root/tezos/install.sh
blob: 0d554720ee8e08b9adc2b86aaf39c5b15270dceb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
set -e

# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# 
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.

ocaml_compiler="4.09.1"
ocaml_switch_name="for_tezos"

printf "\033[1;31m"
echo "**********************************************************************"
echo "* Short install script for tezos from source code, loosely based on: *"
echo "* https://tezos.gitlab.io/introduction/howtoget.html                 *"
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                                    *"
echo "**********************************************************************"
echo 
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

# Check and see if rustc is available, if not we're going to go ahead
# and try to install it from their main source
if ! stat "$(which rustc | sed 1q)" >/dev/null 2>&1 ; then
	echo "Need rustc... installing"
	curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
fi

rustup set profile minimal
rustup toolchain install 1.39.0
rustup default 1.39.0
. $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
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"
fi
opam switch "$ocaml_switch_name"
eval $(opam env)

opam install depext
opam depext tezos

opam install tezos