Skip to content

Commit cfda803

Browse files
LoremIPsummermozesl
authored andcommitted
Always use latest build2 version (Ericsson#655)
* feat: add script to install latest build2 version * ci: always use latest build2 in gitlab CI * docs: update build2 install instructions
1 parent 461b848 commit cfda803

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

.gitlab/build-deps.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ if [ ! -f $DEPS_INSTALL_RUNTIME_DIR/odb-install/bin/odb ]; then
138138
if [[ $ODB_VERSION == "2.5.0" ]]; then
139139
# build2
140140
cd $PACKAGES_DIR
141-
wget --no-verbose --no-clobber https://download.build2.org/0.16.0/build2-install-0.16.0.sh
142-
sh build2-install-0.16.0.sh --yes --trust yes --jobs $(nproc) $PACKAGES_DIR/build2-install
141+
sh $CI_PROJECT_DIR/scripts/install_latest_build2.sh $PACKAGES_DIR/build2-install
143142
export PATH=$PACKAGES_DIR/build2-install/bin:$PATH
144143

145144
# odb, libodb
@@ -160,9 +159,6 @@ if [ ! -f $DEPS_INSTALL_RUNTIME_DIR/odb-install/bin/odb ]; then
160159
bpkg build libodb-sqlite --yes --quiet --jobs $(nproc)
161160
bpkg build libodb-pgsql --yes --quiet --jobs $(nproc)
162161
bpkg install --all --recursive --quiet --jobs $(nproc)
163-
164-
rm -f $PACKAGES_DIR/build2-toolchain-0.16.0.tar.xz
165-
rm -f $PACKAGES_DIR/build2-install-0.16.0.sh
166162
elif [[ $ODB_VERSION == "2.4.0" ]]; then
167163
# odb
168164
cd $PACKAGES_DIR

doc/deps.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ The ODB installation uses the build2 build system. (Build2 is not needed for
120120
CodeCompass so you may delete it right after the installation of ODB.)
121121

122122
```bash
123-
wget https://download.build2.org/0.16.0/build2-install-0.16.0.sh
124-
sh build2-install-0.16.0.sh --yes --trust yes "<build2_install_dir>"
123+
wget https://github.com/Ericsson/CodeCompass/blob/master/scripts/install_latest_build2.sh
124+
sh install_latest_build2.sh "<build2_install_dir>"
125125
```
126126

127127
Now, utilizing the *Build2* toolchain, we can build the *ODB* compiler and

scripts/install_latest_build2.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
if [ $# -lt 1 ]; then
4+
echo "No installation directory was provided for build2!" 1>&2
5+
exit 1
6+
fi
7+
8+
## download phase
9+
10+
install_dir=$1
11+
toolchain_file="toolchain.sha256"
12+
wget --no-verbose --no-clobber https://download.build2.org/toolchain.sha256 -O "${toolchain_file}"
13+
14+
version_line=$(grep -m 1 '' "$toolchain_file")
15+
version_number=$(echo "$version_line" | awk '{print $2}')
16+
version_to_install=build2-install-${version_number}.sh
17+
download_url=https://download.build2.org/${version_number}/${version_to_install}
18+
wget --no-verbose --no-clobber "${download_url}" -O "${version_to_install}"
19+
20+
## sha256 check phase
21+
22+
line_with_version=$(grep "$version_to_install" "$toolchain_file")
23+
checksum_for_version=$(echo "$line_with_version" | awk '{print $1}')
24+
25+
if echo "${checksum_for_version} ${version_to_install}" | sha256sum -c; then
26+
echo "Build2 installer for version ${version_number} has been downloaded!"
27+
else
28+
echo "Expected checksum for build2 installer version ${version_number} doesn't match! Probably the file has been corrupted! Please install it manually!" 1>&2
29+
echo "Expected: ${checksum_for_version}" 1>&2
30+
rm "$version_to_install" "$toolchain_file"
31+
exit 1
32+
fi
33+
34+
## install phase
35+
36+
sh ${version_to_install} --yes --trust yes --jobs $(nproc) "${install_dir}"
37+
38+
## cleanup phase
39+
40+
compressed_toolchain="build2-toolchain-${version_number}.tar.xz"
41+
42+
rm -f "${toolchain_file}" "${version_to_install}" "${compressed_toolchain}"
43+
44+
echo "Build2 version ${version_number} has been successfully installed!"

0 commit comments

Comments
 (0)