Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
aec554e
feat(bundler): Truly portable appimage (experimental)
FabianLars Jan 24, 2025
c0e4344
only 4.1
FabianLars Jan 30, 2025
278738f
gio
FabianLars Jan 30, 2025
9e0d786
uruntime quicksave
FabianLars Jan 30, 2025
6bc146b
don't patch rpath
FabianLars Mar 9, 2025
1e6f5ed
rename mod
FabianLars May 1, 2025
010c237
config instead of env var
FabianLars May 1, 2025
e57209a
new parameters
FabianLars May 1, 2025
308094f
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars May 1, 2025
d8ef2fc
rm appimagetool
FabianLars May 2, 2025
96dcc3e
upinfo
FabianLars May 2, 2025
c6725fd
runtime lite
FabianLars May 2, 2025
78cacbf
zsyncmake (untested like the last 10 commits)
FabianLars May 2, 2025
3d05459
todo
FabianLars May 2, 2025
ce61b57
remove version from filename if upinfo is provided
FabianLars May 3, 2025
d459b69
gst and architecture handling
FabianLars May 3, 2025
f91b0e7
todo
FabianLars May 3, 2025
512e76c
keep version in name
FabianLars May 4, 2025
3b5c9ea
todos
FabianLars May 6, 2025
23719d4
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
FabianLars May 6, 2025
628834b
rm todo
FabianLars May 6, 2025
cae7cb6
wording
FabianLars May 7, 2025
5bac204
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars May 7, 2025
9e7b47e
i forgot the stupid env var...
FabianLars May 8, 2025
de9a590
slightly better errors
FabianLars May 8, 2025
0a1f7d8
don't bundle libegl
FabianLars May 8, 2025
addedc1
Revert "don't bundle libegl"
FabianLars May 8, 2025
72e4b6e
gbm
FabianLars May 8, 2025
fdb85dd
remove -s
FabianLars May 8, 2025
72211be
wrap path in quotation marks
FabianLars May 8, 2025
cbc7321
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
FabianLars Jul 21, 2025
c4ab830
sharun is now the default. remove tauri.conf setting
FabianLars Jul 21, 2025
71b6833
can't remember
FabianLars Sep 1, 2025
729f43c
missing format
FabianLars Sep 1, 2025
6554bd4
Revert "sharun is now the default. remove tauri.conf setting"
FabianLars Sep 1, 2025
6f70297
copy bins
FabianLars Sep 1, 2025
4e04b4d
remove xdg-open leftover
FabianLars Sep 1, 2025
a0be6e1
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
FabianLars Sep 1, 2025
a95f435
add deprecation warning
FabianLars Sep 1, 2025
4553327
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
FabianLars Oct 7, 2025
5a8e2d2
fix merge mistake
FabianLars Oct 7, 2025
516534f
versioned urls
FabianLars Oct 7, 2025
261be30
xvfb
FabianLars Oct 7, 2025
0af5adc
fix download links
FabianLars Oct 8, 2025
562ce6e
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars Oct 8, 2025
abef5bb
fedora maybeee?
FabianLars Oct 8, 2025
f0511be
Revert "fedora maybeee?"
FabianLars Oct 8, 2025
d6f1dde
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
FabianLars Jan 28, 2026
b5573c1
update tools versions
FabianLars Jan 28, 2026
6e35ba2
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars Mar 8, 2026
b7e08fa
initial quick-sharun migration
FabianLars Mar 8, 2026
d25c0ea
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars May 10, 2026
105550c
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars May 17, 2026
2d4995a
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars Jun 15, 2026
056e661
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars Jun 24, 2026
1626269
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars Jul 6, 2026
2105c72
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars Jul 31, 2026
5e8505d
small-ish layout refactor
FabianLars Jul 31, 2026
b686c72
dont use debian helpers
FabianLars Jul 31, 2026
c2fa39f
reuse copy_bin output instead of read_dir
FabianLars Jul 31, 2026
3999799
move desktop file
FabianLars Jul 31, 2026
8afb6d1
fix icon path
FabianLars Jul 31, 2026
26e15fe
for real this time?
FabianLars Jul 31, 2026
e0e9a55
clean up usr/share
FabianLars Jul 31, 2026
b84b425
always redownload quick-sharun.sh
FabianLars Jul 31, 2026
6a8be18
i should set up git on my arch system
FabianLars Jul 31, 2026
72e660b
xdg-open / xdg-mime
FabianLars Jul 31, 2026
503bdbc
Revert "xdg-open / xdg-mime"
FabianLars Aug 1, 2026
02d2a6d
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
lucasfernog-crabnebula Sep 5, 2026
28529a3
fix(bundler): harden the new sharun based AppImage bundler
lucasfernog Sep 5, 2026
9fa9852
fix(cli): correct the new AppImage format config surface
lucasfernog Sep 5, 2026
9147eb3
fix(bundler): run the AppImage tooling with bash to stop CI builds ha…
lucasfernog Sep 5, 2026
1fa75e7
fix(bundler): keep whitespace out of the AppImage AppDir path
lucasfernog Sep 6, 2026
21a5360
fix(utils): accept extract-and-run directories when detecting an AppI…
lucasfernog Sep 6, 2026
3a93f6b
fix(cli): do not sign the AppImage zsync file as an updater artifact
lucasfernog Sep 6, 2026
3b69f58
fix(bundler): name the AppImage icon after the desktop entry and docu…
lucasfernog Sep 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
257 changes: 257 additions & 0 deletions crates/tauri-bundler/src/bundle/linux/appimage/experimental.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use std::{
fs,
path::{Path, PathBuf},
process::Command,
};

