summaryrefslogtreecommitdiffstats
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-11-15 11:53:55 +0000
commit54560698c63c14814b8e22bd0f9e094106561a02 (patch)
treeee41e3b593cb92706f425be8dc54beb241162e34
parentc989f6f4e0388da7a66a1dfccdcdd949a4f8193b (diff)
downloadpoky-54560698c63c14814b8e22bd0f9e094106561a02.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: 06b8f2a5a24be1a87f0eaf29fdba719ebe3bb06e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit c3b3cc4745811b48b9193f83889946b2e1788932) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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 930d87424f..50d44398f9 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 os.rename(plain, pdir) 692 os.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)