Instead of trying to shove a non-zero SDE into the deployed sstate
files which has bad interactions, let it naturally resolve to 0 and do a
"last chance" correction to the fallback SOURCE_DATE_EPOCH.

Also, stop exporting the fallback source date epoch since we don't want
to invalidate *all* tasks when it changes. Instead, make do_unpack
depend on the fallback value to invalidate all the downstream tasks when
it changes.

Finally, we need to make sure that do_deploy_source_date_epoch() gets
rerun when the actual SDE value changes. Introduce a new variable
(SOURCE_DATE_EPOCH_DEP) that this task (and others like it) can depend
on when they need to be invalidated by a change in the source date epoch
value.

Signed-off-by: Joshua Watt <[email protected]>
---
 meta/classes/reproducible_build.bbclass | 23 ++++++++++++++---------
 meta/lib/oe/reproducible.py             |  8 ++------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/meta/classes/reproducible_build.bbclass 
b/meta/classes/reproducible_build.bbclass
index f06e00d70d..74ef8da3c9 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -42,7 +42,13 @@ SDE_FILE = "${SDE_DIR}/__source_date_epoch.txt"
 SDE_DEPLOYDIR = "${WORKDIR}/deploy-source-date-epoch"
 
 # A SOURCE_DATE_EPOCH of '0' might be misinterpreted as no SDE
-export SOURCE_DATE_EPOCH_FALLBACK ??= "1302044400"
+SOURCE_DATE_EPOCH_FALLBACK ??= "1302044400"
+
+# Some tasks do actually depend on the value of the source date epoch, even
+# though it is generally excluded from task signatures. For those tasks, they
+# can add a vardep on this variable
+SOURCE_DATE_EPOCH_DEP = "${SOURCE_DATE_EPOCH}"
+SOURCE_DATE_EPOCH_DEP[vardepvalue] = "${SOURCE_DATE_EPOCH_DEP}"
 
 SSTATETASKS += "do_deploy_source_date_epoch"
 
@@ -55,6 +61,7 @@ do_deploy_source_date_epoch () {
         echo "${SDE_FILE} not found!"
     fi
 }
+do_deploy_source_date_epoch[vardeps] += "SOURCE_DATE_EPOCH_DEP"
 
 python do_deploy_source_date_epoch_setscene () {
     sstate_setscene(d)
@@ -96,19 +103,15 @@ def get_source_date_epoch_value(d):
         return cached
 
     epochfile = d.getVar('SDE_FILE')
-    source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
+    source_date_epoch = 0
     if os.path.isfile(epochfile):
         with open(epochfile, 'r') as f:
             s = f.read()
             try:
                 source_date_epoch = int(s)
-                # workaround for old sstate with SDE_FILE content being 0 - 
use SOURCE_DATE_EPOCH_FALLBACK
-                if source_date_epoch == 0 :
-                    source_date_epoch = 
int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
-                    bb.warn("SOURCE_DATE_EPOCH value from sstate '%s' is 
deprecated/invalid. Reverting to SOURCE_DATE_EPOCH_FALLBACK '%s'" % (s, 
source_date_epoch))
             except ValueError:
-                bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to 
SOURCE_DATE_EPOCH_FALLBACK" % s)
-                source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
+                bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to 
default" % s)
+                source_date_epoch = 0
         bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch)
     else:
         bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % 
(epochfile, source_date_epoch))
@@ -116,10 +119,12 @@ def get_source_date_epoch_value(d):
     d.setVar('__CACHED_SOURCE_DATE_EPOCH', str(source_date_epoch))
     return str(source_date_epoch)
 
-export SOURCE_DATE_EPOCH ?= "${@get_source_date_epoch_value(d)}"
+export SOURCE_DATE_EPOCH ?= "${@get_source_date_epoch_value(d) or 
d.getVar('SOURCE_DATE_EPOCH_FALLBACK')}"
 BB_HASHBASE_WHITELIST += "SOURCE_DATE_EPOCH"
 
 python () {
     if d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1':
         d.appendVarFlag("do_unpack", "postfuncs", " 
create_source_date_epoch_stamp")
+        # Make sure to invalidate all downstream tasks is the 
SOURCE_DATE_EPOCH_FALLBACK value changes
+        d.appendVarFlag("do_unpack", "vardeps", "SOURCE_DATE_EPOCH_FALLBACK")
 }
diff --git a/meta/lib/oe/reproducible.py b/meta/lib/oe/reproducible.py
index 204b9bd734..0fb02ccdb0 100644
--- a/meta/lib/oe/reproducible.py
+++ b/meta/lib/oe/reproducible.py
@@ -90,12 +90,8 @@ def get_source_date_epoch_from_youngest_file(d, sourcedir):
         bb.debug(1, "Newest file found: %s" % newest_file)
     return source_date_epoch
 
-def fixed_source_date_epoch(d):
+def fixed_source_date_epoch():
     bb.debug(1, "No tarball or git repo found to determine SOURCE_DATE_EPOCH")
-    source_date_epoch = d.getVar('SOURCE_DATE_EPOCH_FALLBACK')
-    if source_date_epoch:
-        bb.debug(1, "Using SOURCE_DATE_EPOCH_FALLBACK")
-        return int(source_date_epoch)
     return 0
 
 def get_source_date_epoch(d, sourcedir):
@@ -103,6 +99,6 @@ def get_source_date_epoch(d, sourcedir):
         get_source_date_epoch_from_git(d, sourcedir) or
         get_source_date_epoch_from_known_files(d, sourcedir) or
         get_source_date_epoch_from_youngest_file(d, sourcedir) or
-        fixed_source_date_epoch(d)       # Last resort
+        fixed_source_date_epoch()       # Last resort
     )
 
-- 
2.30.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#148555): 
https://lists.openembedded.org/g/openembedded-core/message/148555
Mute This Topic: https://lists.openembedded.org/mt/80879528/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to