From 5d86b595b9ca0dec18a33dd712023e68f72380af Mon Sep 17 00:00:00 2001 From: "Dr. Peter Poeml" Date: Wed, 5 Jul 2006 10:25:31 +0000 Subject: [PATCH] add new subcommands buildconfig, buildinfo, repos --- osc/commandline.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++ osc/core.py | 26 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/osc/commandline.py b/osc/commandline.py index 696724d5..7a1076dc 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -544,6 +544,52 @@ To find out and , you can use 'osc results' pass +def buildinfo(args): + """buildinfo: Shows the buildinfo which is used in building a package (you need to be inside a package directory) + +usage: osc buildinfo + """ + wd = os.curdir + package = store_read_package(wd) + project = store_read_project(wd) + + platform = args[0] + arch = args[1] + print ''.join(get_buildinfo(project, package, platform, arch)) + + +def buildconfig(args): + """buildconfig: Shows the buildconfig which is used in building a package (you need to be inside a package directory) + +usage: osc buildconfig + """ + wd = os.curdir + package = store_read_package(wd) + project = store_read_project(wd) + + platform = args[0] + arch = args[1] + print ''.join(get_buildconfig(project, package, platform, arch)) + + +def repos(args): + """repos: Shows the repositories which are defined for a package + +usage: 1. osc repos # package = current dir + 2. osc repos + """ + args = parseargs(args) + pacs = findpacs(args) + + for p in pacs: + #print p.name + ':', cmd_rebuild(p.prjname, p.name) + + #print ''.join(get_buildinfo(project, package, platform, arch)) + for platform in get_repos_of_project(p.prjname): + print platform + #print '\n'.join(get_results(project, package, platform)) + + def history(args): """history: Shows the build history of a package (NOT IMPLEMENTED YET) @@ -603,6 +649,8 @@ usage: osc help [SUBCOMMAND...] cmd_dict = { add: ['add'], addremove: ['addremove'], + buildconfig: ['buildconfig'], + buildinfo: ['buildinfo'], commit: ['commit', 'ci', 'checkin'], checkout: ['checkout', 'co'], updatepacmetafromspec: ['updatepacmetafromspec'], @@ -617,6 +665,7 @@ cmd_dict = { meta: ['meta'], platforms: ['platforms'], delete: ['delete', 'del', 'rm', 'remove'], + repos: ['repos'], repourls: ['repourls'], resolved: ['resolved'], results: ['results'], diff --git a/osc/core.py b/osc/core.py index 68613c4f..73327d52 100755 --- a/osc/core.py +++ b/osc/core.py @@ -964,6 +964,18 @@ def get_platforms_of_project(prj): return r +def get_repos_of_project(prj): + f = show_project_meta(prj) + tree = ET.parse(StringIO(''.join(f))) + + repo_line_templ = '%-15s %-10s' + r = [] + for node in tree.findall('repository'): + for node2 in node.findall('arch'): + r.append(repo_line_templ % (node.get('name'), node2.text)) + return r + + def show_results_meta(prj, package, platform): u = makeurl(['result', prj, platform, package, 'result']) f = urllib2.urlopen(u) @@ -1010,6 +1022,20 @@ def get_log(prj, package, platform, arch, offset): return f.read() +def get_buildinfo(prj, package, platform, arch): + # http://api.opensuse.org/rpm/Subversion/Apache_SuSE_Linux_10.1/i586/subversion/buildinfo + u = makeurl(['rpm', prj, platform, arch, package, 'buildinfo']) + f = urllib2.urlopen(u) + return f.read() + + +def get_buildconfig(prj, package, platform, arch): + # http://api.opensuse.org/rpm///_repository//_buildconfig + u = makeurl(['rpm', prj, platform, '_repository', arch, '_buildconfig']) + f = urllib2.urlopen(u) + return f.read() + + def get_history(prj, package): # http://api.opensuse.org/rpm/Apache/factory/i586/apache2/history ? # http://api.opensuse.org/package/Apache/apache2/history ?