Prerelease - Get obs project info instead of request every packages 54/78154/1
authorhyokeun <hyokeun.jeon@samsung.com>
Mon, 4 Jul 2016 10:50:34 +0000 (19:50 +0900)
committerhyokeun <hyokeun.jeon@samsung.com>
Mon, 4 Jul 2016 10:50:34 +0000 (19:50 +0900)
Change-Id: I8ee19c0860a0bf5654251f050df54da65b848965

common/buildservice.py
job_submit.py

index 20c3a14..0cf0cf9 100755 (executable)
@@ -888,3 +888,25 @@ class BuildService(OSC):
                        path_args=path,
                        data=ElementTree.tostring(root))
 
+    def get_sourceinfo_list(self, prj):
+        """
+        Get source info list of the project
+        { package1: [],
+          package2: ['Source Project'/'Source Package'], # if linked package
+          ...}
+        """
+        query = {}
+        query['view'] = 'info'
+        query['parse'] = 0
+        query['nofilename'] = 1
+
+        url = core.makeurl(self.apiurl, ['source', prj], query)
+        _file = core.http_GET(url)
+        root = ElementTree.parse(_file).getroot()
+
+        s_dict = {}
+        for s in root.iter('sourceinfo'):
+            s_dict[s.get('package')] = \
+                ''.join([node.get('project') + '/' +  node.get('package') for node in s.findall('linked')])
+        return s_dict
+
index 7c5d630..4912da7 100755 (executable)
@@ -107,11 +107,13 @@ def create_related_packages(build, obs_target_prj, obs_pre_prj, pre_package):
        obs_pre_prj is the prelease project
        pre_package is the original package
     """
-    for package in build.get_package_list(obs_target_prj):
-        link_prj, link_pkg = build.get_package_linkinfo(obs_target_prj, package)
-        if link_prj == obs_target_prj and link_pkg == pre_package:
-            build.create_link_pac(obs_pre_prj, pre_package, \
-                                   obs_pre_prj, package)
+    sourceinfo = build.get_sourceinfo_list(obs_target_prj)
+    for package in sourceinfo:
+        if sourceinfo[package]:
+            link_prj, link_pkg = sourceinfo[package].split('/')
+            if link_prj == obs_target_prj and link_pkg == pre_package:
+                build.create_link_pac(obs_pre_prj, pre_package, \
+                                       obs_pre_prj, package)
 
 def create_project(git_url, git_project, git_tag, git_revision, build,
                    obs_target_prj, obs_project, submitter, package):