summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/package.bbclass31
1 files changed, 28 insertions, 3 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 62050a18b8..4850134022 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -553,13 +553,25 @@ def copydebugsources(debugsrcdir, sources, d):
553 strip = d.getVar("STRIP") 553 strip = d.getVar("STRIP")
554 objcopy = d.getVar("OBJCOPY") 554 objcopy = d.getVar("OBJCOPY")
555 workdir = d.getVar("WORKDIR") 555 workdir = d.getVar("WORKDIR")
556 sdir = d.getVar("S")
557 sparentdir = os.path.dirname(os.path.dirname(sdir))
558 sbasedir = os.path.basename(os.path.dirname(sdir)) + "/" + os.path.basename(sdir)
556 workparentdir = os.path.dirname(os.path.dirname(workdir)) 559 workparentdir = os.path.dirname(os.path.dirname(workdir))
557 workbasedir = os.path.basename(os.path.dirname(workdir)) + "/" + os.path.basename(workdir) 560 workbasedir = os.path.basename(os.path.dirname(workdir)) + "/" + os.path.basename(workdir)
558 561
562 # If S isnt based on WORKDIR we can infer our sources are located elsewhere,
563 # e.g. using externalsrc; use S as base for our dirs
564 if workdir in sdir:
565 basedir = workbasedir
566 parentdir = workparentdir
567 else:
568 basedir = sbasedir
569 parentdir = sparentdir
570
559 # If build path exists in sourcefile, it means toolchain did not use 571 # If build path exists in sourcefile, it means toolchain did not use
560 # -fdebug-prefix-map to compile 572 # -fdebug-prefix-map to compile
561 if checkbuildpath(sourcefile, d): 573 if checkbuildpath(sourcefile, d):
562 localsrc_prefix = workparentdir + "/" 574 localsrc_prefix = parentdir + "/"
563 else: 575 else:
564 localsrc_prefix = "/usr/src/debug/" 576 localsrc_prefix = "/usr/src/debug/"
565 577
@@ -581,7 +593,7 @@ def copydebugsources(debugsrcdir, sources, d):
581 processdebugsrc += "sed 's#%s##g' | " 593 processdebugsrc += "sed 's#%s##g' | "
582 processdebugsrc += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)" 594 processdebugsrc += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)"
583 595
584 cmd = processdebugsrc % (sourcefile, workbasedir, localsrc_prefix, workparentdir, dvar, debugsrcdir) 596 cmd = processdebugsrc % (sourcefile, basedir, localsrc_prefix, parentdir, dvar, debugsrcdir)
585 try: 597 try:
586 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) 598 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
587 except subprocess.CalledProcessError: 599 except subprocess.CalledProcessError:
@@ -591,9 +603,22 @@ def copydebugsources(debugsrcdir, sources, d):
591 # cpio seems to have a bug with -lL together and symbolic links are just copied, not dereferenced. 603 # cpio seems to have a bug with -lL together and symbolic links are just copied, not dereferenced.
592 # Work around this by manually finding and copying any symbolic links that made it through. 604 # Work around this by manually finding and copying any symbolic links that made it through.
593 cmd = "find %s%s -type l -print0 -delete | sed s#%s%s/##g | (cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s')" % \ 605 cmd = "find %s%s -type l -print0 -delete | sed s#%s%s/##g | (cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s')" % \
594 (dvar, debugsrcdir, dvar, debugsrcdir, workparentdir, dvar, debugsrcdir) 606 (dvar, debugsrcdir, dvar, debugsrcdir, parentdir, dvar, debugsrcdir)
595 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) 607 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
596 608
609
610 # debugsources.list may be polluted from the host if we used externalsrc,
611 # cpio uses copy-pass and may have just created a directory structure
612 # matching the one from the host, if thats the case move those files to
613 # debugsrcdir to avoid host contamination.
614 # Empty dir structure will be deleted in the next step.
615
616 # Same check as above for externalsrc
617 if workdir not in sdir:
618 if os.path.exists(dvar + debugsrcdir + sdir):
619 cmd = "mv %s%s%s/* %s%s" % (dvar, debugsrcdir, sdir, dvar,debugsrcdir)
620 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
621
597 # The copy by cpio may have resulted in some empty directories! Remove these 622 # The copy by cpio may have resulted in some empty directories! Remove these
598 cmd = "find %s%s -empty -type d -delete" % (dvar, debugsrcdir) 623 cmd = "find %s%s -empty -type d -delete" % (dvar, debugsrcdir)
599 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) 624 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)