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

This commit is contained in:
Lucas Fernandes Nogueira 2022-06-04 07:45:24 -07:00 committed by GitHub
parent b369069c5a
commit 2322ac11cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 5 deletions

View File

@ -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.

View File

@ -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.

File diff suppressed because one or more lines are too long

View File

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

View File

@ -6,12 +6,18 @@
set -euxo pipefail set -euxo pipefail
export ARCH={{arch}} export ARCH={{arch}}
APPIMAGE_BUNDLE_XDG_OPEN=${APPIMAGE_BUNDLE_XDG_OPEN-0}
mkdir -p "{{app_name}}.AppDir" mkdir -p "{{app_name}}.AppDir"
cp -r ../appimage_deb/data/usr "{{app_name}}.AppDir" cp -r ../appimage_deb/data/usr "{{app_name}}.AppDir"
cd "{{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. # Copy WebKit files.
find /usr/lib* -name WebKitNetworkProcess -exec mkdir -p "$(dirname '{}')" \; -exec cp --parents '{}' "." \; || true 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 find /usr/lib* -name WebKitWebProcess -exec mkdir -p "$(dirname '{}')" \; -exec cp --parents '{}' "." \; || true

View File

@ -5,7 +5,7 @@
use crate::helpers::{ use crate::helpers::{
app_paths::{app_dir, tauri_dir}, app_paths::{app_dir, tauri_dir},
command_env, command_env,
config::{get as get_config, AppUrl, WindowUrl}, config::{get as get_config, AppUrl, ShellAllowlistOpen, WindowUrl},
manifest::rewrite_manifest, manifest::rewrite_manifest,
updater_signature::sign_file_from_env_variables, updater_signature::sign_file_from_env_variables,
}; };
@ -302,6 +302,14 @@ pub fn command(options: Options) -> Result<()> {
) )
.with_context(|| "failed to build bundler settings")?; .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")?; let bundles = bundle_project(settings).with_context(|| "failed to bundle project")?;
// If updater is active // If updater is active