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