Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] package.bbclass: search for dangling links in installation directory
@ 2012-10-13 12:12 Enrico Scholz
  2012-10-14  1:46 ` Chris Larson
  0 siblings, 1 reply; 5+ messages in thread
From: Enrico Scholz @ 2012-10-13 12:12 UTC (permalink / raw)
  To: openembedded-core; +Cc: Enrico Scholz

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. E.g. build of systemd on an SELinux
  enabled host aborts with:

  | ERROR: Error executing a python function in .../systemd/systemd_git.bb:
  | OSError: [Errno 13] Permission denied: '.../packages-split/systemd-initramfs/init'
  | ...
  | ERROR:      0219:                try:
  | ERROR:  *** 0220:                    s = os.stat(path)
  | ERROR:      0221:                except OSError, (err, strerror):

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, rebuilds are not needed

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 meta/classes/package.bbclass | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 73c4358..30614f0 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1063,14 +1063,23 @@ python populate_packages () {
                 path = os.path.join(root, f)
                 rpath = path[len(inst_root):]
                 pkg_files[pkg].append(rpath)
+
+                if not os.path.islink(path):
+                    continue
+
+                target = os.readlink(path)
+                if target[0] != '/':
+                    # make path absolute relative to inst_root
+                    target = os.path.join(root[len(inst_root):], target)
+
+                # make path absolute; do not use os.path.join() here
+                # because target might start with multiple '/'
+                rtarget = inst_root + target
                 try:
-                    s = os.stat(path)
+                    os.lstat(rtarget)
                 except OSError, (err, strerror):
                     if err != errno.ENOENT:
                         raise
-                    target = os.readlink(path)
-                    if target[0] != '/':
-                        target = os.path.join(root[len(inst_root):], target)
                     dangling_links[pkg].append(os.path.normpath(target))
 
     for pkg in package_list:
-- 
1.7.11.7




^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-10-29 15:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-13 12:12 [PATCH] package.bbclass: search for dangling links in installation directory Enrico Scholz
2012-10-14  1:46 ` Chris Larson
2012-10-14  9:51   ` Enrico Scholz
2012-10-14 14:58     ` Phil Blundell
2012-10-29 15:20       ` Enrico Scholz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox