[v6,07/13] deb-dl-dir: Fix skipping of removed files

Message ID 20200930060707.12785-4-Vijaikumar_Kanagarajan@mentor.com
State Superseded, archived
Headers show
Series Deb-src caching | expand

Commit Message

Vijai Kumar K Sept. 29, 2020, 10:07 p.m. UTC
Some packages are installed and then removed, like localepurge from
image-locales-extension.bbclass. Those information would not be
available in dpkg status file. Use dpkg log instead to see if the
package has been used on the target.

Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
---
 meta/classes/deb-dl-dir.bbclass | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Patch

diff --git a/meta/classes/deb-dl-dir.bbclass b/meta/classes/deb-dl-dir.bbclass
index b2d94e7..a94fb10 100644
--- a/meta/classes/deb-dl-dir.bbclass
+++ b/meta/classes/deb-dl-dir.bbclass
@@ -7,10 +7,16 @@  inherit repository
 
 is_not_part_of_current_build() {
     local package="$( dpkg-deb --show --showformat '${Package}' "${1}" )"
-    local output="$( grep -hs "^Package: ${package}" \
-            "${IMAGE_ROOTFS}"/var/lib/dpkg/status \
-            "${BUILDCHROOT_HOST_DIR}"/var/lib/dpkg/status \
-            "${BUILDCHROOT_TARGET_DIR}"/var/lib/dpkg/status )"
+    local arch="$( dpkg-deb --show --showformat '${Architecture}' "${1}" )"
+    local version="$( dpkg-deb --show --showformat '${Version}' "${1}" )"
+    # Since we are parsing all the debs in DEBDIR, we can to some extend
+    # try to eliminate some debs that are not part of the current multiconfig
+    # build using the below method.
+    local output="$( grep -hs "status installed ${package}:${arch} ${version}" \
+            "${IMAGE_ROOTFS}"/var/log/dpkg.log \
+            "${BUILDCHROOT_HOST_DIR}"/var/log/dpkg.log \
+            "${BUILDCHROOT_TARGET_DIR}"/var/log/dpkg.log | head -1 )"
+
     [ -z "${output}" ]
 }