Patchwork [1/1] archiver.bbclass: Reduce some duplication for function get_licenses

login
register
mail settings
Submitter Xiaofeng Yan
Date June 7, 2012, 2:01 a.m.
Message ID <615f713aad3ee29122c279e380dac3de6a79846e.1339034063.git.xiaofeng.yan@windriver.com>
Download mbox | patch
Permalink /patch/29361/
State Accepted
Commit 31bee6e7b0a23efc1555ab739ef10041803d5bb1
Headers show

Comments

Xiaofeng Yan - June 7, 2012, 2:01 a.m.
From: Xiaofeng Yan <xiaofeng.yan@windriver.com>

The content to modify this bbclass is as follow:
- Use the existing functions to get license as a directory instead of
  rewriting it for avoiding code duplication.
- Use SPDXLICENSEMAP to map licenses

[YOCTO #2473]

Signed-off-by: Xiaofeng Yan <xiaofeng.yan@windriver.com>
---
 meta/classes/archiver.bbclass |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

Patch

diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass
index ed2dbe4..083bb1d 100644
--- a/meta/classes/archiver.bbclass
+++ b/meta/classes/archiver.bbclass
@@ -225,17 +225,18 @@  def archive_logs(d,logdir,bbinc=False):
 
 def get_licenses(d):
 	'''get licenses for running .bb file'''
-	licenses = d.getVar('LICENSE', 1).replace('&', '|')
-	licenses = licenses.replace('(', '').replace(')', '') 
-	clean_licenses = ""
-	for x in licenses.split():
-		if x.strip() == '' or x == 'CLOSED':
-			continue
-		if x != "|":
-			clean_licenses += x
-	if '|' in clean_licenses:
-		clean_licenses = clean_licenses.replace('|','')
-	return clean_licenses
+	import oe.license
+
+	licenses_type = d.getVar('LICENSE', True) or ""
+	lics = oe.license.is_included(licenses_type)[1:][0]
+	lice = ''
+	for lic in lics:
+		licens = d.getVarFlag('SPDXLICENSEMAP', lic)
+		if licens != None:
+			lice += licens
+		else:
+			lice += lic
+	return lice
 	
 
 def move_tarball_deploy(d,tarball_list):