documentation-audit.sh 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. #
  3. # Perform an audit of which packages provide documentation and which
  4. # are missing -doc packages.
  5. #
  6. # Setup requirements: be sure to be building for MACHINE=qemux86. Run
  7. # this script after source'ing the build environment script, so you're
  8. # running it from build/ directory.
  9. #
  10. # Maintainer: Scott Garman <scott.a.garman@intel.com>
  11. REPORT_DOC_SIMPLE="documentation_exists.txt"
  12. REPORT_DOC_DETAIL="documentation_exists_detail.txt"
  13. REPORT_MISSING_SIMPLE="documentation_missing.txt"
  14. REPORT_MISSING_DETAIL="documentation_missing_detail.txt"
  15. REPORT_BUILD_ERRORS="build_errors.txt"
  16. rm -rf $REPORT_DOC_SIMPLE $REPORT_DOC_DETAIL $REPORT_MISSING_SIMPLE $REPORT_MISSING_DETAIL
  17. BITBAKE=`which bitbake`
  18. if [ -z "$BITBAKE" ]; then
  19. echo "Error: bitbake command not found."
  20. echo "Did you forget to source the build environment script?"
  21. exit 1
  22. fi
  23. echo "REMINDER: you need to build for MACHINE=qemux86 or you won't get useful results"
  24. echo "REMINDER: you need to set LICENSE_FLAGS_WHITELIST appropriately in local.conf or "
  25. echo " you'll get false positives. For example, LICENSE_FLAGS_WHITELIST = \"Commercial\""
  26. for pkg in `bitbake -s | awk '{ print \$1 }'`; do
  27. if [[ "$pkg" == "Loading" || "$pkg" == "Loaded" ||
  28. "$pkg" == "Recipe" ||
  29. "$pkg" == "Parsing" || "$pkg" == "Package" ||
  30. "$pkg" == "NOTE:" || "$pkg" == "WARNING:" ||
  31. "$pkg" == "done." || "$pkg" == "===========" ]]
  32. then
  33. # Skip initial bitbake output
  34. continue
  35. fi
  36. if [[ "$pkg" =~ -native$ || "$pkg" =~ -nativesdk$ ||
  37. "$pkg" =~ -cross-canadian ]]; then
  38. # Skip native/nativesdk/cross-canadian recipes
  39. continue
  40. fi
  41. if [[ "$pkg" =~ ^meta- || "$pkg" =~ ^packagegroup- || "$pkg" =~ -image ]]; then
  42. # Skip meta, task and image recipes
  43. continue
  44. fi
  45. if [[ "$pkg" =~ ^glibc- || "$pkg" =~ ^libiconv$ ||
  46. "$pkg" =~ -toolchain$ || "$pkg" =~ ^package-index$ ||
  47. "$pkg" =~ ^linux- || "$pkg" =~ ^adt-installer$ ||
  48. "$pkg" =~ ^eds-tools$ || "$pkg" =~ ^external-python-tarball$ ||
  49. "$pkg" =~ ^qt4-embedded$ || "$pkg" =~ ^qt-mobility ]]; then
  50. # Skip glibc, libiconv, -toolchain, and other recipes known
  51. # to cause build conflicts or trigger false positives.
  52. continue
  53. fi
  54. echo "Building package $pkg..."
  55. bitbake $pkg > /dev/null
  56. if [ $? -ne 0 ]; then
  57. echo "There was an error building package $pkg" >> "$REPORT_MISSING_DETAIL"
  58. echo "$pkg" >> $REPORT_BUILD_ERRORS
  59. # Do not skip the remaining tests, as sometimes the
  60. # exit status is 1 due to QA errors, and we can still
  61. # perform the -doc checks.
  62. fi
  63. echo "$pkg built successfully, checking for a documentation package..."
  64. WORKDIR=`bitbake -e $pkg | grep ^WORKDIR | awk -F '=' '{ print \$2 }' | awk -F '"' '{ print \$2 }'`
  65. FIND_DOC_PKG=`find $WORKDIR/packages-split/*-doc -maxdepth 0 -type d`
  66. if [ -z "$FIND_DOC_PKG" ]; then
  67. # No -doc package was generated:
  68. echo "No -doc package: $pkg" >> "$REPORT_MISSING_DETAIL"
  69. echo "$pkg" >> $REPORT_MISSING_SIMPLE
  70. continue
  71. fi
  72. FIND_DOC_FILES=`find $FIND_DOC_PKG -type f`
  73. if [ -z "$FIND_DOC_FILES" ]; then
  74. # No files shipped with the -doc package:
  75. echo "No files shipped with the -doc package: $pkg" >> "$REPORT_MISSING_DETAIL"
  76. echo "$pkg" >> $REPORT_MISSING_SIMPLE
  77. continue
  78. fi
  79. echo "Documentation shipped with $pkg:" >> "$REPORT_DOC_DETAIL"
  80. echo "$FIND_DOC_FILES" >> "$REPORT_DOC_DETAIL"
  81. echo "" >> "$REPORT_DOC_DETAIL"
  82. echo "$pkg" >> "$REPORT_DOC_SIMPLE"
  83. done