sstate-sysroot-cruft.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/sh
  2. # Used to find files installed in sysroot which are not tracked by sstate manifest
  3. # Global vars
  4. tmpdir=
  5. usage () {
  6. cat << EOF
  7. Welcome to sysroot cruft finding utility.
  8. $0 <OPTION>
  9. Options:
  10. -h, --help
  11. Display this help and exit.
  12. --tmpdir=<tmpdir>
  13. Specify tmpdir, will use the environment variable TMPDIR if it is not specified.
  14. Something like /OE/oe-core/tmp-eglibc (no / at the end).
  15. EOF
  16. }
  17. # Print error information and exit.
  18. echo_error () {
  19. echo "ERROR: $1" >&2
  20. exit 1
  21. }
  22. while [ -n "$1" ]; do
  23. case $1 in
  24. --tmpdir=*)
  25. tmpdir=`echo $1 | sed -e 's#^--tmpdir=##' | xargs readlink -e`
  26. [ -d "$tmpdir" ] || echo_error "Invalid argument to --tmpdir"
  27. shift
  28. ;;
  29. --help|-h)
  30. usage
  31. exit 0
  32. ;;
  33. *)
  34. echo "Invalid arguments $*"
  35. echo_error "Try '$0 -h' for more information."
  36. ;;
  37. esac
  38. done
  39. # sstate cache directory, use environment variable TMPDIR
  40. # if it was not specified, otherwise, error.
  41. [ -n "$tmpdir" ] || tmpdir=$TMPDIR
  42. [ -n "$tmpdir" ] || echo_error "No tmpdir found!"
  43. [ -d "$tmpdir" ] || echo_error "Invalid tmpdir \"$tmpdir\""
  44. OUTPUT=${tmpdir}/sysroot.cruft.`date "+%s"`
  45. WHITELIST="\/var\/pseudo\($\|\/[^\/]*$\) \/shlibs$ \.pyc$ \.pyo$"
  46. mkdir ${OUTPUT}
  47. find ${tmpdir}/sstate-control -name \*.populate-sysroot\* -o -name \*.package\* | xargs cat | grep sysroots | \
  48. sed 's#/$##g; s#///*#/#g' | \
  49. # work around for paths ending with / for directories and multiplied // (e.g. paths to native sysroot)
  50. sort > ${OUTPUT}/master.list.all
  51. sort -u ${OUTPUT}/master.list.all > ${OUTPUT}/master.list # -u because some directories are listed for more recipes
  52. find ${tmpdir}/sysroots/ | \
  53. sort > ${OUTPUT}/sysroot.list
  54. diff ${OUTPUT}/master.list.all ${OUTPUT}/master.list > ${OUTPUT}/duplicates
  55. diff ${OUTPUT}/master.list ${OUTPUT}/sysroot.list > ${OUTPUT}/diff.all
  56. cp ${OUTPUT}/diff.all ${OUTPUT}/diff
  57. for item in ${WHITELIST}; do
  58. sed -i "/${item}/d" ${OUTPUT}/diff;
  59. done
  60. # too many false positives for directories
  61. # echo "Following files are installed in sysroot at least twice"
  62. # cat ${OUTPUT}/duplicates
  63. echo "Following files are installed in sysroot, but not tracked by sstate"
  64. cat ${OUTPUT}/diff