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