Skip to content

Commit

Permalink
fix: static openssl builds
Browse files Browse the repository at this point in the history
  • Loading branch information
userdocs committed Feb 22, 2023
1 parent 9a327cc commit a931b86
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 41 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/cygwin_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ jobs:

name: ${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.filename }}win.zip

env:
cygwin_path: "/cygdrive/c"

steps:
- run: git config --global core.autocrlf input

- name: Checkout
uses: actions/checkout@v3

- name: Move packages_${{ matrix.build }}.cmd to packages.cmd
run: Copy-Item -Path packages_${{ matrix.build }}.cmd -Destination packages.cmd

- name: Host - Get packages_list
run: echo "packages_list=$(Get-Content -Path packages.cmd)" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append

Expand All @@ -47,7 +47,7 @@ jobs:
packages: ${{ env.packages_list }}

- name: Build script
run: C:\cygwin\bin\bash.exe build.sh ${{ matrix.openssl }}
run: C:\cygwin\bin\bash.exe build.sh "${{ matrix.openssl }}" "${{ env.cygwin_path }}"

- name: Archive build
run: Compress-Archive ${{ github.workspace }}\${{ matrix.name }} ${{ matrix.name }}-amd64-${{ matrix.filename }}win.zip
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/cygwin_cmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,20 @@ jobs:

name: ${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.filename }}win.zip

env:
cygwin_path: ""

steps:
- run: git config --global core.autocrlf input

- name: Checkout
uses: actions/checkout@v3

- name: Move packages_${{ matrix.build }}.cmd to packages.cmd
run: Copy-Item -Path packages_${{ matrix.build }}.cmd -Destination packages.cmd

- name: Install cygwin-installer.cmd
run: .\cygwin-installer.cmd

- name: Build static
run: |
.\cygwin\bin\bash.exe -l build.sh ${{ matrix.openssl }}
run: .\cygwin\bin\bash.exe -l build.sh "${{ matrix.openssl }}" "${{ env.cygwin_path }}"

- name: Archive build
run: Compress-Archive ${{ matrix.name }} ${{ matrix.name }}-amd64-${{ matrix.filename }}win.zip
Expand Down
63 changes: 33 additions & 30 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
#!/usr/bin/env bash

# The matrix will pass this as yes or no to the build script - defaults to no but the build will fail if you have libssl-devel installed.
with_openssl="${1:-no}"
printf '\n%b\n' " \e[93m\U25cf\e[0m Building with openssl = ${with_openssl}"
HOME="$(pwd)"
with_openssl="${1:-no}"
cygwin_path="${2:-${HOME}}/cygwin"

printf '\n%b\n' " \e[93m\U25cf\e[0m With openssl = ${with_openssl}"
printf '%b\n' " \e[93m\U25cf\e[0m Build path = ${HOME}"
printf '%b\n' " \e[93m\U25cf\e[0m Cygwin path = ${cygwin_path}"

if [[ "${with_openssl}" == 'yes' ]]; then
printf '\n%b\n' " \e[94m\U25cf\e[0m Downloading zlib"
curl -sL https://github.com/userdocs/qbt-workflow-files/releases/latest/download/zlib.tar.xz -o "${HOME}/zlib.tar.gz"
printf '\n%b\n' " \e[94m\U25cf\e[0m Extracting zlib"
tar xf "${HOME}/zlib.tar.gz" -C "${HOME}"
cd "${HOME}/zlib" || exit 1
printf '\n%b\n\n' " \e[94m\U25cf\e[0m Configuring zlib"
./configure --prefix="${cygwin_path}" --static --zlib-compat
printf '\n%b\n\n' " \e[94m\U25cf\e[0m Building with zlib"
make -j"$(nproc)"
make install
printf '\n%b\n' " \e[94m\U25cf\e[0m Building with openssl"
printf '\n%b\n' " \e[94m\U25cf\e[0m Downloading openssl"
curl -sL "https://github.com/userdocs/qbt-workflow-files/releases/latest/download/openssl.tar.xz" -o "${HOME}/openssl.tar.xz"
printf '\n%b\n' " \e[94m\U25cf\e[0m Extracting openssl"
tar xf "${HOME}/openssl.tar.xz" -C "${HOME}"
cd "${HOME}/openssl" || exit 1
printf '\n%b\n\n' " \e[94m\U25cf\e[0m Building openssl"
./config --prefix="${cygwin_path}" threads no-shared no-dso no-comp
make -j"$(nproc)"
make install_sw
fi

