Mulberry/install.sh
Claude 2cc0338156
Mulberry 1.2.0: fix packaged playback, track-synced visualizer, Last.fm login
- Packaged builds: keep Qt6Quick/Qml (the FFmpeg media plugin links them);
  pruning them disabled all playback in the AppImage/tarball
- Visualizer decodes each track ahead (QAudioDecoder) and follows the playback
  position: works with mpv and Qt, no PipeWire monitor needed for local files
- Packaged Linux builds default to the self-contained Qt engine
- Last.fm: built-in app key, browser login returns to a 127.0.0.1 callback;
  now-playing is re-sent on resume
- Export all playlists (folder, file type, replace/skip/number)
- Unknown/burned CDs: CD placeholder art, no online lookups
- install.sh: --uninstall, --purge, requirement checks, launch log
- CI self-tests now play a file and assert decoding + visualizer output

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01J7imThHV9BMkG24GaxPDeq
2026-10-10 00:04:21 -05:00

130 lines
5.6 KiB
Shell
Executable file

#!/usr/bin/env bash
# Mulberry installer for Linux (per-user, no root needed for the app itself).
#
# ./install.sh install or update
# ./install.sh --uninstall remove the app, launcher, menu entry and icon (keeps your library/settings)
# ./install.sh --purge uninstall AND delete your library, playlists, settings and caches
# ./install.sh --help
set -euo pipefail
SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
PREFIX="$DATA_HOME/mulberry-app"
BIN="$HOME/.local/bin"
APPS="$DATA_HOME/applications"
ICON="$DATA_HOME/icons/hicolor/scalable/apps/mulberry.svg"
bold() { printf '\033[1m%s\033[0m\n' "$*"; }
ok() { printf ' \033[32m✓\033[0m %s\n' "$*"; }
warn() { printf ' \033[33m!\033[0m %s\n' "$*"; }
die() { printf ' \033[31m✗ %s\033[0m\n' "$*" >&2; exit 1; }
refresh_menus() {
command -v update-desktop-database >/dev/null && update-desktop-database "$APPS" 2>/dev/null || true
command -v kbuildsycoca6 >/dev/null && kbuildsycoca6 >/dev/null 2>&1 || true
command -v gtk-update-icon-cache >/dev/null && gtk-update-icon-cache -q "$DATA_HOME/icons/hicolor" 2>/dev/null || true
}
uninstall() {
bold "==> Uninstalling Mulberry"
pkill -f "$PREFIX/venv/bin/python -m mulberry" 2>/dev/null || true
rm -rf "$PREFIX" && ok "removed $PREFIX"
rm -f "$BIN/mulberry" && ok "removed $BIN/mulberry"
rm -f "$APPS/mulberry.desktop" && ok "removed menu entry"
rm -f "$ICON" && ok "removed icon"
refresh_menus
if [[ "${1:-}" == "purge" ]]; then
rm -rf "$DATA_HOME/mulberry" "$CONFIG_HOME/mulberry" "$CACHE_HOME/mulberry"
ok "deleted library, playlists, settings and caches"
else
echo " Your library, playlists and settings were kept in:"
echo " $DATA_HOME/mulberry and $CONFIG_HOME/mulberry"
echo " (run ./install.sh --purge to delete them too)"
fi
bold "Done."
}
case "${1:-}" in
-h|--help)
sed -n '2,7p' "$0" | sed 's/^# \{0,1\}//'
exit 0 ;;
--uninstall|uninstall) uninstall; exit 0 ;;
--purge|purge) uninstall purge; exit 0 ;;
""|--install|install|--update|update) ;;
*) die "unknown option: $1 (try --help)" ;;
esac
bold "==> Checking requirements"
PY="${PYTHON:-python3}"
command -v "$PY" >/dev/null || die "python3 not found — install Python 3.10 or newer"
"$PY" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)' \
|| die "Python 3.10+ is required (found $("$PY" --version 2>&1))"
"$PY" -c 'import venv, ensurepip' 2>/dev/null \
|| die "Python's venv module is missing — install it (Debian/Ubuntu: sudo apt install python3-venv)"
ok "$("$PY" --version)"
missing=()
ldconfig -p 2>/dev/null | grep -q 'libpulse.so.0' || missing+=("libpulse (pipewire-pulse / pulseaudio-libs) — needed by the Qt audio engine")
ldconfig -p 2>/dev/null | grep -q 'libmpv.so' || missing+=("mpv / libmpv — gapless, EQ, ReplayGain, audio CD playback")
command -v cdparanoia >/dev/null || missing+=("cdparanoia — best-quality CD ripping")
command -v ffmpeg >/dev/null || missing+=("ffmpeg — CD rip encoding")
if ((${#missing[@]})); then
warn "Optional packages not found:"
for m in "${missing[@]}"; do echo " - $m"; done
echo " Arch: sudo pacman -S mpv cdparanoia ffmpeg libdiscid"
echo " Fedora: sudo dnf install mpv-libs cdparanoia ffmpeg libdiscid"
echo " Debian/Ubuntu: sudo apt install libmpv2 cdparanoia ffmpeg libdiscid0 libpulse0"
fi
bold "==> Creating virtual environment in $PREFIX"
mkdir -p "$PREFIX"
if [[ ! -x "$PREFIX/venv/bin/python" ]]; then
"$PY" -m venv "$PREFIX/venv" || die "could not create the virtual environment"
fi
"$PREFIX/venv/bin/python" -m pip install --upgrade pip >/dev/null || die "pip upgrade failed"
"$PREFIX/venv/bin/python" -m pip install --upgrade -r "$SRC/requirements.txt" || die "installing Python packages failed"
"$PREFIX/venv/bin/python" -m pip install discid >/dev/null 2>&1 || true # optional (libdiscid)
ok "Python packages installed"
bold "==> Copying application"
rm -rf "$PREFIX/mulberry"
cp -r "$SRC/mulberry" "$PREFIX/mulberry"
find "$PREFIX/mulberry" -name __pycache__ -prune -exec rm -rf {} +
( cd "$PREFIX" && "$PREFIX/venv/bin/python" -c "import mulberry.config, PyQt6.QtWidgets, mutagen, numpy" ) \
|| die "self-check failed: the app's Python modules don't import"
( cd "$PREFIX" && "$PREFIX/venv/bin/python" -c "import PyQt6.QtMultimedia" ) 2>/dev/null \
|| warn "Qt Multimedia couldn't load (usually missing libpulse) — Mulberry will use mpv if installed"
ok "installed to $PREFIX"
mkdir -p "$BIN" "$CACHE_HOME/mulberry"
cat > "$BIN/mulberry" <<LAUNCH
#!/usr/bin/env bash
# Mulberry launcher (generated by install.sh). When started from the app menu,
# output goes to $CACHE_HOME/mulberry/launch.log so problems can be diagnosed.
cd "$PREFIX" || exit 1
if [ -t 1 ]; then
exec "$PREFIX/venv/bin/python" -m mulberry "\$@"
else
exec "$PREFIX/venv/bin/python" -m mulberry "\$@" >>"$CACHE_HOME/mulberry/launch.log" 2>&1
fi
LAUNCH
chmod +x "$BIN/mulberry"
ok "launcher: $BIN/mulberry"
bold "==> Desktop integration"
mkdir -p "$APPS" "$(dirname "$ICON")"
sed "s|^Exec=mulberry|Exec=$BIN/mulberry|" "$SRC/mulberry.desktop" > "$APPS/mulberry.desktop"
cp "$SRC/mulberry/assets/mulberry.svg" "$ICON"
refresh_menus
ok "app-menu entry and icon"
echo
bold "Done! Start Mulberry from your app menu, or run: mulberry"
case ":$PATH:" in
*":$BIN:"*) ;;
*) warn "$BIN is not in your PATH — run it as $BIN/mulberry, or add this to your shell profile:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\"" ;;
esac
echo " Uninstall any time with: ./install.sh --uninstall"