dmg_sign_noterize.py 2.8 KB

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