Debian
Tauri 打包程序生成的常规 Debian 软件包包含将应用发送到基于 Debian 的 Linux 发行版所需的一切,定义应用的图标,生成桌面文件,并指定依赖 libwebkit2gtk-4.1-0
和 libgtk-3-0
,以及 libappindicator3-1
(如果你的应用使用系统托盘)。
¥The stock Debian package generated by the Tauri bundler has everything you need to ship your application to Debian-based Linux distributions, defining your application’s icons, generating a Desktop file, and specifying the dependencies libwebkit2gtk-4.1-0
and libgtk-3-0
, along with libappindicator3-1
if your app uses the system tray.
:::note 注意
macOS 和 Linux 上的 GUI 应用不会从你的 shell 点文件(.bashrc
、.bash_profile
、.zshrc
等)继承 $PATH
。查看 Tauri 的 fix-path-env-rs 包以修复此问题。
¥GUI apps on macOS and Linux do not inherit the $PATH
from your shell dotfiles (.bashrc
, .bash_profile
, .zshrc
, etc). Check out Tauri’s fix-path-env-rs crate to fix this issue.
:::
¥Limitations
核心库(例如 glibc)经常会破坏与旧系统的兼容性。因此,你必须使用你打算支持的最旧的基础系统来构建 Tauri 应用。Ubuntu 18.04 等相对较旧的系统比 Ubuntu 22.04 更适合,因为在 Ubuntu 22.04 上编译的二进制文件对 glibc 版本的要求更高,因此在旧系统上运行时,你会遇到类似 /usr/lib/libc.so.6: version 'GLIBC_2.33' not found
的运行时错误。我们建议使用 Docker 容器或 GitHub Actions 来构建你的 Linux Tauri 应用。
¥Core libraries such as glibc frequently break compatibility with older systems. For this reason, you must build your Tauri application using the oldest base system you intend to support. A relatively old system such as Ubuntu 18.04 is more suited than Ubuntu 22.04, as the binary compiled on Ubuntu 22.04 will have a higher requirement of the glibc version, so when running on an older system, you will face a runtime error like /usr/lib/libc.so.6: version 'GLIBC_2.33' not found
. We recommend using a Docker container or GitHub Actions to build your Tauri application for Linux.
有关更多信息,请参阅问题 tauri-apps/tauri#1355 和 rust-lang/rust#57497,以及 AppImage 指南。
¥See the issues tauri-apps/tauri#1355 and rust-lang/rust#57497, in addition to the AppImage guide for more information.
¥Custom Files
如果你需要更多控制,Tauri 会公开一些 Debian 软件包的配置。
¥Tauri exposes a few configurations for the Debian package in case you need more control.
如果你的应用依赖于其他系统依赖,你可以在 tauri.conf.json > bundle > linux > deb
中指定它们。
¥If your app depends on additional system dependencies you can specify them in tauri.conf.json > bundle > linux > deb
.
要在 Debian 包中包含自定义文件,你可以在 tauri.conf.json > bundle > linux > deb > files
中提供文件或文件夹列表。配置对象将 Debian 包中的路径映射到文件系统上文件的路径,相对于 tauri.conf.json
文件。以下是示例配置:
¥To include custom files in the Debian package, you can provide a list of files or folders in tauri.conf.json > bundle > linux > deb > files
. The configuration object maps the path in the Debian package to the path to the file on your filesystem, relative to the tauri.conf.json
file. Here’s an example configuration:
{ "bundle": { "linux": { "deb": { "files": { "/usr/share/README.md": "../README.md", // copies the README.md file to /usr/share/README.md "/usr/share/assets": "../assets/" // copies the entire assets directory to /usr/share/assets } } } }}
¥Cross-Compiling for ARM-based Devices
本指南涵盖手动编译。查看我们的 GitHub Action 指南,了解利用 QEMU 构建应用的示例工作流程。这会慢得多,但仍然可以构建 AppImage。
¥This guide covers manual compilation. Check out our GitHub Action guide for an example workflow that leverages QEMU to build the app. This will be much slower but will also be able to build AppImages.
如果你不需要频繁编译应用,并且希望一次性完成安装,则手动编译是合适的选择。以下步骤要求你使用基于 Debian/Ubuntu 的 Linux 发行版。
¥Manual compilation is suitable when you don’t need to compile your application frequently and prefer a one-time setup. The following steps expect you to use a Linux distribution based on Debian/Ubuntu.
-
- For ARMv7 (32-bit):
rustup target add armv7-unknown-linux-gnueabihf
- For ARMv8 (ARM64, 64-bit):
rustup target add aarch64-unknown-linux-gnu
- For ARMv7 (32-bit):
-
- For ARMv7:
sudo apt install gcc-arm-linux-gnueabihf
- For ARMv8 (ARM64):
sudo apt install gcc-aarch64-linux-gnu
- For ARMv7:
-
[target.armv7-unknown-linux-gnueabihf]linker = "arm-linux-gnueabihf-gcc"[target.aarch64-unknown-linux-gnu]linker = "aarch64-linux-gnu-gcc"
-
- For ARMv7:
sudo dpkg --add-architecture armhf
- For ARMv8 (ARM64):
sudo dpkg --add-architecture arm64
- For ARMv7:
-
On Debian, this step should not be necessary, but on other distributions, you might need to edit /etc/apt/sources.list to include the ARM architecture variant. For example on Ubuntu 22.04 add these lines to the bottom of the file (Remember to replace jammy with the codename of your Ubuntu version):
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverseThen, to prevent issues with the main packages, you have to add the correct main architecture to all other lines the file contained beforehand. For standard 64-bit systems you need to add [arch=amd64], the full file on Ubuntu 22.04 then looks similar to this:
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to# newer versions of the distribution.deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted# deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted## Major bug fix updates produced after the final release of the## distribution.deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu## team. Also, please note that software in universe WILL NOT receive any## review or updates from the Ubuntu security team.deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe# deb-src http://archive.ubuntu.com/ubuntu/ jammy universedeb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates universe# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates universe## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu## team, and may not be under a free licence. Please satisfy yourself as to## your rights to use the software. Also, please note that software in## multiverse WILL NOT receive any review or updates from the Ubuntu## security team.deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy multiverse# deb-src http://archive.ubuntu.com/ubuntu/ jammy multiversedeb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse## N.B. software from this repository may not have been tested as## extensively as that contained in the main release, although it includes## newer versions of some applications which may provide useful features.## Also, please note that software in backports WILL NOT receive any review## or updates from the Ubuntu security team.deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse# deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiversedeb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricteddeb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security universe# deb-src http://security.ubuntu.com/ubuntu/ jammy-security universedeb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security multiverse# deb-src http://security.ubuntu.com/ubuntu/ jammy-security multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse -
Install the required webkitgtk library for your chosen architecture
Section titled “Install the required webkitgtk library for your chosen architecture”- For ARMv7:
sudo apt install libwebkit2gtk-4.1-dev:armhf
- For ARMv8 (ARM64):
sudo apt install libwebkit2gtk-4.1-dev:arm64
- For ARMv7:
-
This is not always required so you may want to proceed first and check if you see errors like
Failed to find OpenSSL development headers
.- Either install the development headers system-wide:
- For ARMv7:
sudo apt install libssl-dev:armhf
- For ARMv8 (ARM64):
sudo apt install libssl-dev:arm64
- For ARMv7:
- Or enable the vendor feature for the OpenSSL Rust crate which will affect all other Rust dependencies using the same minor version. You can do so by adding this to the dependencies section in your
Cargo.toml
file:
openssl-sys = {version = "0.9", features = ["vendored"]} - Either install the development headers system-wide:
-
Set the
Section titled “Set the PKG_CONFIG_SYSROOT_DIR to the appropriate directory based on your chosen architecture”PKG_CONFIG_SYSROOT_DIR
to the appropriate directory based on your chosen architecture- For ARMv7:
export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/
- For ARMv8 (ARM64):
export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/
- For ARMv7:
-
Build the app for your desired ARM version
Section titled “Build the app for your desired ARM version”- For ARMv7: cargo tauri build —target armv7-unknown-linux-gnueabihf
- For ARMv8 (ARM64): cargo tauri build —target aarch64-unknown-linux-gnu
Choose the appropriate set of instructions based on whether you want to cross-compile your Tauri application for ARMv7 or ARMv8 (ARM64). Please note that the specific steps may vary depending on your Linux distribution and setup.
Tauri v2.8 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站