upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNsable-sh <nsable-sh@noreply.git.bitflash.network>2026-08-13 14:29:14 -0300
committerNsable-sh <nsable-sh@noreply.git.bitflash.network>2026-08-13 14:29:14 -0300
commit44fbf6895bd3acd11f552514e746a2e3876cad2d (patch)
tree2f8a52946999af7ec121c9c0574df1920e3b4fb4 /scripts
parent5dec9b16a5b98ed0e24ec7113b867f22be2d0026 (diff)
release: package Windows builds with managed Tor
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/make-release-checksums.sh2
-rwxr-xr-xscripts/package-windows-tor.sh132
2 files changed, 134 insertions, 0 deletions
diff --git a/scripts/make-release-checksums.sh b/scripts/make-release-checksums.sh
index 5b29e2d..9c4f45a 100755
--- a/scripts/make-release-checksums.sh
+++ b/scripts/make-release-checksums.sh
@@ -10,6 +10,7 @@ Usage: scripts/make-release-checksums.sh [--sign] [--local-user KEYID]
10 10
11Creates SHA256SUMS for release assets in the current directory: 11Creates SHA256SUMS for release assets in the current directory:
12 Bitflash-*-windows.zip 12 Bitflash-*-windows.zip
13 Bitflash-*-windows-with-tor.zip
13 Bitflash-*-x86_64.AppImage 14 Bitflash-*-x86_64.AppImage
14 bitflash-node-*-x86_64 15 bitflash-node-*-x86_64
15 16
@@ -44,6 +45,7 @@ fi
44assets=() 45assets=()
45for pattern in \ 46for pattern in \
46 "Bitflash-*-windows.zip" \ 47 "Bitflash-*-windows.zip" \
48 "Bitflash-*-windows-with-tor.zip" \
47 "Bitflash-*-x86_64.AppImage" \ 49 "Bitflash-*-x86_64.AppImage" \
48 "bitflash-node-*-x86_64" 50 "bitflash-node-*-x86_64"
49do 51do
diff --git a/scripts/package-windows-tor.sh b/scripts/package-windows-tor.sh
new file mode 100755
index 0000000..084fd1a
--- /dev/null
+++ b/scripts/package-windows-tor.sh
@@ -0,0 +1,132 @@
1#!/usr/bin/env bash
2set -euo pipefail
3
4ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5VERSION="${VERSION:-$(sed -n 's/^VERSION[[:space:]]*:= *//p' "$ROOT/Makefile" | head -1)}"
6
7TOR_VERSION="${TOR_VERSION:-15.0.19}"
8TOR_ARCHIVE_NAME="tor-expert-bundle-windows-x86_64-${TOR_VERSION}.tar.gz"
9TOR_URL="${TOR_URL:-https://archive.torproject.org/tor-package-archive/torbrowser/${TOR_VERSION}/${TOR_ARCHIVE_NAME}}"
10TOR_SHA256="${TOR_SHA256:-6AC067402C7B4A3DC37887ED3754B3914B67FDC220C966190683E9CCF91ABF0F}"
11
12BUNDLE_DIR="${BUNDLE_DIR:-$ROOT/Bitflash-${VERSION}-windows}"
13OUT_ZIP="${OUT_ZIP:-$ROOT/Bitflash-${VERSION}-windows-with-tor.zip}"
14CACHE_DIR="${CACHE_DIR:-$ROOT/.cache}"
15ARCHIVE="${TOR_ARCHIVE:-$CACHE_DIR/$TOR_ARCHIVE_NAME}"
16
17usage() {
18 cat <<EOF
19Usage: scripts/package-windows-tor.sh
20
21Creates Bitflash-${VERSION}-windows-with-tor.zip from an existing
22Bitflash-${VERSION}-windows/ release directory.
23
24Environment overrides:
25 VERSION Bitflash release version, default read from Makefile
26 TOR_VERSION Tor Expert Bundle version, default ${TOR_VERSION}
27 TOR_URL Download URL, default official Tor archive URL
28 TOR_SHA256 Expected archive SHA256
29 TOR_ARCHIVE Use an existing archive instead of downloading
30 BUNDLE_DIR Existing unpacked Windows release directory
31 OUT_ZIP Output zip path
32EOF
33}
34
35if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
36 usage
37 exit 0
38fi
39
40need() {
41 command -v "$1" >/dev/null 2>&1 || {
42 echo "missing required command: $1" >&2
43 exit 1
44 }
45}
46
47need sha256sum
48need tar
49need zip
50
51if [ ! -d "$BUNDLE_DIR" ]; then
52 echo "missing Windows release directory: $BUNDLE_DIR" >&2
53 echo "run 'make windows' first, or set BUNDLE_DIR" >&2
54 exit 1
55fi
56if [ ! -f "$BUNDLE_DIR/Bitflash.exe" ]; then
57 echo "missing Bitflash.exe in $BUNDLE_DIR" >&2
58 exit 1
59fi
60BUNDLE_PARENT="$(cd "$(dirname "$BUNDLE_DIR")" && pwd)"
61BUNDLE_NAME="$(basename "$BUNDLE_DIR")"
62OUT_PARENT="$(mkdir -p "$(dirname "$OUT_ZIP")" && cd "$(dirname "$OUT_ZIP")" && pwd)"
63OUT_NAME="$(basename "$OUT_ZIP")"
64OUT_ZIP_ABS="$OUT_PARENT/$OUT_NAME"
65
66mkdir -p "$CACHE_DIR"
67if [ ! -f "$ARCHIVE" ]; then
68 if command -v curl >/dev/null 2>&1; then
69 curl -L --fail --output "$ARCHIVE" "$TOR_URL"
70 elif command -v wget >/dev/null 2>&1; then
71 wget -O "$ARCHIVE" "$TOR_URL"
72 else
73 echo "missing required command: curl or wget" >&2
74 exit 1
75 fi
76fi
77
78got="$(sha256sum "$ARCHIVE" | awk '{print tolower($1)}')"
79want="$(printf '%s' "$TOR_SHA256" | tr 'A-F' 'a-f')"
80if [ "$got" != "$want" ]; then
81 echo "Tor archive SHA256 mismatch" >&2
82 echo " expected: $want" >&2
83 echo " got: $got" >&2
84 exit 1
85fi
86
87tmp="$(mktemp -d "${TMPDIR:-/tmp}/bitflash-tor-package.XXXXXX")"
88trap 'rm -rf "$tmp"' EXIT
89
90mkdir -p "$tmp/extract"
91tar -xzf "$ARCHIVE" -C "$tmp/extract"
92
93if [ ! -f "$tmp/extract/tor/tor.exe" ]; then
94 echo "Tor archive did not contain tor/tor.exe" >&2
95 exit 1
96fi
97
98rm -rf "$BUNDLE_DIR/tor"
99mkdir -p "$BUNDLE_DIR/tor"
100cp -R "$tmp/extract/tor/." "$BUNDLE_DIR/tor/"
101if [ -d "$tmp/extract/docs" ]; then
102 mkdir -p "$BUNDLE_DIR/tor/docs"
103 cp -R "$tmp/extract/docs/." "$BUNDLE_DIR/tor/docs/"
104fi
105if [ -d "$tmp/extract/data" ]; then
106 mkdir -p "$BUNDLE_DIR/tor/data-defaults"
107 cp -R "$tmp/extract/data/." "$BUNDLE_DIR/tor/data-defaults/"
108fi
109
110cat > "$BUNDLE_DIR/TOR-EXPERT-BUNDLE.txt" <<EOF
111Bitflash managed Tor bundle
112
113This Windows package includes the Tor Expert Bundle so -managedtor can start
114Tor without requiring a separate Tor install.
115
116Tor Expert Bundle: ${TOR_VERSION}
117Archive URL: ${TOR_URL}
118Archive SHA256: ${TOR_SHA256}
119
120Bitflash uses tor/tor.exe from this package. Runtime state, hidden-service keys,
121and control authentication cookies are written under the user's Bitflash data
122directory, not inside this release directory.
123EOF
124
125rm -f "$OUT_ZIP_ABS"
126(
127 cd "$BUNDLE_PARENT"
128 zip -qr "$OUT_ZIP_ABS" "$BUNDLE_NAME"
129)
130
131echo "Bundled Tor Expert Bundle ${TOR_VERSION}"
132echo "Built: $OUT_ZIP_ABS"