Patchwork [1/1] license.bbclass: Infinite recursion of or nodes

login
register
mail settings
Submitter Elizabeth Flanagan
Date May 29, 2011, 12:26 a.m.
Message ID <4DE192CF.5050508@intel.com>
Download mbox | patch
Permalink /patch/4963/
State New, archived
Headers show

Comments

Elizabeth Flanagan - May 29, 2011, 12:26 a.m.
This fixes two bugs. When populate_lic was hitting | it was going
into an infinite recursion of the node.

Also, some LICENSE fields may start with "(". We want to avoid
invalid python syntax here, so we strip out the whitespace.

Signed-off-by: Beth Flanagan <elizabeth.flanagan@intel.com>
---
  meta/classes/license.bbclass |   15 ++++++++-------
  1 files changed, 8 insertions(+), 7 deletions(-)
Koen Kooi - May 29, 2011, 7:22 a.m.
Op 29 mei 2011, om 02:26 heeft Elizabeth Flanagan het volgende geschreven:

> 
> This fixes two bugs. When populate_lic was hitting | it was going
> into an infinite recursion of the node.
> 
> Also, some LICENSE fields may start with "(". We want to avoid
> invalid python syntax here, so we strip out the whitespace.
> 
> Signed-off-by: Beth Flanagan <elizabeth.flanagan@intel.com>
> ---
> meta/classes/license.bbclass |   15 ++++++++-------
> 1 files changed, 8 insertions(+), 7 deletions(-)


This doesn't apply for me with git am:

Applying: license.bbclass: Infinite recursion of or nodes
error: patch failed: meta/classes/license.bbclass:22
error: meta/classes/license.bbclass: patch does not apply
Patch failed at 0001 license.bbclass: Infinite recursion of or nodes
When you have resolved this problem run "git am --resolved".

or plain patch:
 
patching file meta/classes/license.bbclass
Hunk #1 FAILED at 22.
Hunk #2 FAILED at 77.
Hunk #3 FAILED at 97.
Hunk #4 FAILED at 106.
Hunk #5 FAILED at 119.
Hunk #6 FAILED at 130.
Hunk #7 FAILED at 157.
Koen Kooi - May 29, 2011, 7:24 a.m.
Op 29 mei 2011, om 09:22 heeft Koen Kooi het volgende geschreven:

> 
> Op 29 mei 2011, om 02:26 heeft Elizabeth Flanagan het volgende geschreven:
> 
>> 
>> This fixes two bugs. When populate_lic was hitting | it was going
>> into an infinite recursion of the node.
>> 
>> Also, some LICENSE fields may start with "(". We want to avoid
>> invalid python syntax here, so we strip out the whitespace.
>> 
>> Signed-off-by: Beth Flanagan <elizabeth.flanagan@intel.com>
>> ---
>> meta/classes/license.bbclass |   15 ++++++++-------
>> 1 files changed, 8 insertions(+), 7 deletions(-)
> 
> 
> This doesn't apply for me with git am:
> 
> Applying: license.bbclass: Infinite recursion of or nodes
> error: patch failed: meta/classes/license.bbclass:22
> error: meta/classes/license.bbclass: patch does not apply
> Patch failed at 0001 license.bbclass: Infinite recursion of or nodes
> When you have resolved this problem run "git am --resolved".
> 
> or plain patch:
> 
> patching file meta/classes/license.bbclass
> Hunk #1 FAILED at 22.
> Hunk #2 FAILED at 77.
> Hunk #3 FAILED at 97.
> Hunk #4 FAILED at 106.
> Hunk #5 FAILED at 119.
> Hunk #6 FAILED at 130.
> Hunk #7 FAILED at 157.

koen@dominion:/OE/tentacle/sources/openembedded-core$ git cherry-pick c45fef44e7b817a4dccd3953633ebcae71f286dc
Finished one cherry-pick.
[master 6d62574] license.bbclass: Infinite recursion of or nodes
 1 files changed, 8 insertions(+), 7 deletions(-)

That worked :)

Patch

diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index a4d34e7..3f93bf5 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -22,7 +22,7 @@  do_populate_lic[cleandirs] = "${LICSSTATEDIR}"
  #
  # We should really discuss standardizing this field, but that's a longer term goal.
  # For now, we can do this and it should grab the most common LICENSE naming variations.
-#
+
  #GPL variations
  SPDXLICENSEMAP[GPL] = "GPL-1"
  SPDXLICENSEMAP[GPLv2] = "GPL-2"
@@ -77,7 +77,8 @@  python do_populate_lic() {
              op = node.op
              if isinstance(op, ast.BitOr):
                  x = LicenseVisitor()
-                x.visit(node)
+                x.visit(node.left)
+                x.visit(node.right)
              else:
                  ast.NodeVisitor.generic_visit(self, node)

@@ -96,7 +97,6 @@  python do_populate_lic() {
              pass

      def find_license(license_type):
-
          try:
              bb.mkdirhier(gen_lic_dest)
          except:
@@ -106,7 +106,7 @@  python do_populate_lic() {
          if not os.path.isfile(os.path.join(generic_directory, license_type)):
              if bb.data.getVarFlag('SPDXLICENSEMAP', license_type, d) != None:
                  # Great, there is an SPDXLICENSEMAP. We can copy!
-                bb.warn("We need to use a SPDXLICENSEMAP for %s" % (license_type))
+                bb.note("We need to use a SPDXLICENSEMAP for %s" % (license_type))
                  spdx_generic = bb.data.getVarFlag('SPDXLICENSEMAP', license_type, d)
                  copy_license(generic_directory, gen_lic_dest, spdx_generic)
                  link_license(gen_lic_dest, destdir, spdx_generic)
@@ -119,7 +119,6 @@  python do_populate_lic() {
              copy_license(generic_directory, gen_lic_dest, license_type)
              link_license(gen_lic_dest, destdir, license_type)

-
      # All the license types for the package
      license_types = bb.data.getVar('LICENSE', d, True)
      # All the license files for the package
@@ -131,7 +130,7 @@  python do_populate_lic() {
      srcdir = bb.data.getVar('S', d, True)
      # Directory we store the generic licenses as set in the distro configuration
      generic_directory = bb.data.getVar('COMMON_LICENSE_DIR', d, True)
-    bb.warn(generic_directory)
+
      try:
          bb.mkdirhier(destdir)
      except:
@@ -158,13 +157,15 @@  python do_populate_lic() {
      gen_lic_dest = os.path.join(bb.data.getVar('LICENSE_DIRECTORY', d, True), "common-licenses")

      clean_licenses = ""
+
      for x in license_types.replace("(", " ( ").replace(")", " ) ").split():
          if ((x != "(") and (x != ")") and (x != "&") and (x != "|")):
              clean_licenses += "'" + x + "'"
          else:
              clean_licenses += " " + x + " "

-    node = ast.parse(clean_licenses)
+    # lstrip any possible indents, since ast needs python syntax.
+    node = ast.parse(clean_licenses.lstrip())
      v = LicenseVisitor()
      v.visit(node)
  }