Fix bug that package name causes for _service
authorZhuoX Li <zhuox.li@intel.com>
Fri, 21 Mar 2014 06:35:44 +0000 (14:35 +0800)
committerZhuoX Li <zhuox.li@intel.com>
Mon, 24 Mar 2014 02:55:37 +0000 (10:55 +0800)
 some 'package name' is different from 'spec name'.
When use 'package nam'e from gerrit to create package,
upload _service file is failed.So here use 'spec name'
to create package and upload _service file.

Change-Id: If9a49591edf6c4cf1ff9dc13170a8ee7b7a61ca0

common/utils.py
job_submit.py
job_submitobs.py

index 64a4e4d..689523c 100644 (file)
@@ -240,10 +240,9 @@ def xml2obj(src):
     return builder.root._attrs.values()[0]
 
 def upload_obs_service(git_url, git_project, git_tag,
-        git_revision, obs_project, build):
+        git_revision, obs_project, build, package):
     """UPload _service file to OBS.Create package if doesn't exist.To replace
     make package in local"""
-    package = os.path.basename(git_project)
     if not build.exists(obs_project, package):
         try:
             build.create_package(obs_project, package)
index f183b88..20bd8ce 100755 (executable)
@@ -51,7 +51,7 @@ def git_obs_map(gerrit_prj, gerrit_branch):
                      (gerrit_prj, gerrit_branch))
 
 def create_project(git_url, git_project, git_tag, git_revision, build,
-                   obs_target_prj, obs_project, submitter):
+                   obs_target_prj, obs_project, submitter, package):
     """Create prerelease OBS project and upload sources for the build."""
 
     # Create review project if it doesn't exist
@@ -79,7 +79,7 @@ def create_project(git_url, git_project, git_tag, git_revision, build,
 
     try:
         upload_obs_service(git_url, git_project, git_tag,
-                           git_revision, obs_project, build)
+                           git_revision, obs_project, build, package)
     except UtilsError, err:
         raise LocalError(err)
 
@@ -121,6 +121,8 @@ def main(build_type):
     for obs_target_prj, _obs_stg_prj, _obs_pkg in obs_target_prjs:
         url = 'ssh://%s:%s' % (os.getenv('GERRIT_HOSTNAME'),
                                os.getenv('GERRIT_SSHPORT'))
+        # get package name from gerrit_project
+        package = os.path.basename(gerrit_project)
         if build_type == 'prerelease':
             if not prerelease_enabled(backenddb, obs_target_prj):
                 print 'Skipping %s as prerelease is not enabled for it' % \
@@ -136,14 +138,14 @@ def main(build_type):
                     if gerrit_account_email:
                         submitter += ' <%s>' % gerrit_account_email
                 create_project(url, gerrit_project, git_tag, gerrit_newrev,
-                               build, obs_target_prj, project, submitter)
+                        build, obs_target_prj, project, submitter, package)
         elif build_type == 'snapshot':
             if not is_ref_deleted(gerrit_oldrev, gerrit_newrev):
                 if build.exists(obs_target_prj):
                     # Upload _service to target project
                     try:
                         upload_obs_service(url, gerrit_project, git_tag, \
-                                gerrit_newrev, obs_target_prj, build)
+                                gerrit_newrev, obs_target_prj, build, package)
                     except UtilsError, err:
                         raise LocalError(err)
                 else:
index a21813c..4b79924 100755 (executable)
@@ -493,7 +493,7 @@ def main():
                 # upload _service to obs
                 try:
                     utils.upload_obs_service(url, gerrit_project, tag,
-                            event['newrev'], obs_stg_prj, build)
+                            event['newrev'], obs_stg_prj, build, spec.name)
                 except utils.UtilsError, err:
                     print err
                     return 1