#!/usr/bin/env bash # Build mautrix-discord with the Lotus patches in discord-bridge/patches/. # # Needs: git, Go (version from upstream go.mod or newer), a C compiler and libolm-dev. # Output: ./mautrix-discord-lotus (dynamically linked against libolm.so.3, which # LXC 151 has from the libolm3 package). # # Deploy (on the Proxmox node hosting LXC 151): # pct push 151 mautrix-discord-lotus /opt/mautrix-discord/mautrix-discord.new # pct exec 151 -- bash -c 'cd /opt/mautrix-discord && cp -a mautrix-discord mautrix-discord.bak-$(date +%Y%m%d) \ # && chown mautrix-discord: mautrix-discord.new && chmod 755 mautrix-discord.new \ # && mv mautrix-discord.new mautrix-discord && systemctl restart mautrix-discord' set -euo pipefail VERSION="${VERSION:-v0.7.7}" HERE="$(cd "$(dirname "$0")" && pwd)" OUT="${OUT:-$PWD/mautrix-discord-lotus}" WORK="$(mktemp -d)" trap 'rm -rf "$WORK"' EXIT git clone -q --depth 1 --branch "$VERSION" https://github.com/mautrix/discord.git "$WORK/src" cd "$WORK/src" for p in "$HERE"/patches/*.patch; do echo "applying $(basename "$p")" git apply "$p" done go test -race -count=1 -run 'Retry|PreSend|Ambiguous|Echo' . COMMIT="$(git rev-parse HEAD)" MAUTRIX="$(go list -m -f '{{.Version}}' maunium.net/go/mautrix)" CGO_ENABLED=1 go build -o "$OUT" -ldflags "-s -w \ -X main.Tag=$VERSION \ -X main.Commit=$COMMIT+lotus \ -X 'main.BuildTime=$(date '+%b %_d %Y, %H:%M:%S')' \ -X 'maunium.net/go/mautrix.GoModVersion=$MAUTRIX'" . "$OUT" --version echo "built $OUT"