documentation-audit.sh 3.4 KB

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