From d80b7c720b2ca41b881983f879d32a98361cd3b4 Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Sat, 7 May 2022 21:43:06 +0800 Subject: [PATCH 1/3] chore: check dependenies before building on Mac OSX --- .github/workflows/build_packages.yaml | 2 +- .github/workflows/build_slim_packages.yaml | 2 +- Makefile | 5 ++- scripts/prepare-build-deps.sh | 41 ++++++++++++++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100755 scripts/prepare-build-deps.sh diff --git a/.github/workflows/build_packages.yaml b/.github/workflows/build_packages.yaml index 37549501c..cc02aba6d 100644 --- a/.github/workflows/build_packages.yaml +++ b/.github/workflows/build_packages.yaml @@ -139,7 +139,7 @@ jobs: - name: prepare run: | brew update - brew install curl zip unzip gnu-sed kerl unixodbc freetds automake bison + brew install curl zip unzip kerl echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH echo "/usr/local/bin" >> $GITHUB_PATH git config --global credential.helper store diff --git a/.github/workflows/build_slim_packages.yaml b/.github/workflows/build_slim_packages.yaml index f3ed58a1b..f05682daa 100644 --- a/.github/workflows/build_slim_packages.yaml +++ b/.github/workflows/build_slim_packages.yaml @@ -151,7 +151,7 @@ jobs: - name: prepare run: | brew update - brew install curl zip unzip gnu-sed kerl unixodbc freetds automake bison + brew install curl zip unzip kerl echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH echo "/usr/local/bin" >> $GITHUB_PATH echo "EMQX_NAME=${{ matrix.profile }}" >> $GITHUB_ENV diff --git a/Makefile b/Makefile index 77c96cc98..fbc79bd5e 100644 --- a/Makefile +++ b/Makefile @@ -111,7 +111,7 @@ cover: $(REBAR) coveralls: $(REBAR) @ENABLE_COVER_COMPILE=1 $(REBAR) as test coveralls send -COMMON_DEPS := $(REBAR) get-dashboard conf-segs +COMMON_DEPS := $(REBAR) prepare-build-deps get-dashboard conf-segs ELIXIR_COMMON_DEPS := ensure-hex ensure-mix-rebar3 ensure-mix-rebar .PHONY: $(REL_PROFILES) @@ -219,6 +219,9 @@ conf-segs: @scripts/merge-config.escript @scripts/merge-i18n.escript +prepare-build-deps: + @scripts/prepare-build-deps.sh + ## elixir target is to create release packages using Elixir's Mix .PHONY: $(REL_PROFILES:%=%-elixir) $(PKG_PROFILES:%=%-elixir) $(REL_PROFILES:%=%-elixir) $(PKG_PROFILES:%=%-elixir): $(COMMON_DEPS) $(ELIXIR_COMMON_DEPS) mix-deps-get diff --git a/scripts/prepare-build-deps.sh b/scripts/prepare-build-deps.sh new file mode 100755 index 000000000..e1ccdd8b3 --- /dev/null +++ b/scripts/prepare-build-deps.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -euo pipefail + +AUTO_INSTALL_BUILD_DEPS="${AUTO_INSTALL_BUILD_DEPS:-0}" + +required_packages_mac_osx="freetds unixodbc" +required_cmds_mac_osx="curl zip unzip autoconf automake bison cmake openssl" + +dependency_missing() { + echo "error: $1 is not found in the system" + if [ "${AUTO_INSTALL_BUILD_DEPS}" = "1" ]; then + echo "brew install $1" + brew install $1 + else + echo "You can install it by running:" + echo " brew install $1" + exit 1 + fi +} + +prepare_mac_osx() { + current_packages=$(brew list) + for package in ${required_packages_mac_osx} + do + if ! echo ${current_packages} | grep -q "${package}"; then + dependency_missing ${package} + fi + done + for cmd in ${required_cmds_mac_osx} + do + if ! command -v "${cmd}" &> /dev/null; then + dependency_missing ${cmd} + fi + done +} + +case $(uname) in + *Darwin*) prepare_mac_osx;; + *) exit 0;; +esac From 48db7ceb5f213e08383c8cae529eccb5a46476fa Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Sat, 7 May 2022 22:30:50 +0800 Subject: [PATCH 2/3] fix: set AUTO_INSTALL_BUILD_DEPS for CI --- .github/workflows/build_packages.yaml | 2 ++ .github/workflows/build_slim_packages.yaml | 4 ++++ scripts/prepare-build-deps.sh | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_packages.yaml b/.github/workflows/build_packages.yaml index cc02aba6d..bc7478ad1 100644 --- a/.github/workflows/build_packages.yaml +++ b/.github/workflows/build_packages.yaml @@ -167,6 +167,8 @@ jobs: - name: build working-directory: source + env: + AUTO_INSTALL_BUILD_DEPS: 1 run: | . $HOME/.kerl/${{ matrix.otp }}/activate make ensure-rebar3 diff --git a/.github/workflows/build_slim_packages.yaml b/.github/workflows/build_slim_packages.yaml index f05682daa..c58561663 100644 --- a/.github/workflows/build_slim_packages.yaml +++ b/.github/workflows/build_slim_packages.yaml @@ -172,6 +172,8 @@ jobs: kerl install ${{ matrix.otp }} $HOME/.kerl/${{ matrix.otp }} - name: Get deps git refs for cache id: deps-refs + env: + AUTO_INSTALL_BUILD_DEPS: 1 run: | . $HOME/.kerl/${{ matrix.otp }}/activate make ensure-rebar3 @@ -184,6 +186,8 @@ jobs: path: _build/default/lib/quicer/ key: ${{ matrix.macos }}-${{ matrix.otp }}-macos-${{ steps.deps-refs.outputs.DEP_QUICER_REF }} - name: build ${{ matrix.profile }} + env: + AUTO_INSTALL_BUILD_DEPS: 1 run: | . $HOME/.kerl/${{ matrix.otp }}/activate make ensure-rebar3 diff --git a/scripts/prepare-build-deps.sh b/scripts/prepare-build-deps.sh index e1ccdd8b3..12daa01bc 100755 --- a/scripts/prepare-build-deps.sh +++ b/scripts/prepare-build-deps.sh @@ -4,8 +4,8 @@ set -euo pipefail AUTO_INSTALL_BUILD_DEPS="${AUTO_INSTALL_BUILD_DEPS:-0}" -required_packages_mac_osx="freetds unixodbc" -required_cmds_mac_osx="curl zip unzip autoconf automake bison cmake openssl" +required_packages_mac_osx="freetds unixodbc bison" +required_cmds_mac_osx="curl zip unzip autoconf automake cmake openssl" dependency_missing() { echo "error: $1 is not found in the system" From fc645f8d3e2faa98926ec67c7322f79af8d4843e Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Sat, 7 May 2022 23:44:36 +0800 Subject: [PATCH 3/3] fix: please the spell checker --- scripts/prepare-build-deps.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/prepare-build-deps.sh b/scripts/prepare-build-deps.sh index 12daa01bc..3c1048a27 100755 --- a/scripts/prepare-build-deps.sh +++ b/scripts/prepare-build-deps.sh @@ -11,7 +11,7 @@ dependency_missing() { echo "error: $1 is not found in the system" if [ "${AUTO_INSTALL_BUILD_DEPS}" = "1" ]; then echo "brew install $1" - brew install $1 + brew install "$1" else echo "You can install it by running:" echo " brew install $1" @@ -23,14 +23,14 @@ prepare_mac_osx() { current_packages=$(brew list) for package in ${required_packages_mac_osx} do - if ! echo ${current_packages} | grep -q "${package}"; then - dependency_missing ${package} + if ! echo "${current_packages}" | grep -q "${package}"; then + dependency_missing "${package}" fi done for cmd in ${required_cmds_mac_osx} do if ! command -v "${cmd}" &> /dev/null; then - dependency_missing ${cmd} + dependency_missing "${cmd}" fi done }