diff options
author | Beth Flanagan <elizabeth.flanagan@intel.com> | 2011-05-28 16:39:35 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-05-29 09:40:03 +0100 |
commit | d43fa5f348e97eff683f109e38087e6f15e29267 (patch) | |
tree | b0877a135edccd967144ecc3b59fd8cdb0ff88eb /meta/classes/license.bbclass | |
parent | 1169f1b066d0028bd2ef7915440450bd42ef165e (diff) | |
download | poky-d43fa5f348e97eff683f109e38087e6f15e29267.tar.gz |
license.bbclass: Infinite recursion of or nodes
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.
(From OE-Core rev: 160621bd9679201e352cc80b22aa2f6e25827576)
Signed-off-by: Beth Flanagan <elizabeth.flanagan@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/license.bbclass')
-rw-r--r-- | meta/classes/license.bbclass | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass index a4d34e7c02..3f93bf5df2 100644 --- a/meta/classes/license.bbclass +++ b/meta/classes/license.bbclass | |||
@@ -22,7 +22,7 @@ do_populate_lic[cleandirs] = "${LICSSTATEDIR}" | |||
22 | # | 22 | # |
23 | # We should really discuss standardizing this field, but that's a longer term goal. | 23 | # We should really discuss standardizing this field, but that's a longer term goal. |
24 | # For now, we can do this and it should grab the most common LICENSE naming variations. | 24 | # For now, we can do this and it should grab the most common LICENSE naming variations. |
25 | # | 25 | |
26 | #GPL variations | 26 | #GPL variations |
27 | SPDXLICENSEMAP[GPL] = "GPL-1" | 27 | SPDXLICENSEMAP[GPL] = "GPL-1" |
28 | SPDXLICENSEMAP[GPLv2] = "GPL-2" | 28 | SPDXLICENSEMAP[GPLv2] = "GPL-2" |
@@ -77,7 +77,8 @@ python do_populate_lic() { | |||
77 | op = node.op | 77 | op = node.op |
78 | if isinstance(op, ast.BitOr): | 78 | if isinstance(op, ast.BitOr): |
79 | x = LicenseVisitor() | 79 | x = LicenseVisitor() |
80 | x.visit(node) | 80 | x.visit(node.left) |
81 | x.visit(node.right) | ||
81 | else: | 82 | else: |
82 | ast.NodeVisitor.generic_visit(self, node) | 83 | ast.NodeVisitor.generic_visit(self, node) |
83 | 84 | ||
@@ -96,7 +97,6 @@ python do_populate_lic() { | |||
96 | pass | 97 | pass |
97 | 98 | ||
98 | def find_license(license_type): | 99 | def find_license(license_type): |
99 | |||
100 | try: | 100 | try: |
101 | bb.mkdirhier(gen_lic_dest) | 101 | bb.mkdirhier(gen_lic_dest) |
102 | except: | 102 | except: |
@@ -106,7 +106,7 @@ python do_populate_lic() { | |||
106 | if not os.path.isfile(os.path.join(generic_directory, license_type)): | 106 | if not os.path.isfile(os.path.join(generic_directory, license_type)): |
107 | if bb.data.getVarFlag('SPDXLICENSEMAP', license_type, d) != None: | 107 | if bb.data.getVarFlag('SPDXLICENSEMAP', license_type, d) != None: |
108 | # Great, there is an SPDXLICENSEMAP. We can copy! | 108 | # Great, there is an SPDXLICENSEMAP. We can copy! |
109 | bb.warn("We need to use a SPDXLICENSEMAP for %s" % (license_type)) | 109 | bb.note("We need to use a SPDXLICENSEMAP for %s" % (license_type)) |
110 | spdx_generic = bb.data.getVarFlag('SPDXLICENSEMAP', license_type, d) | 110 | spdx_generic = bb.data.getVarFlag('SPDXLICENSEMAP', license_type, d) |
111 | copy_license(generic_directory, gen_lic_dest, spdx_generic) | 111 | copy_license(generic_directory, gen_lic_dest, spdx_generic) |
112 | link_license(gen_lic_dest, destdir, spdx_generic) | 112 | link_license(gen_lic_dest, destdir, spdx_generic) |
@@ -119,7 +119,6 @@ python do_populate_lic() { | |||
119 | copy_license(generic_directory, gen_lic_dest, license_type) | 119 | copy_license(generic_directory, gen_lic_dest, license_type) |
120 | link_license(gen_lic_dest, destdir, license_type) | 120 | link_license(gen_lic_dest, destdir, license_type) |
121 | 121 | ||
122 | |||
123 | # All the license types for the package | 122 | # All the license types for the package |
124 | license_types = bb.data.getVar('LICENSE', d, True) | 123 | license_types = bb.data.getVar('LICENSE', d, True) |
125 | # All the license files for the package | 124 | # All the license files for the package |
@@ -131,7 +130,7 @@ python do_populate_lic() { | |||
131 | srcdir = bb.data.getVar('S', d, True) | 130 | srcdir = bb.data.getVar('S', d, True) |
132 | # Directory we store the generic licenses as set in the distro configuration | 131 | # Directory we store the generic licenses as set in the distro configuration |
133 | generic_directory = bb.data.getVar('COMMON_LICENSE_DIR', d, True) | 132 | generic_directory = bb.data.getVar('COMMON_LICENSE_DIR', d, True) |
134 | bb.warn(generic_directory) | 133 | |
135 | try: | 134 | try: |
136 | bb.mkdirhier(destdir) | 135 | bb.mkdirhier(destdir) |
137 | except: | 136 | except: |
@@ -158,13 +157,15 @@ python do_populate_lic() { | |||
158 | gen_lic_dest = os.path.join(bb.data.getVar('LICENSE_DIRECTORY', d, True), "common-licenses") | 157 | gen_lic_dest = os.path.join(bb.data.getVar('LICENSE_DIRECTORY', d, True), "common-licenses") |
159 | 158 | ||
160 | clean_licenses = "" | 159 | clean_licenses = "" |
160 | |||
161 | for x in license_types.replace("(", " ( ").replace(")", " ) ").split(): | 161 | for x in license_types.replace("(", " ( ").replace(")", " ) ").split(): |
162 | if ((x != "(") and (x != ")") and (x != "&") and (x != "|")): | 162 | if ((x != "(") and (x != ")") and (x != "&") and (x != "|")): |
163 | clean_licenses += "'" + x + "'" | 163 | clean_licenses += "'" + x + "'" |
164 | else: | 164 | else: |
165 | clean_licenses += " " + x + " " | 165 | clean_licenses += " " + x + " " |
166 | 166 | ||
167 | node = ast.parse(clean_licenses) | 167 | # lstrip any possible indents, since ast needs python syntax. |
168 | node = ast.parse(clean_licenses.lstrip()) | ||
168 | v = LicenseVisitor() | 169 | v = LicenseVisitor() |
169 | v.visit(node) | 170 | v.visit(node) |
170 | } | 171 | } |