From 3dde175f4d0cf9dfc66852b15599f45de03b792b Mon Sep 17 00:00:00 2001 From: MarkSh1 <39378855+MarkSh1@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:46:24 +0300 Subject: [PATCH] Adobted build scripts for Debian12 and Ubuntu22 (#119) --- .github/workflows/build.yml | 11 +++++++--- .github/workflows/make-build-image.yml | 3 ++- build-scripts/for-linux/build-on-linux.bash | 22 +++++++++++++++++-- .../for-linux/prepare-debian-based-clang.sh | 11 ++++++++-- .../for-linux/prepare-debian-based-jdk.bash | 2 +- .../for-linux/prepare-debian-based.bash | 6 ++++- 6 files changed, 45 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 67eaf74b0dc..1aee4d74b3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,13 +49,18 @@ jobs: for: linux prepare: "debian-based" build_on: linux - use_image: ghcr.io/owtech/foundationdb-build:7.4.0-1.ow.build - parallel: 2 + parallel: 5 + image: foundationdb-build:7.4.0-1.ow.build + owner: owtech runs-on: ${{ matrix.run_on }} steps: - name: Checkout uses: actions/checkout@v3 + + - name: Set building repo + run: | + echo "use_image=ghcr.io/${{matrix.owner}}/${{matrix.image}}" >> "$GITHUB_ENV" - name: Build run: | @@ -68,7 +73,7 @@ jobs: --security-opt label=disable \ --mount=type=bind,src=${{github.workspace}},dst=/home/runner/src,readonly \ --mount=type=bind,src=${{github.workspace}}/bld,dst=/home/runner/bld \ - ${{ matrix.use_image }} \ + $use_image \ /home/runner/src/build-scripts/for-${{ matrix.for }}/build-on-${{ matrix.build_on }}.bash \ ${{needs.calc_ver.outputs.project_ver}} \ ${{needs.calc_ver.outputs.build_ver}} \ diff --git a/.github/workflows/make-build-image.yml b/.github/workflows/make-build-image.yml index a6f7313f08c..4d832e0c48f 100644 --- a/.github/workflows/make-build-image.yml +++ b/.github/workflows/make-build-image.yml @@ -26,6 +26,7 @@ jobs: build-image: needs: [calc_ver] + permissions: write-all strategy: matrix: @@ -59,4 +60,4 @@ jobs: run: echo "${{ secrets.GITHUB_TOKEN }}" | podman login ghcr.io -u $ --password-stdin - name: Push image - run: podman push $IMAGE_NAME ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME + run: podman push $IMAGE_NAME ghcr.io/${GITHUB_REPOSITORY_OWNER@L}/$IMAGE_NAME diff --git a/build-scripts/for-linux/build-on-linux.bash b/build-scripts/for-linux/build-on-linux.bash index d249a162e7a..a97a430d7ec 100755 --- a/build-scripts/for-linux/build-on-linux.bash +++ b/build-scripts/for-linux/build-on-linux.bash @@ -6,6 +6,19 @@ # $4 - Paralllel threads # $5 - Source Dir. If not set then relative to the script dir +#!/bin/bash + +get_oldest_java_path() +{ + if [ -x "$(command -v update-java-alternatives)" ] + then + update-java-alternatives -l | sort -Vk1 | head -n 1 | awk '{print $3}' + else + echo 'update-java-alternatives is not installed' >&2 + ls -d /etc/alternatives/java_sdk_*[0-9] | sort -V | head -n 1 + fi +} + set -e BASE_DIR="$(readlink -f $(dirname $0))" @@ -38,8 +51,13 @@ APP_PRMS="\ # find swift APP_PRMS="$APP_PRMS -DCMAKE_Swift_COMPILER=`$BASE_DIR/find-swift.bash`" -echo "env CC=clang CXX=clang++ cmake -G Ninja $APP_PRMS . $SRC_DIR" -env CC=clang CXX=clang++ cmake -G Ninja $APP_PRMS . $SRC_DIR +# set oldest java +JAVA_OLDEST_PATH=$(get_oldest_java_path) + +echo "env JAVA_HOME=$JAVA_OLDEST_PATH CC=clang CXX=clang++ cmake -G Ninja $APP_PRMS $SRC_DIR" +env JAVA_HOME=$JAVA_OLDEST_PATH CC=clang CXX=clang++ cmake -G Ninja $APP_PRMS $SRC_DIR + +echo "number of parallel jobs: [$PARALLEL_PRMS]" ninja $PARALLEL_PRMS -k 0 diff --git a/build-scripts/for-linux/prepare-debian-based-clang.sh b/build-scripts/for-linux/prepare-debian-based-clang.sh index 36872d3f498..589afd04023 100755 --- a/build-scripts/for-linux/prepare-debian-based-clang.sh +++ b/build-scripts/for-linux/prepare-debian-based-clang.sh @@ -5,9 +5,16 @@ set -e sudo apt update + +# clang no more than 14 version is needed for boost-5.3 building +max_clang_version=14 + RECENT_VERSION=` \ - apt search -o APT::Cache::Search::Version=1 '^clang-[0-9]+$' \ - | tr - ' ' | awk '{print $2;}' | sort -n | tail -n 1` + apt-cache search -o APT::Cache::Search::Version=1 '^clang-[0-9]+$' | \ + tr - ' ' | \ + awk -v ver="$max_clang_version" '{if($2<=ver) print $2;}' | \ + sort -n | \ + tail -n 1` sudo DEBIAN_FRONTEND=noninteractive apt install -y \ clang-$RECENT_VERSION libc++-$RECENT_VERSION-dev libc++abi-$RECENT_VERSION-dev diff --git a/build-scripts/for-linux/prepare-debian-based-jdk.bash b/build-scripts/for-linux/prepare-debian-based-jdk.bash index e1dedc89ab4..eabf65a447e 100755 --- a/build-scripts/for-linux/prepare-debian-based-jdk.bash +++ b/build-scripts/for-linux/prepare-debian-based-jdk.bash @@ -7,7 +7,7 @@ set -e sudo apt update find_pkg() { - apt search -o APT::Cache::Search::Version=1 "^$1\$" | awk '{print $1;}' + apt-cache search -o APT::Cache::Search::Version=1 "^$1\$" | awk '{print $1;}' } PKG_AV="" diff --git a/build-scripts/for-linux/prepare-debian-based.bash b/build-scripts/for-linux/prepare-debian-based.bash index 8ed0b13a486..4203e9ffecf 100755 --- a/build-scripts/for-linux/prepare-debian-based.bash +++ b/build-scripts/for-linux/prepare-debian-based.bash @@ -6,6 +6,9 @@ BASE_DIR=`dirname $0` sudo apt update +# wget is required to download cmake 3.24 if you are using Debian 12 to build. +sudo DEBIAN_FRONTEND=noninteractive apt-get install -y wget + $BASE_DIR/prepare-debian-based-cmake.bash 3.24 $BASE_DIR/prepare-debian-based-clang.sh $BASE_DIR/prepare-debian-based-jdk.bash @@ -38,4 +41,5 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ libmono-system-runtime-serialization4.0-cil \ libmono-system-xml-linq4.0-cil -sudo pip3 install sphinx-bootstrap-theme +sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ + python3-sphinx-bootstrap-theme