use anyhow::Context;

use crate::{
bundle::{linux::debian, settings::Arch},
utils::{fs_utils, http_utils::download, CommandExt},
Settings,
};

use super::write_and_make_executable;

pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
// for backwards compat we keep the amd64 and i386 rewrites in the filename
let appimage_arch = match settings.binary_arch() {
Arch::X86_64 => "amd64",
//Arch::X86 => "i386",
Arch::AArch64 => "aarch64",
//Arch::Armhf => "armhf",
target => {
return Err(crate::Error::ArchError(format!(
"Unsupported architecture: {:?}",
target
)));
}
};
let tools_arch = settings.target().split('-').next().unwrap();

let output_path = settings.project_out_directory().join("bundle/appimage");
if output_path.exists() {
fs::remove_dir_all(&output_path)?;
}

let tools_path = settings
.local_tools_directory()
.map(|d| d.join(".tauri"))
.unwrap_or_else(|| {
dirs::cache_dir().map_or_else(|| output_path.to_path_buf(), |p| p.join("tauri"))
});

fs::create_dir_all(&tools_path)?;

#[allow(unused)]
let (appimagetool, lib4bin, uruntime) = prepare_tools(&tools_path, tools_arch)?;

let package_dir = settings
.project_out_directory()
.join("bundle/appimage_deb/");

let main_binary = settings.main_binary()?;
let product_name = settings.product_name();

let mut settings = settings.clone();
if main_binary.name().contains(' ') {
let main_binary_path = settings.binary_path(main_binary);
let project_out_dir = settings.project_out_directory();

let main_binary_name_kebab = heck::AsKebabCase(main_binary.name()).to_string();
let new_path = project_out_dir.join(&main_binary_name_kebab);
fs::copy(main_binary_path, new_path)?;

let main_binary = settings.main_binary_mut()?;
main_binary.set_name(main_binary_name_kebab);
}

// generate deb_folder structure
let (data_dir, icons) = debian::generate_data(&settings, &package_dir)
.with_context(|| "Failed to build data folders and files")?;
fs_utils::copy_custom_files(&settings.appimage().files, &data_dir)
.with_context(|| "Failed to copy custom files")?;

