summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-08 16:17:09 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-09 10:52:03 +0000
commit3eee8e99e114b3db8b718834ca52da8d2919b83f (patch)
treef87075988ec539a195899fb3dc8260f3827ee476 /meta/classes
parent23d9886aae0296de363545ad7a229722ed83e708 (diff)
downloadpoky-3eee8e99e114b3db8b718834ca52da8d2919b83f.tar.gz
sstate: Make absolute symlinks an error
The current relocation code is broken, at least in the native case. Fixing it would mean trying pass in new data on sstate tasks about the relative positioning of symlinks compared to the sstate relocation paths. Whilst we could do this, right now I'm favouring making this an error and fixing the small number of problematic recipes we have in OE-Core (3). (From OE-Core rev: cf94de4ddee3e5072da8608c9151301fcec02cd0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-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