Skip to content
Tauri 中文网

Flathub

有关 Flatpak 如何工作的详细信息,你可以阅读 构建你的第一个 Flatpak

¥For detailed information on how Flatpak works, you can read Building your first Flatpak

本指南假设你想通过 Flathub(最常用的 Flatpak 分发平台)分发你的 Flatpak。如果你打算使用其他平台,请查阅其文档。

¥This guide assumes you want to distribute your Flatpak via Flathub, the most commonly used platform for Flatpak distribution. If you plan on using other platforms, please consult their documentation instead.

先决条件

¥Prerequisites

要在 Flatpak 运行时内测试你的应用,你可以先在本地构建 Flatpak,然后再将你的应用上传到 Flathub。如果你想快速共享开发构建,这也会有所帮助。

¥To test your app inside the Flatpak runtime you can build the Flatpak locally first before uploading your app to Flathub. This can also be helpful if you want to quickly share development builds.

1.

要在本地构建 Flatpaks,你需要 flatpakflatpak-builder 工具。例如,在 Ubuntu 上,你可以运行此命令:

¥To build Flatpaks locally you need the flatpak and flatpak-builder tools. For example on Ubuntu you can run this command:

Terminal window
sudo apt install flatpak flatpak-builder

2.

Terminal window
flatpak install flathub org.gnome.Platform//46 org.gnome.Sdk//46

3.

4.

id: org.your.id
runtime: org.gnome.Platform
runtime-version: '46'
sdk: org.gnome.Sdk
command: tauri-app
finish-args:
- --socket=wayland # Permission needed to show the window
- --socket=fallback-x11 # Permission needed to show the window
- --device=dri # OpenGL, not necessary for all projects
- --share=ipc
- --talk-name=org.kde.StatusNotifierWatcher # Optional: needed only if your app uses the tray icon
- --filesystem=xdg-run/tray-icon:create # Optional: needed only if your app uses the tray icon - see an alternative way below
modules:
- name: binary
buildsystem: simple
sources:
- type: file
url: https://github.com/your_username/your_repository/releases/download/v1.0.1/yourapp_1.0.1_amd64.deb
sha256: 08305b5521e2cf0622e084f2b8f7f31f8a989fc7f407a7050fa3649facd61469 # This is required if you are using a remote source
only-arches: [x86_64] #This source is only used on x86_64 Computers
# This path points to the binary file which was created in the .deb bundle.
# Tauri also creates a folder which corresponds to the content of the unpacked .deb.
build-commands:
- ar -x *.deb
- tar -xf data.tar.gz
- 'install -Dm755 usr/bin/tauri-app /app/bin/tauri-app'
- install -Dm644 usr/share/applications/yourapp.desktop /app/share/applications/org.your.id.desktop
- install -Dm644 usr/share/icons/hicolor/128x128/apps/yourapp.png /app/share/icons/hicolor/128x128/apps/org.your.id.png
- install -Dm644 usr/share/icons/hicolor/32x32/apps/yourapp.png /app/share/icons/hicolor/32x32/apps/org.your.id.png
- install -Dm644 usr/share/icons/hicolor/256x256@2/apps/yourapp.png /app/share/icons/hicolor/256x256@2/apps/org.your.id.png
- install -Dm644 org.your.id.metainfo.xml /app/share/metainfo/org.your.id.rosary.metainfo.xml

Gnome 46 运行时包含标准 Tauri 应用的所有依赖及其正确版本。

¥The Gnome 46 runtime includes all dependencies of the standard Tauri app with their correct versions.

5.

Terminal window
# Install the flatpak
flatpak -y --user install <local repo name> <your flatpak id>
# Run it
flatpak run <your flatpak id>
# Update it
flatpak -y --user update <your flatpak id>

添加其他库

¥Adding additional libraries

如果你的最终二进制文件需要比默认 tauri 应用更多的库,则需要将它们添加到你的 flatpak 清单中。有两种方法可以做到这一点。为了快速进行本地开发,只需从本地系统包含已构建的库文件 (.so) 即可。但是,不建议在最终构建 flatpak 时这样做,因为你的本地库文件不是为 flatpak 运行时环境构建的。这可能会引入各种很难发现的错误。因此,建议从 flatpak 中的源代码构建程序所依赖的库作为构建步骤。

¥If your final binary requires more libraries than the default tauri app, you need to add them in your flatpak manifest. There are two ways to do this. For fast local development, it may work to simply include the already built library file (.so) from your local system. However, this is not recommended for the final build of the flatpak, as your local library file is not built for the flatpak runtime environment. This can introduce various bugs that can be very hard to find. Therefore, it is recommended to build the library your program depends on from source inside the flatpak as a build step.

提交到 flathub

¥Submitting to flathub

1.

2.

Terminal window
git clone --branch=new-pr git@github.com:your_github_username/flathub.git

3.

Terminal window
cd flathub

4.

Terminal window
git checkout -b your_app_name

5.提交你的更改,然后推送它们。

¥5. Add your apps manifest to the branch. Commit your changes, and then push them.

6.

7.

当你的拉取请求获得批准后,你将收到编辑应用存储库的邀请。从这里开始,你可以不断更新你的应用。

¥When your pull request is approved then you will receive an invitation to edit your apps repository. From here on you can update your app continuously.

你可以阅读有关此 在 flatpak 文档中 的更多信息

¥You can read more about this in the flatpak documentation


Tauri v2.5 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站