public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Adriaan Schmidt <adriaan.schmidt@siemens.com>
To: <isar-users@googlegroups.com>
Cc: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Subject: [PATCH v2 4/4] base.bbclass: don't pass absolute paths to root_cleandirs
Date: Tue, 12 Apr 2022 14:08:13 +0200	[thread overview]
Message-ID: <20220412120813.467516-5-adriaan.schmidt@siemens.com> (raw)
In-Reply-To: <20220412120813.467516-1-adriaan.schmidt@siemens.com>

The directories to be cleaned are contained in the code that is prepended
to the modified task. If those contain absolute paths, it can break caching.
So instead, we pass paths relative to $TMPDIR (code already makes sure
the paths are actually below $TMPDIR).

Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
---
 meta/classes/base.bbclass | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index a7282110..4ec2c813 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -105,14 +105,16 @@ python do_listtasks() {
 root_cleandirs() {
     ROOT_CLEANDIRS_DIRS_PY="${@d.getVar("ROOT_CLEANDIRS_DIRS", True) or ""}"
     ROOT_CLEANDIRS_DIRS="${ROOT_CLEANDIRS_DIRS-${ROOT_CLEANDIRS_DIRS_PY}}"
+    TMPDIR_PY="${@d.getVar("TMPDIR", True) or ""}"
+    TMPDIR="${TMPDIR-${TMPDIR_PY}}"
     for i in $ROOT_CLEANDIRS_DIRS; do
         awk '{ print $2 }' /proc/mounts | grep -q "^${i}\(/\|\$\)" && \
             die "Could not remove $i, because subdir is mounted"
     done
-    if [ -n "$ROOT_CLEANDIRS_DIRS" ]; then
-        sudo rm -rf --one-file-system $ROOT_CLEANDIRS_DIRS
-        mkdir -p $ROOT_CLEANDIRS_DIRS
-    fi
+    for i in $ROOT_CLEANDIRS_DIRS; do
+        sudo rm -rf --one-file-system "$TMPDIR$i"
+        mkdir -p "$TMPDIR$i"
+    done
 }
 
 python() {
@@ -148,8 +150,10 @@ python() {
                     )
 
                 ws = re.match(r"^\s*", d.getVar(e, False)).group()
+                # remove prefix ${TMPDIR}, so we don't have absolute paths in variable e
+                dirs = [dir[len(tmpdir):] for dir in rcleandirs]
                 d.prependVar(
-                    e, cleandir_code.format(ws=ws, dirlist=" ".join(rcleandirs))
+                    e, cleandir_code.format(ws=ws, dirlist=" ".join(dirs))
                 )
 }
 
-- 
2.30.2


  parent reply	other threads:[~2022-04-12 12:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 12:08 [PATCH v2 0/4] Improve cacheability Adriaan Schmidt
2022-04-12 12:08 ` [PATCH v2 1/4] bitbake.conf: always start with empty SRC_URI Adriaan Schmidt
2022-04-12 12:08 ` [PATCH v2 2/4] bitbake.conf: add isar paths to BB_HASHBASE_WHITELIST Adriaan Schmidt
2022-04-12 12:08 ` [PATCH v2 3/4] isar-bootstrap: no absolute paths in SRC_URI Adriaan Schmidt
2022-04-12 12:08 ` Adriaan Schmidt [this message]
2022-05-04  7:50 ` [PATCH v2 0/4] Improve cacheability Anton Mikanovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220412120813.467516-5-adriaan.schmidt@siemens.com \
    --to=adriaan.schmidt@siemens.com \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox