Fetch complete buildconf for each repo
authorLin Yang <lin.a.yang@intel.com>
Tue, 24 Jun 2014 03:53:41 +0000 (11:53 +0800)
committerLin Yang <lin.a.yang@intel.com>
Mon, 7 Jul 2014 09:03:25 +0000 (17:03 +0800)
OBS will insert serveral runtime parameters at the beginning of the build conf,
which are critical to gbs local build. Current the api jenkins used can not
fetch those parameters, only fetch the build conf text. Should use another api
https://api.tizen.org/build/Tizen:Common/atom/_buildconfig.

Fixes: #1997

Change-Id: I8876e6e84bcf3bddbd3119d35f111ac7c3b738fe
Signed-off-by: Lin Yang <lin.a.yang@intel.com>
common/buildservice.py
job_create_snapshot.py

index d7837e6..c2a4e8c 100644 (file)
@@ -282,6 +282,14 @@ class BuildService(OSC):
                     ] = result.get('state')
         return targets
 
+    def get_repo_config(self, project, repo):
+        """
+        get_repo_config(project) -> string
+
+        Get buliding config of repo
+        """
+        return ''.join(core.get_buildconfig(self.apiurl, project, repo))
+
     def get_targets(self, project):
         """
         get_targets(project) -> list
index 5ab3cde..bc6522a 100755 (executable)
@@ -79,6 +79,7 @@ def make_repo(project, backenddb, base_path, live_repo_base, buildconf=None):
     Raises:
         LocalError if can't create repos or can't find image configurations
     """
+
     try:
         snapshot = Snapshot(backenddb, base_path, obs_project=project)
     except SnapshotError, err:
@@ -97,6 +98,14 @@ def make_repo(project, backenddb, base_path, live_repo_base, buildconf=None):
     for repo in targets:
         repomaker = RepoMaker(snapshot.build_id, snapshot.path)
 
+        # Get specific repo buildconf from OBS, put the buildconf together with
+        # repo-md
+        if not buildconf:
+            build = BuildService(os.getenv("OBS_API_URL"),
+                                 os.getenv("OBS_API_USERNAME"),
+                                 os.getenv("OBS_API_PASSWD"))
+            buildconf = build.get_repo_config(project, repo['Name'])
+
         try:
             repomaker.add_repo(live_repo_path, repo['Name'],
                                repo['Architectures'],
@@ -158,16 +167,12 @@ def main():
 
             return 0
 
-    # Get buildconf from OBS, put the buildconf together with repo-md
-    buildconf_str = build.get_project_config(project)
-
     # whether project is not enabled
     if not snapshot_project_enabled(backenddb, project):
         print "Skipping, project isn't found in repo.yaml"
         return 0
 
-    repo_data = make_repo(project, backenddb, base_path, live_repo_base,
-                          buildconf = buildconf_str)
+    repo_data = make_repo(project, backenddb, base_path, live_repo_base)
 
     # update/create the latest repo link
     make_latest_link(os.path.join(base_path, repo_data['repo_path']))