From fab70ef8c97a82b01c4acf059505f6aa31b033dc Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 18 Mar 2022 17:25:04 +0100 Subject: [PATCH 1/5] run Cryptomator binaries instead of java from AppImage launcher .sh --- .github/workflows/appimage.yml | 2 ++ dist/linux/appimage/build.sh | 2 ++ .../resources/AppDir/bin/cryptomator.sh | 25 ++++--------------- dist/linux/launcher-gtk2.properties | 12 +++++++++ 4 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 dist/linux/launcher-gtk2.properties diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index 694f6ee45..ac9ee4eac 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -60,6 +60,7 @@ jobs: --compress=1 - name: Run jpackage run: > + envsubst '${SEMVER_STR} ${REVISION_NUM}' < dist/linux/launcher-gtk2.properties > launcher-gtk2.properties ${JAVA_HOME}/bin/jpackage --verbose --type app-image @@ -83,6 +84,7 @@ jobs: --java-options "-Dcryptomator.mountPointsDir=\"~/.local/share/Cryptomator/mnt\"" --java-options "-Dcryptomator.showTrayIcon=false" --java-options "-Dcryptomator.buildNumber=\"appimage-${{ steps.versions.outputs.revNum }}\"" + --add-launcher Cryptomator-gtk2=launcher-gtk2.properties \ --resource-dir dist/linux/resources - name: Patch Cryptomator.AppDir run: | diff --git a/dist/linux/appimage/build.sh b/dist/linux/appimage/build.sh index 6dd670df2..3cd080de5 100755 --- a/dist/linux/appimage/build.sh +++ b/dist/linux/appimage/build.sh @@ -26,6 +26,7 @@ ${JAVA_HOME}/bin/jlink \ --compress=1 # create app dir +envsubst '${SEMVER_STR} ${REVISION_NUM}' < dist/linux/launcher-gtk2.properties > launcher-gtk2.properties ${JAVA_HOME}/bin/jpackage \ --verbose \ --type app-image \ @@ -48,6 +49,7 @@ ${JAVA_HOME}/bin/jpackage \ --java-options "-Dcryptomator.mountPointsDir=\"~/.local/share/Cryptomator/mnt\"" \ --java-options "-Dcryptomator.showTrayIcon=false" \ --java-options "-Dcryptomator.buildNumber=\"appimage-${REVISION_NO}\"" \ + --add-launcher cryptomator-gtk2=launcher-gtk2.properties \ --resource-dir ../resources # transform AppDir diff --git a/dist/linux/appimage/resources/AppDir/bin/cryptomator.sh b/dist/linux/appimage/resources/AppDir/bin/cryptomator.sh index 82c3e01ca..80b919c72 100755 --- a/dist/linux/appimage/resources/AppDir/bin/cryptomator.sh +++ b/dist/linux/appimage/resources/AppDir/bin/cryptomator.sh @@ -15,26 +15,11 @@ elif command -v pacman &> /dev/null; then # don't forget arch GTK3_PRESENT=`pacman -Qi gtk3 &> /dev/null; echo $?` fi -if [ "$GTK2_PRESENT" -eq 0 ] && [ "$GTK3_PRESENT" -ne 0 ]; then - GTK_FLAG="-Djdk.gtk.version=2" -fi - # workaround for https://github.com/cryptomator/cryptomator-linux/issues/27 export LD_PRELOAD=lib/app/libjffi.so -# start Cryptomator -./lib/runtime/bin/java \ - -p "lib/app/mods" \ - -cp "lib/app/*" \ - -Dfile.encoding="utf-8" \ - -Dcryptomator.logDir="~/.local/share/Cryptomator/logs" \ - -Dcryptomator.pluginDir="~/.local/share/Cryptomator/plugins" \ - -Dcryptomator.mountPointsDir="~/.local/share/Cryptomator/mnt" \ - -Dcryptomator.settingsPath="~/.config/Cryptomator/settings.json:~/.Cryptomator/settings.json" \ - -Dcryptomator.ipcSocketPath="~/.config/Cryptomator/ipc.socket" \ - -Dcryptomator.buildNumber="appimage-${REVISION_NO}" \ - -Dcryptomator.appVersion="${SEMVER_STR}" \ - $GTK_FLAG \ - -Xss5m \ - -Xmx256m \ - -m org.cryptomator.desktop/org.cryptomator.launcher.Cryptomator +if [ "$GTK2_PRESENT" -eq 0 ] && [ "$GTK3_PRESENT" -ne 0 ]; then + ./bin/Cryptomator-gtk2 +else + ./bin/Cryptomator +fi \ No newline at end of file diff --git a/dist/linux/launcher-gtk2.properties b/dist/linux/launcher-gtk2.properties new file mode 100644 index 000000000..bf4727fa9 --- /dev/null +++ b/dist/linux/launcher-gtk2.properties @@ -0,0 +1,12 @@ +java-options=-Xss5m \ + -Xmx256m \ + -Dfile.encoding=\"utf-8\" \ + -Dcryptomator.appVersion=\"${SEMVER_STR}\" \ + -Dcryptomator.logDir=\"~/.local/share/Cryptomator/logs\" \ + -Dcryptomator.pluginDir=\"~/.local/share/Cryptomator/plugins\" \ + -Dcryptomator.settingsPath=\"~/.config/Cryptomator/settings.json:~/.Cryptomator/settings.json\" \ + -Dcryptomator.ipcSocketPath=\"~/.config/Cryptomator/ipc.socket\" \ + -Dcryptomator.mountPointsDir=\"~/.local/share/Cryptomator/mnt\" \ + -Dcryptomator.showTrayIcon=false \ + -Dcryptomator.buildNumber=\"appimage-${REVISION_NUM}\" \ + -Djdk.gtk.version=2 \ No newline at end of file From b565f1d0c0b75025b1f0389249f90b689b2e6ceb Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 18 Mar 2022 17:26:28 +0100 Subject: [PATCH 2/5] remove unused java binaries from jlinked runtime image --- .github/workflows/appimage.yml | 1 + dist/linux/appimage/build.sh | 1 + dist/linux/debian/rules | 1 + dist/mac/dmg/build.sh | 1 + dist/win/build.ps1 | 1 + 5 files changed, 5 insertions(+) diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index ac9ee4eac..10dc04f16 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -54,6 +54,7 @@ jobs: --output runtime --module-path "${JAVA_HOME}/jmods" --add-modules java.base,java.desktop,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr + --strip-native-commands --no-header-files --no-man-pages --strip-debug diff --git a/dist/linux/appimage/build.sh b/dist/linux/appimage/build.sh index 3cd080de5..de0685379 100755 --- a/dist/linux/appimage/build.sh +++ b/dist/linux/appimage/build.sh @@ -20,6 +20,7 @@ ${JAVA_HOME}/bin/jlink \ --output runtime \ --module-path "${JAVA_HOME}/jmods" \ --add-modules java.base,java.desktop,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr \ + --strip-native-commands \ --no-header-files \ --no-man-pages \ --strip-debug \ diff --git a/dist/linux/debian/rules b/dist/linux/debian/rules index e4f824394..eda04ae65 100755 --- a/dist/linux/debian/rules +++ b/dist/linux/debian/rules @@ -19,6 +19,7 @@ override_dh_auto_build: jlink \ --output runtime \ --add-modules java.base,java.desktop,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr \ + --strip-native-commands \ --no-header-files \ --no-man-pages \ --strip-debug \ diff --git a/dist/mac/dmg/build.sh b/dist/mac/dmg/build.sh index c90411acb..df9664eb5 100755 --- a/dist/mac/dmg/build.sh +++ b/dist/mac/dmg/build.sh @@ -38,6 +38,7 @@ ${JAVA_HOME}/bin/jlink \ --output runtime \ --module-path "${JAVA_HOME}/jmods" \ --add-modules java.base,java.desktop,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr \ + --strip-native-commands \ --no-header-files \ --no-man-pages \ --strip-debug \ diff --git a/dist/win/build.ps1 b/dist/win/build.ps1 index 0b0e953bc..5e4cc484a 100644 --- a/dist/win/build.ps1 +++ b/dist/win/build.ps1 @@ -42,6 +42,7 @@ if ($clean -and (Test-Path -Path $runtimeImagePath)) { --output runtime ` --module-path "$Env:JAVA_HOME/jmods" ` --add-modules java.base,java.desktop,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr ` + --strip-native-commands ` --no-header-files ` --no-man-pages ` --strip-debug ` From 8dce21ea403dbb7cbed3acacdc86f2b6cc377338 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 18 Mar 2022 17:31:49 +0100 Subject: [PATCH 3/5] run envsubst as an independent step --- .github/workflows/appimage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index 10dc04f16..e05199967 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -59,9 +59,10 @@ jobs: --no-man-pages --strip-debug --compress=1 + - name: Prepare additional launcher + run: envsubst '${SEMVER_STR} ${REVISION_NUM}' < dist/linux/launcher-gtk2.properties > launcher-gtk2.properties - name: Run jpackage run: > - envsubst '${SEMVER_STR} ${REVISION_NUM}' < dist/linux/launcher-gtk2.properties > launcher-gtk2.properties ${JAVA_HOME}/bin/jpackage --verbose --type app-image From 550546c4b7b669e9d34080fc3414a3f4e19bd8b4 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 18 Mar 2022 17:42:28 +0100 Subject: [PATCH 4/5] not required in yml multiline strings --- .github/workflows/appimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index e05199967..d5fc543f8 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -86,7 +86,7 @@ jobs: --java-options "-Dcryptomator.mountPointsDir=\"~/.local/share/Cryptomator/mnt\"" --java-options "-Dcryptomator.showTrayIcon=false" --java-options "-Dcryptomator.buildNumber=\"appimage-${{ steps.versions.outputs.revNum }}\"" - --add-launcher Cryptomator-gtk2=launcher-gtk2.properties \ + --add-launcher Cryptomator-gtk2=launcher-gtk2.properties --resource-dir dist/linux/resources - name: Patch Cryptomator.AppDir run: | From 504a384225b35448ae0b5f25bc3b9f76e63cee1f Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 18 Mar 2022 17:58:21 +0100 Subject: [PATCH 5/5] fix envsubst --- .github/workflows/appimage.yml | 7 +++---- dist/linux/appimage/resources/AppDir/bin/cryptomator.sh | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index d5fc543f8..01a98b832 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -61,6 +61,9 @@ jobs: --compress=1 - name: Prepare additional launcher run: envsubst '${SEMVER_STR} ${REVISION_NUM}' < dist/linux/launcher-gtk2.properties > launcher-gtk2.properties + env: + SEMVER_STR: ${{ steps.versions.outputs.semVerStr }} + REVISION_NUM: ${{ steps.versions.outputs.revNum }} - name: Run jpackage run: > ${JAVA_HOME}/bin/jpackage @@ -92,7 +95,6 @@ jobs: run: | mv appdir/Cryptomator Cryptomator.AppDir cp -r dist/linux/appimage/resources/AppDir/* Cryptomator.AppDir/ - envsubst '${REVISION_NO} ${SEMVER_STR}' < dist/linux/appimage/resources/AppDir/bin/cryptomator.sh > Cryptomator.AppDir/bin/cryptomator.sh cp dist/linux/common/org.cryptomator.Cryptomator256.png Cryptomator.AppDir/usr/share/icons/hicolor/256x256/apps/org.cryptomator.Cryptomator.png cp dist/linux/common/org.cryptomator.Cryptomator512.png Cryptomator.AppDir/usr/share/icons/hicolor/512x512/apps/org.cryptomator.Cryptomator.png cp dist/linux/common/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg @@ -104,9 +106,6 @@ jobs: ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/.DirIcon ln -s usr/share/applications/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/Cryptomator.desktop ln -s bin/cryptomator.sh Cryptomator.AppDir/AppRun - env: - REVISION_NO: ${{ steps.versions.outputs.revNum }} - SEMVER_STR: ${{ steps.versions.outputs.semVerStr }} - name: Extract libjffi.so # workaround for https://github.com/cryptomator/cryptomator-linux/issues/27 run: | JFFI_NATIVE_JAR=`ls lib/app/ | grep -e 'jffi-[1-9]\.[0-9]\{1,2\}.[0-9]\{1,2\}-native.jar'` diff --git a/dist/linux/appimage/resources/AppDir/bin/cryptomator.sh b/dist/linux/appimage/resources/AppDir/bin/cryptomator.sh index 80b919c72..39579a122 100755 --- a/dist/linux/appimage/resources/AppDir/bin/cryptomator.sh +++ b/dist/linux/appimage/resources/AppDir/bin/cryptomator.sh @@ -19,7 +19,7 @@ fi export LD_PRELOAD=lib/app/libjffi.so if [ "$GTK2_PRESENT" -eq 0 ] && [ "$GTK3_PRESENT" -ne 0 ]; then - ./bin/Cryptomator-gtk2 + bin/Cryptomator-gtk2 else - ./bin/Cryptomator + bin/Cryptomator fi \ No newline at end of file