print ' %s' % [ obs_prj[x] for x in obs_prj if x is not 'config' ]
return obs_prjs
-def git_ref_map(prjdir=None, mapping_file=None, base_project=None):
- """
- Find an OBS Reference Projects correspondent to base_project
- by parsing git-ref-mapping.xml.
- @ Return: [[branch, OBS project, Ref project], ...]
- """
-
- # clone scm/git-ref-mapping.git
- if not clone_gitproject(os.getenv('REF_MAPPING_PRJ'), prjdir):
- print >> sys.stderr, 'Error cloning %s' % os.getenv('REF_MAPPING_PRJ')
- return []
- # read xml contents
- with open(mapping_file) as mf:
- map_obj = xml_to_obj(''.join(mf.readlines()))
- # find matching projects
- found = []
- for path in map_obj.default.path:
- for item in path.branch:
- if base_project is None or item.OBS_project == base_project:
- found.append([item.name, item.OBS_project, item.OBS_staging_project])
- return found
-
def git_virtual_branch_map():
"""
Find an virtual branch by parsing git-obs-mapping.xml
mapping_prj = os.getenv("REF_MAPPING_PRJ")
+ if not clone_gitproject(mapping_prj, \
+ os.path.join(git_cache, mapping_prj), \
+ gerrit_hostname=gerrit_hostname, gerrit_username=gerrit_username, gerrit_sshport=gerrit_sshport):
+ raise MappingError('Error cloning %s' % mapping_prj)
+
git_ref_mapping_path = os.path.join(git_cache, mapping_prj)
mapping_path = '{0}/git-ref-mapping.xml'.format(git_ref_mapping_path)
if not os.path.isfile(mapping_path):
- print 'Cloning %s' % mapping_prj
- if not clone_gitproject(mapping_prj, \
- os.path.join(git_cache, mapping_prj), \
- gerrit_hostname=gerrit_hostname, gerrit_username=gerrit_username, gerrit_sshport=gerrit_sshport):
- raise MappingError('Error cloning %s' % mapping_prj)
+ raise MappingError('mapping file not found %s' % mapping_prj)
# get mappings
mymapping = Mapping(mapping_path)
from common.buildtrigger import trigger_info
from common.git import Git
-from common.mapping import git_ref_map
import xml.etree.cElementTree as ElementTree
from lxml import etree
+from common.git import clone_gitproject
XML_DECLARATION = """<?xml version="1.0" encoding="UTF-8" ?>"""
release_version = release_id.split('_')[-1]
prjdir = os.path.join(os.getenv('WORKSPACE'), os.path.basename(os.getenv('REF_MAPPING_PRJ')))
- mapping_file = '{0}/git-ref-mapping.xml'.format(prjdir)
+ # clone scm/git-ref-mapping.git
+ if not clone_gitproject(os.getenv('REF_MAPPING_PRJ'), prjdir):
+ print >> sys.stderr, 'Error cloning %s' % os.getenv('REF_MAPPING_PRJ')
+ return -1
- # retrieve contents from mapping xml
- found = git_ref_map(prjdir, mapping_file, base_project=base_project)
- if not os.path.exists(mapping_file):
- print '** NO MAPPING FILE FOUND %s' % (mapping_file)
- return 1
- if len(found) == 0:
- print '** REF MAP HAVE NO ITEMS FOR %s' % (base_project)
- return
+ mapping_file = '{0}/git-ref-mapping.xml'.format(prjdir)
# replace old version to new
need_update = False