summaryrefslogtreecommitdiffstats
path: root/meta/classes/sstate.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-09-13 23:56:16 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-09-16 09:50:34 +0100
commit6c5a29035b11a80270ff6e522ae3530a1aaa13e2 (patch)
treea4d19f5f264f695b069d8d1578f346d8f38b5b6f /meta/classes/sstate.bbclass
parent95fa69f3d380d3bb99e8e2ac7e1be3b9f5698fb9 (diff)
downloadpoky-6c5a29035b11a80270ff6e522ae3530a1aaa13e2.tar.gz
sstate: Ensure SDE is accounted for in package task timestamps
When creating packages we build them with --clamp-mtime and use SOURCE_DATE_EPOCH as the maximum mtime. This makes the end packages reproducible. The data stored in sstate for do_package and the package task doesn't benefit from this though and have varying timestamps. This means their outhash varies and means hash equivalance isn't effective at all and doesn't work as intended/desired. We could create the sstate archives with the same clamping however that would lead to different results depending on whether a task was installed from sstate or not. Making that differ is a path to madness. It also wouldn't fix the outhash of the task to be determninistic without clamping of the date in the hash calculation code. Instead, iterate over the files in sstate output and clamp them at the code level. This isn't ideal but does make the file timestamps determnistic everywhere and means we don't have to change the hash calculation code. This issue can be clearly seen looking at the do_package outhash for a recipe which you then re-run the package task for after adding something like whitespace to the install task. The outhash shouldn't change but currently does. (From OE-Core rev: c3b3cc4745811b48b9193f83889946b2e1788932) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/sstate.bbclass')
-rw-r--r--meta/classes/sstate.bbclass18
1 files changed, 18 insertions, 0 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 62e45cb4a8..29679e6a5e 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -640,10 +640,21 @@ python sstate_hardcode_path () {
640 640
641def sstate_package(ss, d): 641def sstate_package(ss, d):
642 import oe.path 642 import oe.path
643 import time
643 644
644 tmpdir = d.getVar('TMPDIR') 645 tmpdir = d.getVar('TMPDIR')
645 646
647 fixtime = False
648 if ss['task'] == "package":
649 fixtime = True
650
651 def fixtimestamp(root, path):
652 f = os.path.join(root, path)
653 if os.lstat(f).st_mtime > sde:
654 os.utime(f, (sde, sde), follow_symlinks=False)
655
646 sstatebuild = d.expand("${WORKDIR}/sstate-build-%s/" % ss['task']) 656 sstatebuild = d.expand("${WORKDIR}/sstate-build-%s/" % ss['task'])
657 sde = int(d.getVar("SOURCE_DATE_EPOCH") or time.time())
647 d.setVar("SSTATE_CURRTASK", ss['task']) 658 d.setVar("SSTATE_CURRTASK", ss['task'])
648 bb.utils.remove(sstatebuild, recurse=True) 659 bb.utils.remove(sstatebuild, recurse=True)
649 bb.utils.mkdirhier(sstatebuild) 660 bb.utils.mkdirhier(sstatebuild)
@@ -656,6 +667,8 @@ def sstate_package(ss, d):
656 # to sstate tasks but there aren't many of these so better just avoid them entirely. 667 # to sstate tasks but there aren't many of these so better just avoid them entirely.
657 for walkroot, dirs, files in os.walk(state[1]): 668 for walkroot, dirs, files in os.walk(state[1]):
658 for file in files + dirs: 669 for file in files + dirs:
670 if fixtime:
671 fixtimestamp(walkroot, file)
659 srcpath = os.path.join(walkroot, file) 672 srcpath = os.path.join(walkroot, file)
660 if not os.path.islink(srcpath): 673 if not os.path.islink(srcpath):
661 continue 674 continue
@@ -677,6 +690,11 @@ def sstate_package(ss, d):
677 bb.utils.mkdirhier(plain) 690 bb.utils.mkdirhier(plain)
678 bb.utils.mkdirhier(pdir) 691 bb.utils.mkdirhier(pdir)
679 bb.utils.rename(plain, pdir) 692 bb.utils.rename(plain, pdir)
693 if fixtime:
694 fixtimestamp(pdir, "")
695 for walkroot, dirs, files in os.walk(pdir):
696 for file in files + dirs:
697 fixtimestamp(walkroot, file)
680 698
681 d.setVar('SSTATE_BUILDDIR', sstatebuild) 699 d.setVar('SSTATE_BUILDDIR', sstatebuild)
682 d.setVar('SSTATE_INSTDIR', sstatebuild) 700 d.setVar('SSTATE_INSTDIR', sstatebuild)