Repository navigation
feat(bundler): Truly portable appimage (experimental) #12491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
FabianLars
wants to merge
76
commits into
dev
Choose a base branch
from
feat/truly-portable-appimage
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+447
−12
Draft
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 c0e4344
only 4.1
FabianLars 278738f
gio
FabianLars 9e0d786
uruntime quicksave
FabianLars 6bc146b
don't patch rpath
FabianLars 1e6f5ed
rename mod
FabianLars 010c237
config instead of env var
FabianLars e57209a
new parameters
FabianLars 308094f
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars d8ef2fc
rm appimagetool
FabianLars 96dcc3e
upinfo
FabianLars c6725fd
runtime lite
FabianLars 78cacbf
zsyncmake (untested like the last 10 commits)
FabianLars 3d05459
todo
FabianLars ce61b57
remove version from filename if upinfo is provided
FabianLars d459b69
gst and architecture handling
FabianLars f91b0e7
todo
FabianLars 512e76c
keep version in name
FabianLars 3b5c9ea
todos
FabianLars 23719d4
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
FabianLars 628834b
rm todo
FabianLars cae7cb6
wording
FabianLars 5bac204
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars 9e7b47e
i forgot the stupid env var...
FabianLars de9a590
slightly better errors
FabianLars 0a1f7d8
don't bundle libegl
FabianLars addedc1
Revert "don't bundle libegl"
FabianLars 72e4b6e
gbm
FabianLars fdb85dd
remove -s
FabianLars 72211be
wrap path in quotation marks
FabianLars cbc7321
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
FabianLars c4ab830
sharun is now the default. remove tauri.conf setting
FabianLars 71b6833
can't remember
FabianLars 729f43c
missing format
FabianLars 6554bd4
Revert "sharun is now the default. remove tauri.conf setting"
FabianLars 6f70297
copy bins
FabianLars 4e04b4d
remove xdg-open leftover
FabianLars a0be6e1
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
FabianLars a95f435
add deprecation warning
FabianLars 4553327
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
FabianLars 5a8e2d2
fix merge mistake
FabianLars 516534f
versioned urls
FabianLars 261be30
xvfb
FabianLars 0af5adc
fix download links
FabianLars 562ce6e
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars abef5bb
fedora maybeee?
FabianLars f0511be
Revert "fedora maybeee?"
FabianLars d6f1dde
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
FabianLars b5573c1
update tools versions
FabianLars 6e35ba2
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars b7e08fa
initial quick-sharun migration
FabianLars d25c0ea
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars 105550c
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars 2d4995a
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars 056e661
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars 1626269
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars 2105c72
Merge branch 'dev' into feat/truly-portable-appimage
FabianLars 5e8505d
small-ish layout refactor
FabianLars b686c72
dont use debian helpers
FabianLars c2fa39f
reuse copy_bin output instead of read_dir
FabianLars 3999799
move desktop file
FabianLars 8afb6d1
fix icon path
FabianLars 26e15fe
for real this time?
FabianLars e0e9a55
clean up usr/share
FabianLars b84b425
always redownload quick-sharun.sh
FabianLars 6a8be18
i should set up git on my arch system
FabianLars 72e660b
xdg-open / xdg-mime
FabianLars 503bdbc
Revert "xdg-open / xdg-mime"
FabianLars 02d2a6d
Merge remote-tracking branch 'origin/dev' into feat/truly-portable-ap…
lucasfernog-crabnebula 28529a3
fix(bundler): harden the new sharun based AppImage bundler
lucasfernog 9fa9852
fix(cli): correct the new AppImage format config surface
lucasfernog 9147eb3
fix(bundler): run the AppImage tooling with bash to stop CI builds ha…
lucasfernog 1fa75e7
fix(bundler): keep whitespace out of the AppImage AppDir path
lucasfernog 21a5360
fix(utils): accept extract-and-run directories when detecting an AppI…
lucasfernog 3a93f6b
fix(cli): do not sign the AppImage zsync file as an updater artifact
lucasfernog 3b69f58
fix(bundler): name the AppImage icon after the desktop entry and docu…
lucasfernog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
257 changes: 257 additions & 0 deletions
257
crates/tauri-bundler/src/bundle/linux/appimage/experimental.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 {} \ | ||
| /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", | ||
|
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)) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(()) | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.