forked from covalenthq/erigon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·133 lines (114 loc) · 3.64 KB
/
install.sh
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
#
# This is a rather minimal example Argbash potential
# Example taken from http://argbash.readthedocs.io/en/stable/example.html
#
# ARG_OPTIONAL_SINGLE([evm_tool_version],[],[version of evm tool to be used],[latest])
# ARG_OPTIONAL_SINGLE([output_location],[],[output location of generated evm binary],[./])
# ARG_OPTIONAL_SINGLE([repo_download_location],[],[location of repo to be downloaded],[./])
# ARG_OPTIONAL_BOOLEAN([remove_repo],[],[should delete repo once build is done?],[off])
# ARG_HELP([builds evm transition tool)])
# ARGBASH_GO()
# needed because of Argbash --> m4_ignore([
### START OF CODE GENERATED BY Argbash v2.9.0 one line above ###
# Argbash is a bash code generator used to get arguments parsing right.
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
# Generated online by https://argbash.io/generate
set -e
die()
{
local _ret="${2:-1}"
test "${_PRINT_HELP:-no}" = yes && print_help >&2
echo "$1" >&2
exit "${_ret}"
}
begins_with_short_option()
{
local first_option all_short_options='h'
first_option="${1:0:1}"
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
}
# THE DEFAULTS INITIALIZATION - OPTIONALS
_arg_evm_tool_version="latest"
_arg_output_location="./"
_arg_repo_download_location="./erigon"
_arg_remove_repo="on"
print_help()
{
printf '%s\n' "builds evm transition tool)"
printf 'Usage: %s [--evm_tool_version <arg>] [--output_location <arg>] [--repo_download_location <arg>] [--(no-)remove_repo] [-h|--help]\n' "$0"
printf '\t%s\n' "--evm_tool_version: version of evm tool to be used (default: 'latest')"
printf '\t%s\n' "--output_location: output location of generated evm binary (default: './')"
printf '\t%s\n' "--repo_download_location: location of repo to be downloaded (default: './erigon')"
printf '\t%s\n' "--remove_repo, --no-remove_repo: should delete repo once build is done? (on by default)"
printf '\t%s\n' "-h, --help: Prints help"
}
parse_commandline()
{
while test $# -gt 0
do
_key="$1"
case "$_key" in
--evm_tool_version)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_evm_tool_version="$2"
shift
;;
--evm_tool_version=*)
_arg_evm_tool_version="${_key##--evm_tool_version=}"
;;
--output_location)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_output_location="$2"
shift
;;
--output_location=*)
_arg_output_location="${_key##--output_location=}"
;;
--repo_download_location)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_repo_download_location="$2"
shift
;;
--repo_download_location=*)
_arg_repo_download_location="${_key##--repo_download_location=}"
;;
--no-remove_repo|--remove_repo)
_arg_remove_repo="on"
test "${1:0:5}" = "--no-" && _arg_remove_repo="off"
;;
-h|--help)
print_help
exit 0
;;
-h*)
print_help
exit 0
;;
*)
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
;;
esac
shift
done
}
parse_commandline "$@"
# OTHER STUFF GENERATED BY Argbash
### END OF CODE GENERATED BY Argbash (sortof) ### ])
# [ <-- needed because of Argbash
if [ "$_arg_evm_tool_version" == "latest" ]; then
git clone https://github.com/covalenthq/erigon.git --depth 1 $_arg_repo_download_location
else
git clone https://github.com/covalenthq/erigon.git $_arg_repo_download_location
cd erigon
git checkout $_arg_evm_tool_version
cd ..
fi
cd erigon
make evm-dbg
cd ..
mv erigon/build/bin/evm $_arg_output_location/
if [ "$_arg_remove_repo" == "on" ]; then
rm -rf erigon
fi
# ] <-- needed because of Argbash