]> code.ossystems Code Review - openembedded-core.git/commitdiff
externalsrc: Fix a source date epoch race in reproducible builds
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 21 Sep 2021 10:55:44 +0000 (11:55 +0100)
committerAnuj Mittal <anuj.mittal@intel.com>
Wed, 20 Oct 2021 14:54:01 +0000 (22:54 +0800)
When reproducible builds are enabled and externalsrc is in use, the
source date epoch function is added. The conditions on the conditional
code removing the unpack task need to match the deltask function, else
the source date epoch function can end up running twice and the functions
can race with each other causing build failures or corruption.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit e82095c02881410035ca23dc12692f074d8ed39b)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
meta/classes/externalsrc.bbclass

index 1ea938fb6296732d8e000b3cc45d53903b5dbfee..9fe9d36f7676c20e6130d36b389f44850811b293 100644 (file)
@@ -109,16 +109,15 @@ python () {
             if local_srcuri and task in fetch_tasks:
                 continue
             bb.build.deltask(task, d)
-
-        if bb.data.inherits_class('reproducible_build', d) and 'do_unpack' in d.getVar("SRCTREECOVEREDTASKS").split():
-            # The reproducible_build's create_source_date_epoch_stamp function must
-            # be run after the source is available and before the
-            # do_deploy_source_date_epoch task.  In the normal case, it's attached
-            # to do_unpack as a postfuncs, but since we removed do_unpack (above)
-            # we need to move the function elsewhere.  The easiest thing to do is
-            # move it into the prefuncs of the do_deploy_source_date_epoch task.
-            # This is safe, as externalsrc runs with the source already unpacked.
-            d.prependVarFlag('do_deploy_source_date_epoch', 'prefuncs', 'create_source_date_epoch_stamp ')
+            if bb.data.inherits_class('reproducible_build', d) and task == 'do_unpack':
+                # The reproducible_build's create_source_date_epoch_stamp function must
+                # be run after the source is available and before the
+                # do_deploy_source_date_epoch task.  In the normal case, it's attached
+                # to do_unpack as a postfuncs, but since we removed do_unpack (above)
+                # we need to move the function elsewhere.  The easiest thing to do is
+                # move it into the prefuncs of the do_deploy_source_date_epoch task.
+                # This is safe, as externalsrc runs with the source already unpacked.
+                d.prependVarFlag('do_deploy_source_date_epoch', 'prefuncs', 'create_source_date_epoch_stamp ')
 
         d.prependVarFlag('do_compile', 'prefuncs', "externalsrc_compile_prefunc ")
         d.prependVarFlag('do_configure', 'prefuncs', "externalsrc_configure_prefunc ")