summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2024-10-25 14:31:52 +0100
committerSteve Sakoman <steve@sakoman.com>2024-12-09 06:25:53 -0800
commit8c3866aa530c7531ef8b7109b9e10c32b0448f47 (patch)
tree9209a8978c5d583e27eaf715a7fd27f56af5da03
parenta0af85c8cf5d254a6cc19af800d7c56f5f1c9214 (diff)
downloadpoky-8c3866aa530c7531ef8b7109b9e10c32b0448f47.tar.gz
do_package/sstate/sstatesig: Change timestamp clamping to hash output only
The code was changing the timestamps of the files in the do_package output, particularly the files added for debug sources. This was to do two things: a) make do_package sstate more reproducible b) ensure better hash equivalence matching Unfortuately the debug source files are hardlinks into the source tree for efficiency so touching these, touches a lot of files in ${B} and ${S}. This causes unpredictable effects if compile is run again for example, or could cause compiling in the install task. The hash equivalence matching is of key importance but we can mimic that using clamping of the file timestamps in the depsig output used to generate the hashes. This patch drops the global timestamp clamping, instead allowing the files to retain their creation timestamps into sstate. This makes do_package sstate slightly less reproducibile. We could clamp the sstate timestamps but that would lead to two different sets of timestamps depending on whether the data came from sstate or not. I'd prefer to have consistent code behaviour, rather than differing behavhour depending on whether data came from sstate or not. If we wanted to have reproducibiliy and fix the "corruption" of S/B and have consistent codepaths, the only other option would be two copies of the sources, which could end up huge and seems the least desireable option. This patch therefore drops the timestamp clamping in the sstate files and tweaks the depsig data generation to clamp the timestamps for do_package instead since this seems the best compromise. I validated that rpm/deb/ipk files still generate correctly as before. (From OE-Core rev: 0e6b2c761f6d727fe21a0ce2803a0f0aef236f59) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 475759fdab7200488b2a568b2ba1aa31a456d113) Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/classes-global/sstate.bbclass16
-rw-r--r--meta/lib/oe/sstatesig.py7
2 files changed, 6 insertions, 17 deletions
diff --git a/meta/classes-global/sstate.bbclass b/meta/classes-global/sstate.bbclass
index 11bb892a42..8e0391c666 100644
--- a/meta/classes-global/sstate.bbclass
+++ b/meta/classes-global/sstate.bbclass
@@ -641,15 +641,6 @@ def sstate_package(ss, d):
641 641
642 tmpdir = d.getVar('TMPDIR') 642 tmpdir = d.getVar('TMPDIR')
643 643
644 fixtime = False
645 if ss['task'] == "package":
646 fixtime = True
647
648 def fixtimestamp(root, path):
649 f = os.path.join(root, path)
650 if os.lstat(f).st_mtime > sde:
651 os.utime(f, (sde, sde), follow_symlinks=False)
652
653 sstatebuild = d.expand("${WORKDIR}/sstate-build-%s/" % ss['task']) 644 sstatebuild = d.expand("${WORKDIR}/sstate-build-%s/" % ss['task'])
654 sde = int(d.getVar("SOURCE_DATE_EPOCH") or time.time()) 645 sde = int(d.getVar("SOURCE_DATE_EPOCH") or time.time())
655 d.setVar("SSTATE_CURRTASK", ss['task']) 646 d.setVar("SSTATE_CURRTASK", ss['task'])
@@ -664,8 +655,6 @@ def sstate_package(ss, d):
664 # to sstate tasks but there aren't many of these so better just avoid them entirely. 655 # to sstate tasks but there aren't many of these so better just avoid them entirely.
665 for walkroot, dirs, files in os.walk(state[1]): 656 for walkroot, dirs, files in os.walk(state[1]):
666 for file in files + dirs: 657 for file in files + dirs:
667 if fixtime:
668 fixtimestamp(walkroot, file)
669 srcpath = os.path.join(walkroot, file) 658 srcpath = os.path.join(walkroot, file)
670 if not os.path.islink(srcpath): 659 if not os.path.islink(srcpath):
671 continue 660 continue
@@ -687,11 +676,6 @@ def sstate_package(ss, d):
687 bb.utils.mkdirhier(plain) 676 bb.utils.mkdirhier(plain)
688 bb.utils.mkdirhier(pdir) 677 bb.utils.mkdirhier(pdir)
689 bb.utils.rename(plain, pdir) 678 bb.utils.rename(plain, pdir)
690 if fixtime:
691 fixtimestamp(pdir, "")
692 for walkroot, dirs, files in os.walk(pdir):
693 for file in files + dirs:
694 fixtimestamp(walkroot, file)
695 679
696 d.setVar('SSTATE_BUILDDIR', sstatebuild) 680 d.setVar('SSTATE_BUILDDIR', sstatebuild)
697 d.setVar('SSTATE_INSTDIR', sstatebuild) 681 d.setVar('SSTATE_INSTDIR', sstatebuild)
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py
index f883497292..1f97606763 100644
--- a/meta/lib/oe/sstatesig.py
+++ b/meta/lib/oe/sstatesig.py
@@ -564,6 +564,7 @@ def OEOuthashBasic(path, sigfile, task, d):
564 if task == "package": 564 if task == "package":
565 include_timestamps = True 565 include_timestamps = True
566 include_root = False 566 include_root = False
567 source_date_epoch = float(d.getVar("SOURCE_DATE_EPOCH"))
567 hash_version = d.getVar('HASHEQUIV_HASH_VERSION') 568 hash_version = d.getVar('HASHEQUIV_HASH_VERSION')
568 extra_sigdata = d.getVar("HASHEQUIV_EXTRA_SIGDATA") 569 extra_sigdata = d.getVar("HASHEQUIV_EXTRA_SIGDATA")
569 570
@@ -655,7 +656,11 @@ def OEOuthashBasic(path, sigfile, task, d):
655 raise Exception(msg).with_traceback(e.__traceback__) 656 raise Exception(msg).with_traceback(e.__traceback__)
656 657
657 if include_timestamps: 658 if include_timestamps:
658 update_hash(" %10d" % s.st_mtime) 659 # Need to clamp to SOURCE_DATE_EPOCH
660 if s.st_mtime > source_date_epoch:
661 update_hash(" %10d" % source_date_epoch)
662 else:
663 update_hash(" %10d" % s.st_mtime)
659 664
660 update_hash(" ") 665 update_hash(" ")
661 if stat.S_ISBLK(s.st_mode) or stat.S_ISCHR(s.st_mode): 666 if stat.S_ISBLK(s.st_mode) or stat.S_ISCHR(s.st_mode):