summaryrefslogtreecommitdiffstats
path: root/meta/classes/package.bbclass
diff options
context:
space:
mode:
authorAlejandro Hernandez Samaniego <alhe@linux.microsoft.com>2022-06-30 20:09:39 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-07-04 15:15:14 +0100
commitc725bdb29b2669e53ea0f9d30f9683f094c9b326 (patch)
treee2f57578083714f32b885322dc18271e3ce42e0e /meta/classes/package.bbclass
parenta55994047b2ebab302d9eeb47b8d9e2c7df12437 (diff)
downloadpoky-c725bdb29b2669e53ea0f9d30f9683f094c9b326.tar.gz
package.bbclass: Fix base directory for debugsource files when using externalsrc
While executing do_package, bitbake checks for a list of debug source files and uses a pattern to match the ones to be included in copydebugsources. Previously when externalsrc was in use either directly or by using devtool, the source location changed and this pattern no longer matched, hence debug source files failed to be included in the corresponding package. Check when the source directory isnt the default (based on WORKDIR), and change the pattern used to match debug source files if that is the case, allowing us to perform do_package properly. Workaround debugsource.list containing paths from the host by moving debug source files away from the host directory structure to avoid host contamination (this seems to happen when packages use $TMPDIR/work-shared and externalsrc is in use). Test matrix included using: - devtool to use externalsrc automatically - externalsrc with a non-devtool based source directory - No externalsrc at all Tested the following packages to be working: - glibc ($TMPDIR/work-shared based) - libxcrypt ($TMPDIR/work based) [YOCTO 8015] (From OE-Core rev: a887bd96fd0a15398e8077ea79df5070971866e4) Signed-off-by: Alejandro Enedino Hernandez Samaniego <alhe@linux.microsoft.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package.bbclass')
-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)