build.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # compile
  9. mvn -B -f../../pom.xml clean package -DskipTests -Plinux
  10. # prepare AppDir
  11. mkdir Cryptomator.AppDir
  12. mv ../../target/libs Cryptomator.AppDir
  13. mv ../../target/mods Cryptomator.AppDir
  14. cp ../../LICENSE.txt Cryptomator.AppDir
  15. # add runtime
  16. ${JAVA_HOME}/bin/jlink
  17. --output Cryptomator.AppDir/runtime
  18. --module-path "${JAVA_HOME}/jmods"
  19. --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
  20. --no-header-files
  21. --no-man-pages
  22. --strip-debug
  23. --compress=1
  24. # extract jffi
  25. JFFI_NATIVE_JAR=`ls Cryptomator.AppDir/libs | grep -e 'jffi-[1-9]\.[0-9]\{1,2\}.[0-9]\{1,2\}-native.jar'`
  26. ${JAVA_HOME}/bin/jar -xf Cryptomator.AppDir/libs/${JFFI_NATIVE_JAR} /jni/x86_64-Linux/
  27. mv jni/x86_64-Linux/* Cryptomator.AppDir/libs/libjffi.so
  28. rm -r jni/x86_64-Linux
  29. # finalize AppDir
  30. envsubst '${REVISION_NO}' < resources/AppDir/bin/cryptomator.sh > Cryptomator.AppDir/bin/cryptomator.sh
  31. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/org.cryptomator.Cryptomator.svg
  32. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/Cryptomator.svg
  33. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/.DirIcon
  34. ln -s usr/share/applications/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/Cryptomator.desktop
  35. ln -s bin/cryptomator.sh Cryptomator.AppDir/AppRun
  36. # load AppImageTool
  37. curl -L https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage -o /tmp/appimagetool.AppImage
  38. chmod +x /tmp/appimagetool.AppImage
  39. # create AppImage
  40. /tmp/appimagetool.AppImage \
  41. Cryptomator.AppDir \
  42. cryptomator-SNAPSHOT-x86_64.AppImage \
  43. -u 'gh-releases-zsync|cryptomator|cryptomator|latest|cryptomator-*-x86_64.AppImage.zsync'