Skip to content

Commit 9df7041

Browse files
committed
Reduce bloat in the output zip package
Avoid dereferencing symlinks when iterating over libc files. Otherwise, we end up with two copies of the same file, one with the symlink name and the actual file. Files which are directly linked to the executable are listed (in the ldd output) by their symlink name. Those are fine to dereference because there's only a single mention of them. The actual (dereferenced) file is not listed in output from ldd.
1 parent 0ce4d7a commit 9df7041

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

packaging/packager

+13-10
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ libc_libs+=$(package_libc_via_dpkg)
8989
libc_libs+=$(package_libc_via_rpm)
9090
libc_libs+=$(package_libc_via_pacman)
9191

92-
if [[ $INCLUDE_LIBC == true ]]; then
93-
list+=$libc_libs;
94-
fi
95-
9692
mkdir -p "$PKG_DIR/bin" "$PKG_DIR/lib"
9793

9894
for i in $list
@@ -101,19 +97,26 @@ do
10197
continue
10298
fi
10399

104-
if [[ $INCLUDE_LIBC == false ]]; then
105-
matched=$(echo $libc_libs | grep --count $i) || true # prevent the non-zero exit status from terminating the script
106-
if [ $matched -gt 0 ]; then
107-
continue
108-
fi
100+
# Do not copy libc files which are directly linked
101+
matched=$(echo $libc_libs | grep --count $i) || true # prevent the non-zero exit status from terminating the script
102+
if [ $matched -gt 0 ]; then
103+
continue
109104
fi
105+
110106
cp $i $PKG_DIR/lib
111107
filename=`basename $i`
112108
if [[ -z "${filename##ld-*}" ]]; then
113109
PKG_LD=$filename # Use this file as the loader
114110
fi
115111
done
116112

113+
if [[ $INCLUDE_LIBC == true ]]; then
114+
for i in $libc_libs
115+
do
116+
cp --no-dereference $i $PKG_DIR/lib
117+
done
118+
fi
119+
117120
bootstrap_script=$(cat <<EOF
118121
#!/bin/bash
119122
set -euo pipefail
@@ -140,7 +143,7 @@ fi
140143
chmod +x "$PKG_DIR/bootstrap"
141144
# some shenanigans to create the right layout in the zip file without extraneous directories
142145
pushd "$PKG_DIR" > /dev/null
143-
zip -r $PKG_BIN_FILENAME.zip *
146+
zip -yr $PKG_BIN_FILENAME.zip *
144147
ORIGIN_DIR=$(dirs -l +1)
145148
mv $PKG_BIN_FILENAME.zip $ORIGIN_DIR
146149
popd > /dev/null

0 commit comments

Comments
 (0)