Skip to content
Tauri 中文网

Debian

由 Tauri 打包器生成的标准 Debian 软件包包含将应用发布到基于 Debian 的 Linux 发行版所需的一切,包括定义应用的图标、生成桌面文件,以及指定依赖 libwebkit2gtk-4.1-0libgtk-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.

🌐 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#1355rust-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 构建应用。这将会慢得多,但也能够构建 AppImages。

🌐 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.

    • 针对 ARMv7(32 位):rustup target add armv7-unknown-linux-gnueabihf
    • 对于 ARMv8(ARM64,64 位):rustup target add aarch64-unknown-linux-gnu
    • 对于 ARMv7:sudo apt install gcc-arm-linux-gnueabihf
    • 针对 ARMv8(ARM64):sudo apt install gcc-aarch64-linux-gnu
  1. [target.armv7-unknown-linux-gnueabihf]
    linker = "arm-linux-gnueabihf-gcc"
    [target.aarch64-unknown-linux-gnu]
    linker = "aarch64-linux-gnu-gcc"
    • 对于 ARMv7:sudo dpkg --add-architecture armhf
    • 针对 ARMv8(ARM64):sudo dpkg --add-architecture arm64
  2. 在 Debian 上,这一步通常不是必需的,但在其他发行版上,你可能需要编辑 /etc/apt/sources.list 以包含 ARM 架构的变体。例如,在 Ubuntu 22.04 上,将这些行添加到文件底部(记得将 jammy 替换为你 Ubuntu 版本的代号):

    deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted
    deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted
    deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universe
    deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universe
    deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiverse
    deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiverse
    deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse
    deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
    deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universe
    deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse

    然后,为了防止主软件包出现问题,你必须将正确的主架构添加到文件之前包含的所有其他行。对于标准的64位系统,你需要添加 [arch=amd64],在 Ubuntu 22.04 上完整的文件看起来类似这样:

    • 对于 ARMv7:sudo apt install libwebkit2gtk-4.1-dev:armhf
    • 针对 ARMv8(ARM64):sudo apt install libwebkit2gtk-4.1-dev:arm64
  3. 这并不总是必须的,所以你可能想先继续操作,然后检查是否出现像 Failed to find OpenSSL development headers 这样的错误。

    • 要么在整个系统中安装开发头文件:
      • 对于 ARMv7:sudo apt install libssl-dev:armhf
      • 针对 ARMv8(ARM64):sudo apt install libssl-dev:arm64
    • 或者启用 OpenSSL Rust crate 的供应商功能,这将影响所有使用相同次版本的其他 Rust 依赖。你可以通过在你的 Cargo.toml 文件的依赖部分添加以下内容来实现:
    openssl-sys = {version = "0.9", features = ["vendored"]}
    • 对于 ARMv7:export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/
    • 针对 ARMv8(ARM64):export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/
    • 对于 ARMv7:cargo tauri build —target armv7-unknown-linux-gnueabihf
    • 对于 ARMv8 (ARM64):cargo tauri build —target aarch64-unknown-linux-gnu

    根据你是否想为 ARMv7 或 ARMv8(ARM64)交叉编译你的 Tauri 应用,选择相应的指令集。请注意,具体步骤可能因你的 Linux 发行版和设置而异。


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