diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-02-08 16:17:09 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-02-09 10:50:54 +0000 |
commit | cf94de4ddee3e5072da8608c9151301fcec02cd0 (patch) | |
tree | fb4e10aacf8bab5678fe19cb81357226c8d74dfc /meta | |
parent | e478550c8cd889f12e336e268e9e3b30827bf840 (diff) | |
download | openembedded-core-cf94de4ddee3e5072da8608c9151301fcec02cd0.tar.gz openembedded-core-cf94de4ddee3e5072da8608c9151301fcec02cd0.tar.bz2 openembedded-core-cf94de4ddee3e5072da8608c9151301fcec02cd0.zip |
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).
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/sstate.bbclass | 42 |
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 () { def sstate_package(ss, d): import oe.path - def make_relative_symlink(path, outputpath, d): - # Replace out absolute TMPDIR paths in symlinks with relative ones - if not os.path.islink(path): - return - link = os.readlink(path) - if not os.path.isabs(link): - return - if not link.startswith(tmpdir): - return - - #base = os.path.relpath(link, os.path.dirname(path)) - - depth = outputpath.rpartition(tmpdir)[2].count('/') - base = link.partition(tmpdir)[2].strip() - while depth > 1: - base = "/.." + base - depth -= 1 - base = "." + base - - bb.debug(2, "Replacing absolute path %s with relative path %s for %s" % (link, base, outputpath)) - os.remove(path) - os.symlink(base, path) - tmpdir = d.getVar('TMPDIR') sstatebuild = d.expand("${WORKDIR}/sstate-build-%s/" % ss['task']) @@ -619,15 +596,20 @@ def sstate_package(ss, d): if d.getVar('SSTATE_SKIP_CREATION') == '1': continue srcbase = state[0].rstrip("/").rsplit('/', 1)[0] + # Find and error for absolute symlinks. We could attempt to relocate but its not + # clear where the symlink is relative to in this context. We could add that markup + # to sstate tasks but there aren't many of these so better just avoid them entirely. for walkroot, dirs, files in os.walk(state[1]): - for file in files: + for file in files + dirs: srcpath = os.path.join(walkroot, file) - dstpath = srcpath.replace(state[1], state[2]) - make_relative_symlink(srcpath, dstpath, d) - for dir in dirs: - srcpath = os.path.join(walkroot, dir) - dstpath = srcpath.replace(state[1], state[2]) - make_relative_symlink(srcpath, dstpath, d) + if not os.path.islink(srcpath): + continue + link = os.readlink(srcpath) + if not os.path.isabs(link): + continue + if not link.startswith(tmpdir): + continue + bb.error("sstate found an absolute path symlink %s pointing at %s. Please replace this with a relative link." % (srcpath, link)) bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0])) os.rename(state[1], sstatebuild + state[0]) |