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.bbclass42
1 files changed, 12 insertions, 30 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index ada6fe5986..bd9c2ae02e 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -583,29 +583,6 @@ python sstate_hardcode_path () {
583def sstate_package(ss, d): 583def sstate_package(ss, d):
584 import oe.path 584 import oe.path
585 585
586 def make_relative_symlink(path, outputpath, d):
587 # Replace out absolute TMPDIR paths in symlinks with relative ones
588 if not os.path.islink(path):
589 return
590 link = os.readlink(path)
591 if not os.path.isabs(link):
592 return
593 if not link.startswith(tmpdir):
594 return
595
596 #base = os.path.relpath(link, os.path.dirname(path))
597
598 depth = outputpath.rpartition(tmpdir)[2].count('/')
599 base = link.partition(tmpdir)[2].strip()
600 while depth > 1:
601 base = "/.." + base
602 depth -= 1
603 base = "." + base
604
605 bb.debug(2, "Replacing absolute path %s with relative path %s for %s" % (link, base, outputpath))
606 os.remove(path)
607 os.symlink(base, path)
608
609 tmpdir = d.getVar('TMPDIR') 586 tmpdir = d.getVar('TMPDIR')
610 587
611 sstatebuild = d.expand("${WORKDIR}/sstate-build-%s/" % ss['task']) 588 sstatebuild = d.expand("${WORKDIR}/sstate-build-%s/" % ss['task'])
@@ -619,15 +596,20 @@ def sstate_package(ss, d):
619 if d.getVar('SSTATE_SKIP_CREATION') == '1': 596 if d.getVar('SSTATE_SKIP_CREATION') == '1':
620 continue 597 continue
621 srcbase = state[0].rstrip("/").rsplit('/', 1)[0] 598 srcbase = state[0].rstrip("/").rsplit('/', 1)[0]
599 # Find and error for absolute symlinks. We could attempt to relocate but its not
600 # clear where the symlink is relative to in this context. We could add that markup
601 # to sstate tasks but there aren't many of these so better just avoid them entirely.
622 for walkroot, dirs, files in os.walk(state[1]): 602 for walkroot, dirs, files in os.walk(state[1]):
623 for file in files: 603 for file in files + dirs:
624 srcpath = os.path.join(walkroot, file) 604 srcpath = os.path.join(walkroot, file)
625 dstpath = srcpath.replace(state[1], state[2]) 605 if not os.path.islink(srcpath):
626 make_relative_symlink(srcpath, dstpath, d) 606 continue
627 for dir in dirs: 607 link = os.readlink(srcpath)
628 srcpath = os.path.join(walkroot, dir) 608 if not os.path.isabs(link):
629 dstpath = srcpath.replace(state[1], state[2]) 609 continue
630 make_relative_symlink(srcpath, dstpath, d) 610 if not link.startswith(tmpdir):
611 continue
612 bb.error("sstate found an absolute path symlink %s pointing at %s. Please replace this with a relative link." % (srcpath, link))
631 bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0])) 613 bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0]))
632 os.rename(state[1], sstatebuild + state[0]) 614 os.rename(state[1], sstatebuild + state[0])
633 615