Files
sigil/scripts/build-appimage.sh
nvrl 1863505de7 Ship speech to text ready to use in both bundles
The AppImage and the Windows zip now carry whisper-cli, sigil-vocals,
ONNX Runtime and the models, so Transcribe works without installing
anything. whisper-cli is built from the whisper.cpp source release with
static ggml, no OpenMP and no SDL (AVX2/FMA/F16C on): on Linux it needs only
glibc, and the mingw cross-build links fully static and needs only the
UCRT. ONNX Runtime is Microsoft's prebuilt library, placed next to
sigil-vocals, which loads it from there. The models (ggml-base and
UVR_MDXNET_1_9703 by default) go in models/ next to the launcher, where it
already looks. License files for ONNX Runtime and whisper.cpp are included.

Toggles, all cached in ~/.cache/sigil-build: WITH_STT=0 leaves it all out,
WITH_MODELS=0 ships the programs only (the launcher downloads models on
demand), WHISPER_MODEL / VOCAL_MODEL pick other models, WHISPER_VERSION /
ORT_VERSION pin the releases. onnxruntime.dll needs the Visual C++ runtime;
VCRT_DIR copies those DLLs into the zip, and the README and sigil-vocals'
error point at the redistributable otherwise.

Checked: both bundles build; from the extracted AppImage and under wine,
sigil-vocals isolates a 15 s clip and whisper-cli transcribes the stem.
2026-11-11 00:20:01 +01:00

