documentation-audit.sh 3.4 KB

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