面向 Flatpak 打包
与 Snap 类似,Jami 也有 Flatpak 版本,发布于Flathub.
什么是 Flatpak?它是如何工作的?
建议您阅读Flatpak 简介 及基础概念,以了解 Flatpak 的基本知识。
重要
在继续之前,请先安装[flatpak]软件包(https://flatpak.org/setup/) 。
源代码
Flatpak 版本的源代码与桌面客户端完全一致。不过,其清单文件、依赖项以及 Flatpak 特有的补丁托管在 (Flathub 要求)的官方 GitHub 仓库中,可点击[此处]访问(https://github.com/flathub/net.jami.Jami).
前置条件
安装 flatpak-builder:
flatpak install flathub org.flatpak.Builder
随后,添加 Flathub 仓库至用户级别:
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
在本地构建 Flatpak
克隆 GitHub 仓库
git clone git@github.com:flathub/net.jami.Jami.git
构建 Jami
flatpak-builder --force-clean --user --install-deps-from=flathub --repo=DIR builddir net.jami.Jami.yml
DIR— 指仓库名称。默认情况下,仓库名应为 repo。如果使用其他名称,则在安装 Jami,、调试 Flatpak以及向Flathub 提交更新时.,必须使用对应的仓库名称。
Install Jami
flatpak install DIR -y net.jami.Jami
Run Jami
flatpak run net.jami.Jami
备注
If there are multiple Flatpak installations of Jami, the --branch=BRANCH switch should be specified after the run command to run the Flatpak that was just built.
The Flatpak installations and their corresponding branches can be checked using the flatpak list command.
To run the Flatpak that was just built and installed, set BRANCH to the branch that corresponds to Origin being repo.
Debugging
Debugging Flatpaks within the sandbox on a local machine is possible.
警告
Due to the way Jami is built for Flatpak, debugging can be time-consuming since jami-core is built as a shared library. This means that each time the debugger is restarted, it is required to wait for the symbols to load. Unless it is certain that the issue being debugged is specific to the Flatpak version of Jami, it is usually faster to build and debug the desktop client locally. For instructions, see here.
Downloading the debug version
The instructions to build the Jami Flatpak as described in the previous section must be complete prior to proceeding. Once done, install the debug version:
flatpak install --include-sdk --include-debug repo -y net.jami.Jami
Starting the debugging environment
The following command will run a shell within the sandbox:
flatpak run --command=sh --devel --filesystem=$(pwd) net.jami.Jami
Once run, the shell should appear similar to the following:
[📦 net.jami.Jami net.jami.Jami]$
There are now two methods for debugging. Regardless of which is chosen, commands described in either section should be run within the sandbox shell.
Debug with the GNU Project Debugger (GDB)
gdb --args /app/bin/jami --debug
Debugging can now be done as usual.
Debug with Visual Studio Code (VS Code)
Start gdbserver.
gdbserver :1234 /app/bin/jami --debug
备注
The port number can be changed if required. Make sure the port number for miDebuggerServerAddress in
.vscode/launch.jsonreflects the new port number.Launch VS Code at the root of the project.
Enter the Run and Debug section (Ctrl+Shift+D).
Select
Attach to Remote GDB.Run Jami (F5).
Setting breakpoints
Source files are located in builddir/files/lib/debug/source at the root of the project and are where breakpoints should be set.
Submitting updates to Flathub
If not done already, install flatpak-builder and add the Flathub repo user-wide as described in the Prerequisites section.
Build the manifest
flatpak run --command=flathub-build org.flatpak.Builder --install net.jami.Jami.yml
Run and test Jami
flatpak run net.jami.Jami
Run the linter
The following commands must be run when changes are made to the YAML files. If there are errors, they must be resolved before opening a pull request. Otherwise, the Flathub test builds will fail as well.
flatpak run --command=flatpak-builder-lint org.flatpak.Builder manifest net.jami.Jami.yml
flatpak run --command=flatpak-builder-lint org.flatpak.Builder repo repo
The list of linter errors can be found here.
Push changes and open a pull request
If the build was successful and passed the linter checks, changes can be pushed to the GitHub repo and a pull request can be opened.
Once the pull request is opened, the Flathub automatic build system will create test builds for the x86_64 and aarch64 architectures.
If the test builds are successful, the pull request will be able to be merged into master, triggering the official builds.
备注
Any changes to finish-args in net.jami.Jami.yml as well as changes to net.jami.Jami.metainfo.xml will require approval by the Flathub maintainers.
Depending on the changes, the build may be rejected or require an explanation or justification.
For the latter, an issue will be opened on the GitHub repository to explain or justify the changes.
To see the status of approval, sign in to Flathub and navigate to Developer Portal → Jami.