Skip to content

Commit

Permalink
Don't trust FUSE, ever. :D
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Jun 5, 2024
1 parent fcb8e1e commit 5e3a088
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions cmake/modules/DownloadBinary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,10 @@ macro(download_binary RESULT_VARIABLE _url _name _prepend_to_path)

# Check if fuse is needed
if("${RESULT_VARIABLE}" MATCHES "\\.AppImage$" OR "${_name}" MATCHES "\\.AppImage$")
message("Checking if FUSE is available to the kernel...")
set(_${RESULT_VARIABLE}_NEEDS_FUSE true)
message(STATUS "AppImage detected, we'll extract the AppImage before using")
set(_${RESULT_VARIABLE}_IS_APPIMAGE true)
endif()

# Check if fuse is available
if(_${RESULT_VARIABLE}_NEEDS_FUSE)
# Ensure we only check on first call
if(NOT _FUSE_CHECKED)
execute_process(COMMAND fusermount -V
${_output_quiet}
COMMAND_ECHO ${_command_echo}
RESULT_VARIABLE _status_code)
set(_FUSED_CHECKED TRUE)
if(_status_code EQUAL 0)
set(_FUSE_FOUND true)
message("FUSE is available")
else()
message("FUSE is NOT available, we'll extract the AppImage before using")
endif()
endif()
endif()

# Determine a suitable working directory
if(CMAKE_CURRENT_BINARY_DIR)
# Assume we're called from configure step
Expand Down Expand Up @@ -117,11 +99,13 @@ macro(download_binary RESULT_VARIABLE _url _name _prepend_to_path)
endif()

# We need to create a subdirectory for this binary and symlink it's AppRun to where it's expected
if(_${RESULT_VARIABLE}_NEEDS_FUSE AND NOT _FUSE_FOUND)
if(_${RESULT_VARIABLE}_IS_APPIMAGE)
if(NOT COMMAND create_symlink)
include(CreateSymlink)
endif()

message(STATUS "Extracting ${_${RESULT_VARIABLE}} to ${_working_dir}/.${_name}/")

# extract appimage
execute_process(COMMAND "${_${RESULT_VARIABLE}}" --appimage-extract
WORKING_DIRECTORY "${_working_dir}"
Expand All @@ -138,6 +122,7 @@ macro(download_binary RESULT_VARIABLE _url _name _prepend_to_path)
file(REMOVE "${_${RESULT_VARIABLE}}")

# symlink the expected binary name to the AppRun file
message(STATUS "Creating a symbolic link ${_${RESULT_VARIABLE}} which points to ${_working_dir}/.${_name}/squashfs-root/AppRun")
create_symlink("${_working_dir}/.${_name}/squashfs-root/AppRun" "${_${RESULT_VARIABLE}}")
endif()

Expand Down

0 comments on commit 5e3a088

Please sign in to comment.