12.1. Remove Unnecessary Files

The system is almost finished. It can be made smaller by removing files that are not necessary.

Create a copy of the file system in case changes need to be made to it later:



cd ${CLFS}

install -dv ${CLFS}/build

mkdir -pv build/final

shopt -s extglob

cp -arv !(build) build/final/



Remove files that aren't needed:

rm -rfv ${CLFS}/build/final/cross-tools
rm -rfv ${CLFS}/build/final/usr/src/*
rm -rfv ${CLFS}/build/final/usr/include
rm -rfv ${CLFS}/build/final/usr/man
rm -rfv ${CLFS}/build/final/usr/share/man
rm -rfv ${CLFS}/build/final/sources

Remove the static libaries:

FILES="$(ls ${CLFS}/build/final/lib/*.a ${CLFS}/build/final/usr/lib/*.a)"
for file in $FILES; do
 rm -fv $file
done