From 9df704157539388b091ff0936f79c34d4ca6993d Mon Sep 17 00:00:00 2001 From: Marco Magdy Date: Fri, 21 Dec 2018 09:57:22 -0800 Subject: [PATCH] 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. --- packaging/packager | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packaging/packager b/packaging/packager index a1f41ce..a8b675b 100755 --- a/packaging/packager +++ b/packaging/packager @@ -89,10 +89,6 @@ libc_libs+=$(package_libc_via_dpkg) libc_libs+=$(package_libc_via_rpm) libc_libs+=$(package_libc_via_pacman) -if [[ $INCLUDE_LIBC == true ]]; then - list+=$libc_libs; -fi - mkdir -p "$PKG_DIR/bin" "$PKG_DIR/lib" for i in $list @@ -101,12 +97,12 @@ do continue fi - if [[ $INCLUDE_LIBC == false ]]; then - matched=$(echo $libc_libs | grep --count $i) || true # prevent the non-zero exit status from terminating the script - if [ $matched -gt 0 ]; then - continue - fi + # Do not copy libc files which are directly linked + matched=$(echo $libc_libs | grep --count $i) || true # prevent the non-zero exit status from terminating the script + if [ $matched -gt 0 ]; then + continue fi + cp $i $PKG_DIR/lib filename=`basename $i` if [[ -z "${filename##ld-*}" ]]; then @@ -114,6 +110,13 @@ do fi done +if [[ $INCLUDE_LIBC == true ]]; then + for i in $libc_libs + do + cp --no-dereference $i $PKG_DIR/lib + done +fi + bootstrap_script=$(cat < /dev/null -zip -r $PKG_BIN_FILENAME.zip * +zip -yr $PKG_BIN_FILENAME.zip * ORIGIN_DIR=$(dirs -l +1) mv $PKG_BIN_FILENAME.zip $ORIGIN_DIR popd > /dev/null