summaryrefslogtreecommitdiffstats
path: root/meta/classes/sstate.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/sstate.bbclass')
-rw-r--r--meta/classes/sstate.bbclass126
1 files changed, 85 insertions, 41 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index f1faf4848e..a767a0203b 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -97,7 +97,7 @@ python () {
97 # These classes encode staging paths into their scripts data so can only be 97 # These classes encode staging paths into their scripts data so can only be
98 # reused if we manipulate the paths 98 # reused if we manipulate the paths
99 if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d) or bb.data.inherits_class('sdk', d) or bb.data.inherits_class('crosssdk', d): 99 if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d) or bb.data.inherits_class('sdk', d) or bb.data.inherits_class('crosssdk', d):
100 scan_cmd = "grep -Irl ${STAGING_DIR} ${SSTATE_BUILDDIR}" 100 scan_cmd = "grep -Irl -e ${RECIPE_SYSROOT} -e ${RECIPE_SYSROOT_NATIVE} ${SSTATE_BUILDDIR}"
101 d.setVar('SSTATE_SCAN_CMD', scan_cmd) 101 d.setVar('SSTATE_SCAN_CMD', scan_cmd)
102 102
103 unique_tasks = sorted(set((d.getVar('SSTATETASKS') or "").split())) 103 unique_tasks = sorted(set((d.getVar('SSTATETASKS') or "").split()))
@@ -131,6 +131,7 @@ def sstate_state_fromvars(d, task = None):
131 lockfiles = (d.getVarFlag("do_" + task, 'sstate-lockfile') or "").split() 131 lockfiles = (d.getVarFlag("do_" + task, 'sstate-lockfile') or "").split()
132 lockfilesshared = (d.getVarFlag("do_" + task, 'sstate-lockfile-shared') or "").split() 132 lockfilesshared = (d.getVarFlag("do_" + task, 'sstate-lockfile-shared') or "").split()
133 interceptfuncs = (d.getVarFlag("do_" + task, 'sstate-interceptfuncs') or "").split() 133 interceptfuncs = (d.getVarFlag("do_" + task, 'sstate-interceptfuncs') or "").split()
134 fixmedir = d.getVarFlag("do_" + task, 'sstate-fixmedir') or ""
134 if not task or len(inputs) != len(outputs): 135 if not task or len(inputs) != len(outputs):
135 bb.fatal("sstate variables not setup correctly?!") 136 bb.fatal("sstate variables not setup correctly?!")
136 137
@@ -146,6 +147,7 @@ def sstate_state_fromvars(d, task = None):
146 ss['lockfiles-shared'] = lockfilesshared 147 ss['lockfiles-shared'] = lockfilesshared
147 ss['plaindirs'] = plaindirs 148 ss['plaindirs'] = plaindirs
148 ss['interceptfuncs'] = interceptfuncs 149 ss['interceptfuncs'] = interceptfuncs
150 ss['fixmedir'] = fixmedir
149 return ss 151 return ss
150 152
151def sstate_add(ss, source, dest, d): 153def sstate_add(ss, source, dest, d):
@@ -195,6 +197,9 @@ def sstate_install(ss, d):
195 srcdir = os.path.join(walkroot, dir) 197 srcdir = os.path.join(walkroot, dir)
196 dstdir = srcdir.replace(state[1], state[2]) 198 dstdir = srcdir.replace(state[1], state[2])
197 #bb.debug(2, "Staging %s to %s" % (srcdir, dstdir)) 199 #bb.debug(2, "Staging %s to %s" % (srcdir, dstdir))
200 if os.path.islink(srcdir):
201 sharedfiles.append(dstdir)
202 continue
198 if not dstdir.endswith("/"): 203 if not dstdir.endswith("/"):
199 dstdir = dstdir + "/" 204 dstdir = dstdir + "/"
200 shareddirs.append(dstdir) 205 shareddirs.append(dstdir)
@@ -203,7 +208,7 @@ def sstate_install(ss, d):
203 whitelist = (d.getVar("SSTATE_DUPWHITELIST") or "").split() 208 whitelist = (d.getVar("SSTATE_DUPWHITELIST") or "").split()
204 match = [] 209 match = []
205 for f in sharedfiles: 210 for f in sharedfiles:
206 if os.path.exists(f): 211 if os.path.exists(f) and not os.path.islink(f):
207 f = os.path.normpath(f) 212 f = os.path.normpath(f)
208 realmatch = True 213 realmatch = True
209 for w in whitelist: 214 for w in whitelist:
@@ -244,6 +249,10 @@ def sstate_install(ss, d):
244 (d.getVar('PN'), "\n ".join(match))) 249 (d.getVar('PN'), "\n ".join(match)))
245 bb.fatal("If the above message is too much, the simpler version is you're advised to wipe out tmp and rebuild (reusing sstate is fine). That will likely fix things in most (but not all) cases.") 250 bb.fatal("If the above message is too much, the simpler version is you're advised to wipe out tmp and rebuild (reusing sstate is fine). That will likely fix things in most (but not all) cases.")
246 251
252 if ss['fixmedir'] and os.path.exists(ss['fixmedir'] + "/fixmepath.cmd"):
253 sharedfiles.append(ss['fixmedir'] + "/fixmepath.cmd")
254 sharedfiles.append(ss['fixmedir'] + "/fixmepath")
255
247 # Write out the manifest 256 # Write out the manifest
248 f = open(manifest, "w") 257 f = open(manifest, "w")
249 for file in sharedfiles: 258 for file in sharedfiles:
@@ -288,17 +297,8 @@ sstate_install[vardepsexclude] += "SSTATE_DUPWHITELIST STATE_MANMACH SSTATE_MANF
288sstate_install[vardeps] += "${SSTATEPOSTINSTFUNCS}" 297sstate_install[vardeps] += "${SSTATEPOSTINSTFUNCS}"
289 298
290def sstate_installpkg(ss, d): 299def sstate_installpkg(ss, d):
291 import oe.path
292 import subprocess
293 from oe.gpg_sign import get_signer 300 from oe.gpg_sign import get_signer
294 301
295 def prepdir(dir):
296 # remove dir if it exists, ensure any parent directories do exist
297 if os.path.exists(dir):
298 oe.path.remove(dir)
299 bb.utils.mkdirhier(dir)
300 oe.path.remove(dir)
301
302 sstateinst = d.expand("${WORKDIR}/sstate-install-%s/" % ss['task']) 302 sstateinst = d.expand("${WORKDIR}/sstate-install-%s/" % ss['task'])
303 sstatefetch = d.getVar('SSTATE_PKGNAME') + '_' + ss['task'] + ".tgz" 303 sstatefetch = d.getVar('SSTATE_PKGNAME') + '_' + ss['task'] + ".tgz"
304 sstatepkg = d.getVar('SSTATE_PKG') + '_' + ss['task'] + ".tgz" 304 sstatepkg = d.getVar('SSTATE_PKG') + '_' + ss['task'] + ".tgz"
@@ -320,11 +320,36 @@ def sstate_installpkg(ss, d):
320 if not signer.verify(sstatepkg + '.sig'): 320 if not signer.verify(sstatepkg + '.sig'):
321 bb.warn("Cannot verify signature on sstate package %s" % sstatepkg) 321 bb.warn("Cannot verify signature on sstate package %s" % sstatepkg)
322 322
323 for f in (d.getVar('SSTATEPREINSTFUNCS') or '').split() + ['sstate_unpack_package'] + (d.getVar('SSTATEPOSTUNPACKFUNCS') or '').split(): 323 sstateinst = d.getVar("SSTATE_INSTDIR")
324 d.setVar('SSTATE_FIXMEDIR', ss['fixmedir'])
325
326 for f in (d.getVar('SSTATEPREINSTFUNCS') or '').split() + ['sstate_unpack_package']:
324 # All hooks should run in the SSTATE_INSTDIR 327 # All hooks should run in the SSTATE_INSTDIR
325 bb.build.exec_func(f, d, (sstateinst,)) 328 bb.build.exec_func(f, d, (sstateinst,))
326 329
330 return sstate_installpkgdir(ss, d)
331
332def sstate_installpkgdir(ss, d):
333 import oe.path
334 import subprocess
335
336 sstateinst = d.getVar("SSTATE_INSTDIR")
337 d.setVar('SSTATE_FIXMEDIR', ss['fixmedir'])
338
339 for f in (d.getVar('SSTATEPOSTUNPACKFUNCS') or '').split():
340 # All hooks should run in the SSTATE_INSTDIR
341 bb.build.exec_func(f, d, (sstateinst,))
342
343 def prepdir(dir):
344 # remove dir if it exists, ensure any parent directories do exist
345 if os.path.exists(dir):
346 oe.path.remove(dir)
347 bb.utils.mkdirhier(dir)
348 oe.path.remove(dir)
349
327 for state in ss['dirs']: 350 for state in ss['dirs']:
351 if d.getVar('SSTATE_SKIP_CREATION') == '1':
352 continue
328 prepdir(state[1]) 353 prepdir(state[1])
329 os.rename(sstateinst + state[0], state[1]) 354 os.rename(sstateinst + state[0], state[1])
330 sstate_install(ss, d) 355 sstate_install(ss, d)
@@ -347,18 +372,18 @@ python sstate_hardcode_path_unpack () {
347 import subprocess 372 import subprocess
348 373
349 sstateinst = d.getVar('SSTATE_INSTDIR') 374 sstateinst = d.getVar('SSTATE_INSTDIR')
350 fixmefn = sstateinst + "fixmepath" 375 sstatefixmedir = d.getVar('SSTATE_FIXMEDIR')
376 fixmefn = sstateinst + "fixmepath"
351 if os.path.isfile(fixmefn): 377 if os.path.isfile(fixmefn):
352 staging = d.getVar('STAGING_DIR') 378 staging_target = d.getVar('RECIPE_SYSROOT')
353 staging_target = d.getVar('STAGING_DIR_TARGET') 379 staging_host = d.getVar('RECIPE_SYSROOT_NATIVE')
354 staging_host = d.getVar('STAGING_DIR_HOST') 380
355 381 if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross-canadian', d):
356 if bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('crosssdk', d) or bb.data.inherits_class('cross-canadian', d):
357 sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIR:%s:g'" % (staging)
358 elif bb.data.inherits_class('cross', d):
359 sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIRTARGET:%s:g; s:FIXMESTAGINGDIR:%s:g'" % (staging_target, staging)
360 else:
361 sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIRHOST:%s:g'" % (staging_host) 382 sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIRHOST:%s:g'" % (staging_host)
383 elif bb.data.inherits_class('cross', d) or bb.data.inherits_class('crosssdk', d):
384 sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIRTARGET:%s:g; s:FIXMESTAGINGDIRHOST:%s:g'" % (staging_target, staging_host)
385 else:
386 sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIRTARGET:%s:g'" % (staging_target)
362 387
363 extra_staging_fixmes = d.getVar('EXTRA_STAGING_FIXMES') or '' 388 extra_staging_fixmes = d.getVar('EXTRA_STAGING_FIXMES') or ''
364 for fixmevar in extra_staging_fixmes.split(): 389 for fixmevar in extra_staging_fixmes.split():
@@ -368,6 +393,18 @@ python sstate_hardcode_path_unpack () {
368 # Add sstateinst to each filename in fixmepath, use xargs to efficiently call sed 393 # Add sstateinst to each filename in fixmepath, use xargs to efficiently call sed
369 sstate_hardcode_cmd = "sed -e 's:^:%s:g' %s | xargs %s" % (sstateinst, fixmefn, sstate_sed_cmd) 394 sstate_hardcode_cmd = "sed -e 's:^:%s:g' %s | xargs %s" % (sstateinst, fixmefn, sstate_sed_cmd)
370 395
396 # Defer do_populate_sysroot relocation command
397 if sstatefixmedir:
398 bb.utils.mkdirhier(sstatefixmedir)
399 with open(sstatefixmedir + "/fixmepath.cmd", "w") as f:
400 sstate_hardcode_cmd = sstate_hardcode_cmd.replace(fixmefn, sstatefixmedir + "/fixmepath")
401 sstate_hardcode_cmd = sstate_hardcode_cmd.replace(sstateinst, "FIXMEFINALSSTATEINST")
402 sstate_hardcode_cmd = sstate_hardcode_cmd.replace(staging_host, "FIXMEFINALSSTATEHOST")
403 sstate_hardcode_cmd = sstate_hardcode_cmd.replace(staging_target, "FIXMEFINALSSTATETARGET")
404 f.write(sstate_hardcode_cmd)
405 bb.utils.copyfile(fixmefn, sstatefixmedir + "/fixmepath")
406 return
407
371 bb.note("Replacing fixme paths in sstate package: %s" % (sstate_hardcode_cmd)) 408 bb.note("Replacing fixme paths in sstate package: %s" % (sstate_hardcode_cmd))
372 subprocess.call(sstate_hardcode_cmd, shell=True) 409 subprocess.call(sstate_hardcode_cmd, shell=True)
373 410
@@ -499,20 +536,19 @@ python sstate_hardcode_path () {
499 # Note: the logic in this function needs to match the reverse logic 536 # Note: the logic in this function needs to match the reverse logic
500 # in sstate_installpkg(ss, d) 537 # in sstate_installpkg(ss, d)
501 538
502 staging = d.getVar('STAGING_DIR') 539 staging_target = d.getVar('RECIPE_SYSROOT')
503 staging_target = d.getVar('STAGING_DIR_TARGET') 540 staging_host = d.getVar('RECIPE_SYSROOT_NATIVE')
504 staging_host = d.getVar('STAGING_DIR_HOST')
505 sstate_builddir = d.getVar('SSTATE_BUILDDIR') 541 sstate_builddir = d.getVar('SSTATE_BUILDDIR')
506 542
507 if bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('crosssdk', d) or bb.data.inherits_class('cross-canadian', d): 543 if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross-canadian', d):
508 sstate_grep_cmd = "grep -l -e '%s'" % (staging)
509 sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIR:g'" % (staging)
510 elif bb.data.inherits_class('cross', d):
511 sstate_grep_cmd = "grep -l -e '%s' -e '%s'" % (staging_target, staging)
512 sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIRTARGET:g; s:%s:FIXMESTAGINGDIR:g'" % (staging_target, staging)
513 else:
514 sstate_grep_cmd = "grep -l -e '%s'" % (staging_host) 544 sstate_grep_cmd = "grep -l -e '%s'" % (staging_host)
515 sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIRHOST:g'" % (staging_host) 545 sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIRHOST:g'" % (staging_host)
546 elif bb.data.inherits_class('cross', d) or bb.data.inherits_class('crosssdk', d):
547 sstate_grep_cmd = "grep -l -e '%s' -e '%s'" % (staging_target, staging_host)
548 sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIRTARGET:g; s:%s:FIXMESTAGINGDIRHOST:g'" % (staging_target, staging_host)
549 else:
550 sstate_grep_cmd = "grep -l -e '%s'" % (staging_target)
551 sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIRTARGET:g'" % (staging_target)
516 552
517 extra_staging_fixmes = d.getVar('EXTRA_STAGING_FIXMES') or '' 553 extra_staging_fixmes = d.getVar('EXTRA_STAGING_FIXMES') or ''
518 for fixmevar in extra_staging_fixmes.split(): 554 for fixmevar in extra_staging_fixmes.split():
@@ -537,14 +573,14 @@ python sstate_hardcode_path () {
537 sstate_hardcode_cmd = "%s | xargs %s | %s | xargs %s %s" % (sstate_scan_cmd, sstate_grep_cmd, sstate_filelist_cmd, xargs_no_empty_run_cmd, sstate_sed_cmd) 573 sstate_hardcode_cmd = "%s | xargs %s | %s | xargs %s %s" % (sstate_scan_cmd, sstate_grep_cmd, sstate_filelist_cmd, xargs_no_empty_run_cmd, sstate_sed_cmd)
538 574
539 bb.note("Removing hardcoded paths from sstate package: '%s'" % (sstate_hardcode_cmd)) 575 bb.note("Removing hardcoded paths from sstate package: '%s'" % (sstate_hardcode_cmd))
540 subprocess.call(sstate_hardcode_cmd, shell=True) 576 subprocess.check_call(sstate_hardcode_cmd, shell=True, cwd=sstate_builddir)
541 577
542 # If the fixmefn is empty, remove it.. 578 # If the fixmefn is empty, remove it..
543 if os.stat(fixmefn).st_size == 0: 579 if os.stat(fixmefn).st_size == 0:
544 os.remove(fixmefn) 580 os.remove(fixmefn)
545 else: 581 else:
546 bb.note("Replacing absolute paths in fixmepath file: '%s'" % (sstate_filelist_relative_cmd)) 582 bb.note("Replacing absolute paths in fixmepath file: '%s'" % (sstate_filelist_relative_cmd))
547 subprocess.call(sstate_filelist_relative_cmd, shell=True) 583 subprocess.check_call(sstate_filelist_relative_cmd, shell=True)
548} 584}
549 585
550def sstate_package(ss, d): 586def sstate_package(ss, d):
@@ -560,6 +596,8 @@ def sstate_package(ss, d):
560 if not link.startswith(tmpdir): 596 if not link.startswith(tmpdir):
561 return 597 return
562 598
599 #base = os.path.relpath(link, os.path.dirname(path))
600
563 depth = outputpath.rpartition(tmpdir)[2].count('/') 601 depth = outputpath.rpartition(tmpdir)[2].count('/')
564 base = link.partition(tmpdir)[2].strip() 602 base = link.partition(tmpdir)[2].strip()
565 while depth > 1: 603 while depth > 1:
@@ -594,14 +632,14 @@ def sstate_package(ss, d):
594 dstpath = srcpath.replace(state[1], state[2]) 632 dstpath = srcpath.replace(state[1], state[2])
595 make_relative_symlink(srcpath, dstpath, d) 633 make_relative_symlink(srcpath, dstpath, d)
596 bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0])) 634 bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0]))
597 oe.path.copyhardlinktree(state[1], sstatebuild + state[0]) 635 os.rename(state[1], sstatebuild + state[0])
598 636
599 workdir = d.getVar('WORKDIR') 637 workdir = d.getVar('WORKDIR')
600 for plain in ss['plaindirs']: 638 for plain in ss['plaindirs']:
601 pdir = plain.replace(workdir, sstatebuild) 639 pdir = plain.replace(workdir, sstatebuild)
602 bb.utils.mkdirhier(plain) 640 bb.utils.mkdirhier(plain)
603 bb.utils.mkdirhier(pdir) 641 bb.utils.mkdirhier(pdir)
604 oe.path.copyhardlinktree(plain, pdir) 642 os.rename(plain, pdir)
605 643
606 d.setVar('SSTATE_BUILDDIR', sstatebuild) 644 d.setVar('SSTATE_BUILDDIR', sstatebuild)
607 d.setVar('SSTATE_PKG', sstatepkg) 645 d.setVar('SSTATE_PKG', sstatepkg)
@@ -614,6 +652,8 @@ def sstate_package(ss, d):
614 652
615 bb.siggen.dump_this_task(sstatepkg + ".siginfo", d) 653 bb.siggen.dump_this_task(sstatepkg + ".siginfo", d)
616 654
655 d.setVar('SSTATE_INSTDIR', sstatebuild)
656
617 return 657 return
618 658
619def pstaging_fetch(sstatefetch, sstatepkg, d): 659def pstaging_fetch(sstatefetch, sstatepkg, d):
@@ -672,14 +712,21 @@ sstate_task_prefunc[dirs] = "${WORKDIR}"
672python sstate_task_postfunc () { 712python sstate_task_postfunc () {
673 shared_state = sstate_state_fromvars(d) 713 shared_state = sstate_state_fromvars(d)
674 714
675 sstate_install(shared_state, d)
676 for intercept in shared_state['interceptfuncs']: 715 for intercept in shared_state['interceptfuncs']:
677 bb.build.exec_func(intercept, d, (d.getVar("WORKDIR"),)) 716 bb.build.exec_func(intercept, d, (d.getVar("WORKDIR"),))
717
678 omask = os.umask(0o002) 718 omask = os.umask(0o002)
679 if omask != 0o002: 719 if omask != 0o002:
680 bb.note("Using umask 0o002 (not %0o) for sstate packaging" % omask) 720 bb.note("Using umask 0o002 (not %0o) for sstate packaging" % omask)
681 sstate_package(shared_state, d) 721 sstate_package(shared_state, d)
682 os.umask(omask) 722 os.umask(omask)
723
724 sstateinst = d.getVar("SSTATE_INSTDIR")
725 d.setVar('SSTATE_FIXMEDIR', shared_state['fixmedir'])
726
727 sstate_installpkgdir(shared_state, d)
728
729 bb.utils.remove(d.getVar("SSTATE_BUILDDIR"), recurse=True)
683} 730}
684sstate_task_postfunc[dirs] = "${WORKDIR}" 731sstate_task_postfunc[dirs] = "${WORKDIR}"
685 732
@@ -704,9 +751,6 @@ sstate_create_package () {
704 fi 751 fi
705 chmod 0664 $TFILE 752 chmod 0664 $TFILE
706 mv -f $TFILE ${SSTATE_PKG} 753 mv -f $TFILE ${SSTATE_PKG}
707
708 cd ${WORKDIR}
709 rm -rf ${SSTATE_BUILDDIR}
710} 754}
711 755
712python sstate_sign_package () { 756python sstate_sign_package () {
@@ -877,7 +921,7 @@ def setscene_depvalid(task, taskdependees, notneeded, d):
877 bb.debug(2, "Considering setscene task: %s" % (str(taskdependees[task]))) 921 bb.debug(2, "Considering setscene task: %s" % (str(taskdependees[task])))
878 922
879 def isNativeCross(x): 923 def isNativeCross(x):
880 return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x 924 return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross")
881 925
882 # We only need to trigger populate_lic through direct dependencies 926 # We only need to trigger populate_lic through direct dependencies
883 if taskdependees[task][1] == "do_populate_lic": 927 if taskdependees[task][1] == "do_populate_lic":