Skip to content
This repository has been archived by the owner on Feb 21, 2021. It is now read-only.

CMake install not possible without root permissions #207

Closed
varhub opened this issue Oct 30, 2015 · 9 comments
Closed

CMake install not possible without root permissions #207

varhub opened this issue Oct 30, 2015 · 9 comments

Comments

@varhub
Copy link
Contributor

varhub commented Oct 30, 2015

CMake install not possible without root permissions

Related to: http://jderobot.org/Varribas-tfm/ARDrone:cmake_advanced#Bad_permissions

Error

  file INSTALL cannot set permissions on
  "/tmp/Jderobot/build/_CPack_Packages/Linux/DEB/jderobot_5.3.0-rc1_amd64/core/usr/local/bin/introrob_py"

  file INSTALL cannot set permissions on
  "/tmp/Jderobot/build/_CPack_Packages/Linux/DEB/jderobot_5.3.0-rc1_amd64/core/usr/local/bin/refereeViewer"

Hint

ls -l /tmp/Jderobot/build/_CPack_Packages/Linux/DEB/jderobot_5.3.0-rc1_amd64/core/usr/local/bin/introrob_py
---x--x--x 1 varribas varribas 76 Oct 30 11:51 /tmp/Jderobot/build/_CPack_Packages/Linux/DEB/jderobot_5.3.0-rc1_amd64/core/usr/local/bin/introrob_py

Solution

  1. Let default permissions
  2. Add missed permissions
@varhub
Copy link
Contributor Author

varhub commented Oct 30, 2015

Let default permissions do not work. Same issue.
Is a CMake bug?

INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/introrob_py DESTINATION bin OPTIONAL)

Speed it up with per-component build
cmake .. -Dbuild-default=OFF -Dbuild_introrob_py=ON -Dbuild_refereeViewer=ON

@varhub
Copy link
Contributor Author

varhub commented Oct 30, 2015

Problem also affects to icestorm

$ make package CMAKE_INSTALL_ALWAYS=1
CPack Error: Problem running tar command: /usr/bin/fakeroot "/usr/bin/cmake" -E tar cfz data.tar.gz  ./usr
CMake Error: archive_read_disk_entry_from_file: Can't open `./usr/local/bin/icestorm'
---x--x--x 1 varribas varribas 108 Oct 30 16:24 ./usr/local/bin/icestorm

@varhub
Copy link
Contributor Author

varhub commented Oct 30, 2015

Issue is harder than expected

Problem related to

  • DESTINATION bin
  • build into /tmp
  • CMake bug

Hint

Replace DESTINATION bin by DESTINATION /tmp will work:
-rw-r--r-- 1 varribas varribas 76 Oct 30 14:33 _CPack_Packages/Linux/DEB/jderobot_5.3.0-rc1_amd64/tmp/introrob_py

