From 5008e722190af0fc42a5af44290dd76cb3915b6f Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Fri, 9 Aug 2024 09:01:41 +0200 Subject: [PATCH] Run build in a single job (#34) --- .github/workflows/build.yml | 23 ++ .github/workflows/common.yml | 118 +++++++ .github/workflows/macos.yml | 605 ----------------------------------- build.sh | 49 ++- dependencies.sh | 43 ++- detect_os.sh | 17 + 6 files changed, 228 insertions(+), 627 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/common.yml delete mode 100644 .github/workflows/macos.yml create mode 100644 detect_os.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9c1d747 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Builds + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + + +jobs: + build_matrix: + strategy: + fail-fast: false + matrix: + os: + - macos-14 + - ubuntu-22.04 + - ubuntu-24.04 + uses: ./.github/workflows/common.yml + with: + os: ${{ matrix.os }} + secrets: inherit diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml new file mode 100644 index 0000000..67f0bca --- /dev/null +++ b/.github/workflows/common.yml @@ -0,0 +1,118 @@ +name: Build dependencies + +on: + workflow_call: + inputs: + os: + required: true + type: string + +env: + BUILD_DIR: ${{ github.workspace }}/build + INSTALL_DIR: ${{ github.workspace }}/install + + CCACHE_DIR: ${{ github.workspace }}/ccache + CCACHE_MAXSIZE: 10G + + CXX_STANDARD: "20" + +jobs: + + build: + runs-on: "${{ inputs.os }}" + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: ./dependencies.sh + + - name: Cache build + uses: actions/cache@v4 + with: + path: ${{ env.CCACHE_DIR }} + key: ccache-${{ runner.os }}-${{ github.job }} + + - name: Initial configure + run: > + cmake -S ${{ github.workspace }} + -B ${{ env.BUILD_DIR }} + -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} + -DCMAKE_BUILD_PARALLEL_LEVEL=3 + -DCMAKE_CXX_STANDARD=${{ env.CXX_STANDARD }} + + + - name: Build + run: > + cmake --build ${BUILD_DIR} + + - name: Remove .pyc files and tests from install directory + run: | + find ${INSTALL_DIR} -type f -name *.pyc -delete + rm -rf ${INSTALL_DIR}/python/3.12.2/lib/python3.12/test + + - name: Package build + run: | + tar czf install.tar.gz -C ${INSTALL_DIR} . + + - uses: actions/upload-artifact@v4 + with: + name: install_${{ inputs.os }} + path: | + install.tar.gz + + make_tarball: + runs-on: ubuntu-latest # we don't need macOS here + needs: [build] + steps: + - uses: actions/download-artifact@v4 + with: + name: install_${{ inputs.os }} + path: . + + - name: Unpack full bundle + run: | + mkdir -p ${INSTALL_DIR} + tar xf install.tar.gz -C ${INSTALL_DIR} + rm install.tar.gz + + - name: Package merged directory + run: | + tar cf - -C ${INSTALL_DIR} . | zstd -o install.tar.zst -19 -T$(nproc) + + - name: Upload merged install directory + uses: actions/upload-artifact@v4 + with: + name: deps_${{ inputs.os }} + path: | + install.tar.zst + + deploy_to_eos: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest # we don't need macOS here + needs: + - make_tarball + env: + DEPLOY_USER: ${{ secrets.DEPLOY_USER }} + DEPLOY_PWD: ${{ secrets.DEPLOY_PWD }} + steps: + - uses: actions/checkout@v4 + + - name: Install prerequisites + run: > + sudo apt-get install -y krb5-user krb5-config + + - uses: actions/download-artifact@v4 + with: + name: deps_${{ inputs.os }} + path: . + + - name: Upload + run: | + echo "$DEPLOY_PWD" | kinit $DEPLOY_USER@CERN.CH 2>&1 >/dev/null + sha=$(echo $GITHUB_SHA | head -c 7) + name=deps.$sha.tar.zst + echo $name + echo $sha + mv install.tar.zst $name + scp -F ssh_config $name $DEPLOY_USER@lxplus.cern.ch:/eos/user/a/atsjenkins/www/ACTS/ci/${{ inputs.os }}/cmake + ssh -F ssh_config $DEPLOY_USER@lxplus.cern.ch ln -f -s $name /eos/user/a/atsjenkins/www/ACTS/ci/${{ inputs.os }}/cmake/deps.latest.tar.zst diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml deleted file mode 100644 index 33f8fec..0000000 --- a/.github/workflows/macos.yml +++ /dev/null @@ -1,605 +0,0 @@ -name: macOS - -on: - push: - branches: - - main - pull_request: - workflow_dispatch: - -env: - BUILD_DIR: ${{ github.workspace }}/build - INSTALL_DIR: ${{ github.workspace }}/install - - CCACHE_DIR: ${{ github.workspace }}/ccache - CCACHE_MAXSIZE: 10G - - CXX_STANDARD: "20" - -jobs: - - build_python: - runs-on: macos-14 - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: ./dependencies.sh - - - name: Cache build - uses: actions/cache@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ runner.os }}-${{ github.job }}-python - restore-keys: | - ccache-${{ runner.os }}-${{ github.job }}-python - ccache-${{ runner.os }}-${{ github.job }}- - - - run: ls -al /Applications/Xcode_15.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ - - - - name: Initial configure - run: > - cmake -S ${{ github.workspace }} - -B ${{ env.BUILD_DIR }} - -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} - -DCMAKE_BUILD_PARALLEL_LEVEL=3 - -DCMAKE_CXX_STANDARD=${{ env.CXX_STANDARD }} - - - - name: Build - run: > - cmake --build ${BUILD_DIR} -- python - - - name: Remove .pyc files and tests from install directory - run: | - find ${INSTALL_DIR} -type f -name *.pyc -delete - rm -rf ${INSTALL_DIR}/python/3.12.2/lib/python3.12/test - - - name: Package build - run: | - tar czf build.tar.gz -C ${BUILD_DIR} . - tar czf install.tar.gz -C ${INSTALL_DIR} . - - - uses: actions/upload-artifact@v4 - with: - name: build_1 - path: | - build.tar.gz - install.tar.gz - - # can run in parallel, not needed by anything else - build_boost_eigen: - runs-on: macos-14 - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: ./dependencies.sh - - - name: Initial configure - run: > - cmake -S ${{ github.workspace }} - -B ${{ env.BUILD_DIR }} - -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} - -DCMAKE_BUILD_PARALLEL_LEVEL=3 - -DCMAKE_CXX_STANDARD=${{ env.CXX_STANDARD }} - - - name: Build - run: > - cmake --build ${BUILD_DIR} -- boost eigen - - - name: Package build - run: | - tar czf build.tar.gz -C ${BUILD_DIR} . - tar czf install.tar.gz -C ${INSTALL_DIR} . - - - uses: actions/upload-artifact@v4 - with: - name: build_boost_eigen - path: | - build.tar.gz - install.tar.gz - - build_tbb: - runs-on: macos-14 - needs: [build_python] - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: ./dependencies.sh - - - name: Cache build - uses: actions/cache@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ runner.os }}-${{ github.job }}-tbb - restore-keys: | - ccache-${{ runner.os }}-${{ github.job }}-tbb - ccache-${{ runner.os }}-${{ github.job }}- - - - uses: actions/download-artifact@v4 - with: - name: build_1 - path: . - - - run: | - mkdir ${BUILD_DIR} - tar xf build.tar.gz -C ${BUILD_DIR} - mkdir ${INSTALL_DIR} - tar xf install.tar.gz -C ${INSTALL_DIR} - - - name: Build - run: > - cmake --build ${BUILD_DIR} -- tbb - - - name: Package build - run: | - tar czf build.tar.gz -C ${BUILD_DIR} . - tar czf install.tar.gz -C ${INSTALL_DIR} . - - - uses: actions/upload-artifact@v4 - with: - name: build_2 - path: | - build.tar.gz - install.tar.gz - - build_nlohmann_json: - runs-on: macos-14 - needs: [build_tbb] - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: ./dependencies.sh - - - name: Cache build - uses: actions/cache@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ runner.os }}-${{ github.job }}-nlohmann_json - restore-keys: | - ccache-${{ runner.os }}-${{ github.job }}-nlohmann_json - ccache-${{ runner.os }}-${{ github.job }}- - - - uses: actions/download-artifact@v4 - with: - name: build_2 - path: . - - - run: | - mkdir ${BUILD_DIR} - tar xf build.tar.gz -C ${BUILD_DIR} - mkdir ${INSTALL_DIR} - tar xf install.tar.gz -C ${INSTALL_DIR} - - - name: Build - run: > - cmake --build ${BUILD_DIR} -- nlohmann_json - - - name: Package build - run: | - tar czf build.tar.gz -C ${BUILD_DIR} . - tar czf install.tar.gz -C ${INSTALL_DIR} . - - - uses: actions/upload-artifact@v4 - with: - name: build_3 - path: | - build.tar.gz - install.tar.gz - - build_root: - runs-on: macos-14 - - needs: [build_nlohmann_json] - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: ./dependencies.sh - - - name: Cache build - uses: actions/cache@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ runner.os }}-${{ github.job }}-root - restore-keys: | - ccache-${{ runner.os }}-${{ github.job }}-root - ccache-${{ runner.os }}-${{ github.job }}- - - - uses: actions/download-artifact@v4 - with: - name: build_3 - path: . - - - run: | - mkdir ${BUILD_DIR} - tar xf build.tar.gz -C ${BUILD_DIR} - mkdir ${INSTALL_DIR} - tar xf install.tar.gz -C ${INSTALL_DIR} - - - name: Build - run: > - cmake --build ${BUILD_DIR} -- root - - - name: Package build - run: | - tar czf build.tar.gz -C ${BUILD_DIR} . - tar czf install.tar.gz -C ${INSTALL_DIR} . - - - uses: actions/upload-artifact@v4 - with: - name: build_4 - path: | - build.tar.gz - install.tar.gz - - build_podio_edm4hep: - runs-on: macos-14 - - needs: [build_root] - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: ./dependencies.sh - - - name: Cache build - uses: actions/cache@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ runner.os }}-${{ github.job }}-podio - restore-keys: | - ccache-${{ runner.os }}-${{ github.job }}-podio - ccache-${{ runner.os }}-${{ github.job }}- - - - uses: actions/download-artifact@v4 - with: - name: build_4 - path: . - - - run: | - mkdir ${BUILD_DIR} - tar xf build.tar.gz -C ${BUILD_DIR} - mkdir ${INSTALL_DIR} - tar xf install.tar.gz -C ${INSTALL_DIR} - - - name: Build - run: > - cmake --build ${BUILD_DIR} -- podio edm4hep - - - name: Package build - run: | - tar czf build.tar.gz -C ${BUILD_DIR} . - tar czf install.tar.gz -C ${INSTALL_DIR} . - - - uses: actions/upload-artifact@v4 - with: - name: build_5 - path: | - build.tar.gz - install.tar.gz - - build_geant4: - runs-on: macos-14 - - needs: [build_podio_edm4hep] - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: ./dependencies.sh - - - name: Cache build - uses: actions/cache@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ runner.os }}-${{ github.job }}-geant4 - restore-keys: | - ccache-${{ runner.os }}-${{ github.job }}-geant4 - ccache-${{ runner.os }}-${{ github.job }}- - - - uses: actions/download-artifact@v4 - with: - name: build_5 - path: . - - - run: | - mkdir ${BUILD_DIR} - tar xf build.tar.gz -C ${BUILD_DIR} - mkdir ${INSTALL_DIR} - tar xf install.tar.gz -C ${INSTALL_DIR} - - - name: Build - run: > - cmake --build ${BUILD_DIR} -- geant4 - - - name: Package build - run: | - tar czf build.tar.gz -C ${BUILD_DIR} . - tar czf install.tar.gz -C ${INSTALL_DIR} . - - - uses: actions/upload-artifact@v4 - with: - name: build_6 - path: | - build.tar.gz - install.tar.gz - - build_geomodel: - runs-on: macos-14 - - needs: - - build_geant4 - - build_boost_eigen - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: ./dependencies.sh - - - name: Cache build - uses: actions/cache@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ runner.os }}-${{ github.job }}-geomodel - restore-keys: | - ccache-${{ runner.os }}-${{ github.job }}-geomodel - ccache-${{ runner.os }}-${{ github.job }}- - - - uses: actions/download-artifact@v4 - with: - name: build_6 - path: . - - - run: | - mkdir ${BUILD_DIR} - tar xf build.tar.gz -C ${BUILD_DIR} - rm build.tar.gz - mkdir ${INSTALL_DIR} - tar xf install.tar.gz -C ${INSTALL_DIR} - rm install.tar.gz - - - uses: actions/download-artifact@v4 - with: - name: build_boost_eigen - path: . - - - name: Unpack boost/eigen bundle - run: | - ls -al - mkdir -p install_boost_eigen - tar xf install.tar.gz -C install_boost_eigen - rm install.tar.gz - mkdir -p build_boost_eigen - tar xf build.tar.gz -C build_boost_eigen - rm build.tar.gz - - - name: Merge directories - run: | - cp -r install_boost_eigen/* ${INSTALL_DIR} - rm -rf install_boost_eigen - cp -r build_boost_eigen/boost ${BUILD_DIR} - rm -rf build_boost_eigen - - - name: Build - run: > - cmake --build ${BUILD_DIR} -- geomodel - - - name: Package build - run: | - tar czf build.tar.gz -C ${BUILD_DIR} . - tar czf install.tar.gz -C ${INSTALL_DIR} . - - - uses: actions/upload-artifact@v4 - with: - name: build_7 - path: | - build.tar.gz - install.tar.gz - - build_dd4hep: - runs-on: macos-14 - - needs: - - build_geomodel - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: ./dependencies.sh - - - name: Cache build - uses: actions/cache@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ runner.os }}-${{ github.job }}-dd4hep - restore-keys: | - ccache-${{ runner.os }}-${{ github.job }}-dd4hep - ccache-${{ runner.os }}-${{ github.job }}- - - - uses: actions/download-artifact@v4 - with: - name: build_7 - path: . - - - run: | - mkdir ${BUILD_DIR} - tar xf build.tar.gz -C ${BUILD_DIR} - mkdir ${INSTALL_DIR} - tar xf install.tar.gz -C ${INSTALL_DIR} - - - name: Build - run: > - cmake --build ${BUILD_DIR} -- dd4hep - - - name: Package build - run: | - tar czf build.tar.gz -C ${BUILD_DIR} . - tar czf install.tar.gz -C ${INSTALL_DIR} . - - - uses: actions/upload-artifact@v4 - with: - name: build_8 - path: | - build.tar.gz - install.tar.gz - - build_hepmc3: - runs-on: macos-14 - - needs: [build_dd4hep] - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: ./dependencies.sh - - - name: Cache build - uses: actions/cache@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ runner.os }}-${{ github.job }}-hepmc3 - restore-keys: | - ccache-${{ runner.os }}-${{ github.job }}-hepmc3 - ccache-${{ runner.os }}-${{ github.job }}- - - - uses: actions/download-artifact@v4 - with: - name: build_8 - path: . - - - run: | - mkdir ${BUILD_DIR} - tar xf build.tar.gz -C ${BUILD_DIR} - mkdir ${INSTALL_DIR} - tar xf install.tar.gz -C ${INSTALL_DIR} - - - name: Build - run: > - cmake --build ${BUILD_DIR} -- hepmc3 - - - name: Package build - run: | - tar czf build.tar.gz -C ${BUILD_DIR} . - tar czf install.tar.gz -C ${INSTALL_DIR} . - - - uses: actions/upload-artifact@v4 - with: - name: build_9 - path: | - build.tar.gz - install.tar.gz - - build_pythia8: - runs-on: macos-14 - - needs: [build_hepmc3] - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: ./dependencies.sh - - - name: Cache build - uses: actions/cache@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-${{ runner.os }}-${{ github.job }}-pythia8 - restore-keys: | - ccache-${{ runner.os }}-${{ github.job }}-pythia8 - ccache-${{ runner.os }}-${{ github.job }}- - - - uses: actions/download-artifact@v4 - with: - name: build_9 - path: . - - - run: | - mkdir ${BUILD_DIR} - tar xf build.tar.gz -C ${BUILD_DIR} - mkdir ${INSTALL_DIR} - tar xf install.tar.gz -C ${INSTALL_DIR} - - - name: Build - run: > - cmake --build ${BUILD_DIR} -- pythia8 - - - name: Package build - run: | - tar czf build.tar.gz -C ${BUILD_DIR} . - tar czf install.tar.gz -C ${INSTALL_DIR} . - - - uses: actions/upload-artifact@v4 - with: - name: build_10 - path: | - build.tar.gz - install.tar.gz - - make_tarball: - runs-on: ubuntu-latest # we don't need macOS here - needs: [build_pythia8] - steps: - - uses: actions/download-artifact@v4 - with: - name: build_10 - path: . - - - name: Unpack full bundle - run: | - mkdir -p ${INSTALL_DIR} - tar xf install.tar.gz -C ${INSTALL_DIR} - rm install.tar.gz - - - name: Package merged directory - run: | - tar cf - -C ${INSTALL_DIR} . | zstd -o install.tar.zst -19 -T$(nproc) - - - name: Upload merged install directory - uses: actions/upload-artifact@v4 - with: - name: deps - path: | - install.tar.zst - - deploy_to_eos: - if: github.ref == 'refs/heads/main' - runs-on: ubuntu-latest # we don't need macOS here - needs: - - make_tarball - env: - DEPLOY_USER: ${{ secrets.DEPLOY_USER }} - DEPLOY_PWD: ${{ secrets.DEPLOY_PWD }} - steps: - - uses: actions/checkout@v4 - - - name: Install prerequisites - run: > - sudo apt-get install -y krb5-user krb5-config - - - uses: actions/download-artifact@v4 - with: - name: deps - path: . - - - name: Upload - run: | - echo "$DEPLOY_PWD" | kinit $DEPLOY_USER@CERN.CH 2>&1 >/dev/null - sha=$(echo $GITHUB_SHA | head -c 7) - name=deps.$sha.tar.zst - echo $name - echo $sha - mv install.tar.zst $name - scp -F ssh_config $name $DEPLOY_USER@lxplus.cern.ch:/eos/user/a/atsjenkins/www/ACTS/ci/macOS/cmake - ssh -F ssh_config $DEPLOY_USER@lxplus.cern.ch ln -f -s $name /eos/user/a/atsjenkins/www/ACTS/ci/macOS/cmake/deps.latest.tar.zst diff --git a/build.sh b/build.sh index da95215..58e205b 100755 --- a/build.sh +++ b/build.sh @@ -31,20 +31,9 @@ fill_line echo "This script will build the ACTS framework and its dependencies." -if [ $(uname) == "Linux" ]; then - os_name=$(cat /etc/os-release | grep -e "^PRETTY_NAME=" | sed 's/PRETTY_NAME="\(.*\)"/\1/g') - if [[ $os_name == *"Ubuntu"* ]]; then - os="ubuntu" - elif [[ $os_name == *"AlmaLinux"* ]]; then - os="almalinux" - fi -elif [ $(uname) == "Darwin" ]; then - os_name="$(sw_vers -productName) $(sw_vers -productVersion)" - os="macos" -else - echo "Only Ubuntu, AlmaLinux and macOS are supported. Exiting." - exit 1 -fi +script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +source ${script_dir}/detect_os.sh echo "OS: ${os_name}" if [ $(whoami) == "root" ]; then @@ -75,7 +64,12 @@ function printDependencyOneliner { trap printDependencyOneliner ERR -script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +function interruptHandler { + kill -TERM -$$ +} + +trap interruptHandler INT + build_dir=${1:-$PWD/build} install_dir=${2:-$PWD/install} @@ -132,10 +126,33 @@ else PROC=$(sysctl -n hw.physicalcpu) fi +build_acts=ON +if [ ! -d "${script_dir}/acts" ]; then + echo "No ACTS directory found, do you want me to clone the upstream repository?" + # ask user for input + read -p "Clone ACTS repository? [y/n] " -n 1 -r + echo "" + echo "Ok!" + if [[ $REPLY =~ ^[Yy]$ ]]; then + read -p "SSH or HTTPS? [s/h] " -n 1 -r + if [[ $REPLY =~ ^[Ss]$ ]]; then + url="git@github.com:acts-project/acts.git" + else + url=https://github.com/acts-project/acts.git + fi + echo "" + echo "Cloning ACTS from ${url} to ${script_dir}/acts" + git clone ${url} ${script_dir}/acts + else + echo "Not cloning ACTS, turning off the ACTS build" + build_acts=OFF + fi +fi + set -e cmake -S ${script_dir} -B ${build_dir} \ - -DBUILD_ACTS=ON \ + -DBUILD_ACTS=${build_acts} \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_COMPILER=g++ \ -DCMAKE_C_COMPILER=gcc \ diff --git a/dependencies.sh b/dependencies.sh index 722ec90..8607076 100755 --- a/dependencies.sh +++ b/dependencies.sh @@ -1,17 +1,48 @@ #!/bin/bash set -e -# @TODO Only on macos - function run() { set -x "$@" { set +x; } 2> /dev/null } +script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +source ${script_dir}/detect_os.sh +echo "OS: ${os_name}" -run brew update -run brew install ccache openssl@3 zlib zstd ncurses expat xerces-c freetype xz lz4 libx11 libxml2 libxpm libxft sqlite -run brew reinstall cmake +if [ $os == "ubuntu" ]; then + echo "Installing dependencies for Ubuntu" + sudo apt-get install -y \ + cmake \ + build-essential \ + libssl-dev \ + zlib1g-dev \ + libncurses5-dev \ + libexpat-dev \ + libxerces-c-dev \ + rsync \ + libfreetype-dev \ + liblzma-dev \ + liblz4-dev \ + libx11-dev \ + libxpm-dev \ + libxft-dev \ + libxext-dev \ + libglu1-mesa-dev \ + libxml2-dev \ + git \ + libzstd-dev \ + libsqlite3-dev +elif [ $os == "macos" ]; then + echo "Installing dependencies for macOS" + run brew update + run brew install ccache openssl@3 zlib zstd ncurses expat xerces-c freetype xz lz4 libx11 libxml2 libxpm libxft jq sqlite + run brew reinstall cmake -brew unlink r || true + brew unlink r || true +else + echo "Only Ubuntu and macOS are supported. Exiting." + exit 1 +fi diff --git a/detect_os.sh b/detect_os.sh new file mode 100644 index 0000000..b943539 --- /dev/null +++ b/detect_os.sh @@ -0,0 +1,17 @@ +if [ $(uname) == "Linux" ]; then + os_name=$(cat /etc/os-release | grep -e "^PRETTY_NAME=" | sed 's/PRETTY_NAME="\(.*\)"/\1/g') + if [[ $os_name == *"Ubuntu"* ]]; then + os="ubuntu" + elif [[ $os_name == *"AlmaLinux"* ]]; then + os="almalinux" + fi +elif [ $(uname) == "Darwin" ]; then + os_name="$(sw_vers -productName) $(sw_vers -productVersion)" + os="macos" +else + echo "Only Ubuntu, AlmaLinux and macOS are supported. Exiting." + exit 1 +fi + +export os +export os_name