fs::create_dir_all(&output_path)?;
let app_dir_path = output_path.join(format!("{}.AppDir", settings.product_name()));
let appimage_filename = format!(
"{}_{}_{}.AppImage",
settings.product_name(),
settings.version_string(),
appimage_arch
);
let appimage_path = output_path.join(&appimage_filename);

fs::create_dir_all(&tools_path)?;
let larger_icon = icons
.iter()
.filter(|i| i.width == i.height)
.max_by_key(|i| i.width)
.expect("couldn't find a square icon to use as AppImage icon");
let larger_icon_path = larger_icon
.path
.strip_prefix(package_dir.join("data"))
.unwrap()
.to_string_lossy()
.to_string();

log::info!(action = "Bundling"; "{} ({})", appimage_filename, appimage_path.display());

fs_utils::copy_dir(&data_dir, &app_dir_path)?;

let app_dir_share = &app_dir_path.join("share/");

fs_utils::copy_dir(&data_dir.join("usr/share/"), app_dir_share)?;

// The appimage spec allows a symlink but sharun doesn't
fs::copy(
app_dir_share.join(format!("applications/{product_name}.desktop")),
app_dir_path.join(format!("{product_name}.desktop")),
)?;

// This could be a symlink as well (supported by sharun as far as i can tell)
fs::copy(
app_dir_path.join(larger_icon_path.strip_prefix("usr/").unwrap()),
app_dir_path.join(format!("{product_name}.png")),
)?;

std::os::unix::fs::symlink(
app_dir_path.join(format!("{product_name}.png")),
app_dir_path.join(".DirIcon"),
)?;

/* std::os::unix::fs::symlink(
app_dir_share.join(format!("applications/{product_name}.desktop")),
app_dir_path.join(format!("{product_name}.desktop")),
)?; */

let strip = if std::env::var("NO_STRIP").unwrap_or("false".to_string()) == "true" {
""
} else {
"-s"
};

let verbosity = match settings.log_level() {
log::Level::Error => "-q", // errors only
log::Level::Info => "", // errors + "normal logs" (mostly rpath)
log::Level::Trace => "-v", // You can expect way over 1k lines from just lib4bin on this level
_ => "",
};

