On 9/09/21 10:18 pm, Richard Purdie wrote:

On Wed, 2021-09-08 at 21:50 -0500, Mark Hatle wrote:
From: Mark Hatle <mark.ha...@xilinx.com>

A variable BUILD_REPRODUCIBLE_BINARIES is set to '1' by default and was used
to control if the postfuncs were added.  However, it didn't actually disable
the reproducible_build (date) logic.  This resulted in the program falling
back to the default date.

This change fully honors the variable and disables the various pieces
that discover and configure the SOURCE_DATE_EPOCH if the value if not
set to '1'.

Signed-off-by: Mark Hatle <mark.ha...@xilinx.com>
Signed-off-by: Mark Hatle <mark.ha...@kernel.crashing.org>
---
  meta/classes/reproducible_build.bbclass | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/meta/classes/reproducible_build.bbclass 
b/meta/classes/reproducible_build.bbclass
index 378121903d..a9c117c3b9 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -47,7 +47,9 @@ TARGET_CC_ARCH:append:class-target = " -Wdate-time"
  # A SOURCE_DATE_EPOCH of '0' might be misinterpreted as no SDE
  export SOURCE_DATE_EPOCH_FALLBACK ??= "1302044400"
-SSTATETASKS += "do_deploy_source_date_epoch"
+# The following are preformed in the anonymous python function, only if
+# BUILD_REPRODUCIBLE_BINARIES == 1
+#SSTATETASKS += "do_deploy_source_date_epoch"
do_deploy_source_date_epoch () {
      mkdir -p ${SDE_DEPLOYDIR}
@@ -73,8 +75,10 @@ python do_deploy_source_date_epoch_setscene () {
do_deploy_source_date_epoch[dirs] = "${SDE_DEPLOYDIR}"
  do_deploy_source_date_epoch[sstate-plaindirs] = "${SDE_DEPLOYDIR}"
-addtask do_deploy_source_date_epoch_setscene
-addtask do_deploy_source_date_epoch before do_configure after do_patch
+# The following are preformed in the anonymous python function, only if
+# BUILD_REPRODUCIBLE_BINARIES == 1
+#addtask do_deploy_source_date_epoch_setscene
+#addtask do_deploy_source_date_epoch before do_configure after do_patch
python create_source_date_epoch_stamp() {
      import oe.reproducible
@@ -123,5 +127,12 @@ BB_HASHBASE_WHITELIST += "SOURCE_DATE_EPOCH"
python () {
      if d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1':
+        # Generate the timestamp with create_source_date_epoch_stamp.
          d.appendVarFlag("do_unpack", "postfuncs", " 
create_source_date_epoch_stamp")
+        d.appendVar('SSTATETASKS', " do_deploy_source_date_epoch")
+        bb.build.addtask('do_deploy_source_date_epoch_setscene', None, None, d)
+        bb.build.addtask('do_deploy_source_date_epoch', 'do_configure', 
'do_patch', d)
+    else:
+        # If this is set at all, the system components will attempt to use it
+        d.delVar('SOURCE_DATE_EPOCH')
  }
Doing this makes me rather sad. Why? If we keep going down this route, all our
code will just become a mess of python rather than metadata.

A better question here is probably whether we can keep the tasks but correctly
disable changing of the date instead?

I really don't want to just pile up anonymous python.

FWIW I'm also leaning towards moving some of the reproducible code into the main
classes/tasks out the box as I'm not sure we're that interested in having non-
reproducible builds.


The do_deploy_source_date_epoch task is pretty cheap. You're going to some trouble here to turn it off, when it only applies to a distro that has chosen to inherit reproducible_build in the first place.

I've always been a bit puzzled by the intention of BUILD_REPRODUCIBLE_BINARIES, given that it's a distro choice to inherit reproducible_build at all. Perhaps the original intention was to avoid the get_source_date_epoch() python functionality in the special case of a problematic recipe? Are you there, Juro? Can you cast any light on this?

If you really, really do need to turn off the SOURCE_DATE_EPOCH variable, perhaps a cleaner approach would be to set it only from within the python anonymous function (rather than deleting it in the negative case). In this way, this entire patch could perhaps be reduced to one line. Note that SOURCE_DATE_EPOCH is already exported by reproducible_build_simple.bbclass — which is already inherited only if BUILD_REPRODUCIBLE_BINARIES == 1.

I think this all achieves your aim: If your distro inherits reproducible_build, but you turn off BUILD_REPRODUCIBLE_BINARIES for one recipe (or in your local.conf), the SOURCE_DATE_EPOCH won't be set.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#155873): 
https://lists.openembedded.org/g/openembedded-core/message/155873
Mute This Topic: https://lists.openembedded.org/mt/85476713/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to