summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2015-09-29 13:45:59 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-29 14:42:29 +0100
commit03666c8a74e0956633d79ad215ea16da72b1b367 (patch)
tree13885dabd7d3efd5cc3c3f8b20a28a374dcb1f71
parent85f6cf736b5ecf3af6d1596b782dae81b9ac1f11 (diff)
downloadpoky-03666c8a74e0956633d79ad215ea16da72b1b367.tar.gz
sstate: run recipe-provided hooks outside of ${B}
To avoid races between the sstate tasks/hooks using ${B} as the cwd, and other tasks such as cmake_do_configure which deletes and re-creates ${B}, ensure that all sstate hooks are run in the right directory, and run the prefunc/postfunc in WORKDIR. (From OE-Core rev: dc8546241a66c6eb076dc67fd165b5216b822ced) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/sstate.bbclass30
1 files changed, 14 insertions, 16 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index f17db0b874..9128adad8a 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -42,16 +42,6 @@ EXTRA_STAGING_FIXMES ?= ""
42 42
43SIGGEN_LOCKEDSIGS_CHECK_LEVEL ?= 'error' 43SIGGEN_LOCKEDSIGS_CHECK_LEVEL ?= 'error'
44 44
45# Specify dirs in which the shell function is executed and don't use ${B}
46# as default dirs to avoid possible race about ${B} with other task.
47sstate_create_package[dirs] = "${SSTATE_BUILDDIR}"
48sstate_unpack_package[dirs] = "${SSTATE_INSTDIR}"
49
50# Do not run sstate_hardcode_path() in ${B}:
51# the ${B} maybe removed by cmake_do_configure() while
52# sstate_hardcode_path() running.
53sstate_hardcode_path[dirs] = "${SSTATE_BUILDDIR}"
54
55python () { 45python () {
56 if bb.data.inherits_class('native', d): 46 if bb.data.inherits_class('native', d):
57 d.setVar('SSTATE_PKGARCH', d.getVar('BUILD_ARCH')) 47 d.setVar('SSTATE_PKGARCH', d.getVar('BUILD_ARCH'))
@@ -144,6 +134,8 @@ def sstate_install(ss, d):
144 shareddirs = [] 134 shareddirs = []
145 bb.utils.mkdirhier(d.expand("${SSTATE_MANIFESTS}")) 135 bb.utils.mkdirhier(d.expand("${SSTATE_MANIFESTS}"))
146 136
137 sstateinst = d.expand("${WORKDIR}/sstate-install-%s/" % ss['task'])
138
147 d2 = d.createCopy() 139 d2 = d.createCopy()
148 extrainf = d.getVarFlag("do_" + ss['task'], 'stamp-extra-info', True) 140 extrainf = d.getVarFlag("do_" + ss['task'], 'stamp-extra-info', True)
149 if extrainf: 141 if extrainf:
@@ -237,7 +229,8 @@ def sstate_install(ss, d):
237 oe.path.copyhardlinktree(state[1], state[2]) 229 oe.path.copyhardlinktree(state[1], state[2])
238 230
239 for postinst in (d.getVar('SSTATEPOSTINSTFUNCS', True) or '').split(): 231 for postinst in (d.getVar('SSTATEPOSTINSTFUNCS', True) or '').split():
240 bb.build.exec_func(postinst, d) 232 # All hooks should run in the SSTATE_INSTDIR
233 bb.build.exec_func(postinst, d, (sstateinst,))
241 234
242 for lock in locks: 235 for lock in locks:
243 bb.utils.unlockfile(lock) 236 bb.utils.unlockfile(lock)
@@ -273,7 +266,8 @@ def sstate_installpkg(ss, d):
273 d.setVar('SSTATE_PKG', sstatepkg) 266 d.setVar('SSTATE_PKG', sstatepkg)
274 267
275 for f in (d.getVar('SSTATEPREINSTFUNCS', True) or '').split() + ['sstate_unpack_package'] + (d.getVar('SSTATEPOSTUNPACKFUNCS', True) or '').split(): 268 for f in (d.getVar('SSTATEPREINSTFUNCS', True) or '').split() + ['sstate_unpack_package'] + (d.getVar('SSTATEPOSTUNPACKFUNCS', True) or '').split():
276 bb.build.exec_func(f, d) 269 # All hooks should run in the SSTATE_INSTDIR
270 bb.build.exec_func(f, d, (sstateinst,))
277 271
278 for state in ss['dirs']: 272 for state in ss['dirs']:
279 prepdir(state[1]) 273 prepdir(state[1])
@@ -545,8 +539,9 @@ def sstate_package(ss, d):
545 539
546 for f in (d.getVar('SSTATECREATEFUNCS', True) or '').split() + ['sstate_create_package'] + \ 540 for f in (d.getVar('SSTATECREATEFUNCS', True) or '').split() + ['sstate_create_package'] + \
547 (d.getVar('SSTATEPOSTCREATEFUNCS', True) or '').split(): 541 (d.getVar('SSTATEPOSTCREATEFUNCS', True) or '').split():
548 bb.build.exec_func(f, d) 542 # All hooks should run in SSTATE_BUILDDIR.
549 543 bb.build.exec_func(f, d, (sstatebuild,))
544
550 bb.siggen.dump_this_task(sstatepkg + ".siginfo", d) 545 bb.siggen.dump_this_task(sstatepkg + ".siginfo", d)
551 546
552 return 547 return
@@ -604,19 +599,22 @@ python sstate_task_prefunc () {
604 shared_state = sstate_state_fromvars(d) 599 shared_state = sstate_state_fromvars(d)
605 sstate_clean(shared_state, d) 600 sstate_clean(shared_state, d)
606} 601}
602sstate_task_prefunc[dirs] = "${WORKDIR}"
607 603
608python sstate_task_postfunc () { 604python sstate_task_postfunc () {
609 shared_state = sstate_state_fromvars(d) 605 shared_state = sstate_state_fromvars(d)
606
610 sstate_install(shared_state, d) 607 sstate_install(shared_state, d)
611 for intercept in shared_state['interceptfuncs']: 608 for intercept in shared_state['interceptfuncs']:
612 bb.build.exec_func(intercept, d) 609 bb.build.exec_func(intercept, d, (d.getVar("WORKDIR", True),))
613 omask = os.umask(002) 610 omask = os.umask(002)
614 if omask != 002: 611 if omask != 002:
615 bb.note("Using umask 002 (not %0o) for sstate packaging" % omask) 612 bb.note("Using umask 002 (not %0o) for sstate packaging" % omask)
616 sstate_package(shared_state, d) 613 sstate_package(shared_state, d)
617 os.umask(omask) 614 os.umask(omask)
618} 615}
619 616sstate_task_postfunc[dirs] = "${WORKDIR}"
617
620 618
621# 619#
622# Shell function to generate a sstate package from a directory 620# Shell function to generate a sstate package from a directory