Ver Fonte

fix(bundler): Build AppImages inside the target folder (#4521)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Robin van Boven há 3 anos atrás
pai
commit
8dd03e69b0

+ 5 - 0
.changes/appimage-bundle-in-target.md

@@ -0,0 +1,5 @@
+---
+"tauri-bundler": patch
+---
+
+Build AppImages inside the `src-tauri/target` folder rather than `~/.cache/tauri`. Making it easier to clean and rebuild from scratch.

+ 13 - 17
tooling/bundler/src/bundle/linux/templates/appimage

@@ -16,14 +16,8 @@ else
     linuxdeploy_arch="$ARCH"
 fi
 
-OUTDIR="${PWD}"
-
-cd "{{tauri_tools_path}}"
-
-# remove the folder if it exists - the rest of the script fails if it does
-rm -rf "{{app_name}}.AppDir"
 mkdir -p "{{app_name}}.AppDir"
-cp -r "${OUTDIR}/../appimage_deb/data/usr" "{{app_name}}.AppDir"
+cp -r ../appimage_deb/data/usr "{{app_name}}.AppDir"
 
 cd "{{app_name}}.AppDir"
 mkdir -p "usr/bin"
@@ -53,8 +47,12 @@ find /usr/lib* -name WebKitNetworkProcess -exec mkdir -p "$(dirname '{}')" \; -e
 find /usr/lib* -name WebKitWebProcess -exec mkdir -p "$(dirname '{}')" \; -exec cp --parents '{}' "." \; || true
 find /usr/lib* -name libwebkit2gtkinjectedbundle.so -exec mkdir -p "$(dirname '{}')" \; -exec cp --parents '{}' "." \; || true
 
-wget -q -4 -N -O AppRun https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-${ARCH} || wget -q -4 -N -O AppRun https://github.com/AppImage/AppImageKit/releases/download/12/AppRun-${ARCH}
-chmod +x AppRun
+wget -q -4 -N -O "{{tauri_tools_path}}/AppRun" https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-${ARCH} || wget -q -4 -N -O "{{tauri_tools_path}}/AppRun" https://github.com/AppImage/AppImageKit/releases/download/12/AppRun-${ARCH}
+chmod +x "{{tauri_tools_path}}/AppRun"
+
+# We need AppRun to be installed as {{app_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" .
 
 cp "{{icon_path}}" .DirIcon
 ln -s "{{icon_path}}" "{{app_name}}.png"
@@ -71,14 +69,12 @@ else
   gst_plugin=""
 fi
 
-wget -q -4 -N -O linuxdeploy-plugin-gtk.sh https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh
-wget -q -4 -N -O linuxdeploy-${ARCH}.AppImage https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-${linuxdeploy_arch}.AppImage
+wget -q -4 -N -O "{{tauri_tools_path}}/linuxdeploy-plugin-gtk.sh" https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh
+wget -q -4 -N -O "{{tauri_tools_path}}/linuxdeploy-${ARCH}.AppImage" https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-${linuxdeploy_arch}.AppImage
 
-chmod +x linuxdeploy-plugin-gtk.sh
-chmod +x linuxdeploy-${ARCH}.AppImage
+chmod +x "{{tauri_tools_path}}/linuxdeploy-plugin-gtk.sh"
+chmod +x "{{tauri_tools_path}}/linuxdeploy-${ARCH}.AppImage"
 
-dd if=/dev/zero bs=1 count=3 seek=8 conv=notrunc of=linuxdeploy-${ARCH}.AppImage
+dd if=/dev/zero bs=1 count=3 seek=8 conv=notrunc of="{{tauri_tools_path}}/linuxdeploy-${ARCH}.AppImage"
 
-OUTPUT="{{appimage_filename}}" ./linuxdeploy-${ARCH}.AppImage --appimage-extract-and-run --appdir "{{app_name}}.AppDir" --plugin gtk ${gst_plugin}  --output appimage
-rm -r "{{app_name}}.AppDir"
-mv "{{appimage_filename}}" "$OUTDIR"
+OUTPUT="{{appimage_filename}}" "{{tauri_tools_path}}/linuxdeploy-${ARCH}.AppImage" --appimage-extract-and-run --appdir "{{app_name}}.AppDir" --plugin gtk ${gst_plugin} --output appimage