From 93f40be56ee46c464661cb6609efb1b1e3b1c4f5 Mon Sep 17 00:00:00 2001 From: phanes Date: Fri, 26 May 2023 12:34:19 -0400 Subject: [PATCH] size reduction of iso - 6.4G --- project_config.sh | 1 + .../x86_64/components/livecd/welcome.bash | 2 +- rex.project/x86_64/components/stage1/gcc.bash | 2 +- .../x86_64/components/stage4/cleanup.bash | 82 +++++++++++++++++++ .../x86_64/components/stage4/shadow.bash | 1 - 5 files changed, 85 insertions(+), 3 deletions(-) diff --git a/project_config.sh b/project_config.sh index 94e5cb1..3201fb2 100755 --- a/project_config.sh +++ b/project_config.sh @@ -69,3 +69,4 @@ if [ -n "$1" ]; then fi # EOF +COLORTERM="truecolor" diff --git a/rex.project/x86_64/components/livecd/welcome.bash b/rex.project/x86_64/components/livecd/welcome.bash index a8a625f..b614179 100755 --- a/rex.project/x86_64/components/livecd/welcome.bash +++ b/rex.project/x86_64/components/livecd/welcome.bash @@ -44,5 +44,5 @@ echo -e "\e[31m$HORSE\e[0m" echo echo "Welcome to Pyrois, the build system for Dark Horse Linux." echo -echo "LIVD CD GENERATOR" +echo "LIVE CD GENERATOR" echo diff --git a/rex.project/x86_64/components/stage1/gcc.bash b/rex.project/x86_64/components/stage1/gcc.bash index ff5bff4..29d1244 100755 --- a/rex.project/x86_64/components/stage1/gcc.bash +++ b/rex.project/x86_64/components/stage1/gcc.bash @@ -489,7 +489,7 @@ if \ [ "$MODE_BUILD_GCC_PASS1" != "true" ] && \ [ "$MODE_INSTALL_GCC_PASS1" != "true" ] && \ [ "$MODE_BUILD_GCC_PASS2" != "true" ] && \ - [ "$MODE_INSTALL_PASS2" != "true" ] && \ + [ "$MODE_INSTALL_GCC_PASS2" != "true" ] && \ [ "$MODE_BUILD_LIBSTDCXX_PASS1" != "true" ] && \ [ "$MODE_INSTALL_LIBSTDCXX_PASS1" != "true" ] && \ [ "$MODE_BUILD_LIBSTDCXX_PASS2" != "true" ] && \ diff --git a/rex.project/x86_64/components/stage4/cleanup.bash b/rex.project/x86_64/components/stage4/cleanup.bash index 60a6d78..64fca0d 100755 --- a/rex.project/x86_64/components/stage4/cleanup.bash +++ b/rex.project/x86_64/components/stage4/cleanup.bash @@ -41,6 +41,88 @@ logprint "Deleting temporary toolchain..." find /usr -depth -name ${T_TRIPLET}\* | xargs rm -vrf assert_zero $? +# almost directly lifted from LFS +logprint "Stripping Debuginfo..." +save_usrlib="$(cd /usr/lib; ls ld-linux*[^g]) + libc.so.6 + libthread_db.so.1 + libquadmath.so.0.0.0 + libstdc++.so.6.0.30 + libitm.so.1.0.0 + libatomic.so.1.2.0" + +pushd /usr/lib + +for LIB in $save_usrlib; do + logprint "Stripping LIB:\t$LIB" + objcopy --only-keep-debug $LIB $LIB.dbg + cp $LIB /tmp/$LIB + assert_zero $? + strip --strip-unneeded /tmp/$LIB + assert_zero $? + objcopy --add-gnu-debuglink=$LIB.dbg /tmp/$LIB + assert_zero $? + install -vm755 /tmp/$LIB /usr/lib + assert_zero $? +done + +online_usrbin="bash find strip" +online_usrlib="libbfd-2.40.so + libsframe.so.0.0.0 + libhistory.so.8.2 + libncursesw.so.6.4 + libm.so.6 + libreadline.so.8.2 + libz.so.1.2.13 + $(cd /usr/lib; find libnss*.so* -type f)" + +for BIN in $online_usrbin; do + logprint "Stripping BIN:\t$BIN" + cp /usr/bin/$BIN /tmp/$BIN + assert_zero $? + strip --strip-unneeded /tmp/$BIN + assert_zero $? + install -vm755 /tmp/$BIN /usr/bin + assert_zero $? +done + +LIB="" +for LIB in $online_usrlib; do + logprint "Stripping LIB:\t$LIB" + cp /usr/lib/$LIB /tmp/$LIB + assert_zero $? + strip --strip-unneeded /tmp/$LIB + assert_zero $? + install -vm755 /tmp/$LIB /usr/lib + assert_zero $? +done + +for i in $(find /usr/lib -type f -name \*.so* ! -name \*dbg) \ + $(find /usr/lib -type f -name \*.a) \ + $(find /usr/{bin,sbin,libexec} -type f); do + case "$online_usrbin $online_usrlib $save_usrlib" in + *$(basename $i)* ) + ;; + * ) strip --strip-unneeded $i + ;; + esac +done + + + +echo; echo; echo +logprint "Cleaning /tmp/" +rm -Rf /tmp/* +assert_zero $? + +logprint "Cleanup .la files..." +find /usr/lib /usr/libexec -name \*.la -delete +assert_zero $? + +logprint "Removing temporary tools..." +find /usr -depth -name "${T_TRIPLET}*" -exec rm -rf {} \; +assert_zero $? + # TODO better integrate test user lifecycle logprint "Execution of ${APPNAME} completed." diff --git a/rex.project/x86_64/components/stage4/shadow.bash b/rex.project/x86_64/components/stage4/shadow.bash index 7e32a13..aa5911a 100755 --- a/rex.project/x86_64/components/stage4/shadow.bash +++ b/rex.project/x86_64/components/stage4/shadow.bash @@ -198,7 +198,6 @@ mode_install() { useradd -D --gid 999 assert_zero $? - logprint "Install operation complete." }