build.sh 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/bin/bash
  2. set -e
  3. cd $(dirname $0)
  4. REVISION_NO=`git rev-list --count HEAD`
  5. # check preconditions
  6. if [ -z "${JAVA_HOME}" ]; then echo "JAVA_HOME not set. Run using JAVA_HOME=/path/to/jdk ./build.sh"; exit 1; fi
  7. command -v mvn >/dev/null 2>&1 || { echo >&2 "mvn not found."; exit 1; }
  8. command -v curl >/dev/null 2>&1 || { echo >&2 "curl not found."; exit 1; }
  9. command -v unzip >/dev/null 2>&1 || { echo >&2 "unzip not found."; exit 1; }
  10. VERSION=$(mvn -f ../../../pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)
  11. SEMVER_STR=${VERSION}
  12. CPU_ARCH=$(uname -p)
  13. if [[ ! "${CPU_ARCH}" =~ x86_64|aarch64 ]]; then echo "Platform ${CPU_ARCH} not supported"; exit 1; fi
  14. mvn -f ../../../pom.xml versions:set -DnewVersion=${SEMVER_STR}
  15. # compile
  16. mvn -B -f ../../../pom.xml clean package -Plinux -DskipTests -Djavafx.platform=linux
  17. cp ../../../LICENSE.txt ../../../target
  18. cp ../../../target/cryptomator-*.jar ../../../target/mods
  19. JAVAFX_VERSION=22.0.2
  20. JAVAFX_ARCH="x64"
  21. JAVAFX_JMODS_SHA256='d44bff3b94d5668fdee18a938d7b1269026d663d44765f02d29a9bdfd3fa1eb0'
  22. if [ "${CPU_ARCH}" = "aarch64" ]; then
  23. JAVAFX_ARCH="aarch64"
  24. JAVAFX_JMODS_SHA256='3d5457136690c4f5bb9522d38b45218e045bdac13c24aa4c808c7c8d17d039c7'
  25. fi
  26. # download javaFX jmods
  27. JAVAFX_JMODS_URL="https://download2.gluonhq.com/openjfx/${JAVAFX_VERSION}/openjfx-${JAVAFX_VERSION}_linux-${JAVAFX_ARCH}_bin-jmods.zip"
  28. curl -L ${JAVAFX_JMODS_URL} -o openjfx-jmods.zip
  29. echo "${JAVAFX_JMODS_SHA256} openjfx-jmods.zip" | shasum -a256 --check
  30. mkdir -p openjfx-jmods
  31. unzip -o -j openjfx-jmods.zip \*/javafx.base.jmod \*/javafx.controls.jmod \*/javafx.fxml.jmod \*/javafx.graphics.jmod -d openjfx-jmods
  32. JMOD_VERSION=$(jmod describe ./openjfx-jmods/javafx.base.jmod | head -1)
  33. JMOD_VERSION=${JMOD_VERSION#*@}
  34. JMOD_VERSION=${JMOD_VERSION%%.*}
  35. POM_JFX_VERSION=$(mvn help:evaluate "-Dexpression=javafx.version" -q -DforceStdout -B -f ../../../pom.xml)
  36. POM_JFX_VERSION=${POM_JFX_VERSION#*@}
  37. POM_JFX_VERSION=${POM_JFX_VERSION%%.*}
  38. if [ $POM_JFX_VERSION -ne $JMOD_VERSION ]; then
  39. >&2 echo "Major JavaFX version in pom.xml (${POM_JFX_VERSION}) != amd64 jmod version (${JMOD_VERSION})"
  40. exit 1
  41. fi
  42. # add runtime
  43. ${JAVA_HOME}/bin/jlink \
  44. --verbose \
  45. --output runtime \
  46. --module-path "${JAVA_HOME}/jmods:openjfx-jmods" \
  47. --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.security.auth,jdk.accessibility,jdk.management.jfr,jdk.net,java.compiler \
  48. --strip-native-commands \
  49. --no-header-files \
  50. --no-man-pages \
  51. --strip-debug \
  52. --compress zip-0
  53. # create app dir
  54. ${JAVA_HOME}/bin/jpackage \
  55. --verbose \
  56. --type app-image \
  57. --runtime-image runtime \
  58. --input ../../../target/libs \
  59. --module-path ../../../target/mods \
  60. --module org.cryptomator.desktop/org.cryptomator.launcher.Cryptomator \
  61. --dest appdir \
  62. --name Cryptomator \
  63. --vendor "Skymatic GmbH" \
  64. --java-options "--enable-preview" \
  65. --java-options "--enable-native-access=org.cryptomator.jfuse.linux.amd64,org.cryptomator.jfuse.linux.aarch64,org.purejava.appindicator" \
  66. --copyright "(C) 2016 - 2024 Skymatic GmbH" \
  67. --java-options "-Xss5m" \
  68. --java-options "-Xmx256m" \
  69. --app-version "${VERSION}.${REVISION_NO}" \
  70. --java-options "-Dfile.encoding=\"utf-8\"" \
  71. --java-options "-Djava.net.useSystemProxies=true" \
  72. --java-options "-Dcryptomator.logDir=\"@{userhome}/.local/share/Cryptomator/logs\"" \
  73. --java-options "-Dcryptomator.pluginDir=\"@{userhome}/.local/share/Cryptomator/plugins\"" \
  74. --java-options "-Dcryptomator.settingsPath=\"@{userhome}/.config/Cryptomator/settings.json:@{userhome}/.Cryptomator/settings.json\"" \
  75. --java-options "-Dcryptomator.p12Path=\"@{userhome}/.config/Cryptomator/key.p12\"" \
  76. --java-options "-Dcryptomator.ipcSocketPath=\"@{userhome}/.config/Cryptomator/ipc.socket\"" \
  77. --java-options "-Dcryptomator.mountPointsDir=\"@{userhome}/.local/share/Cryptomator/mnt\"" \
  78. --java-options "-Dcryptomator.showTrayIcon=true" \
  79. --java-options "-Dcryptomator.integrationsLinux.trayIconsDir=\"@{appdir}/usr/share/icons/hicolor/symbolic/apps\"" \
  80. --java-options "-Dcryptomator.buildNumber=\"appimage-${REVISION_NO}\"" \
  81. --resource-dir ../resources
  82. # transform AppDir
  83. mv appdir/Cryptomator Cryptomator.AppDir
  84. cp -r resources/AppDir/* Cryptomator.AppDir/
  85. envsubst '${REVISION_NO}' < resources/AppDir/bin/cryptomator.sh > Cryptomator.AppDir/bin/cryptomator.sh
  86. cp ../common/org.cryptomator.Cryptomator256.png Cryptomator.AppDir/usr/share/icons/hicolor/256x256/apps/org.cryptomator.Cryptomator.png
  87. cp ../common/org.cryptomator.Cryptomator512.png Cryptomator.AppDir/usr/share/icons/hicolor/512x512/apps/org.cryptomator.Cryptomator.png
  88. cp ../common/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg
  89. cp ../common/org.cryptomator.Cryptomator.tray.svg Cryptomator.AppDir/usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.tray.svg
  90. cp ../common/org.cryptomator.Cryptomator.tray-unlocked.svg Cryptomator.AppDir/usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.tray-unlocked.svg
  91. cp ../common/org.cryptomator.Cryptomator.tray.svg Cryptomator.AppDir/usr/share/icons/hicolor/symbolic/apps/org.cryptomator.Cryptomator.tray-symbolic.svg
  92. cp ../common/org.cryptomator.Cryptomator.tray-unlocked.svg Cryptomator.AppDir/usr/share/icons/hicolor/symbolic/apps/org.cryptomator.Cryptomator.tray-unlocked-symbolic.svg
  93. cp ../common/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/usr/share/applications/org.cryptomator.Cryptomator.desktop
  94. cp ../common/org.cryptomator.Cryptomator.metainfo.xml Cryptomator.AppDir/usr/share/metainfo/org.cryptomator.Cryptomator.metainfo.xml
  95. cp ../common/application-vnd.cryptomator.vault.xml Cryptomator.AppDir/usr/share/mime/packages/application-vnd.cryptomator.vault.xml
  96. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/org.cryptomator.Cryptomator.svg
  97. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/Cryptomator.svg
  98. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/.DirIcon
  99. ln -s usr/share/applications/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/Cryptomator.desktop
  100. ln -s bin/cryptomator.sh Cryptomator.AppDir/AppRun
  101. # load AppImageTool
  102. curl -L https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-${CPU_ARCH}.AppImage -o /tmp/appimagetool.AppImage
  103. chmod +x /tmp/appimagetool.AppImage
  104. # create AppImage
  105. /tmp/appimagetool.AppImage \
  106. Cryptomator.AppDir \
  107. cryptomator-${SEMVER_STR}-${CPU_ARCH}.AppImage \
  108. -u 'gh-releases-zsync|cryptomator|cryptomator|latest|cryptomator-*-${CPU_ARCH}.AppImage.zsync'
  109. echo ""
  110. echo "Done. AppImage successfully created: cryptomator-${SEMVER_STR}-${CPU_ARCH}.AppImage"
  111. echo ""
  112. echo >&2 "To clean up, run: rm -rf Cryptomator.AppDir appdir runtime squashfs-root openjfx-jmods; rm /tmp/appimagetool.AppImage openjfx-jmods.zip"
  113. echo ""