[oe] [PATCH] package.bbclass: search for dangling links in installation directory

Enrico Scholz enrico.scholz at sigma-chemnitz.de
Wed Apr 14 09:41:58 UTC 2010


The old dangling link detection used os.stat() on the file and
registered it as a dangling link when it was not found. This causes
problems when the link is an absolute one because it will check
files of the host system.

E.g. when there is a link

.../tmp/work/../etc/cron.root -> /var/spool/cron/root

Then

* existence of /var/spool/cron/root but not of
  ../tmp/work/.../var/spool/cron/root will be checked

* the build aborts because a 'permission denied' exception is thrown
  but only 'not found' be catched

This patch uses os.lstat() to check whether source file is a link, adds
it to the installation root direction and checks for the existence of
this file then.

As this is only a QA mechanism which does not affect the resulting
package, there is checked for generic OSErrors only, not only for
ENOENT.  Other problems (e.g. EPERM) will be reported by other
functions.
---
 classes/package.bbclass |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/classes/package.bbclass b/classes/package.bbclass
index 990c3f6..ae8e92e 100644
--- a/classes/package.bbclass
+++ b/classes/package.bbclass
@@ -482,15 +482,17 @@ python populate_packages () {
 				path = os.path.join(root, f)
 				rpath = path[len(inst_root):]
 				pkg_files[pkg].append(rpath)
-				try:
-					s = os.stat(path)
-				except OSError, (err, strerror):
-					if err != errno.ENOENT:
-						raise
+				if os.path.islink(path):
 					target = os.readlink(path)
 					if target[0] != '/':
 						target = os.path.join(root[len(inst_root):], target)
-					dangling_links[pkg].append(os.path.normpath(target))
+
+					rtarget = os.path.join(inst_root, target[1:])
+
+					try:
+						os.lstat(rtarget)
+					except OSError:
+						dangling_links[pkg].append(os.path.normpath(target))
 
 	for pkg in package_list:
 		rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 0) or bb.data.getVar('RDEPENDS', d, 0) or "")
-- 
1.7.0.1





More information about the Openembedded-devel mailing list