printf '\n%b\n\n' " \e[94m\U25cf\e[0m Cloning iperf3 git repo"

Expand All @@ -19,15 +45,7 @@ printf '\n%b\n\n' " \e[94m\U25cf\e[0m Bootstrapping iperf3"
./bootstrap.sh

printf '\n%b\n\n' " \e[94m\U25cf\e[0m Configuring iperf3"

if [[ "${with_openssl}" = 'yes' ]]; then
# fix openssl linking - We want this sed replace using a literal match
# shellcheck disable=SC2016
sed -ri 's|OPENSSL_LIBS="-lssl -lcrypto"|OPENSSL_LIBS="${OPENSSL_LIBS}"|g' "$HOME/iperf3_build/configure"
./configure --with-openssl=/usr OPENSSL_LIBS="-l:libssl.dll.a -l:libcrypto.dll.a" --disable-shared --enable-static-bin --prefix="$HOME/iperf3"
else
./configure --disable-shared --enable-static-bin --prefix="$HOME/iperf3"
fi
./configure --disable-shared --enable-static --enable-static-bin --prefix="$HOME/iperf3"

printf '\n%b\n\n' " \e[94m\U25cf\e[0m make"
make -j"$(nproc)"
Expand All @@ -36,23 +54,8 @@ printf '\n%b\n\n' " \e[94m\U25cf\e[0m make install"
[[ -d "$HOME/iperf3" ]] && rm -rf "$HOME/iperf3"
make install

printf '\n%b\n\n' " \e[94m\U25cf\e[0m Copy dll dependencies"

if [[ -d "$HOME/iperf3/bin" ]]; then
# default requirements
# cmd
[[ -f "$HOME/cygwin/bin/cygwin1.dll" ]] && cp -f "$HOME/cygwin/bin/cygwin1.dll" "$HOME/iperf3/bin"
# action
[[ -f "/cygdrive/c/cygwin/bin/cygwin1.dll" ]] && cp -f "/cygdrive/c/cygwin/bin/cygwin1.dll" "$HOME/iperf3/bin"

if [[ "${with_openssl}" == 'yes' ]]; then
# openssl requirements
# cmd
[[ -f "$HOME/cygwin/bin/cygcrypto-1.1.dll" ]] && cp -f "$HOME/cygwin/bin/cygcrypto-1.1.dll" "$HOME/iperf3/bin"
[[ -f "$HOME/cygwin/bin/cygz.dll" ]] && cp -f "$HOME/cygwin/bin/cygz.dll" "$HOME/iperf3/bin"
# action
[[ -f "/cygdrive/c/cygwin/bin/cygcrypto-1.1.dll" ]] && cp -f "/cygdrive/c/cygwin/bin/cygcrypto-1.1.dll" "$HOME/iperf3/bin"
[[ -f "/cygdrive/c/cygwin/bin/cygz.dll" ]] && cp -f "/cygdrive/c/cygwin/bin/cygz.dll" "$HOME/iperf3/bin"
fi
printf '\n%b\n\n' " \e[92m\U25cf\e[0m Copied the dll dependencies"
printf '\n%b\n' " \e[94m\U25cf\e[0m Copy dll dependencies"
[[ -f "${cygwin_path}/bin/cygwin1.dll" ]] && cp -f "${cygwin_path}/bin/cygwin1.dll" "$HOME/iperf3/bin"
printf '\n%b\n' " \e[92m\U25cf\e[0m Copied the dll dependencies"
fi
1 change: 1 addition & 0 deletions packages.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
automake,curl,gcc-core,gcc-g++,git,libtool,make,pkg-config,tar
1 change: 0 additions & 1 deletion packages_basic.cmd

This file was deleted.

1 change: 0 additions & 1 deletion packages_openssl.cmd

This file was deleted.

1 change: 1 addition & 0 deletions pwsh-here.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
powershell.exe -noexit -command Set-Location -literalPath "%~dp0."

0 comments on commit a931b86

Please sign in to comment.