Forráskód Böngészése

fix(bundler): bundle `/usr/bin/xdg-open` in appimage if open API enabled (#4265)

Lucas Fernandes Nogueira 3 éve
szülő
commit
2322ac11cf

+ 6 - 0
.changes/cli-shell-open-api-env-var.md

@@ -0,0 +1,6 @@
+---
+"cli.rs": patch
+"cli.js": patch
+---
+
+Configure the AppImage bundler to copy the `/usr/bin/xdg-open` binary if it exists and the shell `open` API is enabled.

+ 5 - 0
.changes/fix-appimage-shell-api.md

@@ -0,0 +1,5 @@
+---
+"tauri-bundler": patch
+---
+
+Copy the `/usr/bin/xdg-open` binary if it exists and the `APPIMAGE_BUNDLE_XDG_OPEN` environment variable is set.

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
examples/api/dist/assets/vendor.js


+ 1 - 0
examples/api/src-tauri/tauri.conf.json

@@ -92,6 +92,7 @@
         }
       },
       "shell": {
+        "open": true,
         "scope": [
           {
             "name": "sh",

+ 6 - 0
tooling/bundler/src/bundle/linux/templates/appimage

@@ -6,12 +6,18 @@
 set -euxo pipefail
 
 export ARCH={{arch}}
+APPIMAGE_BUNDLE_XDG_OPEN=${APPIMAGE_BUNDLE_XDG_OPEN-0}
 
 mkdir -p "{{app_name}}.AppDir"
 cp -r ../appimage_deb/data/usr "{{app_name}}.AppDir"
 
 cd "{{app_name}}.AppDir"
 
+if [[ "$APPIMAGE_BUNDLE_XDG_OPEN" != "0" ]] && [[ -f "/usr/bin/xdg-open" ]]; then
+  echo "Copying /usr/bin/xdg-open"
+  cp /usr/bin/xdg-open usr/bin
+fi
+
 # Copy WebKit files.
 find /usr/lib* -name WebKitNetworkProcess -exec mkdir -p "$(dirname '{}')" \; -exec cp --parents '{}' "." \; || true
 find /usr/lib* -name WebKitWebProcess -exec mkdir -p "$(dirname '{}')" \; -exec cp --parents '{}' "." \; || true

+ 9 - 1
tooling/cli/src/build.rs

@@ -5,7 +5,7 @@
 use crate::helpers::{
   app_paths::{app_dir, tauri_dir},
   command_env,
-  config::{get as get_config, AppUrl, WindowUrl},
+  config::{get as get_config, AppUrl, ShellAllowlistOpen, WindowUrl},
   manifest::rewrite_manifest,
   updater_signature::sign_file_from_env_variables,
 };
@@ -302,6 +302,14 @@ pub fn command(options: Options) -> Result<()> {
     )
     .with_context(|| "failed to build bundler settings")?;
 
+    // set env vars used by the bundler
+    if matches!(
+      config_.tauri.allowlist.shell.open,
+      ShellAllowlistOpen::Flag(true) | ShellAllowlistOpen::Validate(_)
+    ) {
+      std::env::set_var("APPIMAGE_BUNDLE_XDG_OPEN", "1");
+    }
+
     let bundles = bundle_project(settings).with_context(|| "failed to bundle project")?;
 
     // If updater is active

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott