From 1f66b080afcd6bee9c2e6d94fe878b3969cad675 Mon Sep 17 00:00:00 2001 From: Alexandr Reshetnikov Date: Mon, 28 Aug 2023 12:35:09 +0700 Subject: [PATCH] mysql 8.0.33 alpine static build (#89) - windows shared build - gnu libc shared build with static ssl --- .github/workflows/mysql.yml | 95 +++++++++++++++++++ README.md | 1 + mysql/build_gnu.sh | 93 ++++++++++++++++++ mysql/build_msvc.sh | 70 ++++++++++++++ mysql/build_musl.sh | 88 +++++++++++++++++ mysql/release/_cache_line_size.patch | 23 +++++ .../mysql-connector-c-8.0.27-res_n.patch | 27 ++++++ mysql/test_linux.sh | 10 ++ mysql/test_windows.sh | 8 ++ 9 files changed, 415 insertions(+) create mode 100644 .github/workflows/mysql.yml create mode 100755 mysql/build_gnu.sh create mode 100755 mysql/build_msvc.sh create mode 100755 mysql/build_musl.sh create mode 100644 mysql/release/_cache_line_size.patch create mode 100644 mysql/release/mysql-connector-c-8.0.27-res_n.patch create mode 100755 mysql/test_linux.sh create mode 100755 mysql/test_windows.sh diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml new file mode 100644 index 000000000..418a2dfd0 --- /dev/null +++ b/.github/workflows/mysql.yml @@ -0,0 +1,95 @@ +name: mysql + +on: [pull_request, workflow_dispatch] + +jobs: + alpine-musl: + if: ${{ vars.CURRENT_TOOL == github.workflow }} + uses: ./.github/workflows/build-alpine.yml + with: + workflow: ${{ github.workflow }} + + ubuntu-gnu: + if: ${{ vars.CURRENT_TOOL == github.workflow }} + uses: ./.github/workflows/build-ubuntu.yml + with: + workflow: ${{ github.workflow }} + version: 20.04 + + windows-msvc: + if: ${{ vars.CURRENT_TOOL == github.workflow }} + uses: ./.github/workflows/build-windows.yml + with: + workflow: ${{ github.workflow }} + toolset: msvc + + test-alpine: + needs: alpine-musl + uses: ./.github/workflows/test-alpine.yml + with: + workflow: ${{ github.workflow }} + artifact: build-musl + + test-ubuntu-1804-musl: + needs: alpine-musl + uses: ./.github/workflows/test-ubuntu.yml + with: + workflow: ${{ github.workflow }} + artifact: build-musl + version: 18.04 + + test-ubuntu-musl: + needs: alpine-musl + uses: ./.github/workflows/test-ubuntu.yml + with: + workflow: ${{ github.workflow }} + artifact: build-musl + + test-ubuntu: + needs: ubuntu-gnu + uses: ./.github/workflows/test-ubuntu.yml + with: + workflow: ${{ github.workflow }} + artifact: build-gnu + + test-ubuntu-2004: + needs: ubuntu-gnu + uses: ./.github/workflows/test-ubuntu.yml + with: + workflow: ${{ github.workflow }} + artifact: build-gnu + version: 20.04 + + test-alpine-gnu: + needs: ubuntu-gnu + uses: ./.github/workflows/test-ubuntu.yml + with: + workflow: ${{ github.workflow }} + artifact: build-gnu + + test-windows: + needs: windows-msvc + uses: ./.github/workflows/test-windows.yml + with: + workflow: ${{ github.workflow }} + artifact: build-msvc + + release: + needs: [test-alpine, + test-ubuntu-musl, + test-ubuntu-1804-musl, + test-ubuntu, + test-ubuntu-2004, + test-alpine-gnu, + test-windows] + uses: ./.github/workflows/release.yml + with: + workflow: ${{ github.workflow }} + tool_version: '8.0.33' + prepare_body: | + bsdtar -Oxf ./build-musl/build-musl.tar.gz build-musl.md >> body.md + bsdtar -Oxf ./build-gnu/build-gnu.tar.gz build-gnu.md >> body.md + bsdtar -Oxf ./build-msvc/build-msvc.tar.gz build-msvc.md >> body.md + artifacts: ./build-musl/build-musl.tar.gz,./build-gnu/build-gnu.tar.gz,./build-msvc/build-msvc.tar.gz + secrets: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 5a21b302f..279dd3b5e 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ | [![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/bsdtar-3.7.1/total?label=⭳%20bsdtar-3.7.1)](https://github.com/hemnstill/StandaloneTools/releases/tag/bsdtar-3.7.1) | [![GitHub Repo stars](https://img.shields.io/github/stars/libarchive/libarchive?style=social&label=libarchive)](https://github.com/libarchive/libarchive) [![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/libarchive/libarchive)](https://github.com/libarchive/libarchive/releases/latest) | | [![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/7-Zip-23.01/total?label=⭳%207-Zip-23.01)](https://github.com/hemnstill/StandaloneTools/releases/tag/7-Zip-23.01) | [![SourceForge Downloads](https://img.shields.io/sourceforge/dm/sevenzip?style=social&label=7-Zip)](https://sourceforge.net/projects/sevenzip/) | | [![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/pg_dump-15.1/total?label=⭳%20pg_dump-15.1)](https://github.com/hemnstill/StandaloneTools/releases/tag/pg_dump-15.1) | [![GitHub Repo stars](https://img.shields.io/github/stars/postgres/postgres?style=social&label=postgres)](https://github.com/postgres/postgres) [![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/postgres/postgres)](https://www.postgresql.org/docs/current/index.html) | +| [![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/mysql-8.0.33/total?label=⭳%20mysql-8.0.33)](https://github.com/hemnstill/StandaloneTools/releases/tag/mysql-8.0.33) | [![GitHub Repo stars](https://img.shields.io/github/stars/mysql/mysql-server?style=social&label=mysql-server)](https://github.com/mysql/mysql-server) [![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/mysql/mysql-server)](https://dev.mysql.com/doc/relnotes/mysql/en/) | | [![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/busybox-1.35.0-FRP-4784/total?label=⭳%20busybox-1.35.0-FRP-4784)](https://github.com/hemnstill/StandaloneTools/releases/tag/busybox-1.35.0-FRP-4784) | [![GitHub Repo stars](https://img.shields.io/github/stars/rmyorston/busybox-w32?style=social&label=busybox-w32)](https://github.com/rmyorston/busybox-w32) [![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/rmyorston/busybox-w32)](https://frippery.org/busybox/release-notes/current.html) | | [![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/far2l-2.5.2/total?label=⭳%20far2l-2.5.2)](https://github.com/hemnstill/StandaloneTools/releases/tag/far2l-2.5.2) | [![GitHub Repo stars](https://img.shields.io/github/stars/elfmz/far2l?style=social&label=far2l)](https://github.com/elfmz/far2l) [![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/elfmz/far2l)](https://github.com/elfmz/far2l/releases/latest) | | [![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/pcre2grep-10.40/total?label=⭳%20pcre2grep-10.40)](https://github.com/hemnstill/StandaloneTools/releases/tag/pcre2grep-10.40) | [![GitHub Repo stars](https://img.shields.io/github/stars/PCRE2Project/pcre2?style=social&label=PCRE2)](https://github.com/PCRE2Project/pcre2) [![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/PCRE2Project/pcre2)](https://github.com/PCRE2Project/pcre2/releases/latest) | diff --git a/mysql/build_gnu.sh b/mysql/build_gnu.sh new file mode 100755 index 000000000..8a98748ab --- /dev/null +++ b/mysql/build_gnu.sh @@ -0,0 +1,93 @@ +#!/bin/bash +dp0="$(realpath "$(dirname "$0")")" +set -e + +export DEBIAN_FRONTEND=noninteractive + +echo "::group::install deps" + +apt update +apt install -y build-essential cmake wget +apt install -y libaio-dev libudev-dev libssl-dev ncurses-dev libc6-dev + +echo "::endgroup::" + +tool_name="mysql" +tool_version="8.0.33" +self_toolset_name="build-gnu" +release_version_dirpath="$dp0/release/build" + +mkdir -p "$release_version_dirpath" && cd "$dp0/release" + +download_url="https://github.com/mysql/mysql-server/archive/refs/tags/$tool_name-$tool_version.tar.gz" +echo "::group::prepare sources $download_url" + +"$dp0/../.tools/download_bsdtar.sh" +bsdtar="$dp0/release/bsdtar" + +wget "$download_url" -O "tool-$tool_version.tar.gz" +"$bsdtar" -xf "tool-$tool_version.tar.gz" && cd "mysql-server-mysql-$tool_version" + +echo "::endgroup::" + +echo "::group::build" + +cmake . \ + -DDOWNLOAD_BOOST=1 \ + -DWITH_BOOST=./boost \ + -DFORCE_INSOURCE_BUILD=1 \ + -DWITHOUT_SERVER=1 \ + -DBUILD_SHARED_LIBS=0 \ + -DCMAKE_EXE_LINKER_FLAGS="-lssl -lcrypto" \ + -DWITH_UNIT_TESTS=0 \ + -DWITH_BUILD_ID=0 \ + -DREPRODUCIBLE_BUILD=1 \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_CONFIG=mysql_release + +find . -type f -mindepth 2 -maxdepth 5 -name "link.txt" \ + -exec echo replace '.so' "{}" \; \ + -exec sed -i -e 's@/usr/lib/x86_64-linux-gnu/libssl.so@/usr/lib/x86_64-linux-gnu/libssl.a@g' \ + -e 's@/usr/lib/x86_64-linux-gnu/libcrypto.so@/usr/lib/x86_64-linux-gnu/libcrypto.a@g' "{}" \; + +cmake --build . --config Release + +echo "::endgroup::" + +cp -rf "./runtime_output_directory/." "$release_version_dirpath/" + +cd "$release_version_dirpath" + +find . -mindepth 1 -maxdepth 1 -name '*test*' -exec rm -f "{}" \; +find . -mindepth 1 -maxdepth 1 ! -name "mysql*" -exec rm -f "{}" \; +find . -mindepth 1 -maxdepth 1 -exec strip "{}" \; + +ldd "$tool_name" + +{ printf '### %s + +%s + +
+ ldd mysql + +``` +%s +``` +
+ +
+ sha256sum ./* + +``` +%s +``` +
+ +' "$self_toolset_name.tar.gz" "$("./$tool_name" --version)" "$(ldd "$tool_name")" "$(sha256sum ./*)" +} > "$self_toolset_name.md" + +cat "$self_toolset_name.md" + +tar -czvf "../$self_toolset_name.tar.gz" . + diff --git a/mysql/build_msvc.sh b/mysql/build_msvc.sh new file mode 100755 index 000000000..ca7a9c588 --- /dev/null +++ b/mysql/build_msvc.sh @@ -0,0 +1,70 @@ +#!/bin/bash +dp0="$(realpath "$(dirname "$0")")" +set -e + +echo "::group::install deps" + +echo "::endgroup::" + +tool_name="mysql" +tool_version="8.0.33" +self_toolset_name="build-msvc" +release_version_dirpath="$dp0/release/build" + +mkdir -p "$release_version_dirpath" && cd "$dp0/release" + +download_url="https://github.com/mysql/mysql-server/archive/refs/tags/$tool_name-$tool_version.tar.gz" +echo "::group::prepare sources $download_url" + +"$dp0/../.tools/download_bsdtar.sh" +bsdtar="$dp0/release/bsdtar" + +wget "$download_url" -O "tool-$tool_version.tar.gz" +"$bsdtar" -xf "tool-$tool_version.tar.gz" && cd "mysql-server-mysql-$tool_version" + +echo "::endgroup::" + +echo "::group::build" + +cmake . \ + -DDOWNLOAD_BOOST=1 \ + -DWITH_BOOST=./boost \ + -DFORCE_INSOURCE_BUILD=1 \ + -DWITHOUT_SERVER=1 \ + -DBUILD_SHARED_LIBS=0 \ + -DWITH_UNIT_TESTS=0 \ + -DREPRODUCIBLE_BUILD=1 \ + -G "Visual Studio 16 2019" \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_CONFIG=mysql_release + +cmake --build . --config Release + +cp -rf "./runtime_output_directory/Release/." "$release_version_dirpath/" + +cd "$release_version_dirpath" + +find . -mindepth 1 -maxdepth 1 -name '*test*' -exec rm -f "{}" \; +find . -mindepth 1 -maxdepth 1 \( ! -name "mysql*" -and ! -name "lib*" \) -exec rm -f "{}" \; + +{ printf '### %s + +%s + +
+ sha256sum ./* + +``` +%s +``` +
+ +%s + +' "$self_toolset_name.tar.gz" "$("./$tool_name" --version)" "$(sha256sum ./*)" "$download_url" +} > "$self_toolset_name.md" + +cat "$self_toolset_name.md" + +tar -czvf "../$self_toolset_name.tar.gz" . + diff --git a/mysql/build_musl.sh b/mysql/build_musl.sh new file mode 100755 index 000000000..d57b74796 --- /dev/null +++ b/mysql/build_musl.sh @@ -0,0 +1,88 @@ +#!/bin/bash +dp0="$(realpath "$(dirname "$0")")" +set -e + +echo "::group::install deps" + +apk update +apk add --no-cache alpine-sdk linux-headers build-base autoconf cmake +apk add --no-cache libaio-dev eudev-dev openldap-dev openssl-dev openssl-libs-static ncurses-dev ncurses-static + +echo "::endgroup::" + +tool_name="mysql" +tool_version="8.0.33" +self_toolset_name="build-musl" +release_version_dirpath="$dp0/release/build" + +mkdir -p "$release_version_dirpath" && cd "$dp0/release" + +download_url="https://github.com/mysql/mysql-server/archive/refs/tags/$tool_name-$tool_version.tar.gz" +echo "::group::prepare sources $download_url" + +"$dp0/../.tools/download_bsdtar.sh" +bsdtar="$dp0/release/bsdtar" + +wget "$download_url" -O "tool-$tool_version.tar.gz" +"$bsdtar" -xf "tool-$tool_version.tar.gz" && cd "mysql-server-mysql-$tool_version" + +patch "./libmysql/dns_srv.cc" "$dp0/release/mysql-connector-c-8.0.27-res_n.patch" +patch "./sql/memory/aligned_atomic.h" "$dp0/release/_cache_line_size.patch" + +echo "::endgroup::" + +echo "::group::build" + +cmake . \ + -DDOWNLOAD_BOOST=1 \ + -DWITH_BOOST=./boost \ + -DFORCE_INSOURCE_BUILD=1 \ + -DWITHOUT_SERVER=1 \ + -DBUILD_SHARED_LIBS=0 \ + -DCMAKE_EXE_LINKER_FLAGS="-lssl -lcrypto -static" \ + -DWITH_UNIT_TESTS=0 \ + -DWITH_BUILD_ID=0 \ + -DREPRODUCIBLE_BUILD=1 \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_CONFIG=mysql_release + +find . -type f -mindepth 2 -maxdepth 5 \( -path "*test*/link.txt" -or -path "*json_binlog_main.dir/link.txt" \) \ + -exec echo remove '-static' "{}" \; \ + -exec sed -i -e 's@ -static @ @g' "{}" \; + +find . -type f -mindepth 2 -maxdepth 5 -name "link.txt" \ + -exec echo replace '.so' "{}" \; \ + -exec sed -i -e 's@/usr/lib/libssl.so@/usr/lib/libssl.a@g' \ + -e 's@/usr/lib/libcrypto.so@/usr/lib/libcrypto.a@g' \ + "{}" \; + +cmake --build . --config Release + +echo "::endgroup::" + +cp -rf "./runtime_output_directory/." "$release_version_dirpath/" + +cd "$release_version_dirpath" + +find . -mindepth 1 -maxdepth 1 -name '*test*' -exec rm -f "{}" \; +find . -mindepth 1 -maxdepth 1 ! -name "mysql*" -exec rm -f "{}" \; +find . -mindepth 1 -maxdepth 1 -exec strip "{}" \; + +{ printf '### %s + +%s + +
+ sha256sum ./* + +``` +%s +``` +
+ +' "$self_toolset_name.tar.gz" "$("./$tool_name" --version)" "$(sha256sum ./*)" +} > "$self_toolset_name.md" + +cat "$self_toolset_name.md" + +tar -czvf "../$self_toolset_name.tar.gz" . diff --git a/mysql/release/_cache_line_size.patch b/mysql/release/_cache_line_size.patch new file mode 100644 index 000000000..2e8c38e07 --- /dev/null +++ b/mysql/release/_cache_line_size.patch @@ -0,0 +1,23 @@ +# commit dcfbe3e4b7ad1ded9b17fa04743e9f97b8aad9fa +# Author: Sam James +# Date: Sun Apr 9 04:04:06 2023 +0100 +# +# sql/memory: Fix build on musl +# +# _SC_LEVEL1_DCACHE_LINESIZE is not always available on Linux, e.g. with musl libc. +# +# It's provided by glibc instead and is a glibc-internal. +# +# diff --git a/sql/memory/aligned_atomic.h b/sql/memory/aligned_atomic.h +# index d13d45b9dee..bd19c0cf4d6 100644 +--- a/sql/memory/aligned_atomic.h ++++ b/sql/memory/aligned_atomic.h +@@ -76,7 +76,7 @@ static inline size_t _cache_line_size() { + return line_size; + } + +-#elif defined(__linux__) ++#elif defined(__GLIBC__) + static inline size_t _cache_line_size() { + long size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); + if (size == -1) return 64; diff --git a/mysql/release/mysql-connector-c-8.0.27-res_n.patch b/mysql/release/mysql-connector-c-8.0.27-res_n.patch new file mode 100644 index 000000000..8a32448d6 --- /dev/null +++ b/mysql/release/mysql-connector-c-8.0.27-res_n.patch @@ -0,0 +1,27 @@ +# Musl doesn't have res_n* functions so we are falling back to the not +# thread safe ones. Patch made with help from developer Fabian Groffen +# . +# +# Closes: https://bugs.gentoo.org/761352 +# See also: https://github.com/mysql/mysql-server/pull/385 +# See also: https://bugs.mysql.com/bug.php?id=106034 +--- a/libmysql/dns_srv.cc ++++ b/libmysql/dns_srv.cc +@@ -37,6 +37,17 @@ + #include + #include + ++/* we don't have anything else but the non-thread-safe variants */ ++#if !defined(HAVE_RES_NINIT) ++#define res_ninit(X) (void)X ++#endif ++#if !defined(HAVE_RES_NSEARCH) ++#define res_nsearch(X,D,I,S,B,L) res_search(D,I,S,B,L) ++#endif ++#if !defined(HAVE_RES_NCLOSE) ++#define res_nclose(X) (void)X ++#endif ++ + // POSIX version + + static bool get_dns_srv(Dns_srv_data &data, const char *dnsname, int &error) { diff --git a/mysql/test_linux.sh b/mysql/test_linux.sh new file mode 100755 index 000000000..1afaa7e69 --- /dev/null +++ b/mysql/test_linux.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +"../.tools/install_alpine_glibc.sh" + +testVersion() { + assertEquals "../bin/mysql Ver 8.0.33 for Linux on x86_64 (Source distribution)" "$(../bin/mysql --version)" +} + +# Load and run shUnit2. +source "../.tests/shunit2/shunit2" diff --git a/mysql/test_windows.sh b/mysql/test_windows.sh new file mode 100755 index 000000000..1ff316df1 --- /dev/null +++ b/mysql/test_windows.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +testVersion() { + assertEquals "../bin/mysql.exe Ver 8.0.33 for Win64 on x86_64 (Source distribution)" "$(../bin/mysql.exe --version)" +} + +# Load and run shUnit2. +source "../.tests/shunit2/shunit2"