blob: 547ae127edf548f2d8148de17451cc2ad39e1afb [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#!/bin/bash
2
3DEST_DIR=$1
4
5#cp uClibc so to /lib
6cp -av ${STAGEDIR}/uClibc/lib/* ${DEST_DIR}/lib/
7
8rm -fv ${DEST_DIR}/lib/libubacktrace*
9
10#libgcc_s.so
11cp -av ${CROSS_COMPILE_LIBGCC_LIB}* ${DEST_DIR}/lib/
12chmod a+x ${DEST_DIR}/lib/libgcc_s.so*
13
14#clean kernel modules
15find ${DEST_DIR}/lib/modules -type l -name build | xargs rm -fr
16find ${DEST_DIR}/lib/modules -type l -name source | xargs rm -fr
17
18find ${DEST_DIR}/lib/modules/ -name "modules.*" | xargs rm -rfv
19
20if [ x"$USE_LIBSTDCPP" = x"yes" ]; then
21 LIBCPP_DIR=`dirname ${CROSS_COMPILE_LIBCPP_LIB}`
22 cp -av ${LIBCPP_DIR}/libstdc++.s*[o.0-9] ${DEST_DIR}/lib/
23fi
24
25#strip Executable files and dynamic libraries
26SECTIONS_REMOVE="-R .comment -R .note -R .ARM.attributes -R .ARM.exidx -R .ARM.extab"
27find ${DEST_DIR}/sbin -type f -perm -u+x -exec ${STRIPTOOL} $SECTIONS_REMOVE '{}' ';'
28find ${DEST_DIR}/bin -type f -perm -u+x -exec ${STRIPTOOL} $SECTIONS_REMOVE '{}' ';'
29find ${DEST_DIR}/usr/bin -type f -perm -u+x -exec ${STRIPTOOL} $SECTIONS_REMOVE '{}' ';'
30chmod a+x ${DEST_DIR}/lib/lib*.so*
31find ${DEST_DIR}/lib ! -name \*.ko -type f -perm -u+x -exec ${STRIPTOOL} $SECTIONS_REMOVE '{}' ';'
32find ${DEST_DIR}/lib ! -name cpko.ko -name \*.ko -type f -exec ${STRIPTOOL} --strip-debug --strip-unneeded $SECTIONS_REMOVE '{}' ';'
33find ${DEST_DIR}/recovery/bin -type f -perm -u+x -exec ${STRIPTOOL} $SECTIONS_REMOVE '{}' ';'
34
35if [ x"$USE_REMOVE_COMMENT" = x"yes" ]; then
36 find ${DEST_DIR} -name "*.sh" -type f -exec ${BUILD_DIR}/remove_comment.sh '{}' ';'
37 find ${DEST_DIR} -name "*.conf" -type f -exec sed -i '/^#/d' '{}' ';'
38 find ${DEST_DIR} -name "*.cfg" -type f -exec sed -i '/^#/d' '{}' ';'
39 ${BUILD_DIR}/remove_comment.sh ${DEST_DIR}/etc/rc
40 sed -i '/^#/d' ${DEST_DIR}/etc_ro/nvconfig
41 find ${DEST_DIR}/etc_ro -name "default_parameter_*" -type f -exec sed -i '/^#/d' '{}' ';'
42fi
43