create_mac.sh.cmake 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. # Script to create the Mac installer using the packages tool from
  3. # http://s.sudre.free.fr/Software/Packages/about.html
  4. #
  5. [ "$#" -lt 2 ] && echo "Usage: create_mac_pkg.sh <CMAKE_INSTALL_DIR> <build dir> <installer sign identity>" && exit
  6. # the path of installation must be given as parameter
  7. if [ -z "$1" ]; then
  8. echo "ERROR: Provide the path to CMAKE_INSTALL_DIR to this script as first parameter."
  9. exit 1
  10. fi
  11. if [ -z "$2" ]; then
  12. echo "ERROR: Provide the path to build directory as second parameter."
  13. exit 1
  14. fi
  15. install_path="$1"
  16. build_path="$2"
  17. identity="$3"
  18. prjfile=$build_path/admin/osx/macosx.pkgproj
  19. # The name of the installer package
  20. installer="@APPLICATION_SHORTNAME@-qt@Qt5Core_VERSION@-@MIRALL_VERSION_FULL@@MIRALL_VERSION_SUFFIX@"
  21. installer_file="$installer.pkg"
  22. installer_file_tar="$installer.pkg.tar"
  23. installer_file_tar_bz2="$installer.pkg.tar.bz2"
  24. installer_file_tbz="$installer.pkg.tbz"
  25. # set the installer name to the copied prj config file
  26. /usr/local/bin/packagesutil --file $prjfile set project name "$installer"
  27. # The command line tool of the "Packages" tool, see link above.
  28. pkgbuild=/usr/local/bin/packagesbuild
  29. $pkgbuild -F $install_path $prjfile
  30. rc=$?
  31. if [ $rc == 0 ]; then
  32. echo "Successfully created $installer_file"
  33. else
  34. echo "Failed to create $installer_file"
  35. exit 3
  36. fi
  37. # Sign the finished package if desired.
  38. if [ ! -z "$identity" ]; then
  39. echo "Will try to sign the installer"
  40. pushd $install_path
  41. productsign --timestamp --sign "$identity" "$installer_file" "$installer_file.new"
  42. mv "$installer_file".new "$installer_file"
  43. popd
  44. else
  45. echo "No certificate given, will not sign the pkg"
  46. fi
  47. # FIXME: OEMs?
  48. # they will need to do their own signing..
  49. # Sparkle wants a tbz, it cannot install raw pkg
  50. cd $install_path
  51. tar cf "$installer_file_tar" "$installer_file"
  52. bzip2 -9 "$installer_file_tar"
  53. mv "$installer_file_tar_bz2" "$installer_file_tbz"
  54. rc=$?
  55. if [ $rc == 0 ]; then
  56. echo "Successfully created $installer_file"
  57. else
  58. echo "Failed to create $installer_file"
  59. exit 3
  60. fi