Skip to content

Commit d54b479

Browse files
committed
Handle linking to the loader's symlink
Fixes #51
1 parent 13e5bd6 commit d54b479

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packaging/packager

+12-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ do
115115
filename=$(basename "$i")
116116
if [[ -z "${filename##ld-*}" ]]; then
117117
PKG_LD=$filename # Use this file as the loader
118-
cp "$i" $PKG_DIR/lib
118+
cp "$i" "$PKG_DIR/lib"
119119
fi
120120
continue
121121
fi
@@ -128,12 +128,23 @@ if [[ $INCLUDE_LIBC == true ]]; then
128128
do
129129
filename=$(basename "$i")
130130
if [[ -z "${filename##ld-*}" ]]; then
131+
# if the loader is empty, then the binary is probably linked to a symlink of the loader. The symlink will
132+
# not show up when quering the package manager for libc files. So, in this case, we want to copy the loader
133+
if [[ -z "$PKG_LD" ]]; then
134+
PKG_LD=$filename
135+
cp "$i" "$PKG_DIR/lib" # we want to follow the symlink (default behavior)
136+
fi
131137
continue # We don't want the dynamic loader's symlink because its target is an absolute path (/lib/ld-*).
132138
fi
133139
cp --no-dereference "$i" "$PKG_DIR/lib"
134140
done
135141
fi
136142

143+
if [[ -z "$PKG_LD" ]]; then
144+
echo "Failed to identify, locate or package the loader. Please file an issue on Github!" 1>&2
145+
exit 1
146+
fi
147+
137148
bootstrap_script=$(cat <<EOF
138149
#!/bin/bash
139150
set -euo pipefail

0 commit comments

Comments
 (0)