133 lines
5.1 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Build a single self-contained Linux AppImage.
#
# Bundles: sigil-gui (entry) + sigil (engine) + a static ffmpeg + every
# non-system shared lib the binaries pull in (gathered by linuxdeploy), and
# for speech to text: whisper-cli (built from source), sigil-vocals, ONNX
# Runtime and the models (see _common.sh: WITH_STT, WITH_MODELS, ...).
# The AppRun prepends $APPDIR/usr/bin to PATH, so the launcher finds `sigil`
# and the engine finds `ffmpeg` without anything installed on the host.
#
# Graphics/driver libs (libGL, the Vulkan loader, GPU drivers) are deliberately
# NOT bundled — those must come from the host, same as every other GPU AppImage.
#
# Run on Linux: scripts/build-appimage.sh
# Override ffmpeg source: FFMPEG_LINUX_URL=... scripts/build-appimage.sh
# Without speech to text: WITH_STT=0 scripts/build-appimage.sh
source "$(dirname "${BASH_SOURCE[0]}")/_common.sh"
need cargo
need tar
export APPIMAGE_EXTRACT_AND_RUN=1 # let linuxdeploy run without host FUSE
FFMPEG_LINUX_URL="${FFMPEG_LINUX_URL:-https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz}"
LINUXDEPLOY_URL="https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
# 1. Build the release binaries.
log "cargo build --release (sigil, sigil-gui)"
cargo build --release --manifest-path "$ROOT/Cargo.toml" --bin sigil
if [[ "$WITH_STT" == "1" ]]; then
cargo build --release --manifest-path "$ROOT/Cargo.toml" -p sigil-vocals
fi
# The launcher is its own workspace; build it into the same target dir.
cargo build --release --target-dir "$ROOT/target" --manifest-path "$ROOT/sigil-gui/Cargo.toml"
BIN="$ROOT/target/release"
[[ -x "$BIN/sigil" && -x "$BIN/sigil-gui" ]] || die "expected binaries missing in $BIN"
# 2. Fetch + unpack a static ffmpeg.
FF_TAR="$CACHE/ffmpeg-linux.tar.xz"
fetch "$FFMPEG_LINUX_URL" "$FF_TAR"
FF_DIR="$CACHE/ffmpeg-linux"
rm -rf "$FF_DIR"; mkdir -p "$FF_DIR"
tar -xJf "$FF_TAR" -C "$FF_DIR" --strip-components=1
FFMPEG_BIN="$FF_DIR/ffmpeg"
[[ -x "$FFMPEG_BIN" ]] || die "ffmpeg binary not found after extracting $FF_TAR"
# 3. Fetch linuxdeploy (gathers dependent libs + packs the AppImage).
LD="$CACHE/linuxdeploy-x86_64.AppImage"
fetch "$LINUXDEPLOY_URL" "$LD"
chmod +x "$LD"
# 4. Assemble the AppDir skeleton.
APPDIR="$DIST/Sigil.AppDir"
rm -rf "$APPDIR"
mkdir -p "$APPDIR/usr/bin"
cp "$FFMPEG_BIN" "$APPDIR/usr/bin/ffmpeg"
# Speech to text. whisper-cli is a static build (only glibc + libm), so it
# skips linuxdeploy. ONNX Runtime goes next to sigil-vocals, which loads it
# from there at run time; the models go in usr/bin/models, where the
# launcher looks.
STT_EXES=()
if [[ "$WITH_STT" == "1" ]]; then
WHISPER_CLI=$(build_whisper "$CACHE/whisper-build-linux" \
-DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++")
install -m755 "$WHISPER_CLI" "$APPDIR/usr/bin/whisper-cli"
strip "$APPDIR/usr/bin/whisper-cli" || true
ORT_TGZ="$CACHE/onnxruntime-linux-x64-$ORT_VERSION.tgz"
fetch "$ORT_URL/onnxruntime-linux-x64-$ORT_VERSION.tgz" "$ORT_TGZ"
ORT_SO="onnxruntime-linux-x64-$ORT_VERSION/lib/libonnxruntime.so.$ORT_VERSION"
tar -xzf "$ORT_TGZ" -O "$ORT_SO" > "$APPDIR/usr/bin/libonnxruntime.so"
LIC="$APPDIR/usr/share/licenses"
mkdir -p "$LIC/onnxruntime" "$LIC/whisper.cpp"
for f in LICENSE ThirdPartyNotices.txt; do
tar -xzf "$ORT_TGZ" -O "onnxruntime-linux-x64-$ORT_VERSION/$f" > "$LIC/onnxruntime/$f"
done
cp "$(whisper_src)/LICENSE" "$LIC/whisper.cpp/LICENSE"
stt_models "$APPDIR/usr/bin/models"
STT_EXES=(--executable "$BIN/sigil-vocals")
fi
# Desktop entry + icon (linuxdeploy requires both).
cat > "$DIST/sigil.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=Sigil Visualizer
Comment=Audio-reactive GPU visual engine
Exec=sigil-gui
Icon=sigil
Categories=AudioVideo;Audio;Graphics;
Terminal=false
EOF
# Custom AppRun: put bundled bins + libs ahead of the host's, launch the GUI.
# Icon: linuxdeploy only accepts standard square sizes and names the installed
# icon after the file, which must match `Icon=sigil` above. The checked-in
# assets/sigil-icon.png is already 256x256; copy it under that name.
ICON="$DIST/sigil.png"
[[ -f "$ROOT/assets/sigil-icon.png" ]] || die "missing icon: assets/sigil-icon.png"
cp "$ROOT/assets/sigil-icon.png" "$ICON"
cat > "$DIST/AppRun" <<'EOF'
#!/bin/sh
HERE="$(dirname "$(readlink -f "$0")")"
export PATH="$HERE/usr/bin:$PATH"
export LD_LIBRARY_PATH="$HERE/usr/lib:${LD_LIBRARY_PATH:-}"
exec "$HERE/usr/bin/sigil-gui" "$@"
EOF
chmod +x "$DIST/AppRun"
# 5. Let linuxdeploy bundle deps for the executables and build the image.
log "linuxdeploy: bundling deps + packing AppImage"
rm -f "$DIST"/Sigil*.AppImage
( cd "$DIST" && OUTPUT="Sigil-x86_64.AppImage" "$LD" \
--appdir "$APPDIR" \
--executable "$BIN/sigil-gui" \
--executable "$BIN/sigil" \
--executable "$APPDIR/usr/bin/ffmpeg" \
"${STT_EXES[@]}" \
--desktop-file "$DIST/sigil.desktop" \
--icon-file "$ICON" \
--custom-apprun "$DIST/AppRun" \
--output appimage )
OUT=$(ls -1 "$DIST"/Sigil*.AppImage 2>/dev/null | head -1) || true
[[ -n "${OUT:-}" ]] || die "linuxdeploy produced no AppImage"
chmod +x "$OUT"
log "done → $OUT ($(du -h "$OUT" | cut -f1))"