user.eclass: add some debugging logic

Things are failing when they shouldn't.  Add some debug logic when
they do so we can try & recover.

BUG=chromium:1026502
TEST=CQ passes

Change-Id: I423a719af111c43120f81f7ca97c32ab504f52ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/eclass-overlay/+/1925712
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/eclass/user.eclass b/eclass/user.eclass
index c4352d3..eb5b3df 100644
--- a/eclass/user.eclass
+++ b/eclass/user.eclass
@@ -66,9 +66,11 @@
 	# will be saved at build time and used when merging binpkgs.  Instead,
 	# we need it to be generated at binpkg time too.
 	local cache="${T}/_accounts_dir_cache.list"
-	if [[ -e ${cache} ]]; then
+	if [[ -s ${cache} ]]; then
+		einfo "Using cached list ${cache}"
 		local dir
 		while read -d $'\0' -r dir; do
+			einfo "Adding ${dir} to user/group search path."
 			ACCOUNTS_DIRS+=("${dir}")
 		done <"${cache}"
 		return
@@ -105,8 +107,14 @@
 	local accounts_dir
 	for accounts_dir in "${ACCOUNTS_DIRS[@]}" ; do
 		local template="${accounts_dir}/${db}/${key}"
-		[[ -e "${template}" ]] && echo "${template}" && break
+		if  [[ -e "${template}" ]]; then
+			echo "${template}"
+			return
+		fi
 	done
+
+	# If we're still here, something has gone wrong.
+	eerror "ACCOUNTS_DIRS = ${ACCOUNTS_DIRS[*]}"
 }
 
 # @FUNCTION: _read_db_entry