// TODO(--NOW--): Check if we can make parts of the opengl (incl. libvulkan) deps optional
// TODO(later): rustify this (finding the paths in rust instead of using bash glob patterns)
// TODO(later): Consider putting gst and pulse behind bundleMediaFramwork for ~150mb -> ~130mb
Command::new("/bin/sh")
.current_dir(&app_dir_path)
.args([
"-c",
&format!(
r#"{} -p {} {} -k {} \
Comment thread
FabianLars marked this conversation as resolved.
Resolved
/usr/lib/x86_64-linux-gnu/libGL* \
/usr/lib/x86_64-linux-gnu/libEGL* \
/usr/lib/x86_64-linux-gnu/libvulkan* \
/usr/lib/x86_64-linux-gnu/dri/* \
/usr/lib/x86_64-linux-gnu/libpulsecommon* \
/usr/lib/x86_64-linux-gnu/libnss_mdns* \
/usr/lib/x86_64-linux-gnu/gstreamer-1.0/* \
/usr/lib/x86_64-linux-gnu/libwebkit2gtk-4.1* \
/usr/lib/x86_64-linux-gnu/gio/modules/*"#,
lib4bin.to_string_lossy(),
verbosity,
strip,
&app_dir_path
.join(format!("usr/bin/{}", main_binary.name()))
.to_string_lossy()
),
])
.output_ok()?;

fs_utils::remove_dir_all(&app_dir_path.join("usr/"))?;

// TODO(--NOW--): gstreamer bins

let sharun = app_dir_path.join("sharun");
fs::copy(&sharun, app_dir_path.join("AppRun"))?;

Command::new(sharun)
.current_dir(&app_dir_path)
.arg("-g")
.output_ok()?;

// TODO(--NOW--): verbosity
// TODO(later): -u
// TODO(later): check out uruntime
// ARCH for appimagetool should be x86_64, i686, aarch64, or armhf
Command::new(appimagetool)
.env("ARCH", tools_arch)
.args([
"--comp",
"zstd",
"--mksquashfs-opt",
"-Xcompression-level",
"--mksquashfs-opt",
"22",
"-n",
&app_dir_path.to_string_lossy(),
&appimage_path.to_string_lossy(),
])
.output_ok()?;
/* Command::new(&uruntime)
.env("ARCH", tools_arch)
.args([
"--appimage-mkdwarfs",
"-f",
"--set-owner",
"0",
"--set-group",
"0",
"--no-history",
"--no-create-timestamp",
"--compression",
"zstd:level=22",
"-S24",
Comment thread
FabianLars marked this conversation as resolved.
Resolved
"-B16",
"--header",
&uruntime.to_string_lossy(),
"-i",
&app_dir_path.to_string_lossy(),
"-o",
&appimage_path.to_string_lossy(),
])
.output_ok()?;
{
use std::os::unix::fs::PermissionsExt;
fs::set_permissions(appimage_path, fs::Permissions::from_mode(0o770))?;
} */

fs::remove_dir_all(package_dir)?;
Ok(vec![appimage_path])
}

fn prepare_tools(tools_path: &Path, arch: &str) -> crate::Result<(PathBuf, PathBuf, PathBuf)> {
let appimagetool = tools_path.join(format!("appimagetool-{arch}.AppImage"));
if !appimagetool.exists() {
let data = download(&format!("https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-{arch}.AppImage"))?;
write_and_make_executable(&appimagetool, data)?;
}

let uruntime = tools_path.join(format!("uruntime-appimage-dwarfs-{arch}"));
if !uruntime.exists() {
let data = download(&format!("https://github.com/VHSgunzo/uruntime/releases/latest/download/uruntime-appimage-dwarfs-{arch}"))?;
write_and_make_executable(&uruntime, data)?;
}

let lib4bin = tools_path.join(format!("lib4bin-{arch}"));
if !lib4bin.exists() {
let data =
download("https://raw.githubusercontent.com/VHSgunzo/sharun/refs/heads/main/lib4bin")?;
write_and_make_executable(&lib4bin, data)?;
}

Ok((appimagetool, lib4bin, uruntime))
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use super::debian;
use super::{super::debian, write_and_make_executable};
use crate::{
bundle::settings::Arch,
utils::{fs_utils, http_utils::download, CommandExt},
Expand Down Expand Up @@ -254,12 +254,3 @@ fn prepare_tools(tools_path: &Path, arch: &str) -> crate::Result<PathBuf> {

Ok(linuxdeploy)
}

fn write_and_make_executable(path: &Path, data: Vec<u8>) -> std::io::Result<()> {
use std::os::unix::fs::PermissionsExt;

fs::write(path, data)?;
fs::set_permissions(path, fs::Permissions::from_mode(0o770))?;

Ok(())
}
31 changes: 31 additions & 0 deletions crates/tauri-bundler/src/bundle/linux/appimage/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use std::{
fs,
path::{Path, PathBuf},
};

use crate::Settings;

mod experimental;
mod linuxdeploy;

// TODO: This needs to be a config, not an env var post PoC
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
if std::env::var("TAURI_NEW_APPIMAGE").unwrap_or("false".to_string()) == "true" {
experimental::bundle_project(settings)
} else {
linuxdeploy::bundle_project(settings)
}
}

fn write_and_make_executable(path: &Path, data: Vec<u8>) -> std::io::Result<()> {
use std::os::unix::fs::PermissionsExt;

fs::write(path, data)?;
fs::set_permissions(path, fs::Permissions::from_mode(0o770))?;

Ok(())
}