From: Changqing Li <[email protected]>

Here is SRC_URI of jquery:
SRC_URI = "\
    https://code.jquery.com/${BP}.js;name=js;subdir=${BP} \
    https://code.jquery.com/${BP}.min.js;name=min;subdir=${BP} \
    https://code.jquery.com/${BP}.min.map;name=map;subdir=${BP} \
    "
When ${BP}.js/${BP}.min.js/${BP}.min.map are downloaded in a git repo,
and this git repo is cloned locally as a PREMIRRORS. In this case, mtime
of these files will be current time when checking out. For this recipe,
source_date_epoch will get by function
get_source_date_epoch_from_youngest_file, mtime of
${BP}.js/${BP}.min.js/${BP}.min.map are not stable, so cause the
generated package not reproducible.

A new variable FIXED_SOURCE_DATE_EPOCH is added to support this case.
By default, FIXED_SOURCE_DATE_EPOCH is 0,  and source_date_epoch works
as before. If user build in above case, FIXED_SOURCE_DATE_EPOCH set to 1
in recipe jquery can ensure fixed source date epoch used by this recipe
to support reproducible build.

Signed-off-by: Changqing Li <[email protected]>
---
 meta/conf/bitbake.conf      |  1 +
 meta/lib/oe/reproducible.py | 13 ++++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 5406e542db..2371567da3 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -680,6 +680,7 @@ export SOURCE_DATE_EPOCH ?= 
"${@get_source_date_epoch_value(d)}"
 # A SOURCE_DATE_EPOCH of '0' might be misinterpreted as no SDE
 SOURCE_DATE_EPOCH_FALLBACK ??= "1302044400"
 REPRODUCIBLE_TIMESTAMP_ROOTFS ??= "1520598896"
+FIXED_SOURCE_DATE_EPOCH ?= "0"
 
 ##################################################################
 # Settings used by bitbake-layers.
diff --git a/meta/lib/oe/reproducible.py b/meta/lib/oe/reproducible.py
index 0270024a83..8ed5e2b458 100644
--- a/meta/lib/oe/reproducible.py
+++ b/meta/lib/oe/reproducible.py
@@ -158,11 +158,14 @@ def fixed_source_date_epoch(d):
     return 0
 
 def get_source_date_epoch(d, sourcedir):
-    return (
-        get_source_date_epoch_from_git(d, sourcedir) or
-        get_source_date_epoch_from_youngest_file(d, sourcedir) or
-        fixed_source_date_epoch(d)       # Last resort
-    )
+    if d.getVar('FIXED_SOURCE_DATE_EPOCH') == '0':
+        return (
+            get_source_date_epoch_from_git(d, sourcedir) or
+            get_source_date_epoch_from_youngest_file(d, sourcedir) or
+            fixed_source_date_epoch(d)       # Last resort
+        )
+    else:
+        return fixed_source_date_epoch(d)
 
 def epochfile_read(epochfile, d):
     cached, efile = d.getVar('__CACHED_SOURCE_DATE_EPOCH') or (None, None)
-- 
2.34.1

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

Reply via email to