diff --git a/.changes/appimage_fix.md b/.changes/appimage_fix.md new file mode 100644 index 000000000..f609d6d77 --- /dev/null +++ b/.changes/appimage_fix.md @@ -0,0 +1,5 @@ +--- +"tauri-bundler": minor +--- + +Fixes AppImage bundler (appimagetool usage, build script running properly, proper AppRun and .desktop files). diff --git a/cli/tauri-bundler/src/bundle/appimage_bundle.rs b/cli/tauri-bundler/src/bundle/appimage_bundle.rs index 5c51f56ec..150878cf6 100644 --- a/cli/tauri-bundler/src/bundle/appimage_bundle.rs +++ b/cli/tauri-bundler/src/bundle/appimage_bundle.rs @@ -64,7 +64,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { let temp = HANDLEBARS.render("appimage", &sh_map)?; // create the shell script file in the target/ folder. - let sh_file = output_path.join("build_appimage"); + let sh_file = output_path.join("build_appimage.sh"); common::print_bundling(format!("{:?}", &appimage_path).as_str())?; write(&sh_file, temp)?; @@ -79,14 +79,19 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { .expect("Failed to chmod script"); // execute the shell script to build the appimage. - Command::new(&sh_file) + let status = Command::new(&sh_file) .current_dir(output_path) .stdout(Stdio::piped()) .stderr(Stdio::piped()) - .spawn() + .status() .expect("Failed to execute shell script"); - remove_dir_all(&package_dir)?; - - Ok(vec![appimage_path]) + if !status.success() { + Err(crate::Error::ShellScriptError( + "error running build_appimage.sh".to_owned(), + )) + } else { + remove_dir_all(&package_dir)?; + Ok(vec![appimage_path]) + } } diff --git a/cli/tauri-bundler/src/bundle/templates/appimage b/cli/tauri-bundler/src/bundle/templates/appimage index 07dfd29da..82745caf7 100644 --- a/cli/tauri-bundler/src/bundle/templates/appimage +++ b/cli/tauri-bundler/src/bundle/templates/appimage @@ -5,7 +5,9 @@ cp -r ../deb/{{bundle_name}}/data/usr {{app_name}}.AppDir cd {{app_name}}.AppDir -cp usr/bin/{{app_name}} AppRun +wget -q -O AppRun https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-x86_64 +chmod +x AppRun + cp usr/share/icons/hicolor/256x256/apps/{{app_name}}.png {{app_name}}.png cd .. @@ -21,10 +23,10 @@ echo 'Type=Application' >> {{app_name}}.desktop echo 'Categories=X-Web;' >> {{app_name}}.desktop cp {{app_name}}.desktop {{app_name}}.AppDir/usr/share/applications/{{app_name}}.desktop +mv {{app_name}}.desktop {{app_name}}.AppDir/{{app_name}}.desktop mksquashfs {{app_name}}.AppDir {{app_name}}.squashfs -root-owned -noappend -wget -q -O runtime https://github.com/AppImage/AppImageKit/releases/download/continuous/runtime-x86_64 -cat runtime > {{app_name}}.AppImage -cat {{app_name}}.squashfs >> {{app_name}}.AppImage -chmod a+x {{app_name}}.AppImage +wget -q -O appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage +chmod +x appimagetool +./appimagetool {{app_name}}.AppDir {{app_name}}.AppImage