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