]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
bundle: linux shared lib bundling
authorThomas Debesse <dev@illwieckz.net>
Thu, 1 Aug 2019 19:15:08 +0000 (21:15 +0200)
committerThomas Debesse <dev@illwieckz.net>
Mon, 5 Aug 2019 17:01:17 +0000 (19:01 +0200)
- always rely on up-to-date x11 and gl libraries, bundling them will break on future distros

bundle/CMakeLists.txt
library-bundler

index 1cb5a2214e05fb7562ddf3921ced5c3a9d1f90db..1e2546d06d4060cfa164a5859a47871238bacbb4 100644 (file)
@@ -1,5 +1,7 @@
 if (WIN32)
     set(BUNDLE_OS_NAME "windows")
 if (WIN32)
     set(BUNDLE_OS_NAME "windows")
+elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+    set(BUNDLE_OS_NAME "linux")
 else ()
     set(BUNDLE_OS_NAME "unsupported")
 endif ()
 else ()
     set(BUNDLE_OS_NAME "unsupported")
 endif ()
index 0ef9567c3c4a91896c6b35e3ddeaad7e2a4e846a..cdf2e960bae0206e4eeb75693df1f36bf0e69de0 100755 (executable)
@@ -37,6 +37,10 @@ Common::stripLdd () {
 
 Multi::excludeLdd () {
        case "${system_name}" in
 
 Multi::excludeLdd () {
        case "${system_name}" in
+               'linux')
+                       egrep -v '/libc\./|/libX|/libxcb|/libGL' \
+                       | egrep -v '/libbsd\.|/libICE\.|/libselinux\.|/libSM.\.'
+                       ;;
                'windows')
                        egrep -i '\.dll => [A-Z]:\\msys64\\' \
                        ;;
                'windows')
                        egrep -i '\.dll => [A-Z]:\\msys64\\' \
                        ;;
@@ -54,6 +58,9 @@ Multi::printLdd () {
        local exe_file="${1}"
 
        case "${system_name}" in
        local exe_file="${1}"
 
        case "${system_name}" in
+               'linux')
+                       ldd "${exe_file}"
+                       ;;
                'windows')
                        ntldd --recursive "${exe_file}"
                        ;;
                'windows')
                        ntldd --recursive "${exe_file}"
                        ;;
@@ -62,6 +69,9 @@ Multi::printLdd () {
 
 Multi::getGtkThemeName () {
        case "${system_name}" in
 
 Multi::getGtkThemeName () {
        case "${system_name}" in
+               'linux')
+                       echo 'Adwaita'
+                       ;;
                'windows')
                        echo 'MS-Windows'
                        ;;
                'windows')
                        echo 'MS-Windows'
                        ;;
@@ -70,6 +80,9 @@ Multi::getGtkThemeName () {
 
 Multi::getGtkLibName () {
        case "${system_name}" in
 
 Multi::getGtkLibName () {
        case "${system_name}" in
+               'linux')
+                       echo 'libgtk-x11-2.0.so.0'
+                       ;;
                'windows')
                        echo 'libgtk-win32-2.0-0.dll'
                        ;;
                'windows')
                        echo 'libgtk-win32-2.0-0.dll'
                        ;;
@@ -80,6 +93,10 @@ Multi::getRootPrefix () {
        local lib_file="${1}"
 
        case "${system_name}" in
        local lib_file="${1}"
 
        case "${system_name}" in
+               'linux')
+                       echo "${lib_file}" \
+                       | cut -f2 -d'/'
+                       ;;
                'windows')
                        basename "${lib_file}" \
                        | xargs -n1 -P 1 which \
                'windows')
                        basename "${lib_file}" \
                        | xargs -n1 -P 1 which \
@@ -92,6 +109,10 @@ Multi::getLibPrefix () {
        local lib_file="${1}"
 
        case "${system_name}" in
        local lib_file="${1}"
 
        case "${system_name}" in
+               'linux')
+                       dirname "${lib_file}" \
+                       | cut -f3- -d'/'
+                       ;;
                'windows')
                        echo 'lib'
                        ;;
                'windows')
                        echo 'lib'
                        ;;
@@ -167,6 +188,21 @@ Multi::cleanUp () {
                -exec rmdir --ignore-fail-on-non-empty {} \;
 }
 
                -exec rmdir --ignore-fail-on-non-empty {} \;
 }
 
+Linux::patchExe () {
+       local exe_file="${1}"
+
+       patchelf --set-rpath "${rpath_string}" "${exe_file}"
+}
+
+Linux::patchLib () {
+       local lib_dir="${1}"
+
+       find "${lib_dir}" \
+               -type f \
+               -name '*.so*' \
+               -exec patchelf --set-rpath "${rpath_string}" {} \;
+}
+
 Windows::listLibForManifest () {
        local lib_dir="${1}"
 
 Windows::listLibForManifest () {
        local lib_dir="${1}"
 
@@ -199,8 +235,11 @@ bundle_dir="$(Common::getPath "${bundle_dir}")"
 registry_dir="${bundle_dir}/registry"
 lib_dir="${bundle_dir}/lib"
 
 registry_dir="${bundle_dir}/registry"
 lib_dir="${bundle_dir}/lib"
 
+manifest_file="${lib_dir}/lib.manifest"
+
 rpath_string='@executable_path:lib'
 
 rpath_string='@executable_path:lib'
 
+exe_action='Common::noOp'
 lib_action='Common::noOp'
 
 case "${system_name}" in
 lib_action='Common::noOp'
 
 case "${system_name}" in
@@ -209,6 +248,10 @@ case "${system_name}" in
                Common::getPath "${exe_file}" > "${registry_dir}/$(uuidgen)"
                exit
                ;;
                Common::getPath "${exe_file}" > "${registry_dir}/$(uuidgen)"
                exit
                ;;
+       'linux')
+               exe_action='Linux::patchExe'
+               lib_action='Linux::patchLib'
+               ;;
        'windows')
                lib_action='Windows::writeManifest'
                ;;
        'windows')
                lib_action='Windows::writeManifest'
                ;;
@@ -231,6 +274,8 @@ then
                "${exe_action}" "${exe_file}"
 
                rm "${registry_entry}"
                "${exe_action}" "${exe_file}"
 
                rm "${registry_entry}"
+
+               "${exe_action}" "${exe_file}"
        done
 
        rmdir "${registry_dir}"
        done
 
        rmdir "${registry_dir}"