From: "'Adriaan Schmidt' via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Cc: adriaan.schmidt@siemens.com
Subject: [PATCH] fix: add currenttask-guards to SSTATE(CREATE|POSTINST)FUNCS
Date: Fri, 11 Apr 2025 16:33:04 +0200 [thread overview]
Message-ID: <20250411143304.384348-1-adriaan.schmidt@siemens.com> (raw)
We use SSTATECREATEFUNCS and SSTATEPOSTINSTFUNCS to insert
code for preparation/postprocessing of sstate artifacts.
As it turns out, those are not per-job, but global, so if
a recipe has multiple sstate-cacheable tasks, all of those
functions are executed, and we need to make sure to bail out
of all unintended calls.
Because all invocations are visible in the logs, we add a
message in case a function was skipped, to make logs more
readable.
Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
---
meta/classes/base.bbclass | 9 +++++++++
meta/classes/dpkg-base.bbclass | 2 ++
meta/classes/rootfs.bbclass | 2 ++
meta/recipes-core/isar-bootstrap/isar-bootstrap.inc | 2 ++
meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc | 2 ++
5 files changed, 17 insertions(+)
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index c730eec9..d5a3142b 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -204,6 +204,15 @@ def isar_export_ccache(d):
else:
os.environ['CCACHE_DISABLE'] = '1'
+isar_check_current_task() {
+ if [ "do_${BB_CURRENTTASK}" = "$1" ]; then
+ return 0
+ else
+ echo "skipping because current task is not $1"
+ return 1
+ fi
+}
+
do_fetch[dirs] = "${DL_DIR}"
do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}"
do_fetch[vardeps] += "SRCREV"
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 4468a49a..7f2dcd3f 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -184,6 +184,7 @@ SSTATECREATEFUNCS += "dpkg_build_sstate_prepare"
SSTATEPOSTINSTFUNCS += "dpkg_build_sstate_finalize"
dpkg_build_sstate_prepare() {
+ (isar_check_current_task "do_dpkg_build" || return) || true
# this runs in SSTATE_BUILDDIR, which will be deleted automatically
if [ -n "$(find ${WORKDIR} -maxdepth 1 -name '*.deb' -print -quit)" ]; then
cp -f ${WORKDIR}/*.deb -t .
@@ -191,6 +192,7 @@ dpkg_build_sstate_prepare() {
}
dpkg_build_sstate_finalize() {
+ (isar_check_current_task "do_dpkg_build_setscene" || return) || true
# this runs in SSTATE_INSTDIR
if [ -n "$(find . -maxdepth 1 -name '*.deb' -print -quit)" ]; then
mv -f ./*.deb -t ${WORKDIR}/
diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index cd8fd118..aed50a91 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -437,6 +437,7 @@ SSTATE_TAR_ATTR_FLAGS ?= "--xattrs --xattrs-include='*'"
# the rootfs is owned by root, so we need some sudoing to pack and unpack
rootfs_install_sstate_prepare() {
+ (isar_check_current_task "do_rootfs_install" || return) || true
# this runs in SSTATE_BUILDDIR, which will be deleted automatically
# tar --one-file-system will cross bind-mounts to the same filesystem,
# so we use some mount magic to prevent that
@@ -450,6 +451,7 @@ rootfs_install_sstate_prepare() {
do_rootfs_install_sstate_prepare[lockfiles] = "${REPO_ISAR_DIR}/isar.lock"
rootfs_install_sstate_finalize() {
+ (isar_check_current_task "do_rootfs_install_setscene" || return) || true
# this runs in SSTATE_INSTDIR
# - after building the rootfs, the tar won't be there, but we also don't need to unpack
# - after restoring from cache, there will be a tar which we unpack and then delete
diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
index 08d61a84..a3ab28ca 100644
--- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
+++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
@@ -219,12 +219,14 @@ SSTATECREATEFUNCS += "bootstrap_sstate_prepare"
SSTATEPOSTINSTFUNCS += "bootstrap_sstate_finalize"
bootstrap_sstate_prepare() {
+ (isar_check_current_task "do_bootstrap" || return) || true
# this runs in SSTATE_BUILDDIR, which will be deleted automatically
sudo cp -a "${WORKDIR}/rootfs.tar.zst" ./bootstrap.tar.zst
sudo chown $(id -u):$(id -g) bootstrap.tar.zst
}
bootstrap_sstate_finalize() {
+ (isar_check_current_task "do_bootstrap_setscene" || return) || true
# this runs in SSTATE_INSTDIR
# we should restore symlinks after using tar
if [ -f bootstrap.tar.zst ]; then
diff --git a/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc b/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
index 931f6f13..44775bc5 100644
--- a/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
+++ b/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
@@ -222,12 +222,14 @@ SSTATECREATEFUNCS += "bootstrap_sstate_prepare"
SSTATEPOSTINSTFUNCS += "bootstrap_sstate_finalize"
bootstrap_sstate_prepare() {
+ (isar_check_current_task "do_bootstrap" || return) || true
# this runs in SSTATE_BUILDDIR, which will be deleted automatically
sudo cp -a "${WORKDIR}/rootfs.tar.zst" ./bootstrap.tar.zst
sudo chown $(id -u):$(id -g) bootstrap.tar.zst
}
bootstrap_sstate_finalize() {
+ (isar_check_current_task "do_bootstrap_setscene" || return) || true
# this runs in SSTATE_INSTDIR
# we should restore symlinks after using tar
if [ -f bootstrap.tar.zst ]; then
--
2.39.5
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20250411143304.384348-1-adriaan.schmidt%40siemens.com.
next reply other threads:[~2025-04-11 14:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 14:33 'Adriaan Schmidt' via isar-users [this message]
2025-04-16 14:12 ` Baurzhan Ismagulov
2025-04-25 12:48 ` 'Schmidt, Adriaan' via isar-users
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=20250411143304.384348-1-adriaan.schmidt@siemens.com \
--to=isar-users@googlegroups.com \
--cc=adriaan.schmidt@siemens.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