Skip to contentSkip to conversation

buildhistory: print extra information during list pkg files error

RFC PATCH Atharva Nandanwar 1 participant 1 message Oct 2, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 43 lines

Printing a useful error message while failing should help users understand why we fail with this error. As the current error message doesn't directly link to needing to inherit nopackages.

Previous error message:

| DEBUG: Executing shell function buildhistory_list_pkg_files
| find: ".../meta-toolchain/1.0/packages-split/*": No such file or directory
| WARNING: exit code 1 from a shell command.
| DEBUG: Python function buildhistory_emit_pkghistory finished

New error message:

| ERROR: meta-toolchain-1.0-r0 do_package: meta-toolchain: ../meta-toolchain/1.0/packages-split is empty.
| ERROR: meta-toolchain-1.0-r0 do_package: Possible reasons:
| ERROR: meta-toolchain-1.0-r0 do_package: 1. Recipe doesn't install any files. Inherit nopackages to fix.
| ERROR: meta-toolchain-1.0-r0 do_package: 2. do_packagedata task wasn't executed.
| ERROR: meta-toolchain-1.0-r0 do_package: Execution of '../meta-toolchain/1.0/temp/run.buildhistory_list_pkg_files.1003324' failed with exit code 1
---
 meta/classes/buildhistory.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
meta/classes/buildhistory.bbclass +7 -1
index ce3abaa69d..0e9d5464af 100644
@@ -621,7 +621,13 @@ buildhistory_list_pkg_files() {
 	fi
 
 	# Create individual files-in-package for each recipe's package
-	pkgdirlist=$(find ${PKGDEST}/* -maxdepth 0 -type d)
+	pkgdirlist=$(find ${PKGDEST}/* -maxdepth 0 -type d || true)
+	if [ -z "${pkgdirlist}" ]; then
+		bberror "${PN}: ${PKGDEST} is empty."
+		bberror "Possible reasons:"
+		bberror "1. Recipe doesn't install any files. Inherit nopackages to fix."
+		bbfatal "2. do_packagedata task wasn't executed."
+	fi
 	for pkgdir in $pkgdirlist; do
 		pkgname=$(basename $pkgdir)
 		outfolder="${BUILDHISTORY_DIR_PACKAGE}/$pkgname"
Signature · 1 line
2.34.1

RFC as I'm happy with Reason #1, but Reason #2 could use some help.

Thanks in advance for the feedback!
--Atharva Nandanwar