[oe-commits] Holger Hans Peter Freyther : insane.bbclass: Detect if someone is not using our LDFLAGS

GIT User account git at amethyst.openembedded.net
Tue Oct 28 14:17:49 UTC 2008


Module: openembedded.git
Branch: org.openembedded.dev
Commit: c00633cd751a2ccc6fcf8d1805a358327ae6d628
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=c00633cd751a2ccc6fcf8d1805a358327ae6d628

Author: Holger Hans Peter Freyther <zecke at selfish.org>
Date:   Sun Oct 26 20:14:53 2008 +0100

insane.bbclass: Detect if someone is not using our LDFLAGS

    We started passing --target-style=gnu/both to the linker. If the
    buildsystem is not picking up our LDFLAGS it will not have this
    hash in the binary. E.g. this is true for busybox. Add a check to
    insane.bbclass to check if we have a GNU_HASH in the elf binary.

    Make this a non fatal QA option until the majority of packages
    are fixed.

---

 classes/insane.bbclass |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/classes/insane.bbclass b/classes/insane.bbclass
index 331fd57..7c9966f 100644
--- a/classes/insane.bbclass
+++ b/classes/insane.bbclass
@@ -183,7 +183,7 @@ def package_qa_make_fatal_error(error_class, name, path,d):
 
     TODO: Load a whitelist of known errors
     """
-    return not error_class in [0, 5, 7]
+    return not error_class in [0, 5, 7, 9]
 
 def package_qa_write_error(error_class, name, path, d):
     """
@@ -204,6 +204,7 @@ def package_qa_write_error(error_class, name, path, d):
         "evil hides inside the .pc",
         "the desktop file is not valid",
         ".la contains reference to the workdir",
+        "LDFLAGS ignored",
     ]
 
     log_path = os.path.join( bb.data.getVar('T', d, True), "log.qa_package" )
@@ -325,6 +326,41 @@ def package_qa_check_desktop(path, name, d):
 
     return sane
 
+def package_qa_hash_style(path, name, d):
+    """
+    Check if the binary has the right hash style...
+    """
+    import bb, os
+
+    if os.path.islink(path):
+        return True
+
+    gnu_hash = "--hash-style=gnu" in bb.data.getVar('LDFLAGS', d, True)
+    if not gnu_hash:
+        gnu_hash = "--hash-style=both" in bb.data.getVar('LDFLAGS', d, True)
+
+    objdump = bb.data.getVar('OBJDUMP', d, True)
+    env_path = bb.data.getVar('PATH', d, True)
+
+    sane = True
+    elf = False
+    # A bit hacky. We do not know if path is an elf binary or not
+    # we will search for 'NEEDED' or 'INIT' as this should be printed...
+    # and come before the HASH section (guess!!!) and works on split out
+    # debug symbols too
+    for line in os.popen("LC_ALL=C PATH=%s %s -p '%s' 2> /dev/null" % (env_path, objdump, path), "r"):
+        if "NEEDED" in line or "INIT" in line:
+            sane = False
+            elf = True
+        if "GNU_HASH" in line:
+            sane = True
+
+    if elf and not sane:
+        error_msg = "No GNU_HASH in the elf binary: '%s'" % path
+        return package_qa_handle_error(9, error_msg, name, path, d)
+
+    return True
+
 def package_qa_check_staged(path,d):
     """
     Check staged la and pc files for sanity
@@ -433,7 +469,7 @@ python do_package_qa () {
 
     checks = [package_qa_check_rpath, package_qa_check_devdbg,
               package_qa_check_perm, package_qa_check_arch,
-              package_qa_check_desktop]
+              package_qa_check_desktop, package_qa_hash_style]
     walk_sane = True
     rdepends_sane = True
     for package in packages.split():





More information about the Openembedded-commits mailing list