Skip to content

Commit

Permalink
Always use latest build2 version (Ericsson#655)
Browse files Browse the repository at this point in the history
* feat: add script to install latest build2 version

* ci: always use latest build2 in gitlab CI

* docs: update build2 install instructions
  • Loading branch information
LoremIPsummer authored and mozesl committed Nov 1, 2023
1 parent 461b848 commit cfda803
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
6 changes: 1 addition & 5 deletions .gitlab/build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ if [ ! -f $DEPS_INSTALL_RUNTIME_DIR/odb-install/bin/odb ]; then
if [[ $ODB_VERSION == "2.5.0" ]]; then
# build2
cd $PACKAGES_DIR
wget --no-verbose --no-clobber https://download.build2.org/0.16.0/build2-install-0.16.0.sh
sh build2-install-0.16.0.sh --yes --trust yes --jobs $(nproc) $PACKAGES_DIR/build2-install
sh $CI_PROJECT_DIR/scripts/install_latest_build2.sh $PACKAGES_DIR/build2-install
export PATH=$PACKAGES_DIR/build2-install/bin:$PATH

# odb, libodb
Expand All @@ -160,9 +159,6 @@ if [ ! -f $DEPS_INSTALL_RUNTIME_DIR/odb-install/bin/odb ]; then
bpkg build libodb-sqlite --yes --quiet --jobs $(nproc)
bpkg build libodb-pgsql --yes --quiet --jobs $(nproc)
bpkg install --all --recursive --quiet --jobs $(nproc)

rm -f $PACKAGES_DIR/build2-toolchain-0.16.0.tar.xz
rm -f $PACKAGES_DIR/build2-install-0.16.0.sh
elif [[ $ODB_VERSION == "2.4.0" ]]; then
# odb
cd $PACKAGES_DIR
Expand Down
4 changes: 2 additions & 2 deletions doc/deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ The ODB installation uses the build2 build system. (Build2 is not needed for
CodeCompass so you may delete it right after the installation of ODB.)

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

Now, utilizing the *Build2* toolchain, we can build the *ODB* compiler and
Expand Down
44 changes: 44 additions & 0 deletions scripts/install_latest_build2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

if [ $# -lt 1 ]; then
echo "No installation directory was provided for build2!" 1>&2
exit 1
fi

## download phase

install_dir=$1
toolchain_file="toolchain.sha256"
wget --no-verbose --no-clobber https://download.build2.org/toolchain.sha256 -O "${toolchain_file}"

version_line=$(grep -m 1 '' "$toolchain_file")
version_number=$(echo "$version_line" | awk '{print $2}')
version_to_install=build2-install-${version_number}.sh
download_url=https://download.build2.org/${version_number}/${version_to_install}
wget --no-verbose --no-clobber "${download_url}" -O "${version_to_install}"

## sha256 check phase

line_with_version=$(grep "$version_to_install" "$toolchain_file")
checksum_for_version=$(echo "$line_with_version" | awk '{print $1}')

if echo "${checksum_for_version} ${version_to_install}" | sha256sum -c; then
echo "Build2 installer for version ${version_number} has been downloaded!"
else
echo "Expected checksum for build2 installer version ${version_number} doesn't match! Probably the file has been corrupted! Please install it manually!" 1>&2
echo "Expected: ${checksum_for_version}" 1>&2
rm "$version_to_install" "$toolchain_file"
exit 1
fi

## install phase

sh ${version_to_install} --yes --trust yes --jobs $(nproc) "${install_dir}"

## cleanup phase

compressed_toolchain="build2-toolchain-${version_number}.tar.xz"

rm -f "${toolchain_file}" "${version_to_install}" "${compressed_toolchain}"

echo "Build2 version ${version_number} has been successfully installed!"

0 comments on commit cfda803

Please sign in to comment.