Skip to content

Commit

Permalink
fix(bundler): AppImage startup crash (#10036)
Browse files Browse the repository at this point in the history
* Update appimage

* Update appimage.rs

* changefile

---------

Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
  • Loading branch information
CrabNejonas and FabianLars authored Jun 11, 2024
1 parent f44a2ec commit b9e11a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changes/appimage-duplicate-desktop-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-bundler": "patch:bug"
---

Fixed an issue that caused the AppImage to segfault on start due to an incorrect .desktop file.
5 changes: 1 addition & 4 deletions tooling/bundler/src/bundle/linux/appimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,10 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
let appimage_path = output_path.join(&appimage_filename);
path_utils::create(app_dir_path, true)?;

let upcase_app_name = settings.product_name().to_uppercase();

// setup data to insert into shell script
let mut sh_map = BTreeMap::new();
sh_map.insert("arch", settings.target().split('-').next().unwrap());
sh_map.insert("app_name", settings.product_name());
sh_map.insert("app_name_uppercase", &upcase_app_name);
sh_map.insert("crate_name", settings.main_binary_name());
sh_map.insert("appimage_filename", &appimage_filename);
let tauri_tools_path = dirs::cache_dir().map_or_else(
|| output_path.to_path_buf(),
Expand Down
14 changes: 7 additions & 7 deletions tooling/bundler/src/bundle/linux/templates/appimage
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ else
linuxdeploy_arch="$ARCH"
fi

mkdir -p "{{app_name}}.AppDir"
cp -r ../appimage_deb/data/usr "{{app_name}}.AppDir"
mkdir -p "{{crate_name}}.AppDir"
cp -r ../appimage_deb/data/usr "{{crate_name}}.AppDir"

cd "{{app_name}}.AppDir"
cd "{{crate_name}}.AppDir"
mkdir -p "usr/bin"
mkdir -p "usr/lib"

Expand Down Expand Up @@ -56,14 +56,14 @@ find -L /usr/lib* -name libwebkit2gtkinjectedbundle.so -exec mkdir -p "$(dirname
( cd "{{tauri_tools_path}}" && ( wget -q -4 -N https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-${ARCH} || wget -q -4 -N https://github.com/AppImage/AppImageKit/releases/download/12/AppRun-${ARCH} ) )
chmod +x "{{tauri_tools_path}}/AppRun-${ARCH}"

# We need AppRun to be installed as {{app_name}}.AppDir/AppRun.
# We need AppRun to be installed as {{crate_name}}.AppDir/AppRun.
# Otherwise the linuxdeploy scripts will default to symlinking our main bin instead and will crash on trying to launch.
cp "{{tauri_tools_path}}/AppRun-${ARCH}" AppRun

cp "{{icon_path}}" .DirIcon
ln -sf "{{icon_path}}" "{{app_name}}.png"
ln -sf "{{icon_path}}" "{{crate_name}}.png"

ln -sf "usr/share/applications/{{app_name}}.desktop" "{{app_name}}.desktop"
ln -sf "usr/share/applications/{{crate_name}}.desktop" "{{crate_name}}.desktop"

cd ..

Expand All @@ -83,4 +83,4 @@ chmod +x "{{tauri_tools_path}}/linuxdeploy-${linuxdeploy_arch}.AppImage"

dd if=/dev/zero bs=1 count=3 seek=8 conv=notrunc of="{{tauri_tools_path}}/linuxdeploy-${linuxdeploy_arch}.AppImage"

OUTPUT="{{appimage_filename}}" "{{tauri_tools_path}}/linuxdeploy-${linuxdeploy_arch}.AppImage" --appimage-extract-and-run --appdir "{{app_name}}.AppDir" --plugin gtk ${gst_plugin} --output appimage
OUTPUT="{{appimage_filename}}" "{{tauri_tools_path}}/linuxdeploy-${linuxdeploy_arch}.AppImage" --appimage-extract-and-run --appdir "{{crate_name}}.AppDir" --plugin gtk ${gst_plugin} --output appimage

0 comments on commit b9e11a8

Please sign in to comment.