Skip to content

Commit

Permalink
fix(bundler): bundle /usr/bin/xdg-open in appimage if open API enab…
Browse files Browse the repository at this point in the history
…led (#4265)
  • Loading branch information
lucasfernog committed Jun 4, 2022
1 parent b369069 commit 2322ac1
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changes/cli-shell-open-api-env-var.md
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions .changes/fix-appimage-shell-api.md
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 4 additions & 4 deletions examples/api/dist/assets/vendor.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/api/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
}
},
"shell": {
"open": true,
"scope": [
{
"name": "sh",
Expand Down
6 changes: 6 additions & 0 deletions tooling/bundler/src/bundle/linux/templates/appimage
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion tooling/cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2322ac1

Please sign in to comment.