From 553b9263530def7901c35648afc7e16922c4ce56 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Sat, 25 Apr 2020 08:51:05 -0600 Subject: [PATCH] WIP: Move stuff/ to with_subpackages/b/, strengthen install_package_by_package test (#314) Now I know that if a package fails to build and install that the other packages that did build will install and have the correct permissions. --- test/core/ExamplesUnitTests/CMakeLists.txt | 83 +++++++++++++------ .../append_file_with_line.sh | 6 ++ .../installation/cmake_pbp_install.cmake.in | 21 +++-- .../with_subpackages/b/CMakeLists.txt | 7 ++ .../{c => b}/stuff/exec_script.sh | 0 .../{c => b}/stuff/regular_file.txt | 0 .../with_subpackages/c/CMakeLists.txt | 7 -- 7 files changed, 82 insertions(+), 42 deletions(-) create mode 100755 test/core/ExamplesUnitTests/append_file_with_line.sh rename tribits/examples/TribitsExampleProject/packages/with_subpackages/{c => b}/stuff/exec_script.sh (100%) rename tribits/examples/TribitsExampleProject/packages/with_subpackages/{c => b}/stuff/regular_file.txt (100%) diff --git a/test/core/ExamplesUnitTests/CMakeLists.txt b/test/core/ExamplesUnitTests/CMakeLists.txt index 548f77dbb..16f423cad 100644 --- a/test/core/ExamplesUnitTests/CMakeLists.txt +++ b/test/core/ExamplesUnitTests/CMakeLists.txt @@ -1323,6 +1323,7 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_perms OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 XHOSTTYPE Windows + TEST_0 MESSAGE "Copy TribitsExampleProject so we can change the source permissions" CMND cp @@ -1342,10 +1343,10 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_perms -DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON -DTribitsExProj_ENABLE_WithSubpackages=ON -DCMAKE_INSTALL_PREFIX=install_base/install + -DTribitsExProj_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR=install_base -DTribitsExProj_MAKE_INSTALL_WORLD_READABLE=TRUE -DTribitsExProj_MAKE_INSTALL_GROUP_WRITABLE=TRUE -DTribitsExProj_MAKE_INSTALL_GROUP=${TribitsExProj_INSTALL_OWNING_GROUP} - -DTribitsExProj_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR=install_base TribitsExampleProject PASS_REGULAR_EXPRESSION_ALL "Configuring done" @@ -1374,14 +1375,14 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_perms install_base/install/bin install_base/install/include install_base/install/lib - install_base/install/share/WithSubpackagesC/stuff + install_base/install/share/WithSubpackagesB/stuff PASS_REGULAR_EXPRESSION_ALL "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base" "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install" "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/bin" "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/include" "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/lib" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/share/WithSubpackagesC/stuff" + "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/share/WithSubpackagesB/stuff" ALWAYS_FAIL_ON_NONZERO_RETURN TEST_6 @@ -1392,7 +1393,7 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_perms install_base/install/include/wsp_c install_base/install/lib install_base/install/bin - install_base/install/share/WithSubpackagesC/stuff + install_base/install/share/WithSubpackagesB/stuff PASS_REGULAR_EXPRESSION_ALL "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* MixedLang.hpp" "[d]rwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* wsp_c" @@ -1409,28 +1410,50 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_perms TEST_7 MESSAGE "Make sure that exec_script.sh is exectuable" - CMND ./install_base/install/share/WithSubpackagesC/stuff/exec_script.sh + CMND ./install_base/install/share/WithSubpackagesB/stuff/exec_script.sh PASS_REGULAR_EXPRESSION "exec_script.sh executed and returned this string" ) + # NOTE: The above test checks a few important things: + # + # * The CMake install machinery will actually create multiple base dirs + # under ${CMAKE_INSTALL_PREFIX} in case they don't already exist. + # + # * The group ownership actaully will be set correctly starting with + # ${_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR} which is + # above ${CMAKE_INSTALL_PREFIX}. This is needed to address systems where + # the group sticky bit is disabled (like we see on some SNL systems, see + # ATDV-241). + # + # * Even with the source directory permissions being 'rwx------' (i.e. 700), + # the files isntalled under share/WithSubpackagesB/stuff using + # install(DIRECTORY ... USE_SOURCE_PERMISSIONS) will actually have the + # correct group and other permissions set. TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_package_by_package_perms OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 XHOSTTYPE Windows + TEST_0 MESSAGE "Copy TribitsExampleProject so we can change the source permissions" CMND cp ARGS -r ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject . TEST_1 + MESSAGE "Break the WithSubpackagesB so that it will not install" + CMND ${CMAKE_CURRENT_SOURCE_DIR}/append_file_with_line.sh + ARGS TribitsExampleProject/packages/with_subpackages/c/C.cpp + "C.cpp is broken!" + + TEST_2 MESSAGE "Make TribitsExampleProject source dir user rwX only!" CMND chmod ARGS g-rwx,o-rwx -R TribitsExampleProject - TEST_2 + TEST_3 MESSAGE "Do initial configure with just libs not tests with default install settings" CMND ${CMAKE_COMMAND} ARGS @@ -1448,22 +1471,26 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_package_by_package_perm "Configuring done" ALWAYS_FAIL_ON_NONZERO_RETURN - TEST_3 - MESSAGE "Do make to build everything" + TEST_4 + MESSAGE "Do make -k to build everything that will build" CMND make ARGS ${CTEST_BUILD_FLAGS} - ALWAYS_FAIL_ON_NONZERO_RETURN + PASS_REGULAR_EXPRESSION_ALL + "C.cpp is broken" + "packages/with_subpackages/c/CMakeFiles/pws_c.dir/C.cpp.o.*Error" + ALWAYS_FAIL_ON_ZERO_RETURN - TEST_4 + TEST_5 MESSAGE "Make install_pakage_by_package with fixup of permissions" CMND make ARGS ${CTEST_BUILD_FLAGS} install_package_by_package PASS_REGULAR_EXPRESSION_ALL - ".*/install_base/install/include/wsp_c/C.hpp" - ".*/install_base/install/lib/libpws_c.a" + "The global install failed so resorting to package-by-package installs" + ".*/install_base/install/include/B.hpp" + ".*/install_base/install/lib/libpws_b.a" "Running: chgrp ${TribitsExProj_INSTALL_OWNING_GROUP} -R .*/TriBITS_TribitsExampleProject_install_package_by_package_perms/install_base" "Running: chmod g[+]rwX,o[+]rX -R .*/TriBITS_TribitsExampleProject_install_package_by_package_perms/install_base" - ALWAYS_FAIL_ON_NONZERO_RETURN + ALWAYS_FAIL_ON_ZERO_RETURN - TEST_5 + TEST_6 MESSAGE "Check some installed directory permissions and the owning group" CMND ls ARGS -ld install_base @@ -1471,43 +1498,47 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_package_by_package_perm install_base/install/bin install_base/install/include install_base/install/lib - install_base/install/share/WithSubpackagesC/stuff + install_base/install/share/WithSubpackagesB/stuff PASS_REGULAR_EXPRESSION_ALL "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base" "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install" "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/bin" "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/include" "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/lib" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/share/WithSubpackagesC/stuff" + "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/share/WithSubpackagesB/stuff" ALWAYS_FAIL_ON_NONZERO_RETURN - TEST_6 + TEST_7 MESSAGE "Check some installed file permissions" CMND ls ARGS -l install_base/install install_base/install/include - install_base/install/include/wsp_c install_base/install/lib install_base/install/bin - install_base/install/share/WithSubpackagesC/stuff + install_base/install/share/WithSubpackagesB/stuff PASS_REGULAR_EXPRESSION_ALL "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* MixedLang.hpp" - "[d]rwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* wsp_c" - "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* C.hpp" - "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* Makefile.export.WithSubpackagesC" - "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* libpws_c.a" + "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* B.hpp" + "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* Makefile.export.WithSubpackagesB" + "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* libpws_b.a" "[-]rwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* exec_script.sh" "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* regular_file.txt" ALWAYS_FAIL_ON_NONZERO_RETURN - TEST_7 + TEST_8 MESSAGE "Make sure that exec_script.sh is exectuable" - CMND ./install_base/install/share/WithSubpackagesC/stuff/exec_script.sh + CMND ./install_base/install/share/WithSubpackagesB/stuff/exec_script.sh PASS_REGULAR_EXPRESSION "exec_script.sh executed and returned this string" ) - + # NOTE: In addition to the same checks performed by the test + # TribitsExampleProject_install_perms described above, this above test also + # ensures that owning group and directory permissions get set even if there + # is a package install failure. The other packages that did build correctly + # will get installed and all of the files and directories that did install + # will have the correct group and permissions. + TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_ALL_ST_NoFortran_enable_installation_testing OVERALL_WORKING_DIRECTORY TEST_NAME diff --git a/test/core/ExamplesUnitTests/append_file_with_line.sh b/test/core/ExamplesUnitTests/append_file_with_line.sh new file mode 100755 index 000000000..cfde6be00 --- /dev/null +++ b/test/core/ExamplesUnitTests/append_file_with_line.sh @@ -0,0 +1,6 @@ +#!/bin/bash -e + +FILE_TO_EDIT=$1 +LINE_TO_ADD=$2 + +echo "$LINE_TO_ADD" >> $FILE_TO_EDIT diff --git a/tribits/core/installation/cmake_pbp_install.cmake.in b/tribits/core/installation/cmake_pbp_install.cmake.in index 1a8f413e3..14ee7e532 100644 --- a/tribits/core/installation/cmake_pbp_install.cmake.in +++ b/tribits/core/installation/cmake_pbp_install.cmake.in @@ -12,6 +12,7 @@ execute_process( RESULT_VARIABLE global_install_rtn) if (NOT global_install_rtn EQUAL 0) + message( "\n" "***\n" @@ -19,21 +20,23 @@ if (NOT global_install_rtn EQUAL 0) "***\n" "\n" ) + foreach (pkg_binary_dir ${TRIBITS_ENABLED_PACKAGES_BINARY_DIRS}) execute_process(COMMAND @CMAKE_COMMAND@ -P cmake_install.cmake WORKING_DIRECTORY ${pkg_binary_dir} RESULT_VARIABLE global_install_rtn) endforeach() message(SEND_ERROR "Error, full install failed!") -endif() -set(set_installed_group_and_permissions_file - "${PROJECT_BINARY_DIR}/set_installed_group_and_permissions.cmake") -if (EXISTS "${set_installed_group_and_permissions_file}") - execute_process( - COMMAND @CMAKE_COMMAND@ -P "${set_installed_group_and_permissions_file}" - RESULT_VARIABLE set_installed_rtn) - if (NOT global_install_rtn EQUAL 0) - message(SEND_ERROR "ERROR: Fixup of group and permissions filed!") + set(set_installed_group_and_permissions_file + "${PROJECT_BINARY_DIR}/set_installed_group_and_permissions.cmake") + if (EXISTS "${set_installed_group_and_permissions_file}") + execute_process( + COMMAND @CMAKE_COMMAND@ -P "${set_installed_group_and_permissions_file}" + RESULT_VARIABLE set_installed_rtn) + if (NOT global_install_rtn EQUAL 0) + message(SEND_ERROR "ERROR: Fixup of group and permissions filed!") + endif() endif() + endif() diff --git a/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt b/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt index 6637ed10c..d31a7f610 100644 --- a/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt +++ b/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt @@ -4,4 +4,11 @@ ADD_SUBDIRECTORY(src) TRIBITS_ADD_TEST_DIRECTORIES(tests) +INSTALL( DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/stuff" + DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${PACKAGE_NAME}" + USE_SOURCE_PERMISSIONS PATTERN "*~" EXCLUDE ) +# Above, we must use 'USE_SOURCE_PERMISSIONS' to preserve the executable +# permission on the scripts in that directory. (TriBITS will add commands to +# fix the permissions after the install.) + TRIBITS_SUBPACKAGE_POSTPROCESS() diff --git a/tribits/examples/TribitsExampleProject/packages/with_subpackages/c/stuff/exec_script.sh b/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/exec_script.sh similarity index 100% rename from tribits/examples/TribitsExampleProject/packages/with_subpackages/c/stuff/exec_script.sh rename to tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/exec_script.sh diff --git a/tribits/examples/TribitsExampleProject/packages/with_subpackages/c/stuff/regular_file.txt b/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/regular_file.txt similarity index 100% rename from tribits/examples/TribitsExampleProject/packages/with_subpackages/c/stuff/regular_file.txt rename to tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/regular_file.txt diff --git a/tribits/examples/TribitsExampleProject/packages/with_subpackages/c/CMakeLists.txt b/tribits/examples/TribitsExampleProject/packages/with_subpackages/c/CMakeLists.txt index 818043be8..87a756576 100644 --- a/tribits/examples/TribitsExampleProject/packages/with_subpackages/c/CMakeLists.txt +++ b/tribits/examples/TribitsExampleProject/packages/with_subpackages/c/CMakeLists.txt @@ -17,11 +17,4 @@ TRIBITS_ADD_LIBRARY(pws_c TRIBITS_ADD_TEST_DIRECTORIES(tests) -INSTALL( DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/stuff" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${PACKAGE_NAME}" - USE_SOURCE_PERMISSIONS PATTERN "*~" EXCLUDE ) -# Above, we must use 'USE_SOURCE_PERMISSIONS' to preserve the executable -# permission on the scripts in that directory. (TriBITS will add commands to -# fix the permissions after the install.) - TRIBITS_SUBPACKAGE_POSTPROCESS()