PackagingPostBuild_linux.cmake 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. file(REAL_PATH "${CPACK_SOURCE_DIR}/.." LY_ROOT_FOLDER)
  9. include(${LY_ROOT_FOLDER}/cmake/Platform/Common/PackagingPostBuild_common.cmake)
  10. include(${CPACK_CODESIGN_SCRIPT})
  11. # Init common variables
  12. set(file_name "${CPACK_PACKAGE_FILE_NAME}")
  13. set(checksum ${CPACK_PACKAGE_CHECKSUM})
  14. string(TOLOWER "$ENV{O3DE_PACKAGE_TYPE}" ext)
  15. # Set package variables for package types
  16. if(ext STREQUAL "snap")
  17. if(CPACK_SNAP_DISTRO)
  18. set(file_name "${CPACK_PACKAGE_FILE_NAME}_${CPACK_SNAP_DISTRO}_amd64")
  19. else()
  20. set(file_name "${CPACK_PACKAGE_FILE_NAME}_amd64")
  21. endif()
  22. set(checksum SHA384) # Snap asserts use SHA384
  23. elseif(ext STREQUAL "deb")
  24. # Retain default variables, placeholder for future logic
  25. else()
  26. message(FATAL_ERROR "No valid packaging type defined in O3DE_PACKAGE_TYPE. Stopping build")
  27. endif()
  28. set(pack_file "${CPACK_TOPLEVEL_DIRECTORY}/${file_name}.${ext}")
  29. # Generate checksum file
  30. string(TOLOWER ${checksum} checkext)
  31. set(hash_file "${pack_file}.${checkext}")
  32. file(${checksum} ${pack_file} file_checksum)
  33. file(WRITE ${hash_file} "${file_checksum} ${pack_file}")
  34. if(CPACK_UPLOAD_URL)
  35. # use the internal default path if somehow not specified from cpack_configure_downloads
  36. if(NOT CPACK_UPLOAD_DIRECTORY)
  37. set(CPACK_UPLOAD_DIRECTORY ${CPACK_PACKAGE_DIRECTORY}/CPackUploads)
  38. endif()
  39. if(ext STREQUAL "deb")
  40. # Sign and regenerate checksum
  41. ly_sign_binaries("${pack_file}" "")
  42. file(${checksum} ${pack_file} file_checksum)
  43. file(WRITE ${hash_file} "${file_checksum} ${pack_file}")
  44. endif()
  45. # Copy the artifacts intended to be uploaded to a remote server into the folder specified
  46. # through CPACK_UPLOAD_DIRECTORY. This mimics the same process cpack does natively for
  47. # some other frameworks that have built-in online installer support.
  48. message(STATUS "Copying packaging artifacts to upload directory...")
  49. file(REMOVE_RECURSE ${CPACK_UPLOAD_DIRECTORY})
  50. file(GLOB _artifacts
  51. "${CPACK_TOPLEVEL_DIRECTORY}/*.${ext}"
  52. "${CPACK_TOPLEVEL_DIRECTORY}/*.${checkext}"
  53. "${LY_ROOT_FOLDER}/scripts/signer/Platform/Linux/*.gpg"
  54. "${CPACK_3P_LICENSE_FILE}"
  55. "${CPACK_3P_MANIFEST_FILE}"
  56. )
  57. file(COPY ${_artifacts}
  58. DESTINATION ${CPACK_UPLOAD_DIRECTORY}
  59. )
  60. message(STATUS "Artifacts copied to ${CPACK_UPLOAD_DIRECTORY}")
  61. ly_upload_to_url(
  62. ${CPACK_UPLOAD_URL}
  63. ${CPACK_UPLOAD_DIRECTORY}
  64. ".*(.${ext}|.${checkext}|.gpg|.txt|.json)$"
  65. )
  66. # for auto tagged builds, we will also upload a second copy of the package/checksum
  67. # to a special "Latest" folder under the branch in place of the commit date/hash
  68. if(CPACK_AUTO_GEN_TAG)
  69. set(latest_pack_file "${CPACK_UPLOAD_DIRECTORY}/${file_name}_latest.${ext}")
  70. file(COPY_FILE
  71. ${pack_file}
  72. ${latest_pack_file}
  73. )
  74. ly_upload_to_latest(${CPACK_UPLOAD_URL} "${latest_pack_file}")
  75. set(latest_hash_file "${latest_pack_file}.${checkext}")
  76. file(COPY_FILE
  77. ${hash_file}
  78. ${latest_hash_file}
  79. )
  80. ly_upload_to_latest(${CPACK_UPLOAD_URL} "${latest_hash_file}")
  81. endif()
  82. endif()