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:54:14 -0800
commitde0a865f2db91753190fcd5dc20e59c89e02d42e (patch)
tree9b802b87d96dd4d092c402f134bcad991b5d1267
parentde191df9f67d53b41de1bdffc30b94d140439e07 (diff)
downloadpoky-de0a865f2db91753190fcd5dc20e59c89e02d42e.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: 9df0bf5775ec96773e77c489ba6a443037d65ab6) 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 93df5fa9e6..567797305f 100644
--- a/meta/classes-global/sstate.bbclass
+++ b/meta/classes-global/sstate.bbclass
@@ -648,15 +648,6 @@ def sstate_package(ss, d):
648 648
649 tmpdir = d.getVar('TMPDIR') 649 tmpdir = d.getVar('TMPDIR')
650 650
651 fixtime = False
652 if ss['task'] == "package":
653 fixtime = True
654
655 def fixtimestamp(root, path):
656 f = os.path.join(root, path)
657 if os.lstat(f).st_mtime > sde:
658 os.utime(f, (sde, sde), follow_symlinks=False)
659
660 sstatebuild = d.expand("${WORKDIR}/sstate-build-%s/" % ss['task']) 651 sstatebuild = d.expand("${WORKDIR}/sstate-build-%s/" % ss['task'])
661 sde = int(d.getVar("SOURCE_DATE_EPOCH") or time.time()) 652 sde = int(d.getVar("SOURCE_DATE_EPOCH") or time.time())
662 d.setVar("SSTATE_CURRTASK", ss['task']) 653 d.setVar("SSTATE_CURRTASK", ss['task'])
@@ -671,8 +662,6 @@ def sstate_package(ss, d):
671 # to sstate tasks but there aren't many of these so better just avoid them entirely. 662 # to sstate tasks but there aren't many of these so better just avoid them entirely.
672 for walkroot, dirs, files in os.walk(state[1]): 663 for walkroot, dirs, files in os.walk(state[1]):
673 for file in files + dirs: 664 for file in files + dirs:
674 if fixtime:
675 fixtimestamp(walkroot, file)
676 srcpath = os.path.join(walkroot, file) 665 srcpath = os.path.join(walkroot, file)
677 if not os.path.islink(srcpath): 666 if not os.path.islink(srcpath):
678 continue 667 continue
@@ -694,11 +683,6 @@ def sstate_package(ss, d):
694 bb.utils.mkdirhier(plain) 683 bb.utils.mkdirhier(plain)
695 bb.utils.mkdirhier(pdir) 684 bb.utils.mkdirhier(pdir)
696 bb.utils.rename(plain, pdir) 685 bb.utils.rename(plain, pdir)
697 if fixtime:
698 fixtimestamp(pdir, "")
699 for walkroot, dirs, files in os.walk(pdir):
700 for file in files + dirs:
701 fixtimestamp(walkroot, file)
702 686
703 d.setVar('SSTATE_BUILDDIR', sstatebuild) 687 d.setVar('SSTATE_BUILDDIR', sstatebuild)
704 d.setVar('SSTATE_INSTDIR', sstatebuild) 688 d.setVar('SSTATE_INSTDIR', sstatebuild)
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py
index a46e5502ab..d818fce8f1 100644
--- a/meta/lib/oe/sstatesig.py
+++ b/meta/lib/oe/sstatesig.py
@@ -524,6 +524,7 @@ def OEOuthashBasic(path, sigfile, task, d):
524 if task == "package": 524 if task == "package":
525 include_timestamps = True 525 include_timestamps = True
526 include_root = False 526 include_root = False
527 source_date_epoch = float(d.getVar("SOURCE_DATE_EPOCH"))
527 hash_version = d.getVar('HASHEQUIV_HASH_VERSION') 528 hash_version = d.getVar('HASHEQUIV_HASH_VERSION')
528 extra_sigdata = d.getVar("HASHEQUIV_EXTRA_SIGDATA") 529 extra_sigdata = d.getVar("HASHEQUIV_EXTRA_SIGDATA")
529 530
@@ -615,7 +616,11 @@ def OEOuthashBasic(path, sigfile, task, d):
615 raise Exception(msg).with_traceback(e.__traceback__) 616 raise Exception(msg).with_traceback(e.__traceback__)
616 617
617 if include_timestamps: 618 if include_timestamps:
618 update_hash(" %10d" % s.st_mtime) 619 # Need to clamp to SOURCE_DATE_EPOCH
620 if s.st_mtime > source_date_epoch:
621 update_hash(" %10d" % source_date_epoch)
622 else:
623 update_hash(" %10d" % s.st_mtime)
619 624
620 update_hash(" ") 625 update_hash(" ")
621 if stat.S_ISBLK(s.st_mode) or stat.S_ISCHR(s.st_mode): 626 if stat.S_ISBLK(s.st_mode) or stat.S_ISCHR(s.st_mode):