build.sh 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. # compile
  11. mvn -B -f ../../../pom.xml clean package -DskipTests -Plinux
  12. cp ../../../target/cryptomator-*.jar ../../../target/mods
  13. # add runtime
  14. ${JAVA_HOME}/bin/jlink \
  15. --output runtime \
  16. --module-path "${JAVA_HOME}/jmods" \
  17. --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 \
  18. --no-header-files \
  19. --no-man-pages \
  20. --strip-debug \
  21. --compress=1
  22. # create app dir
  23. envsubst '${SEMVER_STR} ${REVISION_NUM}' < dist/linux/launcher-gtk2.properties > launcher-gtk2.properties
  24. ${JAVA_HOME}/bin/jpackage \
  25. --verbose \
  26. --type app-image \
  27. --runtime-image runtime \
  28. --input ../../../target/libs \
  29. --module-path ../../../target/mods \
  30. --module org.cryptomator.desktop/org.cryptomator.launcher.Cryptomator \
  31. --dest . \
  32. --name Cryptomator \
  33. --vendor "Skymatic GmbH" \
  34. --copyright "(C) 2016 - 2022 Skymatic GmbH" \
  35. --java-options "-Xss5m" \
  36. --java-options "-Xmx256m" \
  37. --app-version "${VERSION}.${REVISION_NO}" \
  38. --java-options "-Dfile.encoding=\"utf-8\"" \
  39. --java-options "-Dcryptomator.logDir=\"~/.local/share/Cryptomator/logs\"" \
  40. --java-options "-Dcryptomator.pluginDir=\"~/.local/share/Cryptomator/plugins\"" \
  41. --java-options "-Dcryptomator.settingsPath=\"~/.config/Cryptomator/settings.json:~/.Cryptomator/settings.json\"" \
  42. --java-options "-Dcryptomator.ipcSocketPath=\"~/.config/Cryptomator/ipc.socket\"" \
  43. --java-options "-Dcryptomator.mountPointsDir=\"~/.local/share/Cryptomator/mnt\"" \
  44. --java-options "-Dcryptomator.showTrayIcon=false" \
  45. --java-options "-Dcryptomator.buildNumber=\"appimage-${REVISION_NO}\"" \
  46. --add-launcher cryptomator-gtk2=launcher-gtk2.properties \
  47. --resource-dir ../resources
  48. # transform AppDir
  49. mv Cryptomator Cryptomator.AppDir
  50. cp -r resources/AppDir/* Cryptomator.AppDir/
  51. chmod +x Cryptomator.AppDir/lib/runtime/bin/java
  52. envsubst '${REVISION_NO}' < resources/AppDir/bin/cryptomator.sh > Cryptomator.AppDir/bin/cryptomator.sh
  53. cp ../common/org.cryptomator.Cryptomator256.png Cryptomator.AppDir/usr/share/icons/hicolor/256x256/apps/org.cryptomator.Cryptomator.png
  54. cp ../common/org.cryptomator.Cryptomator512.png Cryptomator.AppDir/usr/share/icons/hicolor/512x512/apps/org.cryptomator.Cryptomator.png
  55. cp ../common/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg
  56. cp ../common/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/usr/share/applications/org.cryptomator.Cryptomator.desktop
  57. cp ../common/org.cryptomator.Cryptomator.metainfo.xml Cryptomator.AppDir/usr/share/metainfo/org.cryptomator.Cryptomator.metainfo.xml
  58. cp ../common/application-vnd.cryptomator.vault.xml Cryptomator.AppDir/usr/share/mime/packages/application-vnd.cryptomator.vault.xml
  59. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/org.cryptomator.Cryptomator.svg
  60. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/Cryptomator.svg
  61. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/.DirIcon
  62. ln -s usr/share/applications/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/Cryptomator.desktop
  63. ln -s bin/cryptomator.sh Cryptomator.AppDir/AppRun
  64. # extract jffi
  65. JFFI_NATIVE_JAR=`ls Cryptomator.AppDir/lib/app | grep -e 'jffi-[1-9]\.[0-9]\{1,2\}.[0-9]\{1,2\}-native.jar'`
  66. ${JAVA_HOME}/bin/jar -xf Cryptomator.AppDir/lib/app/${JFFI_NATIVE_JAR} /jni/x86_64-Linux/
  67. mv jni/x86_64-Linux/* Cryptomator.AppDir/lib/app/libjffi.so
  68. rm -r jni/x86_64-Linux
  69. # load AppImageTool
  70. curl -L https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage -o /tmp/appimagetool.AppImage
  71. chmod +x /tmp/appimagetool.AppImage
  72. # create AppImage
  73. /tmp/appimagetool.AppImage \
  74. Cryptomator.AppDir \
  75. cryptomator-SNAPSHOT-x86_64.AppImage \
  76. -u 'gh-releases-zsync|cryptomator|cryptomator|latest|cryptomator-*-x86_64.AppImage.zsync'