deb-dl-dir: Fail if "apt-cache dumpavail" returns empty list

Message ID 20250808094520.3031199-1-amikan@ilbers.de
State Under Review
Headers show
Series deb-dl-dir: Fail if "apt-cache dumpavail" returns empty list | expand

Commit Message

Anton Mikanovich Aug. 8, 2025, 9:45 a.m. UTC
For non-host architectures, "apt-cache dumpavail" returns empty output.
Because of this, "debsrc_download" function doesn't download any
source packages without an error.

Make the task fail on empty list so that it could be caught in CI.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/deb-dl-dir.bbclass | 6 ++++++
 1 file changed, 6 insertions(+)

Patch

diff --git a/meta/classes/deb-dl-dir.bbclass b/meta/classes/deb-dl-dir.bbclass
index e75e6be5..4780be20 100644
--- a/meta/classes/deb-dl-dir.bbclass
+++ b/meta/classes/deb-dl-dir.bbclass
@@ -71,6 +71,12 @@  debsrc_download() {
     apt-cache -o APT::Architecture=${DISTRO_ARCH} -o Dir=${rootfs} dumpavail \
     | debsrc_source_version_filter > ${avail}
 
+    if [ $(cat ${avail} | wc -l) -eq 0 ]; then
+        bberror "No packages were found in apt cache"
+        debsrc_undo_mounts "${rootfs}"
+        return 1
+    fi
+
     # Use apt-ftparchive to scan all .deb files found in the download directory
     # and get the <source> <version> pairs that we wish to download
     apt-ftparchive --md5=no --sha1=no --sha256=no --sha512=no \