I have described the issue on the cm...@cmake.org mailing list as
follows:

the CPack DEB generator executes the file tool to determine whether a
file is executable

this is a snippet from CPackDeb.cmake from cmake gitlab master:

# get file info so that we can determine if file is executable or not
    unset(CPACK_DEB_INSTALL_FILES)
    foreach(FILE_ IN LISTS FILE_PATHS_)
      execute_process(COMMAND file "./${FILE_}"
        WORKING_DIRECTORY "${WDIR}"
        OUTPUT_VARIABLE INSTALL_FILE_)
      list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}")
    endforeach()

    # Only dynamically linked ELF files are included
    # Extract only file name infront of ":"
    foreach(_FILE IN LISTS CPACK_DEB_INSTALL_FILES)
      if(_FILE MATCHES "ELF.*dynamically linked")
        string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
        list(APPEND CPACK_DEB_BINARY_FILES "${CMAKE_MATCH_1}")
        set(CONTAINS_EXECUTABLE_FILES_ TRUE)
      endif()
      if(_FILE MATCHES "ELF.*shared object")
        string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
        list(APPEND CPACK_DEB_SHARED_OBJECT_FILES "${CMAKE_MATCH_1}")
      endif()
    endforeach()

The problem is that execute_process(COMMAND file) may fail, and if it
does, we do not add the dependencies of that executable to the generated
deb file. This issue happened to us because our continuous integration
system tried building inside a minimal docker image, where /usr/bin/file
was simply not available, but it might fail for other reasons too: for
example strange things in the user's path, open file limit exceeded or
out of memory conditions.

I would therefore much prefer if the above code:
1) uses a variable ${FILE_EXECUTABLE} for the file tool defaulting to
/usr/bin/file similar to the way it uses the variable
${READELF_EXECUTABLE} for the readelf tool
2) checks the return code on every iteration of the foreach() loop, and
calls message(FATAL_ERROR) if it is non-zero.

-- 
You received this bug notification because you are a member of Kubuntu
Bugs, which is subscribed to cmake in Ubuntu.
https://bugs.launchpad.net/bugs/1647868

Title:
  CPack DEB generator shlibdeps fails silently if /usr/bin/file is not
  installed

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cmake/+bug/1647868/+subscriptions

-- 
kubuntu-bugs mailing list
kubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kubuntu-bugs

Reply via email to