From 351e7cbf01d90c04424229ccb3e7e2b859a81011 Mon Sep 17 00:00:00 2001 From: tresf Date: Sat, 8 Feb 2025 01:55:05 -0500 Subject: [PATCH] Add libdb-5.so to optional as symlink --- cmake/linux/LinuxDeploy.cmake | 54 ++++++++++++++++++++++++--- cmake/linux/apprun-hooks/jack-hook.sh | 2 +- src/3rdparty/weakjack/CMakeLists.txt | 6 +-- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/cmake/linux/LinuxDeploy.cmake b/cmake/linux/LinuxDeploy.cmake index da328000109..01462a3c00b 100644 --- a/cmake/linux/LinuxDeploy.cmake +++ b/cmake/linux/LinuxDeploy.cmake @@ -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) @@ -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}") @@ -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) @@ -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() \ No newline at end of file diff --git a/cmake/linux/apprun-hooks/jack-hook.sh b/cmake/linux/apprun-hooks/jack-hook.sh index e43a635c4ae..1b3f375a868 100644 --- a/cmake/linux/apprun-hooks/jack-hook.sh +++ b/cmake/linux/apprun-hooks/jack-hook.sh @@ -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 diff --git a/src/3rdparty/weakjack/CMakeLists.txt b/src/3rdparty/weakjack/CMakeLists.txt index a855c8e3208..15c6d953e73 100644 --- a/src/3rdparty/weakjack/CMakeLists.txt +++ b/src/3rdparty/weakjack/CMakeLists.txt @@ -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) @@ -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() \ No newline at end of file +endif()