#!/bin/bash

#LFSBOOK says: ensure you're not running any binaries that are about to be
# stripped -- including the active bash shell.

#better: just run from host system!

export LFS=/mnt/lfs_lit

#--strip-debug is quite harmless under normal circumstances. It doesn't strip anything vital
#--strip-all is quite safe on binaries but will destroy libraries
echo "" &&
echo strip binaries: &&
test -d $LFS &&
find $LFS/{,usr/}{bin,sbin} -type f -exec strip --strip-all '{}' ';' &&
find $LFS/usr/qt/bin -type f -exec strip --strip-all '{}' ';'

echo "" &&
echo strip libraries: &&
test -d $LFS &&
find $LFS/{,usr/{,qt/}}lib -type f -exec strip --strip-debug '{}' ';'
echo "stripping done." &&

echo "" &&
echo remove unused locales and mans: &&
cd $LFS/usr/share/locale &&
rm -rf `ls |grep -v de |grep -v en |grep -v alias` &&
cd $LFS/usr/man &&
rm -rf `ls |grep -v de |grep -v man |grep -v whatis` &&
cd $LFS/usr/X11R6/share/locale &&
rm -rf `ls |grep -v de |grep -v en |grep -v alias`
echo "done."
