gen-dependencies.sh 653 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (C) 2012 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. READELF="${READELF:-readelf}"
  10. TARGETS=$*
  11. XARGS="${XARGS:-xargs -r}"
  12. [ -z "$TARGETS" ] && {
  13. echo "$SELF: no directories / files specified"
  14. echo "usage: $SELF [PATH...]"
  15. exit 1
  16. }
  17. find $TARGETS -type f -a -exec file {} \; | \
  18. sed -n -e 's/^\(.*\):.*ELF.*\(executable\|shared object\).*,.* stripped/\1/p' | \
  19. $XARGS -n1 readelf -d | \
  20. awk '$2 ~ /NEEDED/ && $NF !~ /interpreter/ && $NF ~ /^\[?lib.*\.so/ { gsub(/[\[\]]/, "", $NF); print $NF }' | \
  21. sort -u