diff --git a/.gitignore b/.gitignore index e37d0b0..e636d28 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ target/ *.AppImage -releases/ +/releases/ dist/ .directory diff --git a/Cargo.lock b/Cargo.lock index 3f1ef54..a5a5916 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2226,7 +2226,7 @@ dependencies = [ [[package]] name = "mulberry" -version = "2.0.3" +version = "2.0.4" dependencies = [ "base64 0.22.1", "chrono", diff --git a/Cargo.toml b/Cargo.toml index f1139f0..b136d7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mulberry" -version = "2.0.3" +version = "2.0.4" edition = "2021" description = "A Material You music player for Linux" license = "MIT" diff --git a/README.md b/README.md index 385d1b3..743f11d 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,21 @@ focus mode (F11), compact and hidden now-playing layouts, a floating bass-reacti ## Install ### From a release -Download `Mulberry--Linux-x86_64.tar.gz` from the [Releases page](https://archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry/releases), -unpack it and run `./install.sh` inside. It installs to `~/.local` (no root). + +Downloads are on the [Releases page](https://archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry/releases); check them against `SHA256SUMS-`. The Linux builds +are made on Arch Linux and need a recent glibc (the version is named in the packages and checked by the installer), +so they run on Arch and other up-to-date distributions; on older ones, build from source. + +- **Arch Linux:** `sudo pacman -U Mulberry--arch-x86_64.pkg.tar.zst` (package `mulberry-bin`; remove it with + `sudo pacman -R mulberry-bin`). `packaging/arch/PKGBUILD` builds the same package from the release. +- **Debian, Ubuntu and other apt systems:** `sudo apt install ./Mulberry--amd64.deb`. +- **Nix:** `nix profile install git+https://archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry` (this repo is a flake), or `callPackage ./packaging/nix { }`. +- **Any distribution:** unpack `Mulberry--Linux-x86_64.tar.gz` and run `sh install.sh` inside (your home, + `~/.local`, no root) or `sh install.sh --system` (`/usr/local`). `sh uninstall.sh` removes it; `--purge` also + deletes settings and data. `installer.sh` from this repo does the same next to a downloaded tar.gz or AppImage. +- **AppImage:** `chmod +x Mulberry--x86_64.AppImage` and run it. libmpv is bundled in it. +- **Windows (x64):** `Mulberry--Setup.exe` installs for your user only (no admin) with a Start menu entry + and an uninstaller; `Mulberry--Windows-portable.zip` runs from any folder. ### iPhone (jailbroken / TrollStore) `Mulberry--iOS.ipa` on the Releases page installs with TrollStore. The iOS app lives in [`ios/`](ios/README.md) diff --git a/docs/releases/2.0.0.md b/docs/releases/2.0.0.md new file mode 100644 index 0000000..cd99826 --- /dev/null +++ b/docs/releases/2.0.0.md @@ -0,0 +1,10 @@ +# Mulberry 2.0.0 — rewritten in Rust + +- Native Rust app (egui + libmpv): no Python or Qt needed, one binary. +- Right-click a cell of several selected tracks › **Set album/artist/title/… to “value”** writes the tag into every selected file instantly (undo in the toast). +- The wavy seek bar no longer jumps back and forth (monotonic position clock, no per-frame image rescaling). +- Animations capped at 30 fps by default; nothing repaints while paused. About 1 ms CPU per frame. +- Closing the window or Ctrl+Q with the tray icon enabled keeps playing in the background; tray › Quit exits. +- Synced lyrics follow playback; window and tray icon follow the accent colour; compact menus. +- Uses your existing library, playlists and covers; settings are imported once from the old config. +- Linux only for now. Needs libmpv (`mpv`); optional ffmpeg, cdparanoia, yt-dlp. diff --git a/docs/releases/2.0.1.md b/docs/releases/2.0.1.md new file mode 100644 index 0000000..b30c5c0 --- /dev/null +++ b/docs/releases/2.0.1.md @@ -0,0 +1,9 @@ +# Mulberry 2.0.1 + +- **Drop files from your file manager onto the playlist** (also on Wayland/niri): they are inserted where you hover, with an insert line, and a group of files stays together and in order. Wayland support comes from a patched copy of winit (`vendor/winit`). +- Ctrl+V pastes files copied in a file manager. +- Dragging rows shows the insert line reliably; dropping below the last row appends. +- Stop (media key or button) now clears the "playing" marker in the playlist; MPRIS no longer loses its name to a second instance. +- Closing the window or Ctrl+Q keeps playing in the tray when the tray is enabled; Quit in the tray exits. +- Synced lyrics follow playback, window/tray icon follow the accent colour, compact menus, Focus mode in the View menu. +- New README and screenshots. diff --git a/docs/releases/2.0.2.md b/docs/releases/2.0.2.md new file mode 100644 index 0000000..3df6697 --- /dev/null +++ b/docs/releases/2.0.2.md @@ -0,0 +1,9 @@ +# Mulberry 2.0.2 + +- **Windows build**: installer and portable zip (no tray icon or media-key integration yet). Linux gets an AppImage too. +- Ctrl+C / Ctrl+X / Ctrl+V now work in every text field (tag editor, filters, dialogs). +- Player shortcuts (Ctrl+arrows, Ctrl+Z, Ctrl+A, Ctrl+T/W/J/D/E/L/U/H/M) no longer fire while you are typing in a text box. +- Menus: submenu rows line up with the other rows and all rows span the full menu width. +- The floating bass shape's "Change shape" menu item works. +- "Paste files from file manager" removed from the Playlist menu; Ctrl+V still adds copied files. +- Edit lyrics opens with the lyrics currently shown, from any source (synced, plain, embedded, online). diff --git a/docs/releases/2.0.3.md b/docs/releases/2.0.3.md new file mode 100644 index 0000000..4c75a85 --- /dev/null +++ b/docs/releases/2.0.3.md @@ -0,0 +1,5 @@ +# Mulberry 2.0.3 + +- **Web links play again**: starting a YouTube/SoundCloud/… link while another track was playing left the player stuck on "loading" (and the old track kept playing underneath). Links now start as soon as yt-dlp has resolved them, with title, length and live state. +- While a link is being opened the player shows "Opening link with yt-dlp…" instead of "LIVE". +- Links from sites outside the built-in list are handed to yt-dlp when mpv cannot open them. diff --git a/docs/releases/2.0.4.md b/docs/releases/2.0.4.md new file mode 100644 index 0000000..6839a35 --- /dev/null +++ b/docs/releases/2.0.4.md @@ -0,0 +1,8 @@ +# Mulberry 2.0.4 + +- **New icon colour:** the icon is berry red instead of purple, so it stands apart from the other apps in a dock. +- **More packages:** besides the AppImage, tar.gz and Windows installer and zip, there is now an Arch package + (`mulberry-bin`), a Debian/Ubuntu `.deb` and a Nix flake. The tar.gz now unpacks like a prefix (`bin/`, `share/`) + with `install.sh` and `uninstall.sh` (`--system` for `/usr/local`, `--purge` to delete your data). +- **Windows fixes:** links and "show in folder" open in the browser and Explorer (they did nothing before), and + yt-dlp and ffmpeg no longer flash a console window. diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9d1c7b5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,10 @@ +{ + description = "Material You music player"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + outputs = { self, nixpkgs }: + let pkgs = nixpkgs.legacyPackages.x86_64-linux; + in { + packages.x86_64-linux.default = pkgs.callPackage ./packaging/nix { }; + apps.x86_64-linux.default = { type = "app"; program = "${self.packages.x86_64-linux.default}/bin/mulberry"; }; + }; +} diff --git a/installer.sh b/installer.sh new file mode 100755 index 0000000..1e5cbe5 --- /dev/null +++ b/installer.sh @@ -0,0 +1,159 @@ +#!/bin/sh +# Mulberry installer. Installs from a release tar.gz or AppImage, or removes an install. +# installer.sh [--user|--system] [--prefix DIR] [--url URL] [FILE] +# installer.sh --uninstall [--purge] [--user|--system] [--prefix DIR] +# --user (default): ~/.local, no root. --system: /usr/local, sudo only for the copy. +# Without FILE it uses the unpacked release folder it sits in, or Mulberry-*-Linux-x86_64.tar.gz or +# Mulberry-*-x86_64.AppImage next to it. SHA256SUMS- beside the file is checked when present. +# --purge also deletes settings and data (~/.config/mulberry, ~/.local/share/mulberry, ~/.cache/mulberry: settings, library, playlists, caches). DESTDIR=dir stages under dir (no sudo). +# Needs glibc 2.35 or newer. +set -eu + +app=mulberry main=mulberry need=2.35 +mode=install scope=user purge=0 prefix= url= file= +while [ $# -gt 0 ]; do + case $1 in + --user) scope=user ;; + --system) scope=system ;; + --prefix) [ $# -ge 2 ] || { echo "--prefix needs a folder." >&2; exit 2; }; prefix=$2; shift ;; + --url) [ $# -ge 2 ] || { echo "--url needs an address." >&2; exit 2; }; url=$2; shift ;; + --uninstall) mode=uninstall ;; + --purge) purge=1 ;; + -h|--help) sed -n '2,9p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; + -*) echo "Unknown option: $1 (see --help)." >&2; exit 2 ;; + *) file=$1 ;; + esac + shift +done +[ "$purge" = 0 ] || [ "$mode" = uninstall ] || { echo "--purge only goes with --uninstall." >&2; exit 2; } +if [ -z "$prefix" ]; then + if [ "$scope" = system ]; then prefix=/usr/local; else prefix=$HOME/.local; fi +fi +case $prefix in /*) ;; *) echo "--prefix must be an absolute path." >&2; exit 2 ;; esac +prefix=${prefix%/} +destdir=${DESTDIR:-} +root=$destdir$prefix +list=$root/lib/$app/files +sudo= +if [ -z "$destdir" ] && [ "$(id -u)" != 0 ]; then + d=$root; while [ ! -e "$d" ]; do d=$(dirname "$d"); done + [ -w "$d" ] || sudo=sudo +fi + +refresh() { + [ -z "$destdir" ] || return 0 + command -v update-desktop-database >/dev/null 2>&1 && $sudo update-desktop-database -q "$root/share/applications" 2>/dev/null || true + [ -f "$root/share/icons/hicolor/index.theme" ] && command -v gtk-update-icon-cache >/dev/null 2>&1 \ + && $sudo gtk-update-icon-cache -q -t -f "$root/share/icons/hicolor" 2>/dev/null || true +} + +# Removes the files the last install listed, then the folders that became empty. +remove_listed() { + [ -f "$list" ] || return 0 + while IFS= read -r f; do + [ -n "$f" ] || continue + $sudo rm -f "$root/$f" + d=$(dirname "$f") + while [ "$d" != . ] && $sudo rmdir "$root/$d" 2>/dev/null; do d=$(dirname "$d"); done + done < "$list" + $sudo rm -f "$list" + $sudo rmdir "$root/lib/$app" "$root/lib" 2>/dev/null || true +} + +if [ "$mode" = uninstall ]; then + if [ ! -f "$list" ]; then + echo "Mulberry is not installed in $prefix (no $list)." >&2 + [ "$purge" = 1 ] || exit 1 + else + remove_listed + refresh + echo "Mulberry removed from $prefix." + fi + if [ "$purge" = 1 ]; then + rm -rf "${XDG_CONFIG_HOME:-$HOME/.config}/mulberry" + rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/mulberry" + rm -rf "${XDG_CACHE_HOME:-$HOME/.cache}/mulberry" + echo "Settings and data removed (~/.config/mulberry, ~/.local/share/mulberry, ~/.cache/mulberry: settings, library, playlists, caches)." + else + echo "Settings and data are kept (--purge deletes them)." + fi + exit 0 +fi + +# glibc check (MULBERRY_GLIBC overrides the detected version, for tests) +have=${MULBERRY_GLIBC:-$(getconf GNU_LIBC_VERSION 2>/dev/null | sed 's/^glibc //')} +if [ -z "$have" ]; then + echo "Mulberry needs glibc $need or newer, and this system does not report a glibc (musl?). Nothing was installed." >&2; exit 1 +fi +if [ "$(printf '%s\n%s\n' "$need" "$have" | sort -V | head -n 1)" != "$need" ]; then + echo "Mulberry needs glibc $need or newer, and this system has glibc $have. Nothing was installed." >&2; exit 1 +fi + +here=$(cd "$(dirname "$0")" && pwd) +tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT INT TERM + +if [ -n "$url" ]; then + file=$tmp/$(basename "${url%%\?*}") + if command -v curl >/dev/null 2>&1; then curl -fL -o "$file" -- "$url" + elif command -v wget >/dev/null 2>&1; then wget -O "$file" -- "$url" + else echo "Neither curl nor wget is installed, so $url cannot be fetched." >&2; exit 1; fi +fi +src= +if [ -z "$file" ]; then + if [ -f "$here/bin/$main" ]; then src=$here + else + for f in "$here"/Mulberry-*-Linux-x86_64.tar.gz "$here"/Mulberry-*-x86_64.AppImage; do + [ -f "$f" ] && { file=$f; break; } + done + fi +fi +if [ -z "$src" ]; then + [ -n "$file" ] && [ -f "$file" ] || { echo "No Mulberry tar.gz or AppImage was given or found next to the installer." >&2; exit 1; } + dir=$(dirname "$file"); name=$(basename "$file") + for s in "$dir"/SHA256SUMS-*; do + [ -f "$s" ] || continue + line=$(grep -F " $name" "$s" | head -n 1 || true) + [ -n "$line" ] || continue + [ "${line%% *}" = "$(sha256sum "$file" | cut -d' ' -f1)" ] \ + || { echo "The checksum of $name does not match $(basename "$s"). Nothing was installed." >&2; exit 1; } + echo "Checksum ok." + done + mkdir "$tmp/x" + case $name in + *.tar.gz) + tar -xzf "$file" -C "$tmp/x" + src=$(find "$tmp/x" -maxdepth 1 -mindepth 1 -type d | head -n 1) + [ -n "$src" ] && [ -f "$src/bin/$main" ] || { echo "$name has no bin/$main, so it is not a Mulberry release." >&2; exit 1; } ;; + *.AppImage) + cp "$file" "$tmp/app"; chmod 755 "$tmp/app" + (cd "$tmp/x" && "$tmp/app" --appimage-extract >/dev/null 2>&1) || true + [ -d "$tmp/x/squashfs-root/usr/share" ] || { echo "Could not read the contents of $name. Nothing was installed." >&2; exit 1; } + src=$tmp/src; mkdir -p "$src/bin" + mv "$tmp/app" "$src/bin/$main" + mv "$tmp/x/squashfs-root/usr/share" "$src/share" + [ ! -d "$tmp/x/squashfs-root/usr/lib" ] || mv "$tmp/x/squashfs-root/usr/lib" "$src/lib" ;; + *) echo "Unknown file type: $name (need .tar.gz or .AppImage)." >&2; exit 1 ;; + esac +fi + +# Stage with launchers pointing at this prefix, then copy and list every file for --uninstall. +st=$tmp/stage +mkdir -p "$st" +for d in bin lib share; do [ ! -d "$src/$d" ] || cp -R "$src/$d" "$st/$d"; done +for d in "$st"/share/applications/*.desktop; do + [ -f "$d" ] || continue + for b in "$st"/bin/*; do + b=$(basename "$b") + sed -i -e "s#^Exec=$b\( \|\$\)#Exec=$prefix/bin/$b\1#" -e "s#^TryExec=$b\$#TryExec=$prefix/bin/$b#" "$d" + done +done +chmod 755 "$st"/bin/* +(cd "$st" && find . \( -type f -o -type l \) | sed 's|^\./||' | sort) > "$tmp/files" +mkdir -p "$st/lib/$app"; echo "lib/$app/files" >> "$tmp/files"; cp "$tmp/files" "$st/lib/$app/files" + +remove_listed +$sudo mkdir -p "$root" +$sudo cp -R "$st/." "$root/" +refresh +echo "Mulberry installed in $prefix/bin/$main" +case ":$PATH:" in *":$prefix/bin:"*) ;; *) echo "Note: $prefix/bin is not on your PATH." ;; esac diff --git a/packaging/arch/.SRCINFO b/packaging/arch/.SRCINFO new file mode 100644 index 0000000..704189c --- /dev/null +++ b/packaging/arch/.SRCINFO @@ -0,0 +1,35 @@ +pkgbase = mulberry-bin + pkgdesc = Material You music player + pkgver = 2.0.4 + pkgrel = 1 + url = https://archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry + arch = x86_64 + license = MIT + depends = glibc>=2.35 + depends = gcc-libs + depends = mpv + depends = dbus + depends = fontconfig + depends = libglvnd + depends = wayland + depends = libxkbcommon + depends = libxkbcommon-x11 + depends = libx11 + depends = libxcb + depends = libxcursor + depends = libxi + depends = libxrender + depends = hicolor-icon-theme + optdepends = xdg-desktop-portal: open and save dialogs + optdepends = ffmpeg: visualizer analysis and CD encoding + optdepends = cdparanoia: CD ripping + optdepends = yt-dlp: web links + optdepends = libpulse: visualizer for radio streams (parec) + provides = mulberry + conflicts = mulberry + options = !strip + options = !debug + source = Mulberry-2.0.4-Linux-x86_64.tar.gz::https://archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry/releases/download/v2.0.4/Mulberry-2.0.4-Linux-x86_64.tar.gz + sha256sums = 87dab251e23593457ad3e3b2b8ca7903f79af385b805d276ec29e701785e5e5f + +pkgname = mulberry-bin diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILD new file mode 100644 index 0000000..e62f9c1 --- /dev/null +++ b/packaging/arch/PKGBUILD @@ -0,0 +1,33 @@ +# Maintainer: astar76 +# Built by tools/package.sh from the release tar.gz (TARBALL=file://… for an offline build); it keeps pkgver, +# sha256sums and the glibc floor current. +pkgname=mulberry-bin +pkgver=2.0.4 +pkgrel=1 +pkgdesc='Material You music player' +arch=('x86_64') +url='https://archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry' +license=('MIT') +depends=('glibc>=2.35' 'gcc-libs' 'mpv' 'dbus' 'fontconfig' 'libglvnd' 'wayland' 'libxkbcommon' 'libxkbcommon-x11' 'libx11' 'libxcb' 'libxcursor' 'libxi' 'libxrender' 'hicolor-icon-theme') +optdepends=( + 'xdg-desktop-portal: open and save dialogs' + 'ffmpeg: visualizer analysis and CD encoding' + 'cdparanoia: CD ripping' + 'yt-dlp: web links' + 'libpulse: visualizer for radio streams (parec)' +) +provides=('mulberry') +conflicts=('mulberry') +options=('!strip' '!debug') +source=("Mulberry-$pkgver-Linux-x86_64.tar.gz::${TARBALL:-$url/releases/download/v$pkgver/Mulberry-$pkgver-Linux-x86_64.tar.gz}") +sha256sums=('87dab251e23593457ad3e3b2b8ca7903f79af385b805d276ec29e701785e5e5f') + +package() { + cd "$srcdir/mulberry-$pkgver" + install -d "$pkgdir/usr" + for d in bin lib share; do [ ! -d "$d" ] || cp -R "$d" "$pkgdir/usr/"; done + if [ -d "$pkgdir/usr/share/licenses/mulberry" ] && [ "$pkgname" != mulberry ]; then + mv "$pkgdir/usr/share/licenses/mulberry" "$pkgdir/usr/share/licenses/$pkgname" + fi + install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md" +} diff --git a/packaging/mulberry.ico b/packaging/mulberry.ico index a7ad6ae..ff1d647 100644 Binary files a/packaging/mulberry.ico and b/packaging/mulberry.ico differ diff --git a/packaging/mulberry.iss b/packaging/mulberry.iss index f2fb9e1..8e33c40 100644 --- a/packaging/mulberry.iss +++ b/packaging/mulberry.iss @@ -1,18 +1,22 @@ ; Inno Setup script: per-user install (no admin), Start menu entry, uninstaller. -; Built on Linux under wine: iscc /DVersion=2.0.1 /DSrc= mulberry.iss +; Built by tools/package.sh under wine: iscc /DVersion= /DSrc= /DOut= mulberry.iss #ifndef Version #define Version "0.0.0" #endif #ifndef Src #define Src "..\dist\Mulberry" #endif +#ifndef Out + #define Out "..\dist" +#endif [Setup] -AppId={{B4F0C1D2-7A63-4E59-8C1B-52D9E0A7F3C6} +AppId={{} AppName=Mulberry AppVersion={#Version} AppVerName=Mulberry {#Version} -AppPublisher=Mulberry +AppPublisher=astar76 +AppPublisherURL=https://archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry VersionInfoVersion={#Version} VersionInfoProductName=Mulberry VersionInfoDescription=Mulberry Setup @@ -22,11 +26,12 @@ DisableDirPage=auto PrivilegesRequired=lowest ArchitecturesAllowed=x64compatible ArchitecturesInstallIn64BitMode=x64compatible -OutputDir=..\dist +OutputDir={#Out} OutputBaseFilename=Mulberry-{#Version}-Setup SetupIconFile=mulberry.ico UninstallDisplayIcon={app}\mulberry.exe UninstallDisplayName=Mulberry +LicenseFile=..\LICENSE Compression=lzma2/max SolidCompression=yes WizardStyle=modern diff --git a/packaging/mulberry.svg b/packaging/mulberry.svg index b434a53..89052e9 100644 --- a/packaging/mulberry.svg +++ b/packaging/mulberry.svg @@ -1,5 +1,5 @@ - + - + \ No newline at end of file diff --git a/packaging/nix/default.nix b/packaging/nix/default.nix new file mode 100644 index 0000000..63b1c8e --- /dev/null +++ b/packaging/nix/default.nix @@ -0,0 +1,33 @@ +# Mulberry for Nix, from the release tar.gz. Written by tools/package.sh (version and hash); edit the header there. +# nix build .#default or nix profile install . (from the repo), or callPackage this file. +{ lib, stdenv, fetchurl, autoPatchelfHook, makeWrapper, libGL, wayland, libxkbcommon, xorg, fontconfig, dbus, mpv-unwrapped }: + +stdenv.mkDerivation rec { + pname = "mulberry"; + version = "2.0.4"; + src = fetchurl { + url = "https://archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry/releases/download/v${version}/Mulberry-${version}-Linux-x86_64.tar.gz"; + hash = "sha256-h9qyUeI1k0V60+OyuMp5A/ea84W4BdJ27CnnAXheXl8="; + }; + nativeBuildInputs = [ autoPatchelfHook makeWrapper ]; + buildInputs = [ mpv-unwrapped stdenv.cc.cc.lib ]; + # Loaded with dlopen at run time, so autoPatchelf can't see them. + runtimeDependencies = [ libGL wayland libxkbcommon xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr fontconfig dbus ]; + dontBuild = true; + installPhase = '' + runHook preInstall + mkdir -p $out + for d in bin lib share; do [ ! -d $d ] || cp -R $d $out/; done + install -Dm644 README.md $out/share/doc/mulberry/README.md + runHook postInstall + ''; + + meta = { + description = "Material You music player"; + homepage = "https://archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry"; + license = lib.licenses.mit; + platforms = [ "x86_64-linux" ]; + mainProgram = "mulberry"; + sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; + }; +} diff --git a/src/online.rs b/src/online.rs index 5eea623..8fd0820 100644 --- a/src/online.rs +++ b/src/online.rs @@ -600,7 +600,7 @@ pub struct Resolved { /// Use yt-dlp to get a playable audio URL. pub fn resolve_stream(url: &str) -> Res { - let out = std::process::Command::new("yt-dlp") + let out = crate::util::command("yt-dlp") .args(["-J", "--no-playlist", "--no-warnings", "-f", "bestaudio[acodec!=none]/bestaudio/best", "--socket-timeout", "15", url]) .stdin(std::process::Stdio::null()) .output() diff --git a/src/spectrum.rs b/src/spectrum.rs index 1dfb8c7..6ce9074 100644 --- a/src/spectrum.rs +++ b/src/spectrum.rs @@ -151,7 +151,7 @@ impl Spectrum { return; }; self.need_live = false; - let mut cmd = Command::new("ffmpeg"); + let mut cmd = crate::util::command("ffmpeg"); cmd.args(["-v", "quiet", "-nostdin", "-i", path, "-vn", "-ac", "1", "-ar", &TRACK_RATE.to_string(), "-f", "f32le", "-"]) .stdout(Stdio::piped()) .stderr(Stdio::null()) diff --git a/src/util.rs b/src/util.rs index 37699cd..9cd5984 100644 --- a/src/util.rs +++ b/src/util.rs @@ -11,7 +11,9 @@ pub fn format_local(ts: i64, fmt: &str) -> String { /// Open a path or URL with the desktop's default handler. pub fn open_url(url: &str) { - let _ = std::process::Command::new("xdg-open") + // Explorer opens folders, files and web addresses with their default handler on Windows. + let opener = if cfg!(windows) { "explorer" } else { "xdg-open" }; + let _ = std::process::Command::new(opener) .arg(url) .stdin(std::process::Stdio::null()) .stdout(std::process::Stdio::null()) @@ -24,6 +26,10 @@ pub fn show_in_file_manager(path: &str) { if !std::path::Path::new(path).exists() { return; } + if cfg!(windows) { + let _ = std::process::Command::new("explorer").arg(format!("/select,{path}")).spawn(); + return; + } let uri = format!("file://{}", urlencoding::encode(path).replace("%2F", "/")); let ok = std::process::Command::new("dbus-send") .args([ @@ -136,3 +142,16 @@ pub fn clipboard_files() -> Vec { .map(|p| crate::song::percent_decode(p)) .collect() } + +/// A command for a console tool (yt-dlp, ffmpeg) that opens no console window on Windows. +pub fn command(program: impl AsRef) -> std::process::Command { + #[allow(unused_mut)] + let mut cmd = std::process::Command::new(program); + #[cfg(windows)] + { + use std::os::windows::process::CommandExt; + const CREATE_NO_WINDOW: u32 = 0x0800_0000; + cmd.creation_flags(CREATE_NO_WINDOW); + } + cmd +} diff --git a/tools/package.sh b/tools/package.sh new file mode 100755 index 0000000..8805ac9 --- /dev/null +++ b/tools/package.sh @@ -0,0 +1,225 @@ +#!/bin/bash +# Mulberry release packages. Run: tools/package.sh (see the common part below for what it makes) +set -euo pipefail +root=$(cd "$(dirname "$0")/.." && pwd) +APP=mulberry NAME=Mulberry DESKTOP=mulberry.desktop +URL=https://archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry +ver=$(sed -n 's/^version = "\(.*\)"/\1/p' "$root/Cargo.toml" | head -n 1) +BINS=(mulberry) +LICENSE=MIT NIX_LICENSE=mit SUMMARY='Material You music player' +DEB_DEPENDS='libgl1, libegl1, libwayland-client0, libwayland-egl1, libxkbcommon0, libxkbcommon-x11-0, libx11-6, libxcursor1, libxi6, libxrandr2, libfontconfig1, libdbus-1-3, libmpv2' DEB_RECOMMENDS='xdg-desktop-portal, ffmpeg, cdparanoia, yt-dlp, pulseaudio-utils' DEB_SECTION=sound +NIX_ARGS='libGL, wayland, libxkbcommon, xorg, fontconfig, dbus, mpv-unwrapped' NIX_RUNTIME='libGL wayland libxkbcommon xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr fontconfig dbus' NIX_BUILD_INPUTS='mpv-unwrapped stdenv.cc.cc.lib' +WIN=1 WIN_MPV=1 WIN_DLLS=(libmpv-2.dll) BUNDLE_LIBS=1 +ZIG_GLIBC=2.35 +build() { RUSTFLAGS="-L $tools/linuxlib -C link-arg=-Wl,--allow-shlib-undefined" nice cargo zigbuild --release --locked -q -j 2 --target x86_64-unknown-linux-gnu.$ZIG_GLIBC; } +stage() { + install -Dm644 packaging/mulberry.desktop "$1/applications/mulberry.desktop" + icon_pngs assets/mulberry.svg "$1" mulberry + install -Dm644 LICENSE "$1/licenses/mulberry/LICENSE" +} + +# ---------------------------------------------------------------- common part (same in every project) +# Builds into dist/ (and never writes to releases/): +# $NAME--Linux-x86_64.tar.gz bin/ share/ [lib/] laid out like a prefix, with install.sh and uninstall.sh +# $NAME--x86_64.AppImage GUI apps (DESKTOP set); BUNDLE_LIBS=1 adds the non-desktop library closure +# $NAME--arch-x86_64.pkg.tar.zst makepkg from that tar.gz, offline ($PKGDIR/PKGBUILD gets version and checksum) +# $NAME--amd64.deb the same tree under /usr, for apt +# $NAME--Setup.exe and $NAME--Windows-portable.zip when WIN=1 (mingw cross build, Inno Setup in wine) +# SHA256SUMS- +# It also writes packaging/nix/default.nix (fetches the release tar.gz; version and hash filled in here) and the +# glibc floor read from the binary into installer.sh, the PKGBUILD and the .deb. Nothing is downloaded: appimagetool +# and libmpv-2.dll come from ~/.local/opt/build-tools. +# SKIP_BUILD=1 packages the existing build, NO_WIN=1 skips Windows. CARGO_TARGET_DIR is honoured. +cd "$root"; PKGDIR=${PKGDIR:-packaging/arch} +tools=${BUILD_TOOLS:-$HOME/.local/opt/build-tools} +[ "${SKIP_BUILD:-}" = 1 ] || build +tdir=${CARGO_TARGET_DIR:-$root/target} +rel=$tdir/release +# ZIG_GLIBC: built with cargo-zigbuild against that glibc, so the binary runs on older distributions too. +[ -z "${ZIG_GLIBC:-}" ] || rel=$tdir/x86_64-unknown-linux-gnu/release +out=$root/dist +mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}"; work=$(mktemp -d "${XDG_CACHE_HOME:-$HOME/.cache}/package.XXXXXX"); trap 'rm -rf "$work"' EXIT +export SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-$(git log -1 --format=%ct 2>/dev/null || date +%s)} + +# hicolor PNGs from an SVG: icon_pngs +icon_pngs() { + install -Dm644 "$1" "$2/icons/hicolor/scalable/apps/$3.svg" + for n in 16 24 32 48 64 128 256 512; do + mkdir -p "$2/icons/hicolor/${n}x$n/apps"; rsvg-convert -w "$n" -h "$n" "$1" -o "$2/icons/hicolor/${n}x$n/apps/$3.png" + done +} + +# glibc floor: the newest GLIBC_x.y symbol version any shipped binary (or EXTRA_ELF library) needs. +glibc=$(for b in "${BINS[@]}" ${EXTRA_ELF[@]+"${EXTRA_ELF[@]}"}; do objdump -T "$rel/$b"; done | grep -o 'GLIBC_[0-9.]*' | sed 's/GLIBC_//' | sort -uV | tail -n 1) +[ -n "$glibc" ] || { echo "could not read the glibc version from the binary" >&2; exit 1; } +sed -i "s/^app=$APP main=\([^ ]*\) need=.*/app=$APP main=\1 need=$glibc/; s/glibc [0-9.]* or newer\./glibc $glibc or newer./" installer.sh +sed -i "s/'glibc>=[0-9.]*'/'glibc>=$glibc'/" $PKGDIR/PKGBUILD + +# tar.gz: bin/ and share/ laid out like a prefix, so installer.sh, the PKGBUILD, the .deb and Nix just copy them. +rm -rf "$out"; mkdir -p "$out" +t=$work/$APP-$ver +mkdir -p "$t/bin" "$t/share" # stage may add $t/lib too +for b in "${BINS[@]}"; do install -m755 "$rel/$b" "$t/bin/$b"; done +stage "$t/share" +install -m755 installer.sh "$t/install.sh" +printf '#!/bin/sh\n# Removes %s installed by install.sh. --purge also deletes settings and data; --system or --prefix DIR as for install.sh.\nexec sh "$(dirname "$0")/install.sh" --uninstall "$@"\n' "$NAME" > "$t/uninstall.sh" +chmod 755 "$t/uninstall.sh" +cp README.md "$t/" +find "$t" -exec touch -h -d "@$SOURCE_DATE_EPOCH" {} + +tgz=$NAME-$ver-Linux-x86_64.tar.gz +tar -C "$work" --sort=name --owner=0 --group=0 --numeric-owner -cf - "$APP-$ver" | gzip -n -9 > "$out/$tgz" + +# AppImage (GUI apps): the same tree under usr/, desktop file and icon at the top. +if [ -n "${DESKTOP:-}" ]; then + a=$work/AppDir + mkdir -p "$a/usr" + cp -R "$t/bin" "$t/share" "$a/usr/"; [ ! -d "$t/lib" ] || cp -R "$t/lib" "$a/usr/" + if [ "${BUNDLE_LIBS:-0}" = 1 ]; then + # Libraries every desktop already has (glibc, graphics, windowing, sound servers, fonts) stay with the host. + skip='^(linux-vdso|ld-linux|libc|libm|libdl|libpthread|librt|libutil|libresolv|libnsl|libgcc_s|libstdc\+\+|libGL|libGLX|libGLdispatch|libEGL|libOpenGL|libGLESv2|libgbm|libdrm|libvulkan|libX11|libX11-xcb|libxcb.*|libXau|libXdmcp|libXext|libXfixes|libXrandr|libXrender|libXi|libXcursor|libXss|libXv|libXxf86vm|libXinerama|libwayland-.*|libxkbcommon.*|libfontconfig|libfreetype|libharfbuzz|libglib-2.0|libgobject-2.0|libgio-2.0|libgmodule-2.0|libdbus-1|libsystemd|libudev|libasound|libpulse.*|libpipewire-0.3|libjack|libsndio|libcap|libselinux|libpcre2-8|libffi|libz|libexpat|libnss.*)\.so' + mkdir -p "$a/usr/lib" + ldd "$rel/${BINS[0]}" | awk '/=> \//{print $3} $1 ~ /^\// {print $1}' | while read -r lib; do + name=$(basename "$lib"); [[ $name =~ $skip ]] || cp -L "$lib" "$a/usr/lib/$name" + done + fi + cp "$a/usr/share/applications/$DESKTOP" "$a/" + icon=$(sed -n 's/^Icon=//p' "$a/$DESKTOP" | head -n 1) + for ext in svg png; do + f=$(find "$a/usr/share/icons" -name "$icon.$ext" | sort -V | tail -n 1) + [ -n "$f" ] && { cp "$f" "$a/$icon.$ext"; break; } + done + cat > "$a/AppRun" </dev/null) + ARCH=x86_64 "$work/squashfs-root/AppRun" --no-appstream "$a" "$out/$NAME-$ver-x86_64.AppImage" >"$work/ait.log" 2>&1 \ + || { tail -20 "$work/ait.log"; exit 1; } +fi + +# Arch package from the local tar.gz; the repo's PKGBUILD gets this version and checksum. +sum=$(sha256sum "$out/$tgz" | cut -d' ' -f1) +sed -i "s/^pkgver=.*/pkgver=$ver/; s/^sha256sums=.*/sha256sums=('$sum')/" $PKGDIR/PKGBUILD +mkdir "$work/arch"; cp $PKGDIR/PKGBUILD "$work/arch/" +(cd "$work/arch" && makepkg --printsrcinfo > "$root/$PKGDIR/.SRCINFO") +(cd "$work/arch" && TARBALL="file://$out/$tgz" makepkg -f -C --nodeps --noconfirm >"$work/makepkg.log" 2>&1) \ + || { tail -20 "$work/makepkg.log"; exit 1; } +cp "$work"/arch/"$APP"-bin-"$ver"-*-x86_64.pkg.tar.zst "$out/$NAME-$ver-arch-x86_64.pkg.tar.zst" + +# .deb: the tar.gz tree under /usr (licenses go to /usr/share/doc// as Debian expects). +d=$work/deb +mkdir -p "$d/root/usr" "$d/root/usr/share/doc/$APP" "$d/control" +for x in bin lib share; do [ ! -d "$t/$x" ] || cp -R "$t/$x" "$d/root/usr/"; done +if [ -d "$d/root/usr/share/licenses/$APP" ]; then + cp -R "$d/root/usr/share/licenses/$APP/." "$d/root/usr/share/doc/$APP/"; rm -rf "$d/root/usr/share/licenses" +fi +cp README.md "$d/root/usr/share/doc/$APP/" +{ echo "Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/"; echo "Upstream-Name: $NAME" + echo "Source: $URL"; echo; echo "Files: *"; echo "License: $LICENSE"; } > "$d/root/usr/share/doc/$APP/copyright" +size=$(du -sk "$d/root" | cut -f1) +cat > "$d/control/control" < +Installed-Size: $size +Depends: libc6 (>= $glibc)${DEB_DEPENDS:+, $DEB_DEPENDS} +${DEB_RECOMMENDS:+Recommends: $DEB_RECOMMENDS +}Section: ${DEB_SECTION:-misc} +Priority: optional +Homepage: $URL +Description: $SUMMARY + Built from $URL (version $ver). Needs glibc $glibc or newer. +CTL +(cd "$d/root" && find . -type f -printf '%P\n' | sort | xargs -d '\n' md5sum) > "$d/control/md5sums" +find "$d/root" "$d/control" -exec touch -h -d "@$SOURCE_DATE_EPOCH" {} + +echo 2.0 > "$d/debian-binary" +tar -C "$d/control" --sort=name --owner=0 --group=0 --numeric-owner -czf "$d/control.tar.gz" . +tar -C "$d/root" --sort=name --owner=0 --group=0 --numeric-owner -cJf "$d/data.tar.xz" . +deb=$out/$NAME-$ver-amd64.deb +(cd "$d" && ar rcD "$deb" debian-binary control.tar.gz data.tar.xz) +! command -v dpkg-deb >/dev/null || dpkg-deb --info "$deb" >/dev/null + +# Nix: packaging/nix/default.nix fetches this release's tar.gz (flake.nix at the top calls it). +mkdir -p packaging/nix +sri=sha256-$(openssl dgst -sha256 -binary "$out/$tgz" | base64 -w0) +cat > packaging/nix/default.nix < flake.nix </dev/null || { echo "Windows needs mingw-w64-gcc (sudo pacman -S mingw-w64-gcc), or NO_WIN=1." >&2; exit 1; } + if [ -n "${WIN_DLLS[*]:-}" ] && [ "${WIN_MPV:-0}" = 1 ]; then + # import library for libmpv-2.dll, so the cross linker can link "mpv" + lib=$tools/winlib; mkdir -p "$lib" + if [ ! -f "$lib/libmpv.dll.a" ]; then + { echo "LIBRARY libmpv-2.dll"; echo EXPORTS + x86_64-w64-mingw32-objdump -p "$tools/libmpv-2.dll" | sed -n '/\[Ordinal\/Name Pointer\] Table/,/^$/p' | awk '/^\s*\[ *[0-9]+\] \+base/ {print $NF}'; } > "$lib/mpv.def" + x86_64-w64-mingw32-dlltool -d "$lib/mpv.def" -D libmpv-2.dll -l "$lib/libmpv.dll.a" + fi + export RUSTFLAGS="${RUSTFLAGS:-} -L $lib" + fi + [ "${SKIP_BUILD:-}" = 1 ] || nice cargo build --release --locked -q -j 2 --target x86_64-pc-windows-gnu + w=$work/win/$NAME; mkdir -p "$w" + for b in "${BINS[@]}"; do install -m755 "$tdir/x86_64-pc-windows-gnu/release/$b.exe" "$w/"; done + for f in ${WIN_DLLS[@]+"${WIN_DLLS[@]}"}; do install -m644 "$tools/$f" "$w/"; done + install -m644 LICENSE "$w/LICENSE.txt" + find "$work/win" -exec touch -h -d "@$SOURCE_DATE_EPOCH" {} + + (cd "$work/win" && zip -qrX9 "$out/$NAME-$ver-Windows-portable.zip" "$NAME") + iscc="$HOME/.wine/drive_c/users/$USER/AppData/Local/Programs/Inno Setup 7/ISCC.exe" + WINEDEBUG=-all wine "$iscc" /Q "/DVersion=$ver" "/DSrc=Z:$w" "/DOut=Z:$out" "Z:$root/packaging/$APP.iss" >"$work/iscc.log" 2>&1 \ + || { tail -20 "$work/iscc.log"; exit 1; } +fi + +(cd "$out" && sha256sum "$NAME-$ver"-* > "SHA256SUMS-$ver") +echo "glibc floor: $glibc" +ls -l "$out"