Tried

  1. Inspired in http://stackoverflow.com/questions/17381910/cmake-install-installing-config-files
    Must binaries be marked as executable files with COMPONENT binaries?
    FAILED

  2. Use file(PROGRAMS instead FILES

    The PROGRAMS form is identical to the FILES form except that the default permissions for the installed file also include OWNER_EXECUTE, GROUP_EXECUTE, and WORLD_EXECUTE. This form is intended to install programs that are not targets, such as shell scripts. Use the TARGETS form to install targets built within the project.

  3. Set all permissions
    FAILED

  4. Do no set any permissions
    FAILED

  5. make package CMAKE_INSTALL_ALWAYS=1
    https://cmake.org/pipermail/cmake/2011-April/044095.html
    Delay error to tar (just like cmake_advanced#Bad_permissions)
    FAILED

  6. install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION bin FILES_MATCHING PATTERN introrob_py)
    FAILED

@varhub
Copy link
Contributor Author

varhub commented Oct 30, 2015

Tiro la toalla.
cmake .. -Dbuild-default=OFF -Dbuild_introrob_py=ON && make package -j4 2>&1 | tee cmake.log

[TRIMMED OUTPUT]
Linking CXX shared library libimgAnalyze.so
[100%] Built target imgAnalyze
Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: jderobot
CPack: - Install project: jderobot
CPack: Create package
CPackDeb: - Generating dependency list
CPack Error: Problem running tar command: /usr/bin/fakeroot "/usr/bin/cmake" -E tar cfz data.tar.gz  ./usr
Please check /tmp/Jderobot/build/_CPack_Packages/Linux/DEB/Deb.log for errors
CPack Error: Problem compressing the directory
CPack Error: Error when generating package: jderobot
make: *** [package] Error 1


# Run command: /usr/bin/fakeroot "/usr/bin/cmake" -E tar cfz data.tar.gz  ./usr
# Working directory: /tmp/Jderobot/build/_CPack_Packages/Linux/DEB/jderobot_5.3.0-rc1_amd64
# Output:
CMake Error: archive_read_disk_entry_from_file: Can't open `./usr/local/bin/icestorm'
CMake Error: Problem creating tar: data.tar.gz

@fqez
Copy link
Member

fqez commented Oct 30, 2015

Found this in cmake_install.cmake

if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
  list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
   "/usr/local/bin/icestorm")
  if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
    message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
  endif()
  if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
    message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
  endif()
file(INSTALL DESTINATION "/usr/local/bin" TYPE FILE OPTIONAL PERMISSIONS OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE FILES "/home/fran/test2/JdeRobot/src/stable/components/icestorm/icestorm")
endif()

@fqez
Copy link
Member

fqez commented Oct 30, 2015

I found a little bug in the root CMakeLists.txt. It seems that cmake is installing the same binaries twice from two different CMaksLists.txt.
The fragment I am talking about is the following (root CMakeLists):

FOREACH (currentBin ${LIST_COMPONENTS})
    #SET(EXIST EXIST-NOTFOUND)
    find_file(EXIST NAMES ${currentBin} PATHS ${CMAKE_CURRENT_SOURCE_DIR}/src/components/${currentBin})
    #IF (EXIST)
    INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/stable/components/${currentBin}/${currentBin} DESTINATION /usr/local/bin OPTIONAL PERMISSIONS OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE COMPONENT core)
    #ENDIF(EXIST)
    #MESSAGE("${EXIST}")
ENDFOREACH(currentBin)

which collides with this one (~/Jderobot/src/stable/components/introrob_py/CMakeLists.txt):

    INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/introrob_py DESTINATION bin OPTIONAL PERMISSIONS OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE WORLD_READ)

We have to delete one of them, in order to remove the incompatibility. I think the introrob_py has to be erased!

@varhub
Copy link
Contributor Author

varhub commented Oct 30, 2015

One of these two lines must be deleted.
I presume that it must be from root CMakeLists.txt
Why?

  1. install (files ${CMAKE_CURRENT_SOURCE_DIR}/src/stable/components/${currentBin}/${currentBin} is no longer valid. It also needs take into count CMAKE_BINARY_DIR
    So we have 2 types of install:
    • Precreated scripts - from source dir
    • generated binaries - from binary dir
  2. This permission specification is deprecated. To accept it, it must be labeled as PROGRAMS instead FILES
  3. It is installing every component, even not marked to compiled. So build by components is broken by this sentence.
  4. Hidden feature. It should be documented to avoid any future headaches.
  5. Previously, a component was partially removed due this problem (icestorm), so this was happened at least twice (b2a6f6a)

@varhub
Copy link
Contributor Author

varhub commented Oct 30, 2015

After testing it with @fqez (I'm just a viewer through hangouts), we can clever explain it:

  • Multiple install sentences over same file (or target) is allowed, but it will only take first on collision
  • PERMISSIONS OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE is deprecated and break it all, please do not use it.
  • Use PROGRAMS to avoid set explicitly permissions. At now, it set to 755.

These tips will fix this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants