Skip to contentSkip to conversation

insane.bbclass: add qa_package_check_name

PATCH In review Constantin Musca 2 participants 2 messages Nov 13, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 insane.bbclass: add qa_package_check_name

Check if package names match the [a-z0-9.+-]+ regular expression

[YOCTO #3139]

---
 meta/classes/insane.bbclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)
meta/classes/insane.bbclass +12 -0
index d51d1a1..f22e620 100644
@@ -235,6 +235,15 @@ 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_name(name, d):
+    """
+    Check if the package name matches the [a-z0-9.+-]+ regular expression
+    """
+    import re
+    pattern = re.compile("^[a-z0-9.+-]+$")
+    if not pattern.match(name):
+        package_qa_handle_error("pkgname", "%s doesn't match the [a-z0-9.+-]+ regex\n" % name, d)
+
 def package_qa_check_libdir(d):
     """
     Check for wrong library installation paths. For instance, catch
@@ -780,6 +789,9 @@ python do_package_qa () {
                 errorchecks.append(g[testmatrix[e]])
 
         bb.note("Checking Package: %s" % package)
+        # Check package name
+        package_qa_check_name(package, d)
+
         path = "%s/%s" % (pkgdest, package)
         if not package_qa_walk(path, warnchecks, errorchecks, skip, package, d):
             walk_sane  = False
Signature · 1 line
1.7.11.7
#1 lore raw
Quoted 15 lines · Constantin Musca

Check if package names match the [a-z0-9.+-]+ regular expression

[YOCTO #3139]

---
 meta/classes/insane.bbclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)
meta/classes/insane.bbclass +0 -0
index d51d1a1..f22e620 100644

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

Quoted 9 lines
meta/classes/insane.bbclass +6 -0
@@ -235,6 +235,15 @@ 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_name(name, d):
+    """
+    Check if the package name matches the [a-z0-9.+-]+ regular expression
+    """
+    import re
+    pattern = re.compile("^[a-z0-9.+-]+$")

Please stash this somewhere outside the function. Compiling regexps is expensive, using them is much less so. We'll get much performance if we just compile it once.

Cheers,

Richard

Quoted 16 lines
meta/classes/insane.bbclass +6 -0
+    if not pattern.match(name):
+        package_qa_handle_error("pkgname", "%s doesn't match the [a-z0-9.+-]+ regex\n" % name, d)
+
 def package_qa_check_libdir(d):
     """
     Check for wrong library installation paths. For instance, catch
@@ -780,6 +789,9 @@ python do_package_qa () {
                 errorchecks.append(g[testmatrix[e]])
 
         bb.note("Checking Package: %s" % package)
+        # Check package name
+        package_qa_check_name(package, d)
+
         path = "%s/%s" % (pkgdest, package)
         if not package_qa_walk(path, warnchecks, errorchecks, skip, package, d):
             walk_sane  = False