build.sh 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. cd $(dirname $0)
  3. REVISION_NO=`git rev-list --count HEAD`
  4. # check preconditions
  5. if [ -z "${JAVA_HOME}" ]; then echo "JAVA_HOME not set. Run using JAVA_HOME=/path/to/jdk ./build.sh"; exit 1; fi
  6. command -v mvn >/dev/null 2>&1 || { echo >&2 "mvn not found."; exit 1; }
  7. command -v curl >/dev/null 2>&1 || { echo >&2 "curl not found."; exit 1; }
  8. VERSION=$(mvn -f ../../../pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)
  9. SEMVER_STR=${VERSION}
  10. mvn -f ../../../pom.xml versions:set -DnewVersion=${SEMVER_STR}
  11. # compile
  12. mvn -B -f ../../../pom.xml clean package -Plinux -DskipTests
  13. cp ../../../LICENSE.txt ../../../target
  14. cp ../launcher.sh ../../../target
  15. cp ../../../target/cryptomator-*.jar ../../../target/mods
  16. # add runtime
  17. ${JAVA_HOME}/bin/jlink \
  18. --verbose \
  19. --output runtime \
  20. --module-path "${JAVA_HOME}/jmods" \
  21. --add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr \
  22. --strip-native-commands \
  23. --no-header-files \
  24. --no-man-pages \
  25. --strip-debug \
  26. --compress=1
  27. # create app dir
  28. envsubst '${SEMVER_STR} ${REVISION_NUM}' < ../launcher-gtk2.properties > launcher-gtk2.properties
  29. ${JAVA_HOME}/bin/jpackage \
  30. --verbose \
  31. --type app-image \
  32. --runtime-image runtime \
  33. --input ../../../target/libs \
  34. --module-path ../../../target/mods \
  35. --module org.cryptomator.desktop/org.cryptomator.launcher.Cryptomator \
  36. --dest appdir \
  37. --name Cryptomator \
  38. --vendor "Skymatic GmbH" \
  39. --copyright "(C) 2016 - 2023 Skymatic GmbH" \
  40. --java-options "-Xss5m" \
  41. --java-options "-Xmx256m" \
  42. --app-version "${VERSION}.${REVISION_NO}" \
  43. --java-options "-Dfile.encoding=\"utf-8\"" \
  44. --java-options "-Dcryptomator.logDir=\"~/.local/share/Cryptomator/logs\"" \
  45. --java-options "-Dcryptomator.pluginDir=\"~/.local/share/Cryptomator/plugins\"" \
  46. --java-options "-Dcryptomator.settingsPath=\"~/.config/Cryptomator/settings.json:~/.Cryptomator/settings.json\"" \
  47. --java-options "-Dcryptomator.p12Path=\"~/.config/Cryptomator/key.p12\"" \
  48. --java-options "-Dcryptomator.ipcSocketPath=\"~/.config/Cryptomator/ipc.socket\"" \
  49. --java-options "-Dcryptomator.mountPointsDir=\"~/.local/share/Cryptomator/mnt\"" \
  50. --java-options "-Dcryptomator.showTrayIcon=false" \
  51. --java-options "-Dcryptomator.buildNumber=\"appimage-${REVISION_NO}\"" \
  52. --add-launcher cryptomator-gtk2=launcher-gtk2.properties \
  53. --resource-dir ../resources
  54. # transform AppDir
  55. mv appdir/Cryptomator Cryptomator.AppDir
  56. cp -r resources/AppDir/* Cryptomator.AppDir/
  57. envsubst '${REVISION_NO}' < resources/AppDir/bin/cryptomator.sh > Cryptomator.AppDir/bin/cryptomator.sh
  58. cp ../common/org.cryptomator.Cryptomator256.png Cryptomator.AppDir/usr/share/icons/hicolor/256x256/apps/org.cryptomator.Cryptomator.png
  59. cp ../common/org.cryptomator.Cryptomator512.png Cryptomator.AppDir/usr/share/icons/hicolor/512x512/apps/org.cryptomator.Cryptomator.png
  60. cp ../common/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg
  61. cp ../common/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/usr/share/applications/org.cryptomator.Cryptomator.desktop
  62. cp ../common/org.cryptomator.Cryptomator.metainfo.xml Cryptomator.AppDir/usr/share/metainfo/org.cryptomator.Cryptomator.metainfo.xml
  63. cp ../common/application-vnd.cryptomator.vault.xml Cryptomator.AppDir/usr/share/mime/packages/application-vnd.cryptomator.vault.xml
  64. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/org.cryptomator.Cryptomator.svg
  65. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/Cryptomator.svg
  66. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/.DirIcon
  67. ln -s usr/share/applications/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/Cryptomator.desktop
  68. ln -s bin/cryptomator.sh Cryptomator.AppDir/AppRun
  69. # extract jffi
  70. JFFI_NATIVE_JAR=`ls Cryptomator.AppDir/lib/app | grep -e 'jffi-[1-9]\.[0-9]\{1,2\}.[0-9]\{1,2\}-native.jar'`
  71. ${JAVA_HOME}/bin/jar -xf Cryptomator.AppDir/lib/app/${JFFI_NATIVE_JAR} /jni/x86_64-Linux/
  72. mv jni/x86_64-Linux/* Cryptomator.AppDir/lib/app/libjffi.so
  73. rm -r jni/x86_64-Linux
  74. # load AppImageTool
  75. curl -L https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage -o /tmp/appimagetool.AppImage
  76. chmod +x /tmp/appimagetool.AppImage
  77. # create AppImage
  78. /tmp/appimagetool.AppImage \
  79. Cryptomator.AppDir \
  80. cryptomator-${SEMVER_STR}-x86_64.AppImage \
  81. -u 'gh-releases-zsync|cryptomator|cryptomator|latest|cryptomator-*-x86_64.AppImage.zsync'
  82. echo ""
  83. echo "Done. AppImage successfully created: cryptomator-${SEMVER_STR}-x86_64.AppImage"
  84. echo ""
  85. echo >&2 "To clean up, run: rm -rf Cryptomator.AppDir appdir jni runtime squashfs-root; rm launcher-gtk2.properties /tmp/appimagetool.AppImage"
  86. echo ""