[oe-commits] Enrico Scholz : package.bbclass: use oe.path.realpath()
git at git.openembedded.org
git at git.openembedded.org
Mon Feb 11 14:45:50 UTC 2013
Module: openembedded-core.git
Branch: master
Commit: ec2aab09769f4b6817d74d2175afa2b7c7598750
URL: http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=ec2aab09769f4b6817d74d2175afa2b7c7598750
Author: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
Date: Sun Feb 10 13:41:47 2013 +0100
package.bbclass: use oe.path.realpath()
oe.path.realpath() provides are common and more correct implementation
for resolving symlinks within sysroot. Use it.
Old implementation suffered from lot of problems; e.g.
* redundant code
* calls 'os.stat()' which references files on host; this can give wrong
results about existing/non-existing and can cause EPERM (instead of
the catched ENONENT) exceptions
* does not deal with special cases like '..' leaving the sysroot.
Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
meta/classes/package.bbclass | 16 +++++-----------
1 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index b10e6f6..a74ec8a 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -741,7 +741,8 @@ python split_and_strip_files () {
continue
try:
- s = os.stat(file)
+ ltarget = oe.path.realpath(file, dvar, False)
+ s = os.lstat(ltarget)
except OSError, (err, strerror):
if err != errno.ENOENT:
raise
@@ -752,11 +753,6 @@ python split_and_strip_files () {
# If it's a symlink, and points to an ELF file, we capture the readlink target
if os.path.islink(file):
target = os.readlink(file)
- if not os.path.isabs(target):
- ltarget = os.path.join(os.path.dirname(file), target)
- else:
- ltarget = target
-
if isELF(ltarget):
#bb.note("Sym: %s (%d)" % (ltarget, isELF(ltarget)))
symlinks[file] = target
@@ -1005,14 +1001,12 @@ python package_fixsymlinks () {
rpath = path[len(inst_root):]
pkg_files[pkg].append(rpath)
try:
- s = os.stat(path)
+ rtarget = oe.path.realpath(path, inst_root, True)
+ os.lstat(rtarget)
except OSError, (err, strerror):
if err != errno.ENOENT:
raise
- target = os.readlink(path)
- if target[0] != '/':
- target = os.path.join(os.path.dirname(path)[len(inst_root):], target)
- dangling_links[pkg].append(os.path.normpath(target))
+ dangling_links[pkg].append(os.path.normpath(rtarget[len(inst_root):]))
newrdepends = {}
for pkg in dangling_links:
More information about the Openembedded-commits
mailing list