Skip to content

Commit

Permalink
Flatpak support (#347)
Browse files Browse the repository at this point in the history
* proj(pkg): ground work for Flatpak package

* currently the build is working locally using a fork of upstream

* Update icon path in the current workflows

* Add automatic version checker

* automatic version checking with x-checker-data

* Update build dependencies

* Switch from lld to mold

* locale: Use LOCALEDIR passed by building system

* Flatpak misc fixup

* fixed issues with FFmpeg extension
* fixed about dialog icon missing

* misc: fix window icon-name

---------

Signed-off-by: tsukinaha <[email protected]>
Co-authored-by: tsukinaha <[email protected]>
  • Loading branch information
caesarw and tsukinaha authored Feb 21, 2025
1 parent 76127ff commit 3ce20df
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
find share/glib-2.0/ -type f ! -name "*.compiled" -exec rm -f "{}" \;
cp -r /ucrt64/share/icons share/
cp $GITHUB_WORKSPACE/resources/icons/tsukimi.png share/icons/
cp $GITHUB_WORKSPACE/resources/icons/moe.tsuna.tsukimi.png share/icons/
rm -rf share/icons/hicolor && rm -rf share/icons/AdwaitaLegacy && rm -rf share/icons/Adwaita/scalable && rm -rf share/icons/Adwaita/cursors
rm -rf share/icons/Adwaita/16x16 && rm -rf share/icons/Adwaita/symbolic-up-to-32
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
find share/glib-2.0/ -type f ! -name "*.compiled" -exec rm -f "{}" \;
cp -r /${{ matrix.msystem }}/share/icons share/
cp $GITHUB_WORKSPACE/resources/icons/tsukimi.png share/icons/
cp $GITHUB_WORKSPACE/resources/icons/moe.tsuna.tsukimi.png share/icons/
rm -rf share/icons/hicolor && rm -rf share/icons/AdwaitaLegacy && rm -rf share/icons/Adwaita/scalable && rm -rf share/icons/Adwaita/cursors
rm -rf share/icons/Adwaita/16x16 && rm -rf share/icons/Adwaita/symbolic-up-to-32
Expand Down
243 changes: 243 additions & 0 deletions flatpak/moe.tsuna.tsukimi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
id: moe.tsuna.tsukimi
runtime: org.gnome.Platform
runtime-version: "47"
sdk: org.gnome.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.rust-stable
- org.freedesktop.Sdk.Extension.llvm18
add-extensions:
org.freedesktop.Platform.ffmpeg-full:
version: "24.08"
directory: lib/ffmpeg
add-ld-path: .
command: tsukimi
finish-args:
- "--device=dri"
- "--share=ipc"
- "--share=network"
- "--socket=fallback-x11"
- "--socket=wayland"
- "--socket=pulseaudio"
- "--env=RUST_BACKTRACE=full"
cleanup:
- /include
- /lib/pkconfig
- /man
- /share/gtk-doc
- /share/man
- /share/doc
- /share/pkgconfig
- "*.la"
- "*.a"
- /bin/mold
cleanup-commands:
- mkdir -p ${FLATPAK_DEST}/lib/ffmpeg
build-options:
append-path: "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm18/bin"
env:
CARGO_HOME: /run/build/tsukimi/cargo
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: clang
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: "-C link-arg=-fuse-ld=/usr/lib/sdk/rust-stable/bin/mold"
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: clang
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS: "-C link-arg=-fuse-ld=/usr/lib/sdk/rust-stable/bin/mold"

modules:
- name: tsukimi
buildsystem: meson
run-tests: true
sources:
- type: git
url: "https://github.com/caesarw/tsukimi.git"
tag: v0.19.3
x-checker-data:
type: git
version-scheme: semantic
tag-pattern: "^v([\\d.]+)$"
- cargo-sources.json
- type: shell
commands:
- mkdir .cargo
- cp cargo/config .cargo/
- cargo --offline fetch --manifest-path Cargo.toml --verbose
modules:
- name: gstreamer
buildsystem: meson
sources:
- type: archive
url: https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-1.24.11.tar.xz
sha256: 093a379602a250d5cd33b88e723757c80198317efde33893edf3c87b6e53b907

- name: libmpv
cleanup:
- /share/applications
- /share/bash-completion
- /share/icons
- /share/zsh
buildsystem: meson
config-opts:
- -Dlibmpv=true
- -Dbuild-date=false
- -Dalsa=disabled
- -Dlua=enabled
sources:
- type: archive
url: https://github.com/mpv-player/mpv/archive/v0.39.0.tar.gz
sha256: 2ca92437affb62c2b559b4419ea4785c70d023590500e8a52e95ea3ab4554683
x-checker-data:
type: anitya
project-id: 5348
stable-only: true
url-template: https://github.com/mpv-player/mpv/archive/v$version.tar.gz
is-important: true

modules:
- "shared-modules/lua5.1/lua-5.1.5.json"

- name: libv4l2
buildsystem: meson
cleanup:
- /sbin
- /bin
config-opts:
- -Dbpf=disabled
- -Dudevdir=/app/lib/udev
- -Dsystemdsystemunitdir=/dev/null
sources:
- type: archive
url: https://linuxtv.org/downloads/v4l-utils/v4l-utils-1.28.1.tar.xz
sha256: 0fa075ce59b6618847af6ea191b6155565ccaa44de0504581ddfed795a328a82
x-checker-data:
type: anitya
project-id: 9998
stable-only: true
url-template: https://linuxtv.org/downloads/v4l-utils/v4l-utils-$version.tar.xz

- name: nv-codec-headers
cleanup:
- "*"
no-autogen: true
make-install-args:
- PREFIX=/app
sources:
- type: git
url: https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
tag: n13.0.19.0
commit: e844e5b26f46bb77479f063029595293aa8f812d
x-checker-data:
type: git
tag-pattern: ^n([\d.]+)$

- name: libopenmpt
config-opts:
- --disable-static
- --disable-tests
- --disable-examples
- --disable-openmpt123
- --disable-doxygen-doc
- --without-portaudio
cleanup:
- /lib/*.la
sources:
- type: archive
url: https://lib.openmpt.org/files/libopenmpt/src/libopenmpt-0.7.10+release.autotools.tar.gz
sha256: 093713c1c1024f4f10c4779a66ceb2af51fb7c908a9e99feb892d04019220ba1
x-checker-data:
type: anitya
project-id: 141468
stable-only: true
url-template: https://lib.openmpt.org/files/libopenmpt/src/libopenmpt-$version+release.autotools.tar.gz

- name: libass
cleanup:
- /lib/*.la
config-opts:
- --disable-static
sources:
- type: archive
url: https://github.com/libass/libass/releases/download/0.17.3/libass-0.17.3.tar.xz
sha256: eae425da50f0015c21f7b3a9c7262a910f0218af469e22e2931462fed3c50959
x-checker-data:
type: anitya
project-id: 1560
stable-only: true
url-template: https://github.com/libass/libass/releases/download/$version/libass-$version.tar.xz

- name: uchardet
buildsystem: cmake-ninja
config-opts:
- -DCMAKE_BUILD_TYPE=Release
- -DBUILD_STATIC=0
cleanup:
- /bin
- /lib/cmake
sources:
- type: archive
url: https://www.freedesktop.org/software/uchardet/releases/uchardet-0.0.8.tar.xz
sha256: e97a60cfc00a1c147a674b097bb1422abd9fa78a2d9ce3f3fdcc2e78a34ac5f0
x-checker-data:
type: anitya
project-id: 9265
stable-only: true
url-template: https://www.freedesktop.org/software/uchardet/releases/uchardet-$version.tar.xz

- name: rubberband
buildsystem: meson
config-opts:
- -Ddefault_library=shared
cleanup:
- /bin
- /lib/ladspa
sources:
- type: archive
url: https://breakfastquay.com/files/releases/rubberband-4.0.0.tar.bz2
sha256: af050313ee63bc18b35b2e064e5dce05b276aaf6d1aa2b8a82ced1fe2f8028e9
x-checker-data:
type: anitya
project-id: 4222
stable-only: true
url-template: https://breakfastquay.com/files/releases/rubberband-$version.tar.bz2

- name: mujs
cleanup:
- /bin
- /lib/libmujs.a
no-autogen: true
make-args:
- release
- prefix=/app
make-install-args:
- prefix=/app
- install-shared
sources:
- type: git
url: https://github.com/ccxvii/mujs
tag: 1.3.6
commit: cc569c5fa9a7a2498177693b5617605c2ff5b260
x-checker-data:
type: git
tag-pattern: ^([\d.]+)$

- name: libplacebo
buildsystem: meson
sources:
- type: git
url: https://github.com/haasn/libplacebo.git
commit: 1fd3c7bde7b943fe8985c893310b5269a09b46c5
x-checker-data:
type: git
tag-pattern: ^v([\d.]+)$
tag: v7.349.0
modules:
- name: glslang
buildsystem: cmake-ninja
config-opts:
- -DBUILD_SHARED_LIBS=ON
cleanup:
- /bin
- /include
- /lib/cmake
sources:
- type: archive
url: https://github.com/KhronosGroup/glslang/archive/refs/tags/11.12.0.tar.gz
sha256: 7795a97450fecd9779f3d821858fbc2d1a3bf1dd602617d95b685ccbcabc302f
8 changes: 5 additions & 3 deletions resources/icons/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ application_id = 'moe.tsuna.tsukimi'

scalable_dir = join_paths('scalable', 'actions')

icondir = join_paths(get_option('datadir'), 'icons/hicolor')

install_data(
'tsukimi.png',
install_dir: join_paths(get_option('datadir'), 'icons')
)
'moe.tsuna.tsukimi.png',
install_dir: join_paths(icondir, '256x256/apps')
)
File renamed without changes
6 changes: 3 additions & 3 deletions resources/moe.tsuna.tsukimi.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Comment=A simple third-party Emby client
Comment[zh_CN]=一个简单的第三方 Emby 客户端
Comment[zh_TW]=一個簡單的第三方 Emby 客戶端
Exec=tsukimi
Icon=tsukimi
StartupWMClass=tsukimi
Icon=moe.tsuna.tsukimi
StartupWMClass=moe.tsuna.tsukimi
Terminal=false
Type=Application
Categories=GNOME;GTK;AudioVideo;Player;Audio;Video;
StartupNotify=true
Keywords=player;audio;video;multimedia;Emby
Keywords[zh_CN]=播放器;音频;视频;多媒体
Keywords[zh_TW]=播放器;音頻;視頻;多媒體
Keywords[zh_TW]=播放器;音頻;視頻;多媒體
2 changes: 1 addition & 1 deletion resources/resources.gresource.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/moe/tsuna/tsukimi/icons/scalable/actions/">
<file alias="tsukimi">icons/tsukimi.png</file>
<file alias="tsukimi">icons/moe.tsuna.tsukimi.png</file>
<file preprocess="xml-stripblanks" alias="settings-symbolic.svg">icons/scalable/actions/settings-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="arrow-pointing-at-line-down-symbolic.svg">icons/scalable/actions/arrow-pointing-at-line-down-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="large-brush-symbolic.svg">icons/scalable/actions/large-brush-symbolic.svg</file>
Expand Down
2 changes: 1 addition & 1 deletion resources/ui/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<property name="title">Tsukimi</property>
<property name="width-request">500</property>
<property name="height-request">350</property>
<property name="icon-name">tsukimi</property>
<property name="icon-name">moe.tsuna.tsukimi</property>
<child>
<object class="GtkEventControllerKey">
<property name="propagation-phase">capture</property>
Expand Down
10 changes: 8 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
pub static VERSION: &str = "0.19.4";
pub static GETTEXT_PACKAGE: &str = "tsukimi";
pub const VERSION: &str = "0.19.4";
pub const GETTEXT_PACKAGE: &str = "tsukimi";

// If you are using meson, this will be replaced with the correct path.
// Otherwise, you can set it to the correct path where the locale files are installed.
//
// This value is reserved for build.rs.
pub const LOCALEDIR: &str = "/usr/share/locale";
8 changes: 4 additions & 4 deletions src/config.rs.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub static VERSION: &str = @VERSION@;
pub static GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@;
pub static LOCALEDIR: &str = @LOCALEDIR@;
pub static PKGDATADIR: &str = @PKGDATADIR@;
pub const VERSION: &str = @VERSION@;
pub const GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@;
pub const LOCALEDIR: &str = @LOCALEDIR@;
pub const PKGDATADIR: &str = @PKGDATADIR@;
16 changes: 6 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ mod utils;
pub mod client;

pub use arg::Args;
pub use config::{
GETTEXT_PACKAGE,
VERSION,
};
use config::{LOCALEDIR, VERSION};
pub use config::GETTEXT_PACKAGE;
use once_cell::sync::OnceCell;

use clap::Parser;
Expand All @@ -35,17 +33,15 @@ pub const APP_ID: &str = "moe.tsuna.tsukimi";
pub const CLIENT_ID: &str = "Tsukimi";
const APP_RESOURCE_PATH: &str = "/moe/tsuna/tsukimi";

#[cfg(target_os = "linux")]
const LINUX_LOCALEDIR: &str = "/usr/share/locale";
#[cfg(target_os = "windows")]
const WINDOWS_LOCALEDIR: &str = "share\\locale";

pub fn locale_dir() -> &'static str {
static LOCALEDIR: OnceCell<&'static str> = OnceCell::new();
LOCALEDIR.get_or_init(|| {
static FLOCALEDIR: OnceCell<&'static str> = OnceCell::new();
FLOCALEDIR.get_or_init(|| {
#[cfg(target_os = "linux")]
{
LINUX_LOCALEDIR
LOCALEDIR
}
#[cfg(target_os = "windows")]
{
Expand All @@ -65,7 +61,7 @@ pub fn locale_dir() -> &'static str {
pub fn run() -> gtk::glib::ExitCode {
Args::parse().init();
// Initialize gettext
setlocale(LocaleCategory::LcAll, "");
setlocale(LocaleCategory::LcAll, String::new());
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8").expect("Failed to set textdomain codeset");
bindtextdomain(GETTEXT_PACKAGE, locale_dir())
.expect("Invalid argument passed to bindtextdomain");
Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ impl Window {
// TRANSLATORS: 'Name <[email protected]>' or 'Name https://website.example'
.translator_credits(gettext("translator-credits"))
.website("https://github.com/tsukinaha/tsukimi")
.application_icon("tsukimi")
.application_icon("moe.tsuna.tsukimi")
.license_type(gtk::License::Gpl30)
.build();
about.add_acknowledgement_section(Some("Code"), &["Inaha", "Kosette"]);
Expand Down

0 comments on commit 3ce20df

Please sign in to comment.