Repository: AcademySoftwareFoundation/rez (language: python)

Issue:
rez_install_files with LOCAL_SYMLINK fails when an input file has whitespaces in its name
Hi,

Calling rez_install_files with the LOCAL_SYMLINK parameter fails when one of the input files has a symlink in the name. This can be fixed by adding quotes in the following line inside the 'install_files_' macro (rez/src/rezplugins/build_system/cmake_files/InstallFiles.cmake:140):

`install( CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${f} ${CMAKE_INSTALL_PREFIX}/${target_fpath})" )`,

which becomes:

`install( CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \"${f}\" \"${CMAKE_INSTALL_PREFIX}/${target_fpath}\")" )`


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/ubuntu.yaml b/.github/workflows/ubuntu.yaml
index 3ffd1a40f..71216da3c 100644
--- a/.github/workflows/ubuntu.yaml
+++ b/.github/workflows/ubuntu.yaml
@@ -37,6 +37,10 @@ jobs:
         with:
           python-version: ${{ matrix.python-version }}
 
+      - name: apt-get update
+        run: |
+          sudo apt-get update
+
       - name: Verify cmake
         run: |
           cmake --version
diff --git a/src/rezplugins/build_system/cmake_files/InstallFiles.cmake b/src/rezplugins/build_system/cmake_files/InstallFiles.cmake
index fd47842b9..ac013201c 100644
--- a/src/rezplugins/build_system/cmake_files/InstallFiles.cmake
+++ b/src/rezplugins/build_system/cmake_files/InstallFiles.cmake
@@ -134,14 +134,14 @@ macro (install_files_)
 	# install files
 	#
 	foreach(f ${INSTF_DEFAULT_ARGS})
-		get_target_filepath(${f} ${rel_dir} ${dest_dir} target_fpath)
-		get_filename_component(target_path ${target_fpath} PATH)
+		get_target_filepath("${f}" "${rel_dir}" "${dest_dir}" target_fpath)
+		get_filename_component(target_path "${target_fpath}" PATH)
         if(REZ_BUILD_TYPE STREQUAL "central" OR NOT INSTF_LOCAL_SYMLINK)
-		    install(FILES ${f} DESTINATION ${target_path} PERMISSIONS ${perms})
+		    install(FILES "${f}" DESTINATION "${target_path}" PERMISSIONS ${perms})
         else()
             install( CODE "message (STATUS  \"Symlink : ${CMAKE_INSTALL_PREFIX}/${target_fpath} -> ${f}\" )" )
-            install( CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_PREFIX}/${target_path})" )
-            install( CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${f} ${CMAKE_INSTALL_PREFIX}/${target_fpath})" )
+            install( CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory \"${CMAKE_INSTALL_PREFIX}/${target_path}\")" )
+            install( CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \"${f}\" \"${CMAKE_INSTALL_PREFIX}/${target_fpath}\")" )
         endif(REZ_BUILD_TYPE STREQUAL "central" OR NOT INSTF_LOCAL_SYMLINK)
 
 	endforeach(f ${INSTF_DEFAULT_ARGS})


Test patch:
diff --git a/src/rez/data/tests/builds/packages/translate_lib/2.2.0/CMakeLists.txt b/src/rez/data/tests/builds/packages/translate_lib/2.2.0/CMakeLists.txt
index 8dbe11d5f..affcfd0ec 100644
--- a/src/rez/data/tests/builds/packages/translate_lib/2.2.0/CMakeLists.txt
+++ b/src/rez/data/tests/builds/packages/translate_lib/2.2.0/CMakeLists.txt
@@ -18,6 +18,15 @@ rez_install_files(
 	DESTINATION include/translate
 )
 
+# install docs
+FILE(GLOB_RECURSE doc_files "docs/*")
+rez_install_files(
+	${doc_files}
+	RELATIVE src
+	DESTINATION docs
+	LOCAL_SYMLINK # Testing for github issue #553
+)
+
 # install cmake file
 rez_install_cmake(
 	DESTINATION 	cmake
diff --git a/src/rez/data/tests/builds/packages/translate_lib/2.2.0/docs/a spaced document b/src/rez/data/tests/builds/packages/translate_lib/2.2.0/docs/a spaced document
new file mode 100644
index 000000000..44d1261d7
--- /dev/null
+++ b/src/rez/data/tests/builds/packages/translate_lib/2.2.0/docs/a spaced document
@@ -0,0 +1,3 @@
+This file has spaces in its name
+which is here so that cmake macros
+get tested for handling spaces in filenames
diff --git a/src/rez/data/tests/builds/packages/translate_lib/2.2.0/docs/an_unspaced_document b/src/rez/data/tests/builds/packages/translate_lib/2.2.0/docs/an_unspaced_document
new file mode 100644
index 000000000..42580c74f
--- /dev/null
+++ b/src/rez/data/tests/builds/packages/translate_lib/2.2.0/docs/an_unspaced_document
@@ -0,0 +1,3 @@
+This file very much does not
+have a space in its name, as
+a counterpart to the other
diff --git a/src/rez/tests/test_build.py b/src/rez/tests/test_build.py
index cb615f17b..4f74de8cd 100644
--- a/src/rez/tests/test_build.py
+++ b/src/rez/tests/test_build.py
@@ -118,7 +118,12 @@ def _test_build_translate_lib(self):
         self._test_build("translate_lib", "2.2.0")
         context = self._create_context("translate_lib==2.2.0")
         environ = context.get_environ()
-        find_file_in_path('translate_lib.cmake', environ['CMAKE_MODULE_PATH'])
+        root = environ['REZ_TRANSLATE_LIB_ROOT']
+        self.assertTrue(find_file_in_path('translate_lib.cmake', environ['CMAKE_MODULE_PATH']))
+        # is testing symlinks
+        self.assertTrue(find_file_in_path('an_unspaced_document', os.path.join(root, 'docs')))
+        # is testing spaces in symlinks per issue #553
+        self.assertTrue(find_file_in_path('a spaced document', os.path.join(root, 'docs')))
 
     def _test_build_sup_world(self):
         """Build, install, test the sup_world package."""
@@ -156,6 +161,7 @@ def test_builds_anti(self):
         self._test_build_anti()
 
     @program_dependent("cmake")
+    @install_dependent()
     def test_build_cmake(self):
         """Test a cmake-based package."""
         if platform_.name == "windows":