Skip to content

Commit

Permalink
remove env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianLars committed Nov 24, 2024
1 parent b8ce6e4 commit 423ab95
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,9 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
fs::copy("/usr/bin/xdg-mime", app_dir_usr_bin.join("xdg-mime"))?;
}

// TODO: don't rely on env vars
let gstreamer = std::env::var("APPIMAGE_BUNDLE_GSTREAMER")
.map(|x| x == "1")
.unwrap_or(false);

if let Ok(path) = std::env::var("TAURI_TRAY_LIBRARY_PATH") {
let path = PathBuf::from(path);
if let Some(file_name) = path.file_name() {
fs::copy(&path, app_dir_usr_lib.join(file_name))?;
}
}

if std::env::var("APPIMAGE_BUNDLE_XDG_OPEN")
.map(|x| x == "1")
.unwrap_or(false)
{
// xdg-open is only 50kb (in a 80mb+ appimage) and quite commonly used so we just always add it
// we do however check if the user may have provided their own copy already
if !app_dir_usr_bin.join("xdg-open").exists() {
fs::copy("/usr/bin/xdg-open", app_dir_usr_bin.join("xdg-open"))?;
}

Expand Down Expand Up @@ -188,6 +175,18 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
_ => "0",
};

// This should prevent linuxdeploy to be detected by appimage integration tools
let _ = Command::new("dd")
.args([
"if=/dev/zero",
"bs=1",
"count=3",
"seek=8",
"conf=notrunc",
&format!("of={}", linuxdeploy_path.display()),
])
.piped();

let mut cmd = Command::new(linuxdeploy_path);
cmd.env("OUTPUT", &appimage_path);
cmd.args([
Expand All @@ -199,7 +198,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
"--plugin",
"gtk",
]);
if gstreamer {
if settings.appimage().bundle_media_framework {
cmd.args(["--plugin", "gstreamer"]);
}
cmd.args(["--output", "appimage"]);
Expand Down
86 changes: 0 additions & 86 deletions crates/tauri-bundler/src/bundle/linux/appimage/appimage

This file was deleted.

2 changes: 2 additions & 0 deletions crates/tauri-bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ pub struct DebianSettings {
pub struct AppImageSettings {
/// The files to include in the Appimage Binary.
pub files: HashMap<PathBuf, PathBuf>,
/// Whether to include gstreamer plugins for audio/media support.
pub bundle_media_framework: bool,
}

/// The RPM bundle settings.
Expand Down
18 changes: 0 additions & 18 deletions crates/tauri-cli/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,6 @@ pub fn bundle<A: AppSettings>(
_ => log::Level::Trace,
});

// set env vars used by the bundler
#[cfg(target_os = "linux")]
{
if config.bundle.linux.appimage.bundle_media_framework {
std::env::set_var("APPIMAGE_BUNDLE_GSTREAMER", "1");
}

if let Some(open) = config.plugins.0.get("shell").and_then(|v| v.get("open")) {
if open.as_bool().is_some_and(|x| x) || open.is_string() {
std::env::set_var("APPIMAGE_BUNDLE_XDG_OPEN", "1");
}
}

if settings.deep_link_protocols().is_some() {
std::env::set_var("APPIMAGE_BUNDLE_XDG_MIME", "1");
}
}

let bundles = tauri_bundler::bundle_project(&settings)
.map_err(|e| match e {
tauri_bundler::Error::BundlerError(e) => e,
Expand Down
13 changes: 11 additions & 2 deletions crates/tauri-cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,9 @@ fn tauri_config_to_bundle_settings(
#[allow(unused_mut)]
let mut depends_rpm = config.linux.rpm.depends.unwrap_or_default();

#[allow(unused_mut)]
let mut appimage_files = config.linux.appimage.files;

// set env vars used by the bundler and inject dependencies
#[cfg(target_os = "linux")]
{
Expand Down Expand Up @@ -1276,7 +1279,12 @@ fn tauri_config_to_bundle_settings(
}
}

std::env::set_var("TAURI_TRAY_LIBRARY_PATH", path);
// conditionally setting it in case the user provided its own version for some reason
let path = PathBuf::from(path);
if !appimage_files.contains_key(&path) {
// manually construct target path, just in case the source path is something unexpected
appimage_files.insert(Path::new("/usr/lib").join(path.file_name().unwrap()), path);
}
}

depends_deb.push("libwebkit2gtk-4.1-0".to_string());
Expand Down Expand Up @@ -1368,7 +1376,8 @@ fn tauri_config_to_bundle_settings(
post_remove_script: config.linux.deb.post_remove_script,
},
appimage: AppImageSettings {
files: config.linux.appimage.files,
files: appimage_files,
bundle_media_framework: config.linux.appimage.bundle_media_framework,
},
rpm: RpmSettings {
depends: if depends_rpm.is_empty() {
Expand Down

0 comments on commit 423ab95

Please sign in to comment.