#!/usr/bin/env bash set -eu dir=$1 if ! [ -d "$dir/sysroot" ]; then echo "No such sysroot directory: $dir/sysroot" >&2 exit 1 fi title=${2:-$1} rm -rf $dir.size cp -r $dir/sysroot $dir.size ( cd $dir.size find . \ -name '*.a' \ -o -name '*.o' \ -print0 \ | xargs --null rm find . \ -type d \ '(' -name include -o -name info -o -name i18n ')' \ -print0 \ | xargs --null rm -rf strip $(find . -name '*.so' ! -name libc.so ! -name libpthread.so) find sbin usr/bin usr/sbin usr/libexec -type f \ ! -name tzselect ! -name ldd ! -name catchsegv ! -name '[xm]trace' \ | xargs strip ) ( du -s "$dir.size" size "$dir.size/lib/libc.so.6" echo $title ) \ | awk ' NR == 1 { treekiB = $1 } NR == 3 { libcB = $4 } NR == 4 { sub (/option-groups-/, ""); sub (/\.config/, ""); sub (/no-OPTION_EGLIBC_/, ""); title = $0 } END { # full_treekiB = 94756 # with locale data full_treekiB = 31236 # without locale data full_libcB = 1254017.0 print treekiB, libcB printf "%-40s", title printf "%2.1f MiB (%3.0f%%) ", treekiB / 1024, (treekiB * 100 / full_treekiB) printf "%4.0f KiB (%3.0f%%) ", libcB / 1024, (libcB * 100 / full_libcB) printf "\n" } '