Skip to content

Commit d367584

Browse files
committed
Add exception for the loader when copying libc
The loader's symlink points to the absolute path of the ld.so file which on the host machine will reference the wrong file. The whole point is to use the packaged loader, not the host machine's.
1 parent 9df7041 commit d367584

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packaging/packager

+11-6
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,27 @@ do
9797
continue
9898
fi
9999

100-
# Do not copy libc files which are directly linked
100+
# Do not copy libc files which are directly linked unless it's the dynamic loader
101101
matched=$(echo $libc_libs | grep --count $i) || true # prevent the non-zero exit status from terminating the script
102102
if [ $matched -gt 0 ]; then
103+
filename=`basename $i`
104+
if [[ -z "${filename##ld-*}" ]]; then
105+
PKG_LD=$filename # Use this file as the loader
106+
cp $i $PKG_DIR/lib
107+
fi
103108
continue
104109
fi
105110

106111
cp $i $PKG_DIR/lib
107-
filename=`basename $i`
108-
if [[ -z "${filename##ld-*}" ]]; then
109-
PKG_LD=$filename # Use this file as the loader
110-
fi
111112
done
112113

113114
if [[ $INCLUDE_LIBC == true ]]; then
114115
for i in $libc_libs
115116
do
117+
filename=`basename $i`
118+
if [[ -z "${filename##ld-*}" ]]; then
119+
continue # We don't want the dynamic loader's symlink because its target is an absolute path (/lib/ld-*).
120+
fi
116121
cp --no-dereference $i $PKG_DIR/lib
117122
done
118123
fi
@@ -143,7 +148,7 @@ fi
143148
chmod +x "$PKG_DIR/bootstrap"
144149
# some shenanigans to create the right layout in the zip file without extraneous directories
145150
pushd "$PKG_DIR" > /dev/null
146-
zip -yr $PKG_BIN_FILENAME.zip *
151+
zip --symlinks --recurse-paths $PKG_BIN_FILENAME.zip *
147152
ORIGIN_DIR=$(dirs -l +1)
148153
mv $PKG_BIN_FILENAME.zip $ORIGIN_DIR
149154
popd > /dev/null

0 commit comments

Comments
 (0)