rstrip.sh 727 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (C) 2006 OpenWrt.org
  4. #
  5. # This is free software, licensed under the GNU General Public License v2.
  6. # See /LICENSE for more information.
  7. #
  8. SELF=${0##*/}
  9. [ -z "$STRIP" ] && {
  10. echo "$SELF: strip command not defined (STRIP variable not set)"
  11. exit 1
  12. }
  13. TARGETS=$*
  14. [ -z "$TARGETS" ] && {
  15. echo "$SELF: no directories / files specified"
  16. echo "usage: $SELF [PATH...]"
  17. exit 1
  18. }
  19. find $TARGETS -type f -a -exec file {} \; | \
  20. sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.* stripped/\1:\2/p' | \
  21. (
  22. IFS=":"
  23. while read F S; do
  24. echo "$SELF: $F:$S"
  25. [ "${F##*\.}" = "o" -o "${F##*\.}" = "ko" ] && \
  26. eval "$STRIP_KMOD $F" || \
  27. eval "$STRIP $F"
  28. done
  29. )