The 0.3.0-pre.1 build failed on cargo-xwin's download of the MSVC CRT from Microsoft's CDN (a TLS connection cut mid-way, four times): this line cuts some of that CDN's connections now and then. package.sh now fetches it with cargo xwin cache xwin first, up to six times with growing pauses; what came whole stays cached for the next try. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
104 lines
6.4 KiB
Bash
Executable File
104 lines
6.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# The release, in dist/: ProxySuite-<version>-windows-x64-setup.exe, the setup program, and
|
|
# ProxySuite-<version>-windows-x64.zip, the same unpacked with install.cmd. Both hold the
|
|
# programs (the service, proxy-ctl, the app), every component (fetched and verified), the
|
|
# install scripts, the README and the licenses.
|
|
#
|
|
# nix develop --command tools/package.sh (needs curl, git, unzip, zip, pip, go, makensis;
|
|
# nix for the app's shader compiler, tools/fxc-wine.sh)
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
|
|
NAME=ProxySuite-$VERSION-windows-x64
|
|
DIST=dist/$NAME
|
|
CACHE=${CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/proxy-suite-windows}
|
|
# The sources tools/build-*.sh clone, kept for the next build.
|
|
export SRC_CACHE=$CACHE/src
|
|
rm -rf "$DIST" "dist/$NAME.zip"
|
|
mkdir -p "$DIST/components"
|
|
|
|
echo "== components"
|
|
tools/build-tg-ws-proxy.sh "$DIST/components/tg-ws-proxy"
|
|
tools/build-wireproxy-awg.sh "$DIST/components/wireproxy-awg" windows
|
|
tools/build-whitelist-bypass.sh "$DIST/components/whitelist-bypass" windows
|
|
tools/build-amneziawg.sh "$DIST/components/amneziawg"
|
|
tools/build-zapret2-extras.sh "$DIST/components/zapret2-extras"
|
|
cargo build -q --release -p ps-service
|
|
target/release/proxy-suite-service stage-components --to "$DIST/components" --cache "$CACHE"
|
|
rm -rf "$DIST"/components/*.old "$DIST"/components/*.staging
|
|
|
|
echo "== programs"
|
|
# The MSVC CRT and Windows SDK, which cargo-xwin fetches from Microsoft's CDN: this line cuts
|
|
# some of its connections mid-way now and then (a release build failed on it). Fetched first,
|
|
# again until it takes; what came whole stays in the cache.
|
|
for try in 1 2 3 4 5 6; do
|
|
cargo xwin cache xwin && break
|
|
[ "$try" -lt 6 ] || { echo "the MSVC CRT could not be fetched" >&2; exit 1; }
|
|
echo "fetching the MSVC CRT again in $((try * 30)) s" >&2
|
|
sleep $((try * 30))
|
|
done
|
|
cargo xwin build -q --release -p ps-service -p ps-ctl --target x86_64-pc-windows-msvc
|
|
# The app on its own, so its crates' features do not change the service's (Cargo unifies them
|
|
# within one build). Its shaders are compiled by Microsoft's fxc.exe under Wine.
|
|
GPUI_FXC_PATH="$PWD/tools/fxc-wine.sh" cargo xwin build -q --release -p ps-gui --target x86_64-pc-windows-msvc
|
|
for exe in proxy-suite-service proxy-ctl proxy-suite; do
|
|
cp "target/x86_64-pc-windows-msvc/release/$exe.exe" "$DIST/"
|
|
done
|
|
# Its build only warns without its icon (cargo -q shows no warning): the release has it.
|
|
llvm-readobj --coff-resources "$DIST/proxy-suite.exe" | grep 'Type: ICON' >/dev/null || { echo "proxy-suite.exe has no icon"; exit 1; }
|
|
cp ../LICENSE README.md "$DIST/"
|
|
cp tools/install.cmd tools/uninstall.cmd "$DIST/"
|
|
|
|
echo "== THIRD-PARTY.md"
|
|
{
|
|
echo "# Third-party components"
|
|
echo
|
|
echo "Proxy Suite for Windows ($VERSION) is MIT-licensed (LICENSE). It carries, unchanged, the"
|
|
echo "programs below, each from its project's own release, pinned by version and hash in"
|
|
echo "components.json. Their licenses are theirs; where a license asks for its source, it is at"
|
|
echo "the address given."
|
|
echo
|
|
echo "| Component | Version | License | Source |"
|
|
echo "|---|---|---|---|"
|
|
jq -r '.components | to_entries[] | "| \(.key) | \(.value.version) | \(.value.license) | \(.value.homepage) |"' components.json
|
|
echo
|
|
echo "Inside them:"
|
|
echo
|
|
echo "- **WinDivert** (zapret, zapret2): LGPL-3.0 or GPL-2.0, https://github.com/basil00/WinDivert"
|
|
echo "- **cygwin1.dll** (zapret, zapret2): LGPL-3.0, https://cygwin.com"
|
|
echo "- **zapret2** (winws2.exe, its Lua) and **nfqws2-keenetic** (its strategies, lists, blobs): MIT, https://github.com/bol-van/zapret2, https://github.com/nfqws/nfqws2-keenetic"
|
|
echo "- **wintun** (inside sing-box): WireGuard's prebuilt-binary license, https://www.wintun.net"
|
|
echo "- **amneziawg-go** (inside wireproxy-awg, with the suite's patch, and inside amneziawg's awg-tunnel.exe): MIT, https://github.com/amnezia-vpn/amneziawg-go"
|
|
echo "- **z2k** (zapret2-extras: its strategies, made by its own generator, its Lua and lists): MIT, https://github.com/necronicle/z2k"
|
|
echo "- **The public suffix list** (zapret2-extras' public_suffixes.txt, derived): MPL-2.0, https://publicsuffix.org"
|
|
echo "- **proxy-suite's zapret2 Lua** (zapret2-extras' lua/: the extended detector and the layers around z2k's state): MIT, this repository's modules/proxy-suite/zapret2"
|
|
echo "- **Wintun** (amneziawg's wintun.dll, as WireGuard LLC builds and signs it): its prebuilt-binaries license, components/amneziawg/wintun-LICENSE.txt"
|
|
echo "- **Go modules** (inside wireproxy-awg and whitelist-bypass, e.g. Pion's WebRTC): as each project's go.mod pins them, under their own licenses (MIT, BSD-3-Clause, Apache-2.0)"
|
|
echo "- **lyrebird** and **conjure** (Tor's pluggable transports, in the Expert Bundle): their licenses are in components/tor/docs"
|
|
echo "- **CPython $( sed 's/.*+py//' "$DIST/components/tg-ws-proxy/.version" )** (tg-ws-proxy): PSF License, https://www.python.org"
|
|
echo "- **The programs themselves** (proxy-suite-service, proxy-ctl, proxy-suite) are built from"
|
|
echo " this repository and the Rust crates in its Cargo.lock, under their licenses (MIT and/or"
|
|
echo " Apache-2.0 for nearly all). The app is built on GPUI (Apache-2.0,"
|
|
echo " https://github.com/zed-industries/zed; its Windows backend patched as"
|
|
echo " vendor/gpui-pre-windows/PATCHED.md says) and GPUI Kit (Apache-2.0,"
|
|
echo " https://github.com/longbridge/gpui-kit), with Lucide's icons (ISC, https://lucide.dev)."
|
|
echo "- **Python packages** (tg-ws-proxy):"
|
|
sed -n 's/^\([A-Za-z0-9_.-]*\)==\([^ ]*\) .*/ - \1 \2, https:\/\/pypi.org\/project\/\1\/\2\//p' tools/tg-ws-proxy-requirements.txt
|
|
echo
|
|
echo "License files that came with them:"
|
|
echo
|
|
(cd "$DIST" && find components -iname 'LICENSE*' -o -iname 'COPYING*' | sort | sed 's/^/- /')
|
|
} > "$DIST/THIRD-PARTY.md"
|
|
|
|
echo "== zip"
|
|
(cd dist && zip -qr "$NAME.zip" "$NAME")
|
|
(cd dist && sha256sum "$NAME.zip" | tee "$NAME.zip.sha256")
|
|
|
|
echo "== setup"
|
|
# Windows' file version takes four numbers: 0.2.0-pre.1 is 0.2.0.0.
|
|
VERSION4=$(sed 's/-.*//' <<<"$VERSION").0
|
|
rm -f "dist/$NAME-setup.exe"
|
|
makensis -V2 -INPUTCHARSET UTF8 -DVERSION="$VERSION" -DVERSION4="$VERSION4" -DRELEASE="$PWD/$DIST" -DICON="$PWD/crates/ps-gui/assets/proxy-suite.ico" -DOUT="$PWD/dist/$NAME-setup.exe" tools/installer.nsi
|
|
(cd dist && sha256sum "$NAME-setup.exe" | tee "$NAME-setup.exe.sha256")
|
|
du -h "dist/$NAME.zip" "dist/$NAME-setup.exe"
|