X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=library-bundler;h=93ef662a82ffaf81e3ceb67a35a437cdc2b03d47;hb=5217679e3fb04968ed2ef8c19e41554fa7f11072;hp=ceac213fc61a4d99e667b9dc7f14de2664fcc1fe;hpb=f65bcfa852cc0a122c6a1542b81f9c2167df4c5f;p=xonotic%2Fnetradiant.git diff --git a/library-bundler b/library-bundler index ceac213f..93ef662a 100755 --- a/library-bundler +++ b/library-bundler @@ -1,5 +1,7 @@ #! /usr/bin/env bash +set -e + Common::noOp () { printf '' } @@ -24,7 +26,8 @@ Common::getPath () { else printf '%s\n' "${file_path}" fi - fi + fi \ + | sed -e 's|/*$||' } Common::grepLdd () { @@ -45,9 +48,9 @@ Multi::excludeLdd () { # - since we ask user to instal gtk, we can also ask them to install gtkglext, # which is likely to pull gtk itself, x11 and gl dependencies # - old fontconfig does not work correctly if newer fontconfig configuration is installed - # - if gtk and fontconfig is installed, freetype is - egrep -v '/libc\.|/libdl\.|/libm\.|/libX|/libxcb|/libGL' \ - | egrep -v '/libatk|/libgdk|/libgtk|/libgio|/libglib|/libgmodule|/libgobject|/libfontconfig|/libfreetype' + # - if gtk and fontconfig is installed, pango and freetype are + egrep -v '/libc\.|/libstdc\+\+\.|/libdl\.|/libm\.|/libX|/libxcb|/libGL|/libICE\.|/libSM\.|/libpthread\.' \ + | egrep -v '/libatk|/libgdk|/libgtk|/libgio|/libglib|/libgmodule|/libgobject|/libcairo|/libpango|/libfontconfig|/libfreetype' ;; 'windows') egrep -i '\.dll => [A-Z]:\\msys64\\' \ @@ -186,7 +189,7 @@ Multi::bundleLibFromFile () { do lib_basename="$(basename "${lib_file}")" - if [ -f "${bundle_dir}/${lib_basename}" ] + if [ -f "${lib_dir}/${lib_basename}" ] then continue fi @@ -211,24 +214,61 @@ Multi::cleanUp () { -exec rm {} \; find "${bundle_dir}/lib" \ - -type d \ -depth \ + -type d \ -exec rmdir --ignore-fail-on-non-empty {} \; } +Linux::getRpath () { + local exe_file="${1}" + + local exe_dir="$(dirname "${exe_file}")" + local path_start="$(printf '%s' "${bundle_dir}" | wc -c)" + path_start="$((${path_start} + 1))" + + local exe_subdir="$(echo "${exe_dir}" | cut -c "${path_start}-" | sed -e 's|//*|/|;s|^/||')" + + local rpath_origin='$ORIGIN' + + if [ "${exe_subdir}" = '' ] + then + printf '%s/lib\n' "${rpath_origin}" + else + if [ "${exe_subdir}" = 'lib' ] + then + printf '%s\n' "${rpath_origin}" + else + local num_parent_dir="$(echo "${exe_subdir}" | tr '/' '\n' | wc -l)" + local rpath_subdir + local i=0 + while [ "${i}" -lt "${num_parent_dir}" ] + do + rpath_subdir="${rpath_subdir}/.." + i="$((${i} + 1))" + done + printf '%s%s/lib\n' "${rpath_origin}" "${rpath_subdir}" + fi + fi +} + Linux::patchExe () { local exe_file="${1}" - patchelf --set-rpath "${rpath_string}" "${exe_file}" + local linux_rpath_string=$"$(Linux::getRpath "${exe_file}")" + patchelf --set-rpath "${linux_rpath_string}" "${exe_file}" } Linux::patchLib () { local lib_dir="${1}" + local exe_file find "${lib_dir}" \ -type f \ -name '*.so*' \ - -exec patchelf --set-rpath "${rpath_string}" {} \; + | while read exe_file + do + Linux::patchExe "${exe_file}" + done } Windows::listLibForManifest () { @@ -257,7 +297,11 @@ Windows::writeManifest () { system_name="${1}"; shift bundle_dir="${1}"; shift -exe_file="${1}"; shift + +if ! [ -z "${1}" ] +then + exe_file="${1}"; shift +fi bundle_dir="$(Common::getPath "${bundle_dir}")" registry_dir="${bundle_dir}/registry" @@ -265,8 +309,6 @@ lib_dir="${bundle_dir}/lib" manifest_file="${lib_dir}/lib.manifest" -rpath_string='@executable_path:lib' - exe_action='Common::noOp' lib_action='Common::noOp'