diff mbox series

[v2] image-artifact-names: fix default suffix detection

Message ID 20261118203248.1802145-1-chris.laplante@agilent.com
State New
Headers show
Series [v2] image-artifact-names: fix default suffix detection | expand

Commit Message

chris.laplante@agilent.com Nov. 18, 2026, 8:32 p.m. UTC
From: Chris Laplante <chris.laplante@agilent.com>

Read IMAGE_VERSION_SUFFIX without expansion so deploy recipes use
SOURCE_DATE_EPOCH instead of the build timestamp.

AI-Generated: Uses GPT-6.1 Sol

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
---
 meta/classes-recipe/image-artifact-names.bbclass |  3 ++-
 meta/lib/oeqa/selftest/cases/bbtests.py          | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/image-artifact-names.bbclass b/meta/classes-recipe/image-artifact-names.bbclass
index bc76ff0e16..a360ae66da 100644
--- a/meta/classes-recipe/image-artifact-names.bbclass
+++ b/meta/classes-recipe/image-artifact-names.bbclass
@@ -34,7 +34,8 @@  IMAGE_MACHINE_SUFFIX ??= "-${MACHINE}"
 IMAGE_NAME_SUFFIX ??= ".rootfs"
 
 python () {
-    if bb.data.inherits_class('deploy', d) and d.getVar("IMAGE_VERSION_SUFFIX") == "-${DATETIME}":
+    # Compare before expansion to recognize the default DATETIME suffix.
+    if bb.data.inherits_class('deploy', d) and d.getVar("IMAGE_VERSION_SUFFIX", False) == "-${DATETIME}":
         import datetime
         d.setVar("IMAGE_VERSION_SUFFIX", "-" + datetime.datetime.fromtimestamp(int(d.getVar("SOURCE_DATE_EPOCH")), datetime.timezone.utc).strftime('%Y%m%d%H%M%S'))
         d.setVarFlag("IMAGE_VERSION_SUFFIX", "vardepvalue", "")
diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py
index 7e59136814..0c12cc98b9 100644
--- a/meta/lib/oeqa/selftest/cases/bbtests.py
+++ b/meta/lib/oeqa/selftest/cases/bbtests.py
@@ -130,6 +130,21 @@  class BitbakeTests(OESelftestTestCase):
         self.assertTrue('Task dependencies saved to \'task-depends.dot\'' in result.output, msg = "No task dependency \"task-depends.dot\" file was generated for the given task target. bitbake output: %s" % result.output)
         self.assertIn(recipe, ftools.read_file(os.path.join(self.builddir, 'task-depends.dot')))
 
+    def test_deploy_image_version_suffix_sde(self):
+        self.write_recipeinc('emptytest', '''
+inherit deploy image-artifact-names
+IMAGE_VERSION_SUFFIX = "-${DATETIME}"
+SOURCE_DATE_EPOCH = "1234567890"
+''')
+
+        # Commit 0e2fbdb32bae ("image-artifact-names: Use SOURCE_DATE_EPOCH when
+        # making reproducible builds for deploy") intended "-${DATETIME}" to use
+        # SOURCE_DATE_EPOCH for recipes inheriting deploy.
+        self.assertEqual(get_bb_var('IMAGE_VERSION_SUFFIX', 'emptytest'), '-20090213233130')
+
+        self.append_recipeinc('emptytest', 'IMAGE_VERSION_SUFFIX = "-custom"')
+        self.assertEqual(get_bb_var('IMAGE_VERSION_SUFFIX', 'emptytest'), '-custom')
+
     def test_image_manifest(self):
         bitbake('core-image-minimal')
         bb_vars = get_bb_vars(["DEPLOY_DIR_IMAGE", "IMAGE_LINK_NAME"], "core-image-minimal")