Skip to content

Commit

Permalink
Add libdb-5.so to optional as symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Feb 8, 2025
1 parent ea2b21d commit 351e7cb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
54 changes: 49 additions & 5 deletions cmake/linux/LinuxDeploy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ file(GLOB EXCLUDE_LIBS
"${APP}/usr/lib/libwine*"
"${APP}/usr/lib/libcarla_native*"
"${APP}/usr/lib/${lmms}/optional/libcarla*"
"${APP}/usr/lib/${lmms}/optional/libweakjack*"
"${APP}/usr/lib/libjack*")

list(SORT EXCLUDE_LIBS)
Expand All @@ -190,9 +189,6 @@ foreach(_lib IN LISTS EXCLUDE_LIBS)
endif()
endforeach()

# Symlink jack to avoid crash for systems without it
create_symlink("${APP}/usr/lib/libweakjack.so" "${APP}/usr/lib/${lmms}/optional/libjack.so.0")

# FIXME: Remove when linuxdeploy supports subfolders https://github.com/linuxdeploy/linuxdeploy/issues/305
foreach(_lib IN LISTS LIBS)
if(EXISTS "${_lib}")
Expand Down Expand Up @@ -220,6 +216,54 @@ endforeach()

file(REMOVE_RECURSE "${SUIL_MODULES_TARGET}" "${APP}/usr/lib/${lmms}/ladspa/")

# Copy "exclude-list" lib(s) into specified location
macro(copy_excluded ldd_target name_match destination relocated_lib)
execute_process(COMMAND ldd
"${ldd_target}"
OUTPUT_VARIABLE ldd_output
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)

# escape periods to avoid double-escaping
string(REPLACE "." "\\." name_match "${name_match}")

# cli output --> list
string(REPLACE "\n" ";" ldd_list "${ldd_output}")

foreach(line ${ldd_list})
if(line MATCHES "${name_match}")
# Assumes format "libname.so.0 => /lib/location/libname.so.0 (0x00007f48d0b0e000)"
string(REPLACE " " ";" parts "${line}")
list(LENGTH parts len)
math(EXPR index "${len}-2")
list(GET parts ${index} lib)
# Resolve any possible symlinks
file(REAL_PATH "${lib}" libreal)
get_filename_component(symname "${lib}" NAME)
get_filename_component(realname "${libreal}" NAME)
file(MAKE_DIRECTORY "${destination}")
# Copy, but with original symlink name
file(COPY "${libreal}" DESTINATION "${destination}")
file(RENAME "${destination}/${realname}" "${destination}/${symname}")
set("${relocated_lib}" "${destination}/${symname}")
break()
endif()
endforeach()
endmacro()

# copy libjack
copy_excluded("${APP}/usr/bin/lmms" "libjack.so" "${APP}/usr/lib/jack" relocated_jack)
if(relocated_jack)
# libdb's not excluded, re-use macro to obtain path for symlink https://github.com/LMMS/lmms/issues/7689
copy_excluded("${relocated_jack}" "libdb-" "${APP}/usr/lib/jack" relocated_libdb)
get_filename_component(libdb_name "${relocated_libdb}" NAME)
if(relocated_libdb AND EXISTS "${APP}/usr/lib/${libdb_name}")
file(REMOVE "${relocated_libdb}")
create_symlink("${APP}/usr/lib/${libdb_name}" "${relocated_libdb}")
endif()
endif()

if(CPACK_TOOL STREQUAL "appimagetool")
# Create ".AppImage" file using appimagetool (default)

Expand Down Expand Up @@ -275,4 +319,4 @@ elseif(CPACK_TOOL STREQUAL "makeself")
message(STATUS "Installer created: ${RUN_FILE}")
else()
message(FATAL_ERROR "Packaging tool CPACK_TOOL=\"${CPACK_TOOL}\" is not yet supported")
endif()
endif()
2 changes: 1 addition & 1 deletion cmake/linux/apprun-hooks/jack-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ME="$( basename "${BASH_SOURCE[0]}")"
export LC_ALL=C
if ldd "$DIR/usr/bin/lmms" |grep "libjack.so.0" |grep "not found" > /dev/null 2>&1; then
echo "[$ME] Jack does not appear to be installed. That's OK, we'll use a dummy version instead." >&2
export LD_LIBRARY_PATH="$DIR/usr/lib/lmms/optional:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$DIR/usr/lib/jack:$LD_LIBRARY_PATH"
else
echo "[$ME] Jack appears to be installed on this system, so we'll use it." >&2
fi
Expand Down
6 changes: 2 additions & 4 deletions src/3rdparty/weakjack/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Use weak jack library linking
if(LMMS_HAVE_WEAKJACK)
add_library(weakjack SHARED
add_library(weakjack STATIC
weakjack/weak_libjack.c
)
target_include_directories(weakjack PUBLIC weakjack)
Expand All @@ -11,6 +11,4 @@ if(LMMS_HAVE_WEAKJACK)
USE_WEAK_JACK=1
NO_JACK_METADATA=1
)

install(TARGETS weakjack LIBRARY DESTINATION "${PLUGIN_DIR}/optional")
endif()
endif()

0 comments on commit 351e7cb

Please sign in to comment.