Skip to contentSkip to conversation

insane.bbclass: add library dir sanity check

PATCH In review Radu Moisan 2 participants 3 messages Sep 14, 2012

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 insane.bbclass: add library dir sanity check

Check in ${PKGD} for libraries in other locations
then ${libdir}. Trigger a warning if so.

[Yocto #2038]

---
 meta/classes/insane.bbclass |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
meta/classes/insane.bbclass +18 -0
index e74eb3f..d748c26 100644
@@ -212,6 +212,18 @@ def package_qa_check_staticdev(path, name, d, elf, messages):
         messages.append("non -staticdev package contains static .a library: %s path '%s'" % \
                  (name, package_qa_clean_path(path,d)))
 
+def package_qa_check_libdir(path,libdir):
+    """
+    Check in path for libraries in other locations then libdir. Trigger a warning if so.
+    """
+    import re
+    lib_re = re.compile("^.*\.(so)")
+    for root, dirs, files in os.walk(path):
+        if libdir not in root:
+            for file in files:
+                if lib_re.match(file):
+                    bb.warn("Found library in wrong location: %s" % os.path.join(root,file))
+
 QAPATHTEST[debug-files] = "package_qa_check_dbg"
 def package_qa_check_dbg(path, name, d, elf, messages):
     """
@@ -688,6 +700,12 @@ python do_package_qa () {
             rdepends_sane = False
 
 
+    ml = d.getVar("MLPREFIX", True) or ""
+    if ml:
+        pkgd = d.getVar('PKGD', True)
+        libdir = d.getVar("libdir", True)
+        package_qa_check_libdir(pkgd,libdir)
+
     if not walk_sane or not rdepends_sane:
         bb.fatal("QA run found fatal errors. Please consider fixing them.")
     bb.note("DONE with PACKAGE QA")
Signature · 1 line
1.7.9.5
#1 lore raw

has problems with re pattern.
preparing v4

radu

Quoted 46 lines · Radu Moisan

Check in ${PKGD} for libraries in other locations
then ${libdir}. Trigger a warning if so.

[Yocto #2038]

---
  meta/classes/insane.bbclass |   18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
meta/classes/insane.bbclass +18 -0
index e74eb3f..d748c26 100644
@@ -212,6 +212,18 @@ def package_qa_check_staticdev(path, name, d, elf, messages):
          messages.append("non -staticdev package contains static .a library: %s path '%s'" % \
                   (name, package_qa_clean_path(path,d)))
 
+def package_qa_check_libdir(path,libdir):
+    """
+    Check in path for libraries in other locations then libdir. Trigger a warning if so.
+    """
+    import re
+    lib_re = re.compile("^.*\.(so)")
+    for root, dirs, files in os.walk(path):
+        if libdir not in root:
+            for file in files:
+                if lib_re.match(file):
+                    bb.warn("Found library in wrong location: %s" % os.path.join(root,file))
+
  QAPATHTEST[debug-files] = "package_qa_check_dbg"
  def package_qa_check_dbg(path, name, d, elf, messages):
      """
@@ -688,6 +700,12 @@ python do_package_qa () {
              rdepends_sane = False
 
 
+    ml = d.getVar("MLPREFIX", True) or ""
+    if ml:
+        pkgd = d.getVar('PKGD', True)
+        libdir = d.getVar("libdir", True)
+        package_qa_check_libdir(pkgd,libdir)
+
      if not walk_sane or not rdepends_sane:
          bb.fatal("QA run found fatal errors. Please consider fixing them.")
      bb.note("DONE with PACKAGE QA")
#2 lore raw
In reply to Radu Moisan
Quoted 19 lines · Radu Moisan

Check in ${PKGD} for libraries in other locations
then ${libdir}. Trigger a warning if so.

[Yocto #2038]

---
 meta/classes/insane.bbclass |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
meta/classes/insane.bbclass +1 -0
index e74eb3f..d748c26 100644
@@ -212,6 +212,18 @@ def package_qa_check_staticdev(path, name, d, elf, messages):
         messages.append("non -staticdev package contains static .a library: %s path '%s'" % \
                  (name, package_qa_clean_path(path,d)))
 
+def package_qa_check_libdir(path,libdir):

meta/classes/insane.bbclass def package_qa_check_staticdev(path, name, d, elf, messages): · line 225

Quoted 10 lines
meta/classes/insane.bbclass +10 -0
+    """
+    Check in path for libraries in other locations then libdir. Trigger a warning if so.
+    """
+    import re
+    lib_re = re.compile("^.*\.(so)")
+    for root, dirs, files in os.walk(path):
+        if libdir not in root:
+            for file in files:
+                if lib_re.match(file):
+                    bb.warn("Found library in wrong location: %s" % os.path.join(root,file))

This is heading in the right direction but this needs to be something like:

messages = []
for ...:
...
messages.append("Found library in wrong location: %s" % os.path.join(root,file))
if messages:

    package_qa_handle_error("libdir", "\n".join(messages), d)

so that it checks ERROR_QA for libdir and is either a warning or is fatal.

Pattern wise, this needs to look for \lib.*\.so or ${exec_prefix}\lib.* \.so and then check it doesn't start with ${base_libdir}/ or ${libdir}/ respectively.

meta/classes/insane.bbclass python do_package_qa () { · line 708

Quoted 11 lines
meta/classes/insane.bbclass +6 -0
     """
@@ -688,6 +700,12 @@ python do_package_qa () {
             rdepends_sane = False
 
 
+    ml = d.getVar("MLPREFIX", True) or ""
+    if ml:
+        pkgd = d.getVar('PKGD', True)
+        libdir = d.getVar("libdir", True)
+        package_qa_check_libdir(pkgd,libdir)
+

With the above changes, this doesn't need to be multilib specific. It will likely show more warnings on multilib builds at least.

I'd also appreciate a list of failures on a world mulitlib build (you should be able to set that away in the background and generate it) to see how widespread any problems might be.

Cheers,

Richard