TPE-334 ABS license rule 76/150976/1
authorhyokeun <hyokeun.jeon@samsung.com>
Tue, 19 Sep 2017 08:10:42 +0000 (17:10 +0900)
committerhyokeun <hyokeun.jeon@samsung.com>
Tue, 19 Sep 2017 08:10:42 +0000 (17:10 +0900)
Change-Id: Id39d340059d1482ec49cc6ba8f6dc70b77ebbe4f

abs/job_abs_build.py

index 0b7c50a..147de00 100644 (file)
@@ -220,16 +220,15 @@ def retrieve_project_property(src_git, tag):
     ret_prop = {}
 
     def retrieve_license(src_root):
-        sdk_license = ''
-        license_file = os.path.join(src_root, 'LICENSE')
-        if os.path.isfile(license_file):
-            shutil.copy(license_file, os.path.dirname(src_root))
-            with open(license_file, 'r') as r_file:
-                for x in r_file.readlines():
-                    matchline = re.search(r'.*Licensed under the (.*) License, Version (.*) \(the \"License\"\).*;', x)
-                    if matchline:
-                        sdk_license = '%s-%s' % (matchline.groups()[0], matchline.groups()[1])
-        print 'SDK_LICENSE: [%s]' % sdk_license
+        sdk_license = None
+        for f in os.listdir(src_root):
+            if os.path.isfile(os.path.join(src_root, f)) and f.startswith('LICENSE'):
+                with open(os.path.join(src_root, f), 'r') as r_file:
+                    for x in r_file.readlines():
+                        matchline = re.search(r'.*Licensed under the (.*) License, Version (.*) \(the \"License\"\).*;', x)
+                        if matchline:
+                            sdk_license = '%s-%s' % (matchline.groups()[0], matchline.groups()[1])
+                            print 'LICENSE %s from %s' % (sdk_license, f)
         return sdk_license
 
     def retrieve_properties_from_project_def(src_root):
@@ -308,7 +307,10 @@ def retrieve_project_property(src_git, tag):
     ret_prop['sdk_license'] = retrieve_license(src_git.path)
 
     for r in ret_prop:
-        print '  [%s]: %s' % (r, ret_prop[r].rstrip())
+        if ret_prop[r]:
+            print '  [%s]: %s' % (r, ret_prop[r].rstrip())
+        else:
+            print '  [%s]: %s' % (r, ret_prop[r])
     return ret_prop
 
 def fetch_source(gerrit_env, src_root, project, branch=None, tag=None, patchset=False, \
@@ -414,7 +416,7 @@ def generate_spec_file(tizen_studio, src_git, prop, data):
 
     # SPEC configuration
     group = ''
-    license = prop.get('license')
+    sdk_license = prop.get('sdk_license')
     summary = ''
     if os.path.isdir(os.path.join(src_git.path, 'packaging')):
         for filename in os.listdir(os.path.join(src_git.path, 'packaging')):
@@ -432,6 +434,9 @@ def generate_spec_file(tizen_studio, src_git, prop, data):
     if license == '' or license is None: license = 'N/A'
     if summary == '' or summary is None: summary = data.get('obs_package').replace('org.tizen.', '')
 
+    if sdk_license is not None and sdk_license != '':
+        license = sdk_license
+
     vcs = '#VCS_FROM:   %s' % (data.get('project') + "#" + prop.get('commit_id'))
     vcs_desc = vcs.split(' ')[-1]
 
@@ -678,6 +683,13 @@ def start_build(fields):
             mailer.add_message('Result: FAIL')
             mailer.add_message('\n\n%s' % project_properties.get('ret_error'))
         return 1
+    if 'sdk_license' not in project_properties or project_properties.get('sdk_license') is None:
+        print 'No LICENSE provided.'
+        if data.get('buildcheck', None) == None:
+            mailer.add_title('No LICENSE file')
+            mailer.add_message('Result: FAIL')
+            mailer.add_message('\n\n%s' % 'No LICENSE provided.')
+        return 1
 
     # Make tarball to share source codes easily with vm machine
     zipping_workspace(src_root)