summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes-global/package.bbclass68
1 files changed, 28 insertions, 40 deletions
diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass
index 418400da8c..2d985d8aff 100644
--- a/meta/classes-global/package.bbclass
+++ b/meta/classes-global/package.bbclass
@@ -565,26 +565,16 @@ def copydebugsources(debugsrcdir, sources, d):
565 objcopy = d.getVar("OBJCOPY") 565 objcopy = d.getVar("OBJCOPY")
566 workdir = d.getVar("WORKDIR") 566 workdir = d.getVar("WORKDIR")
567 sdir = d.getVar("S") 567 sdir = d.getVar("S")
568 sparentdir = os.path.dirname(os.path.dirname(sdir)) 568 cflags = d.expand("${CFLAGS}")
569 sbasedir = os.path.basename(os.path.dirname(sdir)) + "/" + os.path.basename(sdir)
570 workparentdir = os.path.dirname(os.path.dirname(workdir))
571 workbasedir = os.path.basename(os.path.dirname(workdir)) + "/" + os.path.basename(workdir)
572
573 # If S isnt based on WORKDIR we can infer our sources are located elsewhere,
574 # e.g. using externalsrc; use S as base for our dirs
575 if workdir in sdir or 'work-shared' in sdir:
576 basedir = workbasedir
577 parentdir = workparentdir
578 else:
579 basedir = sbasedir
580 parentdir = sparentdir
581 569
582 # If build path exists in sourcefile, it means toolchain did not use 570 prefixmap = {}
583 # -fdebug-prefix-map to compile 571 for flag in cflags.split():
584 if checkbuildpath(sourcefile, d): 572 if not flag.startswith("-fdebug-prefix-map"):
585 localsrc_prefix = parentdir + "/" 573 continue
586 else: 574 if "recipe-sysroot" in flag:
587 localsrc_prefix = "/usr/src/debug/" 575 continue
576 flag = flag.split("=")
577 prefixmap[flag[1]] = flag[2]
588 578
589 nosuchdir = [] 579 nosuchdir = []
590 basepath = dvar 580 basepath = dvar
@@ -595,28 +585,26 @@ def copydebugsources(debugsrcdir, sources, d):
595 bb.utils.mkdirhier(basepath) 585 bb.utils.mkdirhier(basepath)
596 cpath.updatecache(basepath) 586 cpath.updatecache(basepath)
597 587
598 # Ignore files from the recipe sysroots (target and native) 588 for pmap in prefixmap:
599 processdebugsrc = "LC_ALL=C ; sort -z -u '%s' | egrep -v -z '((<internal>|<built-in>)$|/.*recipe-sysroot.*/)' | " 589 # Ignore files from the recipe sysroots (target and native)
600 # We need to ignore files that are not actually ours 590 cmd = "LC_ALL=C ; sort -z -u '%s' | egrep -v -z '((<internal>|<built-in>)$|/.*recipe-sysroot.*/)' | " % sourcefile
601 # we do this by only paying attention to items from this package 591 # We need to ignore files that are not actually ours
602 processdebugsrc += "fgrep -zw '%s' | " 592 # we do this by only paying attention to items from this package
603 # Remove prefix in the source paths 593 cmd += "fgrep -zw '%s' | " % prefixmap[pmap]
604 processdebugsrc += "sed 's#%s##g' | " 594 # Remove prefix in the source paths
605 processdebugsrc += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)" 595 cmd += "sed 's#%s/##g' | " % (prefixmap[pmap])
606 596 cmd += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)" % (pmap, dvar, prefixmap[pmap])
607 cmd = processdebugsrc % (sourcefile, basedir, localsrc_prefix, parentdir, dvar, debugsrcdir)
608 try:
609 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
610 except subprocess.CalledProcessError:
611 # Can "fail" if internal headers/transient sources are attempted
612 pass
613
614 # cpio seems to have a bug with -lL together and symbolic links are just copied, not dereferenced.
615 # Work around this by manually finding and copying any symbolic links that made it through.
616 cmd = "find %s%s -type l -print0 -delete | sed s#%s%s/##g | (cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s')" % \
617 (dvar, debugsrcdir, dvar, debugsrcdir, parentdir, dvar, debugsrcdir)
618 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
619 597
598 try:
599 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
600 except subprocess.CalledProcessError:
601 # Can "fail" if internal headers/transient sources are attempted
602 pass
603 # cpio seems to have a bug with -lL together and symbolic links are just copied, not dereferenced.
604 # Work around this by manually finding and copying any symbolic links that made it through.
605 cmd = "find %s%s -type l -print0 -delete | sed s#%s%s/##g | (cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s')" % \
606 (dvar, prefixmap[pmap], dvar, prefixmap[pmap], pmap, dvar, prefixmap[pmap])
607 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
620 608
621 # debugsources.list may be polluted from the host if we used externalsrc, 609 # debugsources.list may be polluted from the host if we used externalsrc,
622 # cpio uses copy-pass and may have just created a directory structure 610 # cpio uses copy-pass and may have just created a directory structure