build.sh 2.3 KB

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