Преглед изворни кода

Linux installer improvements (#17885)

* Add desktop icons for Linux deb/snap install

Signed-off-by: Steve Pham <[email protected]>

* Update to use the original svg

Signed-off-by: Steve Pham <[email protected]>

* Fix file permissions and update debian desktop processing

Signed-off-by: Steve Pham <[email protected]>

* Add icon desktop support for SNAP packages

Signed-off-by: Steve Pham <[email protected]>

---------

Signed-off-by: Steve Pham <[email protected]>
Steve Pham пре 1 година
родитељ
комит
34fd7151e4

+ 8 - 0
cmake/Platform/Common/Install_common.cmake

@@ -1136,6 +1136,14 @@ function(ly_setup_o3de_install)
         COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
     )
 
+    if("$ENV{O3DE_PACKAGE_TYPE}" STREQUAL "DEB")
+        ly_install(FILES
+            ${LY_ROOT_FOLDER}/Code/Tools/ProjectManager/Resources/o3de.svg
+            DESTINATION .
+            COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
+        )
+    endif()
+
     # Inject other build directories
     foreach(external_dir ${LY_INSTALL_EXTERNAL_BUILD_DIRS})
         ly_install(CODE

+ 1 - 1
cmake/Platform/Linux/Install_linux.cmake

@@ -27,7 +27,7 @@ function(ly_copy source_files relative_target_directory)
         if("${source_file}" IS_NEWER_THAN "${target_file}")
             message(STATUS "Copying ${source_file} to ${full_target_directory}...")
             file(MAKE_DIRECTORY "${full_target_directory}")
-            file(COPY "${source_file}" DESTINATION "${full_target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN)
+            file(COPY "${source_file}" DESTINATION "${full_target_directory}" USE_SOURCE_PERMISSIONS FOLLOW_SYMLINK_CHAIN)
             file(TOUCH_NOCREATE "${target_file}")
 
             # Special case for install

+ 27 - 6
cmake/Platform/Linux/Packaging/postinst.in

@@ -13,10 +13,31 @@ set -o errexit # exit on the first failure encountered
     ln -s @CPACK_PACKAGING_INSTALL_PREFIX@/bin/Linux/profile/Default/o3de /usr/local/bin/o3de
     ln -s @CPACK_PACKAGING_INSTALL_PREFIX@/bin/Linux/profile/Default/AssetProcessor /usr/local/bin/o3de.assetprocessor
     ln -s @CPACK_PACKAGING_INSTALL_PREFIX@/bin/Linux/profile/Default/Editor /usr/local/bin/o3de.editor
-       
-    pushd @CPACK_PACKAGING_INSTALL_PREFIX@
-    chown -R $SUDO_USER .
-    sudo -u $SUDO_USER python/get_python.sh
-    popd
 
-} &> /dev/null # hide output
+    # Generate the desktop icon
+    DESKTOP_ICON_FILE=/usr/share/applications/o3de.desktop
+
+    echo -e "[Desktop Entry]\n\
+Version=@CPACK_PACKAGE_VERSION@\n\
+Name=O3DE\n\
+Comment=O3DE Project Manager\n\
+Type=Application\n\
+Exec=@CPACK_PACKAGING_INSTALL_PREFIX@/bin/Linux/profile/Default/o3de\n\
+Path=@CPACK_PACKAGING_INSTALL_PREFIX@/bin/Linux/profile/Default/\n\
+Icon=@CPACK_PACKAGING_INSTALL_PREFIX@/o3de.svg\n\
+Terminal=false\n\
+StartupWMClass=O3DE.SNAP\n\
+StartupNotify=true\n\
+X-GNOME-Autostart-enabled=true\n\
+" > $DESKTOP_ICON_FILE
+
+    if [ "" != "$SUDO_USER" ]
+    then
+        pushd @CPACK_PACKAGING_INSTALL_PREFIX@
+        chown -R $SUDO_USER .
+        sudo -u $SUDO_USER python/get_python.sh
+        popd
+    fi
+
+} 
+#&> /dev/null # hide output

+ 1 - 0
cmake/Platform/Linux/Packaging/postrm.in

@@ -13,4 +13,5 @@ set -o errexit # exit on the first failure encountered
     rm -f /usr/local/bin/o3de
     rm -f /usr/local/bin/o3de.assetprocessor
     rm -f /usr/local/bin/o3de.editor
+    rm -f /usr/share/applications/o3de.desktop
 }

+ 26 - 3
cmake/Platform/Linux/Packaging_Snapcraft.cmake

@@ -37,6 +37,29 @@ foreach(engine_subfolder ${O3DE_PY_SUBDIRS})
     endforeach()
 endforeach()
 
+
+# Generate the files needed for the desktop icon
+file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/snap/gui/")
+string(JOIN "\n" O3DE_DESKTOP_CONTENT
+  "[Desktop Entry]"
+  "Version=${CPACK_PACKAGE_VERSION}"
+  "Name=O3DE"
+  "Comment=O3DE Project Manager"
+  "Type=Application"
+  "Exec=o3de"
+  "Icon=\${SNAP}/meta/gui/o3de.svg"
+  "Terminal=false"
+  "StartupWMClass=O3DE-Snap"
+  "StartupNotify=true"
+  "X-GNOME-Autostart-enabled=true"
+)
+file(WRITE "${CPACK_TEMPORARY_DIRECTORY}/snap/gui/o3de.desktop" ${O3DE_DESKTOP_CONTENT})
+file(COPY_FILE
+     "${LY_ROOT_FOLDER}/Code/Tools/ProjectManager/Resources/o3de.svg"
+     "${CPACK_TEMPORARY_DIRECTORY}/snap/gui/o3de.svg"
+)
+
+
 # make sure that all files have the correct permissions
 execute_process (COMMAND chmod -R 755 O3DE
                  WORKING_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}
@@ -56,6 +79,6 @@ set(snap_file "${CPACK_TEMPORARY_DIRECTORY}/o3de_${CPACK_PACKAGE_VERSION}_amd64.
 # Manually copy the files, the CPACK_EXTERNAL_BUILT_PACKAGES process runs after our packaging post build script
 # which is too late to be uploaded.
 file(COPY_FILE
-                ${snap_file}
-                "${CPACK_TOPLEVEL_DIRECTORY}/${snap_file_name}.snap"
-            )
+     ${snap_file}
+     "${CPACK_TOPLEVEL_DIRECTORY}/${snap_file_name}.snap"
+)

+ 1 - 1
cmake/Platform/Linux/runtime_dependencies_linux.cmake.in

@@ -56,7 +56,7 @@ function(ly_copy source_files relative_target_directory)
             if((NOT source_file_size EQUAL target_file_size) OR "${source_file}" IS_NEWER_THAN "${target_file}")
                 message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...")
                 file(MAKE_DIRECTORY "${full_target_directory}")
-                file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN)
+                file(COPY "${source_file}" DESTINATION "${target_directory}" USE_SOURCE_PERMISSIONS FOLLOW_SYMLINK_CHAIN)
                 file(TOUCH_NOCREATE "${target_file}")
 
                 # Special case, shared libraries that are copied from qt/plugins have their RPATH set to \$ORIGIN/../../lib