Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] insane.bbclass: add qa_package_check_name
@ 2012-11-13 14:08 Constantin Musca
  2012-11-13 14:45 ` Richard Purdie
  0 siblings, 1 reply; 2+ messages in thread
From: Constantin Musca @ 2012-11-13 14:08 UTC (permalink / raw)
  To: openembedded-core; +Cc: Constantin Musca

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

[YOCTO #3139]

Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
---
 meta/classes/insane.bbclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index d51d1a1..f22e620 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -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
-- 
1.7.11.7




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

* Re: [PATCH] insane.bbclass: add qa_package_check_name
  2012-11-13 14:08 [PATCH] insane.bbclass: add qa_package_check_name Constantin Musca
@ 2012-11-13 14:45 ` Richard Purdie
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2012-11-13 14:45 UTC (permalink / raw)
  To: Constantin Musca; +Cc: openembedded-core

On Tue, 2012-11-13 at 16:08 +0200, Constantin Musca wrote:
> Check if package names match the [a-z0-9.+-]+ regular
> expression
> 
> [YOCTO #3139]
> 
> Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
> ---
>  meta/classes/insane.bbclass | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
> index d51d1a1..f22e620 100644
> --- a/meta/classes/insane.bbclass
> +++ b/meta/classes/insane.bbclass
> @@ -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

> +    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





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

end of thread, other threads:[~2012-11-13 14:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-13 14:08 [PATCH] insane.bbclass: add qa_package_check_name Constantin Musca
2012-11-13 14:45 ` Richard Purdie

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