From d399a694d67b379a2fb456ec69c2336eeb3fab64 Mon Sep 17 00:00:00 2001 From: AlbertXingZhang <12808025+AlbertXingZhang@users.noreply.github.com> Date: Thu, 7 Nov 2024 09:59:23 -0800 Subject: [PATCH 1/2] fix the failure when the dynamic loader path is different from the one from libc --- packaging/packager | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packaging/packager b/packaging/packager index c050696..92dbf57 100755 --- a/packaging/packager +++ b/packaging/packager @@ -128,13 +128,14 @@ do continue fi - # Do not copy libc files which are directly linked unless it's the dynamic loader + filename=$(basename "$i") + if [[ -z "${filename##ld-*}" ]]; then + PKG_LD=$filename # Use this file as the loader + cp "$i" "$PKG_DIR/lib" + fi + + # Do not copy libc files which are directly linked if hasElement "$i" "${libc_libs[@]}"; then - filename=$(basename "$i") - if [[ -z "${filename##ld-*}" ]]; then - PKG_LD=$filename # Use this file as the loader - cp "$i" "$PKG_DIR/lib" - fi continue fi From 934e53fea16b0a13fd8e58cc6029904272090716 Mon Sep 17 00:00:00 2001 From: AlbertXingZhang <12808025+AlbertXingZhang@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:04:50 -0800 Subject: [PATCH 2/2] use the dynamic loader from libc if the one from ldd is not found in libc --- packaging/packager | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packaging/packager b/packaging/packager index 92dbf57..5d1e6d8 100755 --- a/packaging/packager +++ b/packaging/packager @@ -128,21 +128,20 @@ do continue fi - filename=$(basename "$i") - if [[ -z "${filename##ld-*}" ]]; then - PKG_LD=$filename # Use this file as the loader - cp "$i" "$PKG_DIR/lib" - fi - - # Do not copy libc files which are directly linked + # Do not copy libc files which are directly linked unless it's the dynamic loader if hasElement "$i" "${libc_libs[@]}"; then + filename=$(basename "$i") + if [[ -z "${filename##ld-*}" ]]; then + PKG_LD=$filename # Use this file as the loader + cp "$i" "$PKG_DIR/lib" + fi continue fi cp "$i" $PKG_DIR/lib done -if [[ $INCLUDE_LIBC == true ]]; then +if [[ $INCLUDE_LIBC == true || -z "$PKG_LD" ]]; then for i in "${libc_libs[@]}" do filename=$(basename "$i") @@ -152,10 +151,15 @@ if [[ $INCLUDE_LIBC == true ]]; then if [[ -z "$PKG_LD" ]]; then PKG_LD=$filename cp "$i" "$PKG_DIR/lib" # we want to follow the symlink (default behavior) + if [[ $INCLUDE_LIBC != true ]]; then + break + fi fi continue # We don't want the dynamic loader's symlink because its target is an absolute path (/lib/ld-*). fi - cp --no-dereference "$i" "$PKG_DIR/lib" + if [[ $INCLUDE_LIBC == true ]]; then + cp --no-dereference "$i" "$PKG_DIR/lib" + fi done fi