dmg_sign_noterize.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import os
  2. import argparse # Command line arguments parsing and help.
  3. import subprocess
  4. ULTIMAKER_CURA_DOMAIN = os.environ.get("ULTIMAKER_CURA_DOMAIN", "nl.ultimaker.cura")
  5. def build_dmg(source_path: str, dist_path: str, filename: str) -> None:
  6. create_dmg_executable = os.environ.get("CREATE_DMG_EXECUTABLE", "create-dmg")
  7. arguments = [create_dmg_executable,
  8. "--window-pos", "640", "360",
  9. "--window-size", "690", "503",
  10. "--app-drop-link", "520", "272",
  11. "--volicon", f"{source_path}/packaging/icons/VolumeIcons_Cura.icns",
  12. "--icon-size", "90",
  13. "--icon", "Ultimaker-Cura.app", "169", "272",
  14. "--eula", f"{source_path}/packaging/cura_license.txt",
  15. "--background", f"{source_path}/packaging/dmg/cura_background_dmg.png",
  16. f"{dist_path}/{filename}",
  17. f"{dist_path}/Ultimaker-Cura.app"]
  18. subprocess.run(arguments)
  19. def sign(dist_path: str, filename: str) -> None:
  20. codesign_executable = os.environ.get("CODESIGN", "codesign")
  21. codesign_identity = os.environ.get("CODESIGN_IDENTITY")
  22. arguments = [codesign_executable,
  23. "-s", codesign_identity,
  24. "--timestamp",
  25. "-i", f"{ULTIMAKER_CURA_DOMAIN}.dmg", # TODO: check if this really should have the extra dmg. We seem to be doing this also in the old Rundeck scripts
  26. f"{dist_path}/{filename}"]
  27. subprocess.run(arguments)
  28. def notarize(dist_path: str, filename: str) -> None:
  29. notarize_user = os.environ.get("MAC_NOTARIZE_USER")
  30. notarize_password = os.environ.get("MAC_NOTARIZE_PASS")
  31. altool_executable = os.environ.get("ALTOOL_EXECUTABLE", "altool")
  32. arguments = [
  33. "xcrun", altool_executable,
  34. "--notarize-app",
  35. "--primary-bundle-id", ULTIMAKER_CURA_DOMAIN,
  36. "--username", notarize_user,
  37. "--password", notarize_password,
  38. "--file", f"{dist_path}/{filename}"
  39. ]
  40. subprocess.run(arguments)
  41. if __name__ == "__main__":
  42. parser = argparse.ArgumentParser(description = "Create dmg of Cura.")
  43. parser.add_argument("source_path", type=str, help="Path to Conan install Cura folder.")
  44. parser.add_argument("dist_path", type=str, help="Path to Pyinstaller dist folder")
  45. parser.add_argument("filename", type = str, help = "Filename of the dmg (e.g. 'Ultimaker-Cura-5.1.0-beta-Linux-X64.dmg')")
  46. args = parser.parse_args()
  47. build_dmg(args.source_path, args.dist_path, args.filename)
  48. sign(args.dist_path, args.filename)
  49. notarize_dmg = bool(os.environ.get("NOTARIZE_DMG", "TRUE"))
  50. if notarize_dmg:
  51. notarize(args.dist_path, args.filename)