-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild-deb.sh
More file actions
executable file
·409 lines (359 loc) · 15.9 KB
/
Copy pathbuild-deb.sh
File metadata and controls
executable file
·409 lines (359 loc) · 15.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#!/bin/bash
set -e
cd "$(dirname "$0")"
# Packaging deps manifest audit — fails the build before any work if the
# Depends/Recommends lines below diverge from packaging/dependencies.yaml.
# Prevents silent regressions (cf. ffmpeg removed in d4d1fff "fix v1.1.1").
python3 packaging/audit-deps.py
VERSION="1.4.0~beta"
PKG_DIR="pkg/dictee"
# Final artefacts go in .dev/dist/ (gitignored), keeping the repo root clean.
DIST_DIR=".dev/dist"
mkdir -p "$DIST_DIR"
DOTOOL_REPO="https://git.sr.ht/~geb/dotool"
DOTOOL_DIR="/tmp/dotool-build"
# shellcheck disable=SC1091
source ./build-common.sh
echo "========================================"
echo " Building dictee $VERSION"
echo "========================================"
echo ""
echo "Build dependencies:"
echo " sudo apt install golang-go scdoc libxkbcommon-dev"
echo ""
# Wrappers Python / shell, configs, locales, VERSION, assets.
# Shared with build-rpm.sh / build-tar.sh via build-common.sh — single
# source of truth, no more drift between scripts.
dict_prepare_pkg_dir
# Build dotool (keyboard input tool)
build_dotool() {
echo "=== Building dotool ==="
# Vérifier les dépendances de compilation
local missing=()
command -v go >/dev/null || missing+=("golang-go")
command -v scdoc >/dev/null || missing+=("scdoc")
dpkg -s libxkbcommon-dev >/dev/null 2>&1 || missing+=("libxkbcommon-dev")
if [ ${#missing[@]} -gt 0 ]; then
echo "Dépendances manquantes pour compiler dotool : ${missing[*]}"
echo " sudo apt install ${missing[*]}"
exit 1
fi
if [ ! -f "$DOTOOL_DIR/dotool" ]; then
rm -rf "$DOTOOL_DIR"
git clone "$DOTOOL_REPO" "$DOTOOL_DIR"
(cd "$DOTOOL_DIR" && ./build.sh)
else
echo "dotool already built, skipping"
fi
# Install into package tree
cp "$DOTOOL_DIR/dotool" "$PKG_DIR/usr/bin/"
cp "$DOTOOL_DIR/dotoold" "$PKG_DIR/usr/bin/"
mkdir -p "$PKG_DIR/etc/udev/rules.d"
cp "$DOTOOL_DIR/80-dotool.rules" "$PKG_DIR/etc/udev/rules.d/"
echo "dotool built and staged"
echo ""
}
build_dotool
# Plasmoid: now built by dict_prepare_pkg_dir (build-common.sh) so all
# builders (deb / rpm / tar) embed the same just-built artifact. We just
# expose a copy in $DIST_DIR/ for upload-as-release-asset convenience.
expose_plasmoid_in_dist() {
if [ -f "$PKG_DIR/usr/share/dictee/dictee.plasmoid" ]; then
mkdir -p "$DIST_DIR"
cp "$PKG_DIR/usr/share/dictee/dictee.plasmoid" "$DIST_DIR/dictee.plasmoid"
echo "Plasmoid exposed in $DIST_DIR/"
fi
}
expose_plasmoid_in_dist
# Build CUDA version
build_cuda() {
echo "=== [CUDA] Compiling binaries with GPU support ==="
# Use a dedicated staging dir so the CUDA binaries + libonnxruntime libs
# don't get overwritten by the subsequent CPU build (which would leave
# pkg/dictee/usr/bin/transcribe-daemon as a CPU binary and silently
# downgrade `/usr/bin/transcribe-daemon` dev symlinks). Snapshot the
# common staging (pkg/dictee, populated by dict_prepare_pkg_dir +
# build_dotool) so we inherit all .py wrappers, configs, locales,
# systemd units, etc. — only the binaries + control + libs differ.
local PKG_DIR="pkg/dictee-cuda"
rm -rf "$PKG_DIR"
cp -a pkg/dictee "$PKG_DIR"
# CRITICAL: --no-default-features disables ort-defaults (static linking)
# load-dynamic enables runtime loading of libonnxruntime.so for CUDA
cargo build --release --no-default-features --features "cuda,sortformer,load-dynamic" \
--bin transcribe \
--bin transcribe-daemon \
--bin transcribe-client \
--bin transcribe-diarize \
--bin transcribe-stream-diarize \
--bin transcribe-diarize-batch \
--bin diarize-only
# Update control file for CUDA
cat > "$PKG_DIR/DEBIAN/control" << 'EOF'
Package: dictee-cuda
Version: 1.4.0~beta
Section: sound
Priority: optional
Architecture: amd64
Depends: python3, python3-venv, python3-pip, python3-evdev, pulseaudio-utils, pipewire | alsa-utils, libnotify-bin, python3-pyqt6, python3-pyqt6.qtmultimedia, python3-pyqt6.qtsvg, sox, ffmpeg
Recommends: wl-clipboard, xclip | xsel, curl, translate-shell, python3-numpy, docker.io, python3-gi, gir1.2-ayatanaappindicator3-0.1, qt6-gtk-platformtheme, pkexec, libkf6config-bin, wireplumber
Suggests: gnome-shell-extension-appindicator
Conflicts: dictee-cpu
Provides: dictee
Maintainer: rcspam <rcspams@gmail.com>
Description: Fast speech-to-text with NVIDIA Parakeet (CUDA GPU version)
A daemon-based speech recognition system using NVIDIA's Parakeet TDT model.
This version uses CUDA for GPU acceleration (NVIDIA GPUs only).
Falls back to CPU if CUDA is not available.
.
Features:
- GPU-accelerated transcription via CUDA
- Low-latency daemon mode with preloaded model
- Push-to-talk dictation with dotool integration
- Speaker diarization with Sortformer (who speaks when)
EOF
# Copy binaries
cp target/release/transcribe "$PKG_DIR/usr/bin/"
cp target/release/transcribe-daemon "$PKG_DIR/usr/bin/"
cp target/release/transcribe-client "$PKG_DIR/usr/bin/"
cp target/release/transcribe-diarize "$PKG_DIR/usr/bin/"
cp target/release/transcribe-stream-diarize "$PKG_DIR/usr/bin/"
cp target/release/transcribe-diarize-batch "$PKG_DIR/usr/bin/"
cp target/release/diarize-only "$PKG_DIR/usr/bin/"
# ONNX Runtime CUDA libs (load-dynamic: libonnxruntime.so not in target/release)
echo "=== Copying CUDA ONNX Runtime libs ==="
mkdir -p "$PKG_DIR/usr/lib/dictee"
# Search paths for libonnxruntime.so (not produced by load-dynamic build)
ORT_LIB=""
for candidate in \
"target/release/libonnxruntime.so" \
"onnxruntime-linux-x64-gpu-*/lib/libonnxruntime.so" \
"$HOME/.cache/ort.pyke.io/dfbin/*/libonnxruntime.so"; do
# shellcheck disable=SC2086
for f in $candidate; do
if [ -f "$f" ]; then
ORT_LIB="$f"
break 2
fi
done
done
if [ -z "$ORT_LIB" ]; then
echo "ERROR: libonnxruntime.so not found! Download ONNX Runtime GPU from:"
echo " https://github.com/microsoft/onnxruntime/releases"
echo "Extract it in the project root (onnxruntime-linux-x64-gpu-*/lib/)"
exit 1
fi
echo "Using libonnxruntime.so from: $ORT_LIB"
cp -L "$ORT_LIB" "$PKG_DIR/usr/lib/dictee/"
# Provider libs from the same directory as libonnxruntime.so.
# ORT_DIR was historically undefined — fall back to dirname(ORT_LIB).
ORT_LIB_DIR="$(dirname "$ORT_LIB")"
_missing_providers=""
for lib in libonnxruntime_providers_cuda.so libonnxruntime_providers_shared.so; do
if [ -f "$ORT_LIB_DIR/$lib" ]; then
cp -L "$ORT_LIB_DIR/$lib" "$PKG_DIR/usr/lib/dictee/"
echo " $lib ← $ORT_LIB_DIR/$lib"
else
_missing_providers="$_missing_providers $lib"
fi
done
if [ -n "$_missing_providers" ]; then
echo "ERROR: CUDA providers missing in $ORT_LIB_DIR:$_missing_providers" >&2
echo "The CUDA package will silently fall back to CPU at runtime." >&2
exit 1
fi
# CUDA runtime libs (cudart, cublas, cudnn, cufft, curand, nvrtc) are
# NOT bundled here. They are pip-installed at postinst time into
# /opt/dictee/cuda-venv and symlinked into /usr/lib/dictee/ so this
# package stays portable on any distro without requiring the NVIDIA
# repo. See pkg/dictee/DEBIAN/postinst.
# ld.so.conf.d entry so the dynamic linker finds them
mkdir -p "$PKG_DIR/etc/ld.so.conf.d"
echo "/usr/lib/dictee" > "$PKG_DIR/etc/ld.so.conf.d/dictee.conf"
chmod 755 "$PKG_DIR/usr/bin/"*
chmod 755 "$PKG_DIR/DEBIAN/postinst"
chmod 755 "$PKG_DIR/DEBIAN/postrm"
# Compress man pages
gzip -9 -f "$PKG_DIR/usr/share/man/man1/"*.1 2>/dev/null || true
gzip -9 -f "$PKG_DIR/usr/share/man/fr/man1/"*.1 2>/dev/null || true
dpkg-deb --build "$PKG_DIR" "$DIST_DIR/dictee-cuda_${VERSION}_amd64.deb"
# Decompress for next build
gunzip "$PKG_DIR/usr/share/man/man1/"*.gz 2>/dev/null || true
gunzip "$PKG_DIR/usr/share/man/fr/man1/"*.gz 2>/dev/null || true
# The universal CUDA tarball is now built by ./build-tar.sh, which
# runs its own CUDA build — no need to stash binaries or libs from
# this script anymore.
# Cleanup CUDA libs for CPU build (keep shared scripts/modules).
# Glob *.so* catches libcudart.so.12 / libcufft.so.11 too (the plain
# *.so only matches libonnxruntime.so, leaving 278 MB of CUDA libs
# behind inside the CPU .deb).
rm -f "$PKG_DIR/usr/lib/dictee/"*.so \
"$PKG_DIR/usr/lib/dictee/"*.so.* \
"$PKG_DIR/etc/ld.so.conf.d/dictee.conf"
echo "Built: $DIST_DIR/dictee-cuda_${VERSION}_amd64.deb"
}
# Build CPU version
build_cpu() {
echo ""
echo "=== [CPU] Compiling binaries for CPU-only ==="
# Dedicated staging dir (cf. build_cuda comment). Snapshot the common
# staging — only the binaries + control differ from the CUDA flavor.
local PKG_DIR="pkg/dictee-cpu"
rm -rf "$PKG_DIR"
cp -a pkg/dictee "$PKG_DIR"
cargo build --release --features "sortformer" \
--bin transcribe \
--bin transcribe-daemon \
--bin transcribe-client \
--bin transcribe-diarize \
--bin transcribe-stream-diarize \
--bin transcribe-diarize-batch \
--bin diarize-only
# Update control file for CPU
cat > "$PKG_DIR/DEBIAN/control" << 'EOF'
Package: dictee-cpu
Version: 1.4.0~beta
Section: sound
Priority: optional
Architecture: amd64
Depends: python3, python3-venv, python3-evdev, pulseaudio-utils, pipewire | alsa-utils, libnotify-bin, python3-pyqt6, python3-pyqt6.qtmultimedia, python3-pyqt6.qtsvg, sox, ffmpeg
Recommends: wl-clipboard, xclip | xsel, curl, translate-shell, python3-numpy, docker.io, python3-gi, gir1.2-ayatanaappindicator3-0.1, qt6-gtk-platformtheme, pkexec, libkf6config-bin, wireplumber
Suggests: gnome-shell-extension-appindicator
Conflicts: dictee-cuda
Provides: dictee
Maintainer: rcspam <rcspams@gmail.com>
Description: Fast speech-to-text with NVIDIA Parakeet (CPU version)
A daemon-based speech recognition system using NVIDIA's Parakeet TDT model.
This version runs on CPU only (works on any computer, slower than GPU).
.
Features:
- CPU-based transcription (no GPU required)
- Low-latency daemon mode with preloaded model
- Push-to-talk dictation with dotool integration
- Speaker diarization with Sortformer (who speaks when)
EOF
# Copy binaries
cp target/release/transcribe "$PKG_DIR/usr/bin/"
cp target/release/transcribe-daemon "$PKG_DIR/usr/bin/"
cp target/release/transcribe-client "$PKG_DIR/usr/bin/"
cp target/release/transcribe-diarize "$PKG_DIR/usr/bin/"
cp target/release/transcribe-stream-diarize "$PKG_DIR/usr/bin/"
cp target/release/transcribe-diarize-batch "$PKG_DIR/usr/bin/"
cp target/release/diarize-only "$PKG_DIR/usr/bin/"
chmod 755 "$PKG_DIR/usr/bin/"*
# Compress man pages
gzip -9 -f "$PKG_DIR/usr/share/man/man1/"*.1 2>/dev/null || true
gzip -9 -f "$PKG_DIR/usr/share/man/fr/man1/"*.1 2>/dev/null || true
dpkg-deb --build "$PKG_DIR" "$DIST_DIR/dictee-cpu_${VERSION}_amd64.deb"
echo "Built: $DIST_DIR/dictee-cpu_${VERSION}_amd64.deb"
# Decompress for potential next build
gunzip "$PKG_DIR/usr/share/man/man1/"*.gz 2>/dev/null || true
gunzip "$PKG_DIR/usr/share/man/fr/man1/"*.gz 2>/dev/null || true
}
# Build standalone dictee-plasmoid .deb (Architecture: all, depends on dictee).
# Rebuild guarantees pkg/dictee-plasmoid/ is refreshed from source on every run
# so the .deb content always matches the just-built dictee.plasmoid.
build_plasmoid_deb() {
echo ""
echo "=== [PLASMOID] Building standalone dictee-plasmoid .deb ==="
local PP="pkg/dictee-plasmoid"
if [ ! -f "$DIST_DIR/dictee.plasmoid" ]; then
echo "ERROR: $DIST_DIR/dictee.plasmoid not built (build_plasmoid must run first)." >&2
exit 1
fi
# /usr/share/dictee/dictee.plasmoid is shipped by dictee-cuda/cpu (used by
# their postinst for `kpackagetool6 -i`). NOT shipped here to avoid the
# dpkg file-conflict observed in v1.3.4 ("trying to overwrite '/usr/share/
# dictee/dictee.plasmoid', which is also in package dictee-cuda"). The
# extracted tree below is enough for plasmashell auto-discovery.
rm -rf "$PP/usr/share/dictee"
# Refresh the extracted plasmoid tree under /usr/share/plasma/plasmoids/
local PLASMA_DIR="$PP/usr/share/plasma/plasmoids/com.github.rcspam.dictee"
rm -rf "$PLASMA_DIR"
mkdir -p "$PLASMA_DIR"
unzip -q -o "$DIST_DIR/dictee.plasmoid" -d "$PLASMA_DIR"
# Refresh locale .mo files from plasmoid source (system-wide install path)
for _lang in fr de es it pt uk; do
local _mo="plasmoid/package/contents/locale/$_lang/LC_MESSAGES/plasma_applet_com.github.rcspam.dictee.mo"
if [ -f "$_mo" ]; then
mkdir -p "$PP/usr/share/locale/$_lang/LC_MESSAGES"
cp "$_mo" "$PP/usr/share/locale/$_lang/LC_MESSAGES/"
fi
done
# Regenerate control file with current $VERSION
cat > "$PP/DEBIAN/control" << EOF
Package: dictee-plasmoid
Version: ${VERSION}
Section: kde
Priority: optional
Architecture: all
Depends: dictee
Recommends: python3-numpy, pulseaudio-utils
Maintainer: rcspam <rcspams@gmail.com>
Description: KDE Plasma 6 widget for dictee voice dictation
A native KDE Plasma 6 widget for dictee voice dictation.
Displays real-time audio visualization during recording, daemon status,
and provides quick controls (dictate, translate, meeting).
.
Five animation styles with configurable sensitivity and color gradients.
EOF
chmod 755 "$PP/DEBIAN/postinst" "$PP/DEBIAN/postrm" 2>/dev/null || true
dpkg-deb --build "$PP" "$DIST_DIR/dictee-plasmoid_${VERSION}_all.deb"
echo "Built: $DIST_DIR/dictee-plasmoid_${VERSION}_all.deb"
echo ""
}
# Build tar.gz (non-Debian)
# The universal CUDA tarball is now built by ./build-tar.sh — that
# script does its own forced CUDA build (with hard guards) so the
# archive can never silently end up with CPU binaries again.
# Run `./build-tar.sh` separately when you need the tarball.
# Build all Debian variants
# Order matters: CPU first, CUDA last → cargo build for CUDA finishes the
# pass, so target/release/ ends with CUDA-build binaries. That way the dev
# host symlinks /usr/bin/transcribe-{daemon,…} → target/release/* keep
# working in GPU mode after the script returns.
build_cpu
build_cuda
build_plasmoid_deb
# Safeguard: the build MUST produce cuda + cpu + plasmoid .deb. If any is
# missing, someone removed or broke a build step — fail loud instead of
# shipping an incomplete release. Do not remove this check.
_expected_debs=(
"$DIST_DIR/dictee-cuda_${VERSION}_amd64.deb"
"$DIST_DIR/dictee-cpu_${VERSION}_amd64.deb"
"$DIST_DIR/dictee-plasmoid_${VERSION}_all.deb"
)
_missing=""
for _d in "${_expected_debs[@]}"; do
[ -f "$_d" ] || _missing="$_missing $_d"
done
if [ -n "$_missing" ]; then
echo "" >&2
echo "ERROR: expected .deb packages missing:$_missing" >&2
echo "Every build must produce cuda + cpu + plasmoid .deb." >&2
exit 1
fi
echo ""
echo "========================================"
echo " Build complete!"
echo "========================================"
echo ""
echo "Packages created in $DIST_DIR/ :"
echo " - dictee-cuda_${VERSION}_amd64.deb (Debian/Ubuntu, NVIDIA GPU)"
echo " - dictee-cpu_${VERSION}_amd64.deb (Debian/Ubuntu, CPU)"
echo " - dictee-plasmoid_${VERSION}_all.deb (Debian/Ubuntu, plasmoid only)"
echo " - dictee-${VERSION}_amd64.tar.gz (Autres distributions)"
echo ""
echo "Install (.deb):"
echo " sudo dpkg -i $DIST_DIR/dictee-{cuda,cpu}_${VERSION}_amd64.deb"
echo " sudo dpkg -i $DIST_DIR/dictee-plasmoid_${VERSION}_all.deb # plasmoid only"
echo " sudo apt-get install -f # if dependencies missing"
echo ""
echo "Install (.tar.gz):"
echo " tar xzf $DIST_DIR/dictee-${VERSION}_amd64.tar.gz"
echo " cd dictee-${VERSION}"
echo " sudo ./install.sh"
echo ""
echo "Uninstall:"
echo " sudo dpkg -r dictee-{cuda,cpu,plasmoid}"
echo " sudo ./uninstall.sh # tar.gz"