build-macos-app.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. echo 'Generating macos app bundle...'
  3. realpath() {
  4. path="$(ls "$PWD/$1")"
  5. echo "$path"
  6. }
  7. # Change our working directory to the parent directory of this script
  8. real_path="$(realpath "$0")"
  9. parent_dir="$(dirname "$real_path")"
  10. cd "$parent_dir"
  11. if [ ! -e ../build/install/curator ]; then
  12. echo "You must run 'gradle installDist' before this script!" 1>&2
  13. exit 1
  14. fi
  15. # Delete old app
  16. rm -rf ../build/macos/Curator.app
  17. # Copy empty application
  18. mkdir -p ../build/macos/Curator.app/Contents/MacOS/ ../build/macos/Curator.app/Contents/Resources/
  19. # Copy Info.plist and icon
  20. cp macos/Info.plist ../build/macos/Curator.app/Contents/Info.plist
  21. cp macos/icon.icns ../build/macos/Curator.app/Contents/Resources/icon.icns
  22. # Copy compiled app
  23. cp -r ../build/install/curator ../build/macos/Curator.app/Contents/MacOS/
  24. rm ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator.bat
  25. echo "Compiling start script..."
  26. # Compile start script (required to make JFileChooser work)
  27. shc -r -f ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator -o ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator.x
  28. rm ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator.x.c
  29. mv ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator.x ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator
  30. # Build install image (if we are on a mac)
  31. echo 'Building intsall image...'
  32. if which hdiutil >/dev/null 2>/dev/null; then
  33. # Set up temp dir
  34. rm -rf ../build/tmp/macos
  35. mkdir -p ../build/tmp/macos
  36. cp -r ../build/macos/Curator.app ../build/tmp/macos/
  37. ln -s /Applications ../build/tmp/macos/Applications
  38. # Create image
  39. hdiutil create -ov -volname "Curator" -srcfolder ../build/tmp/macos ../build/macos/Curator.dmg >/dev/null
  40. else
  41. echo "hdiutil(1) not found! Can't build DMG image."
  42. fi
  43. echo "App bundle generated in 'build/macos'!"