From 4bf05e2e35cac3b4310512367ccfcca0023d9fdc Mon Sep 17 00:00:00 2001 From: acetone <63557806+freeacetone@users.noreply.github.com> Date: Fri, 2 Oct 2026 13:16:31 -0400 Subject: [PATCH] build static FreeBSD binaries for release --- .github/workflows/build-freebsd.yml | 30 ++++++++++++++++------------- .github/workflows/release.yml | 10 +++++++++- contrib/static/build-freebsd.sh | 28 +++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 14 deletions(-) create mode 100755 contrib/static/build-freebsd.sh diff --git a/.github/workflows/build-freebsd.yml b/.github/workflows/build-freebsd.yml index 2ad20f2a..77d90139 100644 --- a/.github/workflows/build-freebsd.yml +++ b/.github/workflows/build-freebsd.yml @@ -14,16 +14,16 @@ on: - libi2pd_client/** - Makefile - Makefile.bsd - tags: - - '*' + - contrib/static/build-freebsd.sh pull_request: branches: - '*' + workflow_call: jobs: build: runs-on: ubuntu-latest - name: FreeBSD ${{ matrix.release }} with UPnP + name: FreeBSD ${{ matrix.release }} static strategy: fail-fast: false @@ -34,27 +34,31 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Test in FreeBSD - id: test + - name: Build in FreeBSD uses: vmactions/freebsd-vm@v1 with: release: ${{ matrix.release }} usesh: true - mem: 2048 + mem: 4096 sync: rsync copyback: true prepare: | sed -i '' 's|/quarterly"|/latest"|' /etc/pkg/FreeBSD.conf pkg update -f - pkg install -y devel/cmake devel/gmake devel/boost-libs security/openssl35 net/miniupnpc + pkg install -y devel/cmake devel/gmake perl5 devel/boost-libs net/miniupnpc run: | set -e - cd build - cmake -DWITH_UPNP=ON -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/usr/local . - gmake -j2 - ./i2pd --version - ./i2pd --version | grep -E '^OpenSSL (3\.([5-9]|[1-9][0-9])|[4-9])\.' - ./i2pd --version | grep -E '^Boost version 1\.(8[1-9]|9[0-9])\.' + sh contrib/static/build-freebsd.sh + file build/i2pd | grep 'statically linked' + build/i2pd --version + build/i2pd --version | grep -E '^OpenSSL (3\.([5-9]|[1-9][0-9])|[4-9])\.' + build/i2pd --version | grep -E '^Boost version 1\.(8[1-9]|9[0-9])\.' + mkdir /tmp/datadir + build/i2pd --datadir=/tmp/datadir --log=file --logfile=/tmp/datadir/i2pd.log --loglevel=info & + sleep 15 + kill -0 $! + grep 'Daemon: Starting NetDB' /tmp/datadir/i2pd.log + kill -9 $! - name: Upload artifacts uses: actions/upload-artifact@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f658f42..f1bf28e2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,9 +18,12 @@ jobs: debian: uses: ./.github/workflows/build-deb.yml + freebsd: + uses: ./.github/workflows/build-freebsd.yml + release: name: Draft release - needs: [windows, macos, linux, debian] + needs: [windows, macos, linux, debian, freebsd] runs-on: ubuntu-latest permissions: contents: write @@ -49,6 +52,11 @@ jobs: done chmod +x artifacts/i2pd-macos/i2pd tar -czf release/i2pd_${TAG}_osx.tar.gz -C artifacts/i2pd-macos i2pd + for dir in artifacts/i2pd-freebsd-*; do + chmod +x $dir/i2pd + rel=${dir##*-} + tar -czf release/i2pd_${TAG}_freebsd${rel%%.*}_amd64.tar.gz -C $dir i2pd + done cp artifacts/i2pd-linux-all/* release/ cp artifacts/i2pd_trixie_*/i2pd_*.deb release/ cd release diff --git a/contrib/static/build-freebsd.sh b/contrib/static/build-freebsd.sh new file mode 100755 index 00000000..90fe7859 --- /dev/null +++ b/contrib/static/build-freebsd.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Fully static i2pd for FreeBSD, run from the source tree with the cmake, gmake, perl5, boost-libs and miniupnpc packages +set -e + +OPENSSL_VERSION=3.5.8 +JOBS=4 + +SRC=$(pwd) +WORK=${TMPDIR:-/tmp}/i2pd-freebsd +mkdir -p "$WORK" +cd "$WORK" + +OPENSSL=openssl-$OPENSSL_VERSION +fetch -q https://github.com/openssl/openssl/releases/download/$OPENSSL/$OPENSSL.tar.gz +fetch -q https://github.com/openssl/openssl/releases/download/$OPENSSL/$OPENSSL.tar.gz.sha256 +[ "$(sha256 -q $OPENSSL.tar.gz)" = "$(cut -d' ' -f1 $OPENSSL.tar.gz.sha256)" ] +tar xzf $OPENSSL.tar.gz +cd $OPENSSL +# no-autoload-config: a static binary must not read the host's openssl.cnf +./Configure --prefix="$WORK/openssl" --libdir=lib --openssldir=/nonexistent \ + no-autoload-config no-shared no-module no-dso no-engine no-tests no-docs +gmake -j$JOBS build_libs +gmake install_dev + +cd "$SRC/build" +cmake -DWITH_STATIC=ON -DWITH_UPNP=ON -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR="$WORK/openssl" . +gmake -j$JOBS +strip i2pd