1
1
#! /bin/bash
2
2
3
- # ## Builds cardano-node on Ubuntu or Fedora using Cabal and verifys successful installation
3
+ # ## Builds cardano-node on Ubuntu or Fedora using Cabal and verifies successful installation
4
4
# ## Please note: sudo is not used because user is root
5
5
# ## Please note: 'source ~/.bashrc' cmd is not used because Docker runs this script as subscript
6
6
7
7
echo " "
8
8
9
- if [[ $TAGGED_VERSION == " null" ]]
9
+ # Check that environment variables are correctly set up.
10
+ if [[ -z " ${GIT_OBJECT} " ]]
10
11
then
11
- printf " Please specify TAGGED_VERSION on docker run.\ne.g. '-e TAGGED_VERSION=1.23.0'"
12
+ >&2 printf " Please specify GIT_OBJECT_TYPE on docker run.\ne.g. '-e GIT_OBJECT_TYPE=tag' or '-e GIT_OBJECT_TYPE=commit'"
13
+ elif [[ -z " ${GIT_OBJECT} " ]]
14
+ then
15
+ >&2 printf " Please specify GIT_OBJECT on docker run.\ne.g. '-e GIT_OBJECT=1.23.0' for tags, or '-e GIT_OBJECT=78wagy3aw87ef' for commits."
16
+ exit 1
12
17
fi
13
18
14
- echo " Using tagged version $TAGGED_VERSION "
19
+ echo " Using git object ' $GIT_OBJECT ' of type ' $GIT_OBJECT_TYPE ' "
15
20
cd ~ || exit 1
16
21
22
+ # Set up GHC and cabal-install versions
23
+ GHC_VERSION=" 8.10.7"
24
+ GHC=" ghc-$GHC_VERSION "
25
+ GHC_SUFFIX=" x86_64-deb9-linux.tar.xz"
26
+ GHC_FULL=" $GHC -$GHC_SUFFIX "
27
+
28
+ echo " Using GHC version $GHC_VERSION "
29
+
30
+ CABAL_VERSION=" 3.6.2.0"
31
+ CABAL=" cabal-install-$CABAL_VERSION "
32
+ CABAL_SUFFIX=" x86_64-linux-deb10.tar.xz"
33
+ CABAL_FULL=" $CABAL -$CABAL_SUFFIX "
34
+
35
+ echo " Using cabal-install version $CABAL_VERSION "
36
+
17
37
# Install dependencies
18
38
echo " Install dependencies"
19
39
if [[ $( cat /etc/os-release) == * " fedora" * ]]
20
40
then
21
41
echo " Running on Fedora"
22
42
yum update -y
23
43
yum install git gcc gcc-c++ tmux gmp-devel make tar xz wget zlib-devel libtool autoconf -y
24
- yum install systemd-devel ncurses-devel ncurses-compat-libs -y
44
+ yum install systemd-devel ncurses-devel ncurses-compat-libs openssl-devel lmdb-devel -y
25
45
elif [[ $( cat /etc/os-release) == * " ubuntu" * ]]
26
46
then
27
47
echo " Running on Ubuntu"
28
48
apt-get update -y
29
- apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf -y
49
+ apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf liblmdb-dev -y
30
50
else
31
- echo " /etc/os-relase does not contain 'fedora' or 'ubuntu'"
32
- cat /etc/os-release
51
+ >&2 echo " /etc/os-relase does not contain 'fedora' or 'ubuntu'"
52
+ >&2 cat /etc/os-release
33
53
exit 1
34
54
fi
35
55
36
56
# Download, unpack, install and update Cabal
37
57
echo " Download, unpack, install and update Cabal"
38
- wget https://downloads.haskell.org/~cabal/cabal-install-3.2.0.0/cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz
39
- tar -xf cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz
40
- rm cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz cabal.sig
58
+ wget https://downloads.haskell.org/~cabal/$CABAL / $CABAL_FULL
59
+ tar -xf $CABAL_FULL
60
+ rm $CABAL_FULL
41
61
mkdir -p ~ /.local/bin
42
62
mv cabal ~ /.local/bin/
43
63
54
74
55
75
cabal update
56
76
57
- if [[ $( cabal --version) != * " cabal-install version 3.2.0.0 " * ]]
77
+ if [[ $( cabal --version) != * " cabal-install version $CABAL_VERSION " * ]]
58
78
then
59
- echo " cabal version $( cabal --version) is not 3.2.0.0 "
79
+ >&2 echo " cabal version $( cabal --version) is not $CABAL_VERSION "
60
80
exit 1
61
81
else
62
- echo " cabal version 3.2.0.0 is correct"
82
+ echo " cabal version $CABAL_VERSION is correct"
63
83
fi
64
84
65
- # Download and install GHC
85
+ # Download, unpack and install GHC
66
86
echo " Download and install GHC"
67
87
68
88
mkdir -p ~ /src || exit 1
69
89
cd ~ /src || exit 1
70
- wget https://downloads.haskell.org/ghc/8.10.2/ghc-8.10.2-x86_64-deb9-linux.tar.xz
71
- tar -xf ghc-8.10.2-x86_64-deb9-linux.tar.xz
72
- rm ghc-8.10.2-x86_64-deb9-linux.tar.xz
73
- cd ghc-8.10.2 || exit 1
90
+ wget https://downloads.haskell.org/ghc/$GHC_VERSION / $GHC_FULL
91
+ tar -xf $GHC_FULL
92
+ rm $GHC_FULL
93
+ cd $GHC || exit 1
74
94
./configure
75
95
make install
76
96
97
+ if [[ $( ghc --version) != * " version $GHC_VERSION " * ]]
98
+ then
99
+ >&2 echo " ghc version $( ghc --version) is not $GHC_VERSION "
100
+ exit 1
101
+ else
102
+ echo " ghc version $GHC_VERSION is correct"
103
+ fi
104
+
77
105
# Install Libsodium
78
- echo " Install Lobsodium "
106
+ echo " Install Libsodium "
79
107
80
108
mkdir -p ~ /src || exit 1
81
109
cd ~ /src || exit 1
@@ -90,6 +118,19 @@ make install
90
118
export LD_LIBRARY_PATH=" /usr/local/lib:$LD_LIBRARY_PATH "
91
119
export PKG_CONFIG_PATH=" /usr/local/lib/pkgconfig:$PKG_CONFIG_PATH "
92
120
121
+ # Install Secp256k1
122
+ echo " Install Secp256k1"
123
+
124
+ mkdir -p ~ /src || exit 1
125
+ cd ~ /src || exit 1
126
+ git clone https://github.com/bitcoin-core/secp256k1
127
+ cd secp256k1 || exit 1
128
+ git checkout ac83be33
129
+ ./autogen.sh
130
+ ./configure --enable-module-schnorrsig --enable-experimental
131
+ make
132
+ make install
133
+
93
134
# Download the source code for cardano-node
94
135
echo " Download the source code for cardano-node"
95
136
@@ -99,42 +140,101 @@ git clone https://github.com/input-output-hk/cardano-node.git
99
140
cd cardano-node || exit 1
100
141
git fetch --all --recurse-submodules --tags
101
142
102
- if [[ $( git tag) != * " $TAGGED_VERSION " * ]]
143
+ # Checkout with prechecks for git object and git object type
144
+ if [[ $( git cat-file -t " $GIT_OBJECT " ) != " commit" ]]
103
145
then
104
- echo " $( git tag ) does not contain $TAGGED_VERSION "
146
+ >&2 echo " $( git cat-file -t " $GIT_OBJECT " ) does not refer to a commit/tag. "
105
147
exit 1
106
148
fi
107
149
108
- git checkout " tags/$TAGGED_VERSION "
150
+ case $GIT_OBJECT_TYPE in
151
+ tag)
152
+ if [[ $( git tag) != * " $GIT_OBJECT " ]]
153
+ then
154
+ >&2 echo " $( git tag) does not contain $GIT_OBJECT "
155
+ exit 1
156
+ fi
157
+ ;;
158
+ commit)
159
+ :
160
+ ;;
161
+ * )
162
+ exit 1
163
+ ;;
164
+ esac
165
+
166
+ git checkout " $GIT_OBJECT "
109
167
110
168
# Configure and build options
111
169
echo " Configure and build options"
112
- cabal configure --with-compiler=ghc-8.10.2
170
+ cabal configure --with-compiler=$GHC
113
171
echo " package cardano-crypto-praos" >> cabal.project.local
114
172
echo " flags: -external-libsodium-vrf" >> cabal.project.local
115
173
116
174
# Build and install the node
117
175
echo " Build and install the node"
118
176
cabal build all
119
- cabal install all --bindir ~ /.local/bin
120
-
121
- if [[ ! -d ~ /.local/bin/dist-newstyle/build/x86_64-linux/ghc-8.10.2/cardano-cli-$TAGGED_VERSION /x/ ]]
177
+ cabal install --bindir=~ /.local/bin cardano-node cardano-cli
178
+
179
+ # This is a bit of ugly indirection, and can probably be done better. The
180
+ # problem is that the path is a glob, and so might match more than 1
181
+ # path
182
+ INSTALLED=false
183
+ for d in ~ /.local/bin/dist-newstyle/build/x86_64-linux/" $GHC " /cardano-cli-* /x/
184
+ do
185
+ echo " Found installation directory: $d "
186
+ INSTALLED=true
187
+ done
188
+
189
+ if ! $INSTALLED
122
190
then
123
191
echo " Cabal build's --binddir did not work! Manually copying to ~/.local/bin/"
124
- cp -p " dist-newstyle/build/x86_64-linux/ghc-8.10.2/cardano-node-$TAGGED_VERSION /x/cardano-node/build/cardano-node/cardano-node" ~ /.local/bin/
125
- cp -p " dist-newstyle/build/x86_64-linux/ghc-8.10.2/cardano-cli-$TAGGED_VERSION /x/cardano-cli/build/cardano-cli/cardano-cli" ~ /.local/bin/
126
- fi
127
-
128
- # Verify node is installed
129
- echo " Verify node is installed"
130
- if [[ $( cardano-cli --version) == * " $TAGGED_VERSION " * ]]
131
- then
132
- cardano-cli --version
133
- else
134
- echo " $( cardano-cli --version) does not contain $TAGGED_VERSION "
135
- exit 1
192
+ cp -p " $( ./scripts/bin-path.sh cardano-node) " ~ /.local/bin/
193
+ cp -p " $( ./scripts/bin-path.sh cardano-cli) " ~ /.local/bin/
136
194
fi
137
195
196
+ # Verify installation
197
+ case $GIT_OBJECT_TYPE in
198
+ tag)
199
+ GIT_TAG=$GIT_OBJECT
200
+
201
+ # Verify cli is installed
202
+ echo " Verify cli is installed"
203
+ if [[ $( cardano-cli --version) == * " $GIT_TAG " * ]]
204
+ then
205
+ cardano-cli --version
206
+ else
207
+ >&2 echo " $( cardano-cli --version) does not contain $GIT_TAG "
208
+ exit 1
209
+ fi
210
+
211
+ # Verify node is installed
212
+ echo " Verify node is installed"
213
+ if [[ $( cardano-node --version) == * " $GIT_TAG " * ]]
214
+ then
215
+ cardano-node --version
216
+ else
217
+ >&2 echo " $( cardano-node --version) does not contain $GIT_TAG "
218
+ exit 1
219
+ fi
220
+
221
+ ;;
222
+ commit)
223
+ # Verify cli is installed
224
+ echo " Verify cli is installed"
225
+ cardano-cli --version
226
+
227
+ # Verify node is installed
228
+ echo " Verify node is installed"
229
+ cardano-node --version
230
+
231
+ ;;
232
+ * )
233
+ exit 1
234
+ ;;
235
+ esac
236
+
237
+ # Succes message
138
238
printf " \nSuccess\n\n"
139
239
echo " You can use 'docker exec -it <container-id> /bin/bash' in a separate session to play in the environment."
140
240
echo " Press any key to stop container."
0 commit comments