diff options
author | Yonghee Han <onstudy@samsung.com> | 2017-07-24 14:30:25 +0900 |
---|---|---|
committer | Yonghee Han <onstudy@samsung.com> | 2017-07-24 14:55:32 +0900 |
commit | 744f36bec0cf1856781918cfd20529eb3c4af88d (patch) | |
tree | 5a952b26a99cff2719d3eaee57fcbf38b18be3c2 | |
parent | 1314dadfe634ebdeecefa80964522126a2c3ada0 (diff) | |
download | repa-744f36bec0cf1856781918cfd20529eb3c4af88d.tar.gz repa-744f36bec0cf1856781918cfd20529eb3c4af88d.tar.bz2 repa-744f36bec0cf1856781918cfd20529eb3c4af88d.zip |
Implement repa update
repa update can change the reference project in arget project.
repa update should help RE to mantain the target projects.
ex) repa update <submission> --refprj <reference project>
Change-Id: Icd42b15d8da636bcd7353088e815377d31d3cc6f
-rw-r--r-- | packaging/repa.spec | 2 | ||||
-rw-r--r-- | repa.1 | 31 | ||||
-rwxr-xr-x | repa/main.py | 2 | ||||
-rw-r--r-- | repa/update.py | 105 | ||||
-rwxr-xr-x | setup.py | 3 |
5 files changed, 138 insertions, 5 deletions
diff --git a/packaging/repa.spec b/packaging/repa.spec index 35f79e0..63cf1e5 100644 --- a/packaging/repa.spec +++ b/packaging/repa.spec @@ -1,5 +1,5 @@ Name: repa -Version: 0.5 +Version: 0.6 Summary: Release Engineering Process Assistant %if 0%{?opensuse_bs} Release: 1.<CI_CNT>.<B_CNT> @@ -58,6 +58,9 @@ Submission group is a temporary group of submissions, created for testing purpos .RS 2 11. \fBremove\fR - remove submission .RE +.RS 2 +12. \fBupdate\fR - update submission +.RE .\" =========================================================================== .\" Global options @@ -533,6 +536,30 @@ Provide a comment with the explanation of a reason for remove. This is mandatory Run editor to edit comment. Editor is taken from EDITOR environment variable. .RE +.\" +.\" The "update" command description +.\" +.SS \fBupdate\fR <submission> [options] + +.RS 2 +Update submission + +.\" +.\" The "remove" command's options +.\" +.RS 2 +\fBOPTIONS\fR +.RS 2 +.B \-h, \-\-help +.RS 2 +Print short help text about the "update" command and exit. +.RE + +.PP +.B \-r \-\-refprj COMMENT +.RS 2 +Provide a update with the reference project. This is mandatory option. +.RE .SH CONFIGURATION FILE @@ -548,7 +575,7 @@ Example: [general] .RE .RS 2 -apiurl = https://api.tizen.org +apiurl = https://build.tizen.org .RE .RS 2 apiuser = your_user_name @@ -557,7 +584,7 @@ apiuser = your_user_name apipasswd = your_password .RE .RS 2 -jenkins_url = https://build.tizen.org/robot +jenkins_url = https://robot.tizen.org .RE .RS 2 jenkins_user = your_jenkins_user_name diff --git a/repa/main.py b/repa/main.py index 37f62db..68bfac8 100755 --- a/repa/main.py +++ b/repa/main.py @@ -57,7 +57,7 @@ def parse_args(argv): ArgumentParser(prog='repa', description='Release Engineering Process Assistant') parser.add_argument('--version', action='version', - version='%(prog)s version 0.5') + version='%(prog)s version 0.6') parser.add_argument('-s', '--section', default='general', help='config section to use') parser.add_argument('-p', '--project', help='target project', diff --git a/repa/update.py b/repa/update.py new file mode 100644 index 0000000..fbf6f78 --- /dev/null +++ b/repa/update.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# +# This file is part of REPA: Release Engineering Process Assistant. +# +# Copyright (C) 2013 Intel Corporation +# +# REPA is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# 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., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. + +""" +REPA: Release Engineering Process Assistant. + +Copyright (C) Intel Corporation 2013 +Licence: GPL version 2 +Author: Ed Bartosh <eduard.bartosh@intel.com> + +List module. +Get list of submissions. +""" + +import sys +import json +from xml.etree import cElementTree as ET + +from repa.common import get_project_by_name +from repa.obs import OBS + +from repa.main import sub_main + +def set_update_reference_project(obs, prj, ref_target_prj=None): + """ Set update reference for project """ + + if ref_target_prj is None: + raise RepaException("Update reference is not supported. ") + + meta = obs.get_meta(prj) + # repalace link project + xml_meta = ET.fromstring(''.join(meta)) + for link_project in xml_meta.findall('link'): + link_project.set('project', ref_target_prj) + # replace repository path + for repo_element in xml_meta.findall('repository'): + for element in repo_element.findall('path'): + element.set('project',ref_target_prj) + # replace description + description = json.loads(xml_meta.find('description').text) + if description: + description['ref_obs_target_prj'] = ref_target_prj + xml_meta.find('description').text = json.dumps(description) + obs.set_meta(ET.tostring(xml_meta), prj) + +def update(obs, name, target, ref_target_prj): + """update meta of information about submission""" + prj, meta, build_results = get_project_by_name(obs, name, target) + + if meta['ref_obs_target_prj']: + print 'old_ref: %s new_ref: %s' %(meta['ref_obs_target_prj'], + ref_target_prj) + else: + raise RepaException("update is not supported. " + "ref_obs_target_prj values: %s" % \ + (ref_obs_target_prj)) + + if not obs.exists(ref_target_prj): + raise RepaException("update is not supported. " + "ref_target_prj %s is not exists" % \ + (ref_target_prj)) + set_update_reference_project(obs, prj, ref_target_prj) + +class Update(object): + """Subcommand: Update meta of information about submission.""" + + name = 'update' + description = 'Update meta of Information about submission' + help = description + + @staticmethod + def add_arguments(parser, config): + """ + Add arguments to the parser. Called from [sub_]main. + Set defaults for arguments from config. + """ + parser.add_argument('submission', help='submission or group') + parser.add_argument('-r', '--refprj', + help='Update reference project in project') + @staticmethod + def run(argv): + """Command line entry point. Called from [sub_]main""" + obs = OBS(argv.apiurl, argv.apiuser, argv.apipasswd) + return update(obs, argv.submission, argv.project, argv.refprj) + + +if __name__ == '__main__': + sys.exit(sub_main(sys.argv[1:], Update())) @@ -31,7 +31,7 @@ import os from setuptools import setup setup(name="repa", - version='0.5', + version='0.6', author='Ed Bartosh', author_email='eduard.bartosh@intel.com', packages=['repa'], @@ -52,5 +52,6 @@ setup(name="repa", 'rebuild = repa.rebuild:Rebuild', 'lock = repa.lock:Lock', 'unlock = repa.unlock:Unlock', + 'update = repa.update:Update', 'remove = repa.remove:Remove'] }) |