2006-04-20 16:26:50 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
# Copyright (C) 2006 Peter Poeml / Novell Inc. All rights reserved.
|
2006-04-20 16:26:50 +02:00
|
|
|
# This program is free software; it may be used, copied, modified
|
|
|
|
# and distributed under the terms of the GNU General Public Licence,
|
|
|
|
# either version 2, or (at your option) any later version.
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
|
2006-05-10 16:34:59 +02:00
|
|
|
from core import *
|
2006-10-10 16:04:34 +02:00
|
|
|
import conf
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
usage_general = """\
|
|
|
|
usage: osc <subcommand> [options] [args]
|
|
|
|
OpenSUSE build service command-line tool, version %s.
|
|
|
|
Type 'osc help <subcommand>' for help on a specific subcommand.
|
|
|
|
|
|
|
|
Most subcommands take file and/or directory arguments, recursing
|
|
|
|
on the directories. If no arguments are supplied to such a
|
|
|
|
command, it recurses on the current directory (inclusive) by default.
|
|
|
|
|
2006-12-12 03:01:39 +01:00
|
|
|
Please see also:
|
|
|
|
* http://en.opensuse.org/Build_Service_Tutorial
|
|
|
|
* http://en.opensuse.org/Build_Service/CLI
|
|
|
|
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
Available subcommands:
|
|
|
|
""" % get_osc_version()
|
|
|
|
|
|
|
|
|
|
|
|
def init(args):
|
|
|
|
"""Initialize a directory to be a working copy of an existing buildservice
|
|
|
|
package. (This is the same as checking out a package and then copying sources
|
|
|
|
into the directory. It does NOT create a new package.)
|
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc init <prj> <pac>
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
project = args[0]
|
|
|
|
package = args[1]
|
|
|
|
init_package_dir(project, package, os.path.curdir)
|
|
|
|
print 'Initializing %s (Project: %s, Package: %s)' % (os.curdir, project, package)
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def ls(args):
|
|
|
|
"""ls (list): List existing content on the server
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc ls # list projects
|
2006-05-23 15:48:58 +02:00
|
|
|
ls Apache # list packages in a project
|
|
|
|
ls Apache subversion # list files of package of a project
|
|
|
|
"""
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
if not args:
|
2006-10-10 16:04:34 +02:00
|
|
|
print '\n'.join(meta_get_project_list())
|
2006-05-23 15:48:58 +02:00
|
|
|
elif len(args) == 1:
|
|
|
|
project = args[0]
|
|
|
|
print '\n'.join(meta_get_packagelist(project))
|
|
|
|
elif len(args) == 2:
|
|
|
|
project = args[0]
|
|
|
|
package = args[1]
|
|
|
|
print '\n'.join(meta_get_filelist(project, package))
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
|
|
|
|
def meta(args):
|
|
|
|
"""Shows meta information
|
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc meta Apache # show meta of project 'Apache'
|
|
|
|
osc meta Apache subversion # show meta of package 'subversion'
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
if not args:
|
|
|
|
print 'missing argument'
|
2006-07-20 16:23:10 +02:00
|
|
|
print
|
2006-05-23 15:48:58 +02:00
|
|
|
print meta.func_doc
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if len(args) == 2:
|
|
|
|
project = args[0]
|
|
|
|
package = args[1]
|
|
|
|
print ''.join(show_package_meta(project, package))
|
|
|
|
print ''.join(show_files_meta(project, package))
|
|
|
|
|
|
|
|
elif len(args) == 1:
|
|
|
|
project = args[0]
|
|
|
|
print ''.join(show_project_meta(project))
|
|
|
|
|
|
|
|
|
2006-09-15 12:53:44 +02:00
|
|
|
def editpac(args):
|
|
|
|
"""editpac (createpac): Edit package meta information
|
|
|
|
If the named package does not exist, it will be created.
|
|
|
|
|
|
|
|
usage: osc createpac <prj> <pac>
|
|
|
|
osc editpac <prj> <pac>
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not args or len(args) != 2:
|
|
|
|
sys.exit('missing argument\n\n%s\n' % editpac.func_doc)
|
|
|
|
|
|
|
|
project = args[0]
|
|
|
|
package = args[1]
|
|
|
|
edit_meta(project, package)
|
|
|
|
|
|
|
|
|
|
|
|
def editprj(args):
|
|
|
|
"""editprj (createprj): Edit project meta information
|
|
|
|
If the named project does not exist, it will be created.
|
|
|
|
|
|
|
|
usage: osc createprj <prj>
|
|
|
|
osc editprj <prj>
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not args or len(args) != 1:
|
|
|
|
sys.exit('missing argument\n\n%s\n' % editprj.func_doc)
|
|
|
|
|
|
|
|
project = args[0]
|
|
|
|
edit_meta(project, None)
|
|
|
|
|
|
|
|
|
2006-05-23 17:27:43 +02:00
|
|
|
def editmeta(args):
|
|
|
|
"""Edit project/package meta information
|
|
|
|
If the named project or package does not exist, it will be created.
|
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc editmeta FooPrj # edit meta of project 'FooPrj'
|
|
|
|
osc editmeta FooPrj barpackage # edit meta of package 'barpackage'
|
2006-05-23 17:27:43 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
if not args:
|
|
|
|
print 'missing argument'
|
2006-07-20 16:23:10 +02:00
|
|
|
print
|
2006-09-15 12:53:44 +02:00
|
|
|
print editmeta.func_doc
|
2006-05-23 17:27:43 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if len(args) == 2:
|
|
|
|
project = args[0]
|
|
|
|
package = args[1]
|
|
|
|
edit_meta(project, package)
|
|
|
|
|
|
|
|
elif len(args) == 1:
|
|
|
|
project = args[0]
|
|
|
|
edit_meta(project, None)
|
|
|
|
|
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
def edituser(args):
|
|
|
|
"""edituser: Edit user meta information
|
|
|
|
usage: osc edituser <user>
|
|
|
|
|
|
|
|
If the named user id does not exist, it will be created.
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not args or len(args) != 1:
|
|
|
|
user = conf.config['user']
|
|
|
|
else:
|
|
|
|
user = args[0]
|
|
|
|
edit_user_meta(user)
|
|
|
|
|
|
|
|
|
2006-08-07 12:08:54 +02:00
|
|
|
def linkpac(args):
|
|
|
|
""""Link" a package to another package -- possibly cross-project.
|
|
|
|
|
|
|
|
usage: osc linkpac SOURCEPRJ SOURCEPAC DESTPRJ [DESTPAC]
|
|
|
|
|
|
|
|
The DESTPAC name is optional; the source packages' name will be used if
|
|
|
|
DESTPAC is omitted.
|
|
|
|
|
2006-08-10 18:39:13 +02:00
|
|
|
Afterwards, you will want to 'checkout DESTPRJ DESTPAC'.
|
|
|
|
|
|
|
|
To add a patch, add the patch as file and add it to the _link file.
|
|
|
|
You can also specify text which will be inserted at the top of the spec file.
|
|
|
|
|
|
|
|
See the examples in the _link file.
|
2006-08-07 12:08:54 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not args or len(args) < 3:
|
|
|
|
print 'missing argument'
|
|
|
|
print
|
|
|
|
print linkpac.func_doc
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
src_project = args[0]
|
|
|
|
src_package = args[1]
|
|
|
|
dst_project = args[2]
|
|
|
|
if len(args) > 3:
|
|
|
|
dst_package = args[3]
|
|
|
|
else:
|
|
|
|
dst_package = src_package
|
|
|
|
|
|
|
|
if src_project == dst_project and src_package == dst_package:
|
2006-09-21 16:33:24 +02:00
|
|
|
sys.exit('osc: error: source and destination are the same')
|
2006-08-07 12:08:54 +02:00
|
|
|
link_pac(src_project, src_package, dst_project, dst_package)
|
|
|
|
|
|
|
|
|
2006-09-21 16:33:24 +02:00
|
|
|
def copypac(args):
|
|
|
|
""""Copy" a package, possibly cross-project.
|
|
|
|
|
|
|
|
usage: osc copypac SOURCEPRJ SOURCEPAC DESTPRJ [DESTPAC]
|
|
|
|
|
|
|
|
The DESTPAC name is optional; the source packages' name will be used if
|
|
|
|
DESTPAC is omitted.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not args or len(args) < 3:
|
|
|
|
print 'missing argument'
|
|
|
|
print
|
|
|
|
print copypac.func_doc
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
src_project = args[0]
|
|
|
|
src_package = args[1]
|
|
|
|
dst_project = args[2]
|
|
|
|
if len(args) > 3:
|
|
|
|
dst_package = args[3]
|
|
|
|
else:
|
|
|
|
dst_package = src_package
|
|
|
|
|
|
|
|
if src_project == dst_project and src_package == dst_package:
|
|
|
|
sys.exit('osc: error: source and destination are the same')
|
|
|
|
copy_pac(src_project, src_package, dst_project, dst_package)
|
|
|
|
|
|
|
|
|
2006-08-11 12:37:29 +02:00
|
|
|
def deletepac(args):
|
|
|
|
"""deletepac: Delete a package on the server.
|
|
|
|
|
|
|
|
usage: osc deletepac <prj> <pac>
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not args or len(args) < 2:
|
|
|
|
print 'missing argument'
|
|
|
|
print
|
|
|
|
print deletepac.func_doc
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
project = args[0]
|
|
|
|
package = args[1]
|
|
|
|
|
|
|
|
delete_package(project, package)
|
|
|
|
|
|
|
|
|
2006-09-25 17:11:03 +02:00
|
|
|
def deleteprj(args):
|
|
|
|
"""deleteprj: Delete a project on the server.
|
|
|
|
|
|
|
|
usage: osc deleteprj <prj>
|
|
|
|
|
|
|
|
As a safety measure, project must be empty (i.e., you first need to delete all
|
|
|
|
packages first).
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not args or len(args) < 1:
|
|
|
|
print 'missing argument'
|
|
|
|
print
|
|
|
|
print deleteprj.func_doc
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
project = args[0]
|
|
|
|
|
|
|
|
if meta_get_packagelist(project) != []:
|
|
|
|
sys.exit('project must be empty before deleting it.')
|
|
|
|
delete_project(project)
|
|
|
|
|
|
|
|
|
2006-05-31 14:13:26 +02:00
|
|
|
def updatepacmetafromspec(args):
|
|
|
|
"""Update package meta information from a specfile
|
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: 1. osc updatepacmetafromspec # current dir
|
|
|
|
2. osc updatepacmetafromspec dir1 dir2 ...
|
2006-05-31 14:13:26 +02:00
|
|
|
"""
|
|
|
|
args = parseargs(args)
|
|
|
|
pacs = findpacs(args)
|
|
|
|
|
|
|
|
for p in pacs:
|
|
|
|
|
|
|
|
p.read_meta_from_spec()
|
2006-06-26 17:12:40 +02:00
|
|
|
p.update_pac_meta()
|
2006-05-31 14:13:26 +02:00
|
|
|
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def diff(args):
|
|
|
|
"""diff: Generates a diff, to view the local changes
|
|
|
|
|
|
|
|
usage: 1. osc diff # current dir
|
|
|
|
2. osc diff file1 file2 ...
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
args = parseargs(args)
|
|
|
|
pacs = findpacs(args)
|
|
|
|
|
|
|
|
for p in pacs:
|
|
|
|
if p.todo == []:
|
|
|
|
for i in p.filenamelist:
|
|
|
|
s = p.status(i)
|
|
|
|
if s == 'M' or s == 'C':
|
|
|
|
p.todo.append(i)
|
|
|
|
|
|
|
|
d = []
|
|
|
|
for filename in p.todo:
|
|
|
|
d.append('Index: %s\n' % filename)
|
|
|
|
d.append('===================================================================\n')
|
|
|
|
d.append(get_source_file_diff(p.dir, filename, p.rev))
|
|
|
|
if d:
|
|
|
|
print ''.join(d)
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-06-02 16:00:58 +02:00
|
|
|
def repourls(args):
|
|
|
|
"""repourls: shows URLs on which to access the .repos files
|
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: 1. osc repourls
|
|
|
|
2. osc repourls [dir1] [dir2] ...
|
2006-06-02 16:00:58 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
args = parseargs(args)
|
|
|
|
pacs = findpacs(args)
|
|
|
|
|
|
|
|
url_tmpl = 'http://software.opensuse.org/download/%s/%s/%s.repo'
|
|
|
|
for p in pacs:
|
|
|
|
platforms = get_platforms_of_project(p.prjname)
|
|
|
|
for platform in platforms:
|
|
|
|
print url_tmpl % (p.prjname.replace(':', ':/'), platform, p.prjname)
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def checkout(args):
|
|
|
|
"""checkout (co): Check out content from the server.
|
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc co Apache # entire project
|
|
|
|
osc co Apache subversion # a package
|
|
|
|
osc co Apache subversion foo # single file -> to current dir
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
project = package = filename = None
|
|
|
|
try:
|
|
|
|
project = args[0]
|
|
|
|
package = args[1]
|
|
|
|
filename = args[2]
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
if filename:
|
|
|
|
get_source_file(project, package, filename)
|
|
|
|
|
|
|
|
elif package:
|
|
|
|
checkout_package(project, package)
|
|
|
|
|
2006-10-19 00:30:53 +02:00
|
|
|
elif project:
|
2006-05-23 15:48:58 +02:00
|
|
|
# all packages
|
|
|
|
for package in meta_get_packagelist(project):
|
2006-04-20 16:26:50 +02:00
|
|
|
checkout_package(project, package)
|
2006-10-19 00:30:53 +02:00
|
|
|
else:
|
|
|
|
print 'missing argument'
|
|
|
|
print
|
|
|
|
print checkout.func_doc
|
|
|
|
sys.exit(1)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def status(args):
|
|
|
|
"""Show the status (which files have been changed locally)
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc st
|
|
|
|
osc st <directory>
|
|
|
|
osc st file1 file2 ...
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
args = parseargs(args)
|
2006-09-29 15:15:41 +02:00
|
|
|
|
|
|
|
pacpaths = []
|
|
|
|
for arg in args:
|
|
|
|
# when 'status' is run inside a project dir, it should
|
|
|
|
# stat all packages existing in the wc
|
|
|
|
if is_project_dir(arg):
|
|
|
|
prj = Project(arg)
|
|
|
|
pacpaths += [arg + '/' + n for n in prj.pacs_have]
|
|
|
|
elif is_package_dir(arg):
|
|
|
|
pacpaths.append(arg)
|
2006-09-29 16:34:18 +02:00
|
|
|
elif os.path.isfile(arg):
|
|
|
|
pacpaths.append(arg)
|
2006-09-29 15:15:41 +02:00
|
|
|
else:
|
|
|
|
sys.exit('osc: error: %s is neither a project or a package directory' % arg)
|
|
|
|
|
|
|
|
|
|
|
|
pacs = findpacs(pacpaths)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
for p in pacs:
|
|
|
|
|
|
|
|
# no files given as argument? Take all files in current dir
|
|
|
|
if not p.todo:
|
|
|
|
p.todo = p.filenamelist + p.filenamelist_unvers
|
|
|
|
|
|
|
|
for filename in p.todo:
|
2006-09-29 16:34:18 +02:00
|
|
|
if filename in p.excluded:
|
|
|
|
continue
|
2006-05-23 15:48:58 +02:00
|
|
|
s = p.status(filename)
|
|
|
|
if s == 'F':
|
2006-09-29 15:15:41 +02:00
|
|
|
print statfrmt('!', pathjoin(p.dir, filename))
|
2006-05-23 15:48:58 +02:00
|
|
|
elif s != ' ':
|
2006-09-29 15:15:41 +02:00
|
|
|
print statfrmt(s, pathjoin(p.dir, filename))
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def add(args):
|
|
|
|
"""Mark files to be added upon next 'checkin'
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc add file1 file2 ...
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
if not args:
|
|
|
|
print '%s requires at least one argument' % cmd
|
|
|
|
sys.exit(1)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
filenames = parseargs(args)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
for filename in filenames:
|
|
|
|
if not os.path.exists(filename):
|
|
|
|
print "file '%s' does not exist" % filename
|
2006-05-11 09:27:50 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
pacs = findpacs(filenames)
|
|
|
|
|
|
|
|
for pac in pacs:
|
|
|
|
for filename in pac.todo:
|
2006-09-29 16:34:18 +02:00
|
|
|
if filename in pac.excluded:
|
2006-05-23 15:48:58 +02:00
|
|
|
continue
|
2006-09-21 16:33:24 +02:00
|
|
|
if filename in pac.filenamelist:
|
|
|
|
print 'osc: warning: \'%s\' is already under version control' % filename
|
|
|
|
continue
|
2006-05-23 15:48:58 +02:00
|
|
|
|
|
|
|
pac.addfile(filename)
|
|
|
|
print statfrmt('A', filename)
|
2006-05-11 09:27:50 +02:00
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def addremove(args):
|
|
|
|
"""addremove: Adds all new files in local copy and removes all disappeared files.
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc addremove
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
args = parseargs(args)
|
|
|
|
pacs = findpacs(args)
|
|
|
|
for p in pacs:
|
|
|
|
|
|
|
|
p.todo = p.filenamelist + p.filenamelist_unvers
|
|
|
|
|
|
|
|
for filename in p.todo:
|
2006-09-21 16:33:24 +02:00
|
|
|
if os.path.isdir(filename):
|
|
|
|
continue
|
2006-05-23 15:48:58 +02:00
|
|
|
state = p.status(filename)
|
|
|
|
if state == '?':
|
|
|
|
p.addfile(filename)
|
2006-05-19 22:13:29 +02:00
|
|
|
print statfrmt('A', filename)
|
2006-05-23 15:48:58 +02:00
|
|
|
elif state == '!':
|
|
|
|
p.put_on_deletelist(filename)
|
|
|
|
p.write_deletelist()
|
|
|
|
os.unlink(os.path.join(p.storedir, filename))
|
|
|
|
print statfrmt('D', filename)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-04-24 14:04:20 +02:00
|
|
|
|
2006-07-03 12:00:20 +02:00
|
|
|
def commit(args):
|
2006-06-06 12:50:40 +02:00
|
|
|
"""commit (ci): Upload change content from your working copy to the repository
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc ci # current dir
|
|
|
|
osc ci <dir>
|
|
|
|
osc ci file1 file2 ...
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
args = parseargs(args)
|
|
|
|
pacs = findpacs(args)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
for p in pacs:
|
2006-06-06 12:50:40 +02:00
|
|
|
|
|
|
|
# commit only if the upstream revision is the same as the working copy's
|
|
|
|
upstream_rev = show_upstream_rev(p.prjname, p.name)
|
|
|
|
if p.rev != upstream_rev:
|
|
|
|
print 'Working copy \'%s\' is out of date (rev %s vs rev %s).' % (p.absdir, p.rev, upstream_rev)
|
|
|
|
print 'Looks as if you need to update it first.'
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
p.todo = p.filenamelist_unvers + p.filenamelist
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
for filename in p.todo:
|
|
|
|
st = p.status(filename)
|
|
|
|
if st == 'A' or st == 'M':
|
|
|
|
p.todo_send.append(filename)
|
|
|
|
print 'Sending %s' % filename
|
|
|
|
elif st == 'D':
|
|
|
|
p.todo_delete.append(filename)
|
|
|
|
print 'Deleting %s' % filename
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
if not p.todo_send and not p.todo_delete:
|
|
|
|
print 'nothing to do for package %s' % p.name
|
|
|
|
continue
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
print 'Transmitting file data ',
|
|
|
|
for filename in p.todo_send:
|
2006-05-30 12:07:16 +02:00
|
|
|
sys.stdout.write('.')
|
|
|
|
p.put_source_file(filename)
|
2006-05-23 15:48:58 +02:00
|
|
|
for filename in p.todo_delete:
|
2006-05-30 12:07:16 +02:00
|
|
|
p.delete_source_file(filename)
|
2006-05-23 15:48:58 +02:00
|
|
|
p.to_be_deleted.remove(filename)
|
2006-10-12 15:22:56 +02:00
|
|
|
if conf.config['do_commits'] == '1':
|
|
|
|
p.commit(msg='MESSAGE')
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
p.update_filesmeta()
|
|
|
|
p.write_deletelist()
|
|
|
|
print
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def update(args):
|
|
|
|
"""Update a working copy
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc up
|
|
|
|
osc up [pac_dir] # update a single package by its path
|
|
|
|
osc up * # from within a project dir, update all packages
|
|
|
|
osc up # from within a project dir, update all packages
|
2006-05-23 15:48:58 +02:00
|
|
|
AND check out all newly added packages
|
|
|
|
"""
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
args = parseargs(args)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
for arg in args:
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
# when 'update' is run inside a project dir, it should...
|
|
|
|
if is_project_dir(arg):
|
2006-05-22 12:50:37 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
prj = Project(arg)
|
2006-05-22 12:50:37 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
# (a) update all packages
|
2006-06-26 17:11:22 +02:00
|
|
|
args += prj.pacs_have
|
2006-05-22 12:50:37 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
# (b) fetch new packages
|
|
|
|
prj.checkout_missing_pacs()
|
|
|
|
args.remove(arg)
|
2006-05-22 12:50:37 +02:00
|
|
|
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
pacs = findpacs(args)
|
2006-05-22 12:50:37 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
for p in pacs:
|
2006-05-22 12:50:37 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
# save filelist and (modified) status before replacing the meta file
|
|
|
|
saved_filenames = p.filenamelist
|
2006-06-26 17:11:22 +02:00
|
|
|
saved_modifiedfiles = [ f for f in p.filenamelist if p.status(f) == 'M' ]
|
|
|
|
|
2006-05-23 18:16:14 +02:00
|
|
|
oldp = p
|
2006-05-23 15:48:58 +02:00
|
|
|
p.update_filesmeta()
|
|
|
|
p = Package(p.dir)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
# which files do no longer exist upstream?
|
2006-06-26 17:11:22 +02:00
|
|
|
disappeared = [ f for f in saved_filenames if f not in p.filenamelist ]
|
2006-05-23 15:48:58 +02:00
|
|
|
|
2006-04-28 17:37:25 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
for filename in saved_filenames:
|
|
|
|
if filename in disappeared:
|
|
|
|
print statfrmt('D', filename)
|
2006-05-30 12:07:16 +02:00
|
|
|
p.delete_localfile(filename)
|
2006-05-23 15:48:58 +02:00
|
|
|
continue
|
|
|
|
|
|
|
|
for filename in p.filenamelist:
|
|
|
|
|
|
|
|
state = p.status(filename)
|
2006-05-29 23:04:14 +02:00
|
|
|
if state == 'M' and p.findfilebyname(filename).md5 == oldp.findfilebyname(filename).md5:
|
2006-05-23 18:16:14 +02:00
|
|
|
# no merge necessary... local file is changed, but upstream isn't
|
|
|
|
pass
|
|
|
|
elif state == 'M' and filename in saved_modifiedfiles:
|
2006-05-23 15:48:58 +02:00
|
|
|
status_after_merge = p.mergefile(filename)
|
|
|
|
print statfrmt(status_after_merge, filename)
|
|
|
|
elif state == 'M':
|
|
|
|
p.updatefile(filename)
|
|
|
|
print statfrmt('U', filename)
|
|
|
|
elif state == '!':
|
|
|
|
p.updatefile(filename)
|
|
|
|
print 'Restored \'%s\'' % filename
|
|
|
|
elif state == 'F':
|
|
|
|
p.updatefile(filename)
|
|
|
|
print statfrmt('A', filename)
|
|
|
|
elif state == ' ':
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
p.update_pacmeta()
|
|
|
|
|
|
|
|
#print ljust(p.name, 45), 'At revision %s.' % p.rev
|
|
|
|
print 'At revision %s.' % p.rev
|
2006-04-28 17:37:25 +02:00
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-04-28 17:37:25 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
|
|
|
|
def delete(args):
|
|
|
|
"""rm (remove, del, delete): Mark files to be deleted upon next 'checkin'
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc rm file1 file2 ...
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
if not args:
|
|
|
|
print 'delete requires at least one argument'
|
|
|
|
sys.exit(1)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
args = parseargs(args)
|
|
|
|
pacs = findpacs(args)
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
for p in pacs:
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
for filename in p.todo:
|
|
|
|
p.put_on_deletelist(filename)
|
|
|
|
p.write_deletelist()
|
|
|
|
try:
|
|
|
|
os.unlink(os.path.join(p.dir, filename))
|
|
|
|
os.unlink(os.path.join(p.storedir, filename))
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
print statfrmt('D', filename)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def resolved(args):
|
|
|
|
"""If an update can't be merged automatically, a file is in 'C' (conflict)
|
|
|
|
state, and conflicts are marked with special <<<<<<< and >>>>>>> lines.
|
|
|
|
After manually resolving the problem, use
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc resolved <filename>
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
2006-05-11 09:27:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
if not args:
|
|
|
|
print 'this command requires at least one argument'
|
|
|
|
sys.exit(1)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
args = parseargs(args)
|
|
|
|
pacs = findpacs(args)
|
2006-04-25 14:25:53 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
for p in pacs:
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
for filename in p.todo:
|
|
|
|
print "Resolved conflicted state of '%s'" % filename
|
|
|
|
p.clear_from_conflictlist(filename)
|
2006-05-22 16:12:06 +02:00
|
|
|
|
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
def usermeta(args):
|
|
|
|
"""usermeta: show metadata about user <userid>
|
2006-05-22 16:12:06 +02:00
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
usage: osc usermeta <userid>
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
2006-05-22 16:12:06 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
if not args:
|
|
|
|
print 'this command requires at least one argument'
|
|
|
|
sys.exit(1)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
r = get_user_meta(args[0])
|
2006-05-23 15:48:58 +02:00
|
|
|
if r:
|
|
|
|
print ''.join(r)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def platforms(args):
|
|
|
|
"""platforms: Shows platforms
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage 1. osc platforms
|
2006-05-23 15:48:58 +02:00
|
|
|
Shows available platforms/build targets
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
2. osc platforms <project>
|
2006-05-23 15:48:58 +02:00
|
|
|
Shows the configured platforms/build targets of a project
|
|
|
|
"""
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
if args:
|
|
|
|
project = args[0]
|
|
|
|
print '\n'.join(get_platforms_of_project(project))
|
|
|
|
else:
|
|
|
|
print '\n'.join(get_platforms())
|
|
|
|
|
|
|
|
|
|
|
|
def results_meta(args):
|
|
|
|
"""Shows the build results of the package in raw XML
|
2006-04-29 22:44:09 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc results_meta [platform]
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
if args:
|
|
|
|
platform = args[0]
|
|
|
|
print ''.join(show_results_meta(project, package, platform))
|
|
|
|
else:
|
2006-04-29 22:44:09 +02:00
|
|
|
for platform in get_platforms_of_project(project):
|
2006-05-23 15:48:58 +02:00
|
|
|
print ''.join(show_results_meta(project, package, platform))
|
2006-04-29 22:44:09 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
|
|
|
|
def results(args):
|
|
|
|
"""Shows the build results of a package
|
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: 1. osc results # package = current dir
|
|
|
|
2. osc results <packagedir>
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
if args and len(args) > 1:
|
|
|
|
print 'getting results for more than one package is not supported'
|
|
|
|
print sys.exit(1)
|
|
|
|
|
|
|
|
if args:
|
|
|
|
wd = args[0]
|
|
|
|
else:
|
2006-04-20 16:26:50 +02:00
|
|
|
wd = os.curdir
|
2006-05-23 15:48:58 +02:00
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
|
|
|
|
for platform in get_platforms_of_project(project):
|
|
|
|
print '\n'.join(get_results(project, package, platform))
|
|
|
|
|
|
|
|
|
2006-09-25 17:11:03 +02:00
|
|
|
def prjresults(args):
|
|
|
|
"""Shows the aggregated build results of an entire project
|
|
|
|
|
|
|
|
usage: 1. osc prjresults # package = current dir
|
|
|
|
2. osc prjresults <packagedir>
|
|
|
|
"""
|
|
|
|
|
|
|
|
if args and len(args) > 1:
|
|
|
|
print 'getting results for more than one project is not supported'
|
|
|
|
print sys.exit(1)
|
|
|
|
|
|
|
|
if args:
|
|
|
|
wd = args[0]
|
|
|
|
else:
|
|
|
|
wd = os.curdir
|
|
|
|
|
|
|
|
try:
|
|
|
|
project = store_read_project(wd)
|
|
|
|
except:
|
|
|
|
sys.exit('\'%s\' is not an osc project directory' % wd)
|
|
|
|
|
|
|
|
print '\n'.join(get_prj_results(project))
|
|
|
|
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def log(args):
|
|
|
|
"""log: Shows the log file from a package (you need to be inside a package directory)
|
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc log <platform> <arch>
|
|
|
|
|
|
|
|
To find out <platform> and <arch>, you can use 'osc results'
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
2006-09-25 17:11:03 +02:00
|
|
|
|
|
|
|
if not args or len(args) != 2:
|
|
|
|
print 'missing argument'
|
|
|
|
print
|
|
|
|
print log.func_doc
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
platform = args[0]
|
|
|
|
arch = args[1]
|
2006-06-16 14:40:26 +02:00
|
|
|
offset = 0
|
2006-06-30 01:41:10 +02:00
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
log_chunk = get_log(project, package, platform, arch, offset)
|
|
|
|
if len(log_chunk) == 0:
|
|
|
|
break
|
|
|
|
offset += len(log_chunk)
|
|
|
|
print log_chunk.strip()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
pass
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-07-05 12:25:31 +02:00
|
|
|
def buildinfo(args):
|
2006-07-12 16:14:50 +02:00
|
|
|
"""buildinfo: Shows the build "info" which is used in building a package
|
2006-09-15 13:47:34 +02:00
|
|
|
This command is mostly used internally by the 'build' command.
|
|
|
|
It needs to be called inside a package directory.
|
2006-07-05 12:25:31 +02:00
|
|
|
|
2006-09-15 13:47:34 +02:00
|
|
|
usage: osc buildinfo <platform> <arch> [specfile]
|
|
|
|
|
2006-09-18 18:45:59 +02:00
|
|
|
The [specfile] argument is optional. <specfile> is a local specfile (or .dsc
|
|
|
|
file) which is sent to the server, and the buildinfo will be based on it.
|
2006-09-15 13:47:34 +02:00
|
|
|
If the argument is not supplied, the buildinfo is derived from the specfile
|
|
|
|
which is currently in the package.
|
|
|
|
|
|
|
|
The returned data is XML and contains a list of the packages used in building,
|
|
|
|
their source, and the expanded BuildRequires.
|
2006-07-05 12:25:31 +02:00
|
|
|
"""
|
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
|
2006-07-12 16:14:50 +02:00
|
|
|
if args is None or len(args) < 2:
|
|
|
|
print 'missing argument'
|
2006-07-20 16:23:10 +02:00
|
|
|
print
|
2006-07-12 16:14:50 +02:00
|
|
|
print buildinfo.func_doc
|
|
|
|
print 'Valid arguments for this package are:'
|
|
|
|
print
|
|
|
|
repos(None)
|
|
|
|
print
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-07-05 12:25:31 +02:00
|
|
|
platform = args[0]
|
|
|
|
arch = args[1]
|
2006-09-15 13:47:34 +02:00
|
|
|
|
|
|
|
# were we given a specfile (third argument)?
|
|
|
|
try:
|
|
|
|
spec = open(args[2]).read()
|
|
|
|
except IndexError:
|
|
|
|
spec = None
|
|
|
|
except IOError, e:
|
|
|
|
sys.exit(e)
|
|
|
|
|
|
|
|
print ''.join(get_buildinfo(project, package, platform, arch, specfile=spec))
|
2006-07-05 12:25:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
def buildconfig(args):
|
2006-07-12 16:14:50 +02:00
|
|
|
"""buildconfig: Shows the build configuration which is used in building a package
|
2006-09-15 13:47:34 +02:00
|
|
|
This command is mostly used internally by the 'build' command.
|
|
|
|
It needs to be called inside a package directory.
|
2006-07-05 12:25:31 +02:00
|
|
|
|
|
|
|
usage: osc buildconfig <platform> <arch>
|
2006-09-15 13:47:34 +02:00
|
|
|
|
|
|
|
The returned data is the project-wide build configuration in a format which is
|
|
|
|
directly readable by the build script. It contains RPM macros and BuildRequires
|
|
|
|
expansions, for example.
|
2006-07-05 12:25:31 +02:00
|
|
|
"""
|
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
|
2006-07-12 16:14:50 +02:00
|
|
|
if args is None or len(args) < 2:
|
|
|
|
print 'missing argument'
|
2006-07-20 16:23:10 +02:00
|
|
|
print
|
2006-07-12 16:14:50 +02:00
|
|
|
print buildconfig.func_doc
|
|
|
|
print 'Valid arguments for this package are:'
|
|
|
|
print
|
|
|
|
repos(None)
|
|
|
|
print
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-07-05 12:25:31 +02:00
|
|
|
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 <packagedir>
|
|
|
|
"""
|
|
|
|
args = parseargs(args)
|
|
|
|
pacs = findpacs(args)
|
|
|
|
|
|
|
|
for p in pacs:
|
|
|
|
|
|
|
|
for platform in get_repos_of_project(p.prjname):
|
|
|
|
print platform
|
|
|
|
|
|
|
|
|
2006-07-14 19:39:46 +02:00
|
|
|
def build(args):
|
2006-07-17 15:38:37 +02:00
|
|
|
"""build: build a package on your local machine
|
2006-07-14 19:39:46 +02:00
|
|
|
You need to call the command inside a package directory.
|
|
|
|
|
2006-07-14 20:39:44 +02:00
|
|
|
usage: 1. osc build <platform> <arch> <specfile> [--clean|--noinit]
|
|
|
|
2. BUILD_DIST=... osc build <specfile> [--clean|--noinit]
|
2006-07-17 15:38:37 +02:00
|
|
|
where BUILD_DIST equals <platform>-<arch>
|
2006-07-14 19:45:44 +02:00
|
|
|
|
2006-07-17 15:15:42 +02:00
|
|
|
|
|
|
|
You may want to configure sudo with option NOPASSWD for /usr/bin/build
|
|
|
|
and set su-wrapper to 'sudo' in .oscrc.
|
2006-10-10 16:04:34 +02:00
|
|
|
|
|
|
|
Note:
|
|
|
|
Configuration can be overridden by envvars, e.g.
|
|
|
|
OSC_SU_WRAPPER overrides the setting of su-wrapper.
|
|
|
|
BUILD_DIST or OSC_BUILD_DIST overrides the build target.
|
|
|
|
BUILD_ROOT or OSC_BUILD_ROOT overrides the build-root.
|
2006-07-14 19:39:46 +02:00
|
|
|
"""
|
|
|
|
|
2006-07-17 15:38:37 +02:00
|
|
|
import osc.build
|
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
if not os.path.exists('/usr/lib/build/debsort'):
|
|
|
|
sys.exit('Error: you need build.rpm with version 2006.6.14 or newer.\nSee http://software.opensuse.org/download/openSUSE:/Tools/')
|
|
|
|
|
2006-07-14 20:39:44 +02:00
|
|
|
builddist = os.getenv('BUILD_DIST')
|
|
|
|
if builddist:
|
|
|
|
#sys.argv[4] = sys.argv[1]
|
|
|
|
hyphen = builddist.rfind('-')
|
|
|
|
sys.argv.insert(2, builddist[hyphen+1:])
|
|
|
|
sys.argv.insert(2, builddist[:hyphen])
|
|
|
|
print sys.argv
|
|
|
|
|
|
|
|
elif args is None or len(args) < 3:
|
2006-07-14 19:39:46 +02:00
|
|
|
print 'missing argument'
|
2006-07-20 16:23:10 +02:00
|
|
|
print
|
2006-07-14 19:39:46 +02:00
|
|
|
print build.func_doc
|
|
|
|
print 'Valid arguments are:'
|
2006-07-17 15:38:37 +02:00
|
|
|
print 'you have to choose a repo to build on'
|
|
|
|
print 'possible repositories are:'
|
2006-07-14 19:39:46 +02:00
|
|
|
print
|
2006-07-17 15:38:37 +02:00
|
|
|
(i, o) = os.popen4(['osc', 'repos'])
|
|
|
|
i.close()
|
|
|
|
|
|
|
|
for line in o.readlines():
|
|
|
|
a = line.split()[1] # arch
|
|
|
|
if a == osc.build.hostarch or \
|
|
|
|
a in osc.build.can_also_build.get(osc.build.hostarch, []):
|
|
|
|
print line.strip()
|
2006-07-14 19:39:46 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
osc.build.main(sys.argv[1:])
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-08-10 18:39:13 +02:00
|
|
|
def buildhistory(args):
|
|
|
|
"""buildhistory (buildhist): Shows the build history of a package
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2006-08-10 18:39:13 +02:00
|
|
|
usage: osc buildhistory <platform> <arch>
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-08-10 18:39:13 +02:00
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-08-10 18:39:13 +02:00
|
|
|
if args is None or len(args) < 2:
|
|
|
|
print 'missing argument'
|
|
|
|
print
|
|
|
|
print buildhistory.func_doc
|
|
|
|
print 'Valid arguments for this package are:'
|
|
|
|
print
|
|
|
|
repos(None)
|
|
|
|
print
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
platform = args[0]
|
|
|
|
arch = args[1]
|
2006-09-25 17:11:03 +02:00
|
|
|
print '\n'.join(get_buildhistory(project, package, platform, arch))
|
2006-05-23 15:48:58 +02:00
|
|
|
|
2006-09-29 12:37:53 +02:00
|
|
|
|
2006-06-08 12:30:29 +02:00
|
|
|
def rebuildpac(args):
|
2006-10-10 16:04:34 +02:00
|
|
|
"""rebuildpac: Causes a package to be rebuilt
|
2006-06-08 12:30:29 +02:00
|
|
|
|
2006-09-25 17:11:03 +02:00
|
|
|
usage: osc rebuildpac <project> <package> [<repo> [<arch>]]
|
2006-10-10 16:04:34 +02:00
|
|
|
|
|
|
|
With the optional <repo> and <arch> arguments, the rebuild can be limited
|
|
|
|
to a certain repository or architecture.
|
|
|
|
|
|
|
|
Note that it is normally NOT needed to kick off rebuilds like this, because
|
|
|
|
they principally happen in a fully automatic way, triggered by source
|
|
|
|
check-ins. In particular, the order in which packages are built is handled
|
|
|
|
by the build service.
|
2006-06-08 12:30:29 +02:00
|
|
|
"""
|
|
|
|
|
2006-09-25 17:11:03 +02:00
|
|
|
if args is None or len(args) < 2:
|
|
|
|
print 'missing argument'
|
|
|
|
print
|
|
|
|
print rebuildpac.func_doc
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
repo = arch = None
|
|
|
|
project = args[0]
|
|
|
|
package = args[1]
|
|
|
|
if len(args) > 2:
|
|
|
|
repo = args[2]
|
|
|
|
if len(args) > 3:
|
|
|
|
arch = args[3]
|
|
|
|
|
|
|
|
print package + ':', cmd_rebuild(project, package, repo, arch)
|
2006-06-08 12:30:29 +02:00
|
|
|
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def help(args):
|
|
|
|
"""help: Describe the usage of this program or its subcommands.
|
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
usage: osc help [SUBCOMMAND...]
|
2006-05-23 15:48:58 +02:00
|
|
|
"""
|
|
|
|
if args:
|
2006-07-03 12:00:20 +02:00
|
|
|
cmd = args[0]
|
|
|
|
for i in cmd_dict.keys():
|
|
|
|
if cmd in cmd_dict[i]:
|
|
|
|
cmd = i
|
|
|
|
break
|
2006-05-23 15:48:58 +02:00
|
|
|
|
|
|
|
try:
|
2006-07-03 12:00:20 +02:00
|
|
|
print cmd.func_doc
|
2006-05-23 15:48:58 +02:00
|
|
|
|
2006-07-03 12:00:20 +02:00
|
|
|
except AttributeError, KeyError:
|
2006-05-23 15:48:58 +02:00
|
|
|
print 'unknown command \'%s\'' % cmd
|
|
|
|
sys.exit(1)
|
|
|
|
else:
|
|
|
|
print usage_general
|
2006-07-03 12:00:20 +02:00
|
|
|
lines = []
|
|
|
|
for i in cmd_dict.keys():
|
|
|
|
line = ' ' + (i.__name__)
|
|
|
|
if len(cmd_dict[i]) > 1:
|
|
|
|
line += ' (%s)' % ', '.join(cmd_dict[i][1:])
|
|
|
|
lines.append(line)
|
|
|
|
lines.sort()
|
|
|
|
lines.append('')
|
|
|
|
print '\n'.join(lines)
|
2006-05-23 15:48:58 +02:00
|
|
|
|
|
|
|
|
2006-07-14 19:39:46 +02:00
|
|
|
# all commands and aliases are defined here
|
|
|
|
# a function with the respective name is assumed to exist
|
2006-05-23 15:48:58 +02:00
|
|
|
cmd_dict = {
|
2006-07-03 12:00:20 +02:00
|
|
|
add: ['add'],
|
|
|
|
addremove: ['addremove'],
|
2006-07-14 19:39:46 +02:00
|
|
|
build: ['build'],
|
2006-07-05 12:25:31 +02:00
|
|
|
buildconfig: ['buildconfig'],
|
|
|
|
buildinfo: ['buildinfo'],
|
2006-07-03 12:00:20 +02:00
|
|
|
commit: ['commit', 'ci', 'checkin'],
|
|
|
|
checkout: ['checkout', 'co'],
|
|
|
|
updatepacmetafromspec: ['updatepacmetafromspec'],
|
2006-08-11 12:37:29 +02:00
|
|
|
deletepac: ['deletepac'],
|
2006-09-25 17:11:03 +02:00
|
|
|
deleteprj: ['deleteprj'],
|
2006-07-03 12:00:20 +02:00
|
|
|
diff: ['diff'],
|
|
|
|
editmeta: ['editmeta'],
|
2006-09-15 12:53:44 +02:00
|
|
|
editpac: ['editpac', 'createpac'],
|
2006-09-21 16:33:24 +02:00
|
|
|
copypac: ['copypac'],
|
2006-09-15 12:53:44 +02:00
|
|
|
editprj: ['editprj', 'createprj'],
|
2006-07-03 12:00:20 +02:00
|
|
|
help: ['help'],
|
2006-08-10 18:39:13 +02:00
|
|
|
buildhistory: ['buildhistory', 'buildhist'],
|
2006-08-07 12:08:54 +02:00
|
|
|
linkpac: ['linkpac'],
|
2006-10-12 15:22:56 +02:00
|
|
|
usermeta: ['usermeta'],
|
|
|
|
edituser: ['edituser'],
|
2007-01-12 04:52:46 +01:00
|
|
|
init: ['init'], # deprecated
|
2006-07-03 12:00:20 +02:00
|
|
|
log: ['log'],
|
|
|
|
ls: ['ls', 'list'],
|
|
|
|
meta: ['meta'],
|
|
|
|
platforms: ['platforms'],
|
|
|
|
delete: ['delete', 'del', 'rm', 'remove'],
|
2006-07-05 12:25:31 +02:00
|
|
|
repos: ['repos'],
|
2006-07-03 12:00:20 +02:00
|
|
|
repourls: ['repourls'],
|
|
|
|
resolved: ['resolved'],
|
|
|
|
results: ['results'],
|
2006-09-25 17:11:03 +02:00
|
|
|
prjresults: ['prjresults'],
|
2006-07-03 12:00:20 +02:00
|
|
|
results_meta: ['results_meta'],
|
|
|
|
rebuildpac: ['rebuildpac'],
|
2007-01-07 01:59:34 +01:00
|
|
|
status: ['status', 'stat', 'st'],
|
2006-07-03 12:00:20 +02:00
|
|
|
update: ['update', 'up'],
|
2006-05-23 15:48:58 +02:00
|
|
|
}
|
|
|
|
|
2006-07-03 12:00:20 +02:00
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def main():
|
|
|
|
"""handling of commandline arguments, and dispatching to subcommands"""
|
|
|
|
|
2006-10-10 16:04:34 +02:00
|
|
|
conf.get_config()
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
# which subcommand?
|
|
|
|
if len(sys.argv) < 2:
|
|
|
|
print "Type 'osc help' for usage."
|
|
|
|
sys.exit(0)
|
|
|
|
|
2006-07-03 12:00:20 +02:00
|
|
|
cmd = sys.argv[1]
|
2006-05-23 15:48:58 +02:00
|
|
|
|
|
|
|
# more arguments?
|
|
|
|
if len(sys.argv) > 2:
|
|
|
|
args = sys.argv[2:]
|
2006-04-20 16:26:50 +02:00
|
|
|
else:
|
2006-05-23 15:48:58 +02:00
|
|
|
args = None
|
|
|
|
|
2006-07-03 12:00:20 +02:00
|
|
|
for i in cmd_dict.keys():
|
|
|
|
if cmd in cmd_dict[i]:
|
|
|
|
cmd = i
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
# run subcommand
|
2006-05-23 17:27:43 +02:00
|
|
|
if cmd not in cmd_dict:
|
|
|
|
print 'unknown command \'%s\'' % cmd
|
|
|
|
print "Type 'osc help' for usage."
|
|
|
|
sys.exit(1)
|
2006-07-03 12:00:20 +02:00
|
|
|
cmd(args)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
if __name__ == '__main__':
|
2006-10-10 16:04:34 +02:00
|
|
|
import sys, os.path
|
|
|
|
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
|
2006-04-20 16:26:50 +02:00
|
|
|
main()
|
|
|
|
|