[1/2] deb-dl-dir: Avoid multiple find run on export

Message ID 20240712065646.2156320-2-amikan@ilbers.de
State Accepted, archived
Headers show
Series Protect isar-apt usages in shell | expand

Commit Message

Anton Mikanovich July 12, 2024, 6:56 a.m. UTC
We are running find on isar-apt repo for every new deb in cache.
This can be optimised by collecting isar-apt content once and compare
deb name with this list later.
It can be also usefull for the future isar-apt lock protection.

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

Patch

diff --git a/meta/classes/deb-dl-dir.bbclass b/meta/classes/deb-dl-dir.bbclass
index 8e0243fe..2d8739dc 100644
--- a/meta/classes/deb-dl-dir.bbclass
+++ b/meta/classes/deb-dl-dir.bbclass
@@ -89,6 +89,9 @@  deb_dl_dir_export() {
     export rootfs="${1}"
     export owner=$(id -u):$(id -g)
     mkdir -p "${pc}"
+
+    isar_debs="\$(find '${REPO_ISAR_DIR}/${DISTRO}' -name '*.deb' -print)"
+
     flock "${pc}".lock sudo -Es << 'EOSUDO'
         set -e
         printenv | grep -q BB_VERBOSE_LOGS && set -x
@@ -98,9 +101,8 @@  deb_dl_dir_export() {
         while read p; do
             # skip files from a previous export
             [ -f "${pc}/${p##*/}" ] && continue
-            # can not reuse bitbake function here, this is basically
-            # "repo_contains_package"
-            package=$(find "${REPO_ISAR_DIR}"/"${DISTRO}" -name ${p##*/})
+            # skip packages from isar-apt
+            package=$(echo "$isar_debs" | grep -F -m 1 "${p##*/}" | cat)
             if [ -n "$package" ]; then
                 cmp --silent "$package" "$p" && continue
             fi