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.
🌐 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 构建应用。这将会慢得多,但也能够构建 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(32 位):
-
- 对于 ARMv7:
sudo apt install gcc-arm-linux-gnueabihf - 针对 ARMv8(ARM64):
sudo apt install gcc-aarch64-linux-gnu
- 对于 ARMv7:
-
[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
- 对于 ARMv7:
-
在 Debian 上,这一步通常不是必需的,但在其他发行版上,你可能需要编辑 /etc/apt/sources.list 以包含 ARM 架构的变体。例如,在 Ubuntu 22.04 上,将这些行添加到文件底部(记得将 jammy 替换为你 Ubuntu 版本的代号):
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 multiverse然后,为了防止主软件包出现问题,你必须将正确的主架构添加到文件之前包含的所有其他行。对于标准的64位系统,你需要添加 [arch=amd64],在 Ubuntu 22.04 上完整的文件看起来类似这样:
# 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 -
- 对于 ARMv7:
sudo apt install libwebkit2gtk-4.1-dev:armhf - 针对 ARMv8(ARM64):
sudo apt install libwebkit2gtk-4.1-dev:arm64
- 对于 ARMv7:
-
这并不总是必须的,所以你可能想先继续操作,然后检查是否出现像
Failed to find OpenSSL development headers这样的错误。- 要么在整个系统中安装开发头文件:
- 对于 ARMv7:
sudo apt install libssl-dev:armhf - 针对 ARMv8(ARM64):
sudo apt install libssl-dev:arm64
- 对于 ARMv7:
- 或者启用 OpenSSL Rust crate 的供应商功能,这将影响所有使用相同次版本的其他 Rust 依赖。你可以通过在你的
Cargo.toml文件的依赖部分添加以下内容来实现:
openssl-sys = {version = "0.9", features = ["vendored"]} - 要么在整个系统中安装开发头文件:
-
根据你选择的架构,将
Section titled “根据你选择的架构,将 PKG_CONFIG_SYSROOT_DIR 设置为适当的目录”PKG_CONFIG_SYSROOT_DIR设置为适当的目录- 对于 ARMv7:
export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/ - 针对 ARMv8(ARM64):
export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/
- 对于 ARMv7:
-
- 对于 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 旗下网站