From 62ee349cf18532dac8736488752c00e89de78fcd Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 30 May 2024 11:48:12 +0100 Subject: [PATCH] sstate/buildhistory: Fix plaindirs handling to occur before SSTATEPOSTINSTFUNCS buildhistory is showing issues where plaindirs installed files (such as package listings) are not reliably being handled with installs from sstate. The reason is that plaindirs is being handled after SSTATEPOSTINSTFUNCS instead of before it, meaning the files visible in a non-sstate accelerated code run are different to show from an accelerated run. This can be observed by the missing files lists for packages in buildhistory, both in from scratch builds and in builds from sstate. In builds where sstate is installed over an existing build directory, the files are present though, so there is a determinism problem. Fix this by moving the code into sstate_install, this is the only call site for the funciton. Since the move needs prepdir, move that as well as it's call site, being careful to handle the two different definitions of SSTATE_INSTDIR. The version originally in the function was obsolete and was causing the postinstfuncs to run in an incorrect directory. The only user is buildhistory and it wasn't sensitive to cwd however so this happened not to cause a problem. Fix the code to use the correct location. Signed-off-by: Richard Purdie --- meta/classes-global/sstate.bbclass | 47 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/meta/classes-global/sstate.bbclass b/meta/classes-global/sstate.bbclass index f4ebeb5859a..beb22f424e8 100644 --- a/meta/classes-global/sstate.bbclass +++ b/meta/classes-global/sstate.bbclass @@ -223,12 +223,23 @@ def sstate_install(ss, d): import oe.sstatesig import subprocess + def prepdir(dir): + # remove dir if it exists, ensure any parent directories do exist + if os.path.exists(dir): + oe.path.remove(dir) + bb.utils.mkdirhier(dir) + oe.path.remove(dir) + + sstateinst = d.getVar("SSTATE_INSTDIR") + + for state in ss['dirs']: + prepdir(state[1]) + bb.utils.rename(sstateinst + state[0], state[1]) + sharedfiles = [] shareddirs = [] bb.utils.mkdirhier(d.expand("${SSTATE_MANIFESTS}")) - sstateinst = d.expand("${WORKDIR}/sstate-install-%s/" % ss['task']) - manifest, d2 = oe.sstatesig.sstate_get_manifest_filename(ss['task'], d) if os.access(manifest, os.R_OK): @@ -327,6 +338,17 @@ def sstate_install(ss, d): if os.path.exists(state[1]): oe.path.copyhardlinktree(state[1], state[2]) + for plain in ss['plaindirs']: + workdir = d.getVar('WORKDIR') + sharedworkdir = os.path.join(d.getVar('TMPDIR'), "work-shared") + src = sstateinst + "/" + plain.replace(workdir, '') + if sharedworkdir in plain: + src = sstateinst + "/" + plain.replace(sharedworkdir, '') + dest = plain + bb.utils.mkdirhier(src) + prepdir(dest) + bb.utils.rename(src, dest) + for postinst in (d.getVar('SSTATEPOSTINSTFUNCS') or '').split(): # All hooks should run in the SSTATE_INSTDIR bb.build.exec_func(postinst, d, (sstateinst,)) @@ -391,29 +413,8 @@ def sstate_installpkgdir(ss, d): # All hooks should run in the SSTATE_INSTDIR bb.build.exec_func(f, d, (sstateinst,)) - def prepdir(dir): - # remove dir if it exists, ensure any parent directories do exist - if os.path.exists(dir): - oe.path.remove(dir) - bb.utils.mkdirhier(dir) - oe.path.remove(dir) - - for state in ss['dirs']: - prepdir(state[1]) - bb.utils.rename(sstateinst + state[0], state[1]) sstate_install(ss, d) - for plain in ss['plaindirs']: - workdir = d.getVar('WORKDIR') - sharedworkdir = os.path.join(d.getVar('TMPDIR'), "work-shared") - src = sstateinst + "/" + plain.replace(workdir, '') - if sharedworkdir in plain: - src = sstateinst + "/" + plain.replace(sharedworkdir, '') - dest = plain - bb.utils.mkdirhier(src) - prepdir(dest) - bb.utils.rename(src, dest) - return True python sstate_hardcode_path_unpack () { -- 2.47.3