diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-03-14 20:31:12 +0100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-03-14 20:31:12 +0100 |
commit | 3c3d81e5a001b82fadb75607b35b303e4c46f7bf (patch) | |
tree | 98b2011881822dc691fa3d57105f790ebb86d6f3 | |
parent | b2557439592960345efddb428e964b5a457827fb (diff) | |
download | mbuto-3c3d81e5a001b82fadb75607b35b303e4c46f7bf.tar mbuto-3c3d81e5a001b82fadb75607b35b303e4c46f7bf.tar.gz mbuto-3c3d81e5a001b82fadb75607b35b303e4c46f7bf.tar.bz2 mbuto-3c3d81e5a001b82fadb75607b35b303e4c46f7bf.tar.lz mbuto-3c3d81e5a001b82fadb75607b35b303e4c46f7bf.tar.xz mbuto-3c3d81e5a001b82fadb75607b35b303e4c46f7bf.tar.zst mbuto-3c3d81e5a001b82fadb75607b35b303e4c46f7bf.zip |
mbuto: Add support for additional libraries typically loaded via dlopen(3)
Example: glibc needs, for basic tasks such as domain resolution,
libnss_files and libnss_dns, which in turn links to libresolv.
Add a LIBS_DLOPEN variable to hold pairs of libraries typically
doing this and additional libraries to copy -- not a complete list,
just what's strictly needed for basic functionality.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rwxr-xr-x | mbuto | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -27,6 +27,12 @@ PROGS="${PROGS:-kata-agent ash,dash,bash ip mount ls modprobe insmod mkdir nsenter ln}" +# Libraries commonly loaded via dlopen(3) (strictly needed for basic tasks) +LIBS_DLOPEN="${LIBS_DLOPEN:- + libc.so.6 libnss_dns.so.2 + libc.so.6 libnss_files.so.2 +}" + # Links: installed target program, then link name, one per line LINKS="${LINKS:- kata-agent /init @@ -397,6 +403,21 @@ libs_copy_ld_so() { "${CP}" --parents --preserve=all "${1}" "${wd}" } +# libs_dlopen_copy() - Recursively copy matching libraries from LIBS_DLOPEN +# $1: Library (base path) that loads further libraries using dlopen(3) +libs_dlopen_copy() { + __match= + for __t in ${LIBS_DLOPEN}; do + [ -z "${__match}" ] && __match="${__t}" && continue + if [ "${__match}" = "$(basename ${1})" ]; then + __path="$(dirname "${1}")/${__t}" + "${CP}" --parents --preserve=all "${__path}" "${wd}" + libs_copy "${__path}" + __match= + fi + done +} + # libs_copy() - Recursively copy shared dependencies for programs and libraries # $1: Host path to program or library libs_copy() { @@ -427,6 +448,8 @@ libs_copy() { libs_copy "${__path}" done + libs_dlopen_copy "${1}" + # Dynamic linker is listed as single path, make sure we copy it once __ld_so= for __l in $("${LDD}" "${1}" 2>/dev/null); do @@ -820,6 +843,11 @@ usage() { echo "Environmental variables can be used to replace:" echo " PROGS" echo " base programs" + echo " LIBS_DLOPEN" + echo " additional libraries, not directly linked from" + echo " programs, typically loaded via dlopen(3) by matching" + echo " libraries, in the form" + echo " MATCHING_LIBRARY ADDITIONAL_LIBRARY" echo " KMODS" echo " base kernel modules" echo " NODES" |