+++ /dev/null
-#!/usr/bin/env python
-
-# Copyright (c) 2012 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; version 2 of the License
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-import os
-import time
-import re
-
-#Define the prerelease name:
-# home:<user_id>:prerelease:<origin_target_obs_project>:<tag_time_stampe>
-#
-
-def get_prerelease_project_name(obs_target_prj, obs_user,
- git_tag_name):
- """ get the prerelease project name on OBS from gerrit event
- parameter """
- return "home:%s:prerelease:%s:%s" %(
- obs_user,
- obs_target_prj,
- os.path.basename(git_tag_name)
- )
-
-def get_info_from_prerelease_name(prerelease_project_name):
- """ return user_id, target_project, tag_time_stamp """
- match = re.match("home:(.*):prerelease:(.*):([\.\w-]*)",
- prerelease_project_name)
- if not match:
- raise Exception, "Ivalid project name found, %s" %prerelease_project_name
-
- return match.group(1), match.group(2), match.group(3)
-
-class PreRelease:
- """pre-release project class, this class includes the operation of OBS
- throught proejctbuild(buildservice) and the repo info etc"""
-
- def __init__(self, obs_target_prj, obs_user, git_tag_name,
- git_project_name, projectbuild):
-
- self.target_project = obs_target_prj
- self.user = obs_user
- self.git_tag = git_tag_name
- self.git_project = git_project_name
- self.tag_time_stamp = os.path.basename(self.git_tag)
-
- self.obs_project = get_prerelease_project_name(obs_target_prj,
- obs_user,
- git_tag_name)
-
- self.projectbuild = projectbuild
-
- def obs_project_name(self):
- return self.obs_project
-
- def cleanup(self):
- self.projectbuild.cleanup()
-
- def create(self, git):
-
- git.checkout(self.git_tag)
- if projectbuild.bs.is_new_project(self.obs_project):
- os.system("gbs rb -B %s -T %s %s" %(self.target_project,
- self.obs_project,
- git.path))
-
- print "Temporary review project created on OBS: %s" %(self.obs_project)
-
- project_info = "OBS_REQ_PRJ: %s\nGIT_PROJECT: %s\nGIT_TAG: %s\n" %(
- self.target_project,
- self.git_project,
- self.git_tag)
- projectbuild.linkbuild_localdep(desp = project_info)
- else:
- os.system("gbs rb -T %s %s" %(self.obs_project,
- git.path))
- print "Temporary review project %s exists, committed." %(self.obs_project)
-
- time.sleep(2)
-
- try:
- status = projectbuild.get_repostatus()
- print status
- except:
- print "WARN: did get any status from OBS project"
-
- def get_parent_project(self, repo_category = 'standard'):
- return self.projectbuild.bs.get_parent_project(self.obs_project,
- repo_category)
-
- def get_available_archs(self, repo_category = 'standard'):
- """ return the archs with repo published """
- avail_arch = []
-
- archs = self.projectbuild.bs.get_project_arch(self.obs_project,
- repo_category)
- status = self.projectbuild.get_repostatus()
- for arch in archs:
- if status["%s/%s" %(repo_category, arch)] == "published":
- avail_arch.append(arch)
- return avail_arch
-
-class PreRelease2(PreRelease):
- """pre-release project class with obs_project as init parameter """
-
- def __init__(self, obs_project, projectbuild):
- self.user, self.target_project, self.tag_time_stamp = \
- get_info_from_prerelease_name(obs_project)
-
- PreRelease.__init__(self, self.target_project, self.user,
- '', '', projectbuild)
-
- self.obs_project = obs_project
-
- self.update_git_info()
-
- def update_git_info(self):
- desp = self.projectbuild.bs.get_project_desp(self.obs_project)
-
- if not desp:
- raise Exception, "Error: No project description found"
-
- for line in desp.split('\n'):
- if line.startswith('GIT_TAG'):
- self.git_tag = line.split(':')[1].strip()
- elif line.startswith('GIT_PROJECT'):
- self.git_project = line.split(':')[1].strip()