Skip to content

Commit

Permalink
mysql 8.0.33 alpine static build (#89)
Browse files Browse the repository at this point in the history
- windows shared build
- gnu libc shared build with static ssl
  • Loading branch information
hemnstill authored Aug 28, 2023
1 parent 2f5825a commit 1f66b08
Show file tree
Hide file tree
Showing 9 changed files with 415 additions and 0 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/mysql.yml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
93 changes: 93 additions & 0 deletions mysql/build_gnu.sh
Original file line number Diff line number Diff line change
@@ -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
<details>
<summary>ldd mysql</summary>
```
%s
```
</details>
<details>
<summary>sha256sum ./*</summary>
```
%s
```
</details>
' "$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" .

70 changes: 70 additions & 0 deletions mysql/build_msvc.sh
Original file line number Diff line number Diff line change
@@ -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
<details>
<summary>sha256sum ./*</summary>
```
%s
```
</details>
%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" .

88 changes: 88 additions & 0 deletions mysql/build_musl.sh
Original file line number Diff line number Diff line change
@@ -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
<details>
<summary>sha256sum ./*</summary>
```
%s
```
</details>
' "$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" .
23 changes: 23 additions & 0 deletions mysql/release/_cache_line_size.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# commit dcfbe3e4b7ad1ded9b17fa04743e9f97b8aad9fa
# Author: Sam James <[email protected]>
# 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;
Loading

0 comments on commit 1f66b08

Please sign in to comment.