fix(tauri) use appimagetool to build, finish script run, proper AppRun (#682)

This commit is contained in:
Lucas Fernandes Nogueira 2020-06-17 12:49:45 -03:00 committed by GitHub
parent 02317dce9c
commit ea74c5cc01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 11 deletions

5
.changes/appimage_fix.md Normal file
View File

@ -0,0 +1,5 @@
---
"tauri-bundler": minor
---
Fixes AppImage bundler (appimagetool usage, build script running properly, proper AppRun and .desktop files).

View File

@ -64,7 +64,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
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<Vec<PathBuf>> {
.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])
}
}

View File

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