1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-09 22:36:14 +01:00

+ - make buildhist command usable without checked out package

+ - rename old "platform/s" names to "repository/ies" (internal cleanup only)
This commit is contained in:
Adrian Schröter 2009-09-08 08:14:27 +00:00
parent 7ea7ecee3d
commit 48e96a96fb
5 changed files with 108 additions and 82 deletions

2
NEWS
View File

@ -7,6 +7,8 @@
- added default project to new getpac and bco subcommand. .oscrc:getpac_default_project = OpenSUSE:Factory
(not added to branch subcommand, to not interfere with its syntax.)
- add support for generic python-keyring lib, supports KWallet, Gnome keyring, MacOS and Windows.
- make buildhist command usable without checked out package
- rename old "platform/s" names to "repository/ies" (internal cleanup only)
#
# Features which require OBS 1.7
#

12
README
View File

@ -176,10 +176,10 @@ Generates a diff, to view the changes
Shows the build results of the package
osc results
osc results [platform]
osc results [repository]
Shows the log file of a package (you need to be inside a package directory)
osc log <platform> <arch>
osc log <repository> <arch>
Shows the URLs of .repo files which are packages sources for Yum/YaST/smart
osc repourls [dir]
@ -187,11 +187,11 @@ Shows the URLs of .repo files which are packages sources for Yum/YaST/smart
Triggers a package rebuild for all repositories/architectures of a package
osc rebuildpac [dir]
Shows available platforms/build targets
osc platforms
Shows available repository/build targets
osc repository
Shows the configured platforms/build targets of a project
osc platforms <project>
Shows the configured repository/build targets of a project
osc repository <project>
Shows meta information
osc meta Apache

View File

@ -245,7 +245,7 @@ class Osc(cmdln.Cmdln):
if opts.binaries and (not opts.repo or not opts.arch):
raise oscerr.WrongOptions('Sorry, -r <repo> -a <arch> missing\n'
'You can list repositories with: \'osc platforms <project>\'')
'You can list repositories with: \'osc repositories <project>\'')
if opts.binaries and opts.expand:
raise oscerr.WrongOptions('Sorry, --binaries and --expand are mutual exclusive.')
@ -1534,9 +1534,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
url_tmpl = 'http://download.opensuse.org/repositories/%s/%s/%s.repo'
for p in pacs:
platforms = get_platforms_of_project(p.apiurl, p.prjname)
for platform in platforms:
print url_tmpl % (p.prjname.replace(':', ':/'), platform, p.prjname)
repositories = get_repositories_of_project(p.apiurl, p.prjname)
for repository in repositories:
print url_tmpl % (p.prjname.replace(':', ':/'), repository, p.prjname)
@ -1623,7 +1623,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
elif project:
prj_dir = project
if sys.platform[:3] == 'win':
if sys.repository[:3] == 'win':
prj_dir = prj_dir.replace(':', ';')
if os.path.exists(prj_dir):
sys.exit('osc: project \'%s\' already exists' % project)
@ -2118,15 +2118,16 @@ Please submit there instead, or use --nodevelproject to force direct submission.
p.clear_from_conflictlist(filename)
def do_platforms(self, subcmd, opts, *args):
"""${cmd_name}: Shows available platforms
@cmdln.alias('platforms')
def do_repositories(self, subcmd, opts, *args):
"""${cmd_name}: Shows available repositories
Examples:
1. osc platforms
Shows all available platforms/build targets
1. osc repositories
Shows all available repositories/build targets
2. osc platforms <project>
Shows the configured platforms/build targets of a project
2. osc repositories <project>
Shows the configured repositories/build targets of a project
${cmd_usage}
${cmd_option_list}
@ -2134,9 +2135,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if args:
project = args[0]
print '\n'.join(get_platforms_of_project(conf.config['apiurl'], project))
print '\n'.join(get_repositories_of_project(conf.config['apiurl'], project))
else:
print '\n'.join(get_platforms(conf.config['apiurl']))
print '\n'.join(get_repositories(conf.config['apiurl']))
@cmdln.hide(1)
@ -2293,14 +2294,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.alias('bl')
@cmdln.option('-s', '--start', metavar='START',
help='get log starting from the offset')
def do_buildlog(self, subcmd, opts, platform, arch):
def do_buildlog(self, subcmd, opts, repository, arch):
"""${cmd_name}: Shows the build log of a package
Shows the log file of the build of a package. Can be used to follow the
log while it is being written.
Needs to be called from within a package directory.
The arguments PLATFORM and ARCH are the first two columns in the 'osc
The arguments REPOSITORY and ARCH are the first two columns in the 'osc
results' output.
${cmd_usage}
@ -2316,7 +2317,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if opts.start:
offset = int(opts.start)
print_buildlog(apiurl, project, package, platform, arch, offset)
print_buildlog(apiurl, project, package, repository, arch, offset)
@cmdln.alias('rbl')
@ -2328,9 +2329,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
log while it is being written.
usage:
osc remotebuildlog project package platform arch
osc remotebuildlog project package repository arch
or
osc remotebuildlog project/package/platform/arch
osc remotebuildlog project/package/repository/arch
${cmd_option_list}
"""
args = slash_split(args)
@ -2360,11 +2361,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
The returned data is XML and contains a list of the packages used in
building, their source, and the expanded BuildRequires.
The arguments PLATFORM and ARCH can be taken from the first two columns
The arguments REPOSITORY and ARCH can be taken from the first two columns
of the 'osc repos' output.
usage:
osc buildinfo PLATFORM ARCH [BUILD_DESCR]
osc buildinfo REPOSITORY ARCH [BUILD_DESCR]
${cmd_option_list}
"""
@ -2380,7 +2381,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print
raise oscerr.WrongArgs('Missing argument')
platform = args[0]
repository = args[0]
arch = args[1]
# were we given a specfile (third argument)?
@ -2393,12 +2394,12 @@ Please submit there instead, or use --nodevelproject to force direct submission.
return 1
print ''.join(get_buildinfo(apiurl,
project, package, platform, arch,
project, package, repository, arch,
specfile=spec,
addlist=opts.extra_pkgs))
def do_buildconfig(self, subcmd, opts, platform, arch):
def do_buildconfig(self, subcmd, opts, repository, arch):
"""${cmd_name}: Shows the build config
Shows the build configuration which is used in building a package.
@ -2409,7 +2410,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
which is directly readable by the build script. It contains RPM macros
and BuildRequires expansions, for example.
The arguments PLATFORM and ARCH can be taken from the first two columns
The arguments REPOSITORY and ARCH can be taken from the first two columns
of the 'osc repos' output.
${cmd_usage}
@ -2421,7 +2422,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
project = store_read_project(wd)
apiurl = store_read_apiurl(wd)
print ''.join(get_buildconfig(apiurl, project, package, platform, arch))
print ''.join(get_buildconfig(apiurl, project, package, repository, arch))
def do_repos(self, subcmd, opts, *args):
@ -2440,8 +2441,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
args = parseargs(args)
for arg in args:
for platform in get_repos_of_project(store_read_apiurl(arg), store_read_project(arg)):
print platform
for repository in get_repos_of_project(store_read_apiurl(arg), store_read_project(arg)):
print repository
@cmdln.option('--clean', action='store_true',
@ -2499,7 +2500,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
You need to call the command inside a package directory, which should be a
buildsystem checkout. (Local modifications are fine.)
The arguments PLATFORM and ARCH can be taken from the first two columns
The arguments REPOSITORY and ARCH can be taken from the first two columns
of the 'osc repos' output. BUILD_DESCR is either a RPM spec file, or a
Debian dsc file.
@ -2519,11 +2520,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc build [OPTS] --alternative-project openSUSE:10.3 standard i586 BUILD_DESCR
usage:
osc build [OPTS] PLATFORM ARCH BUILD_DESCR
osc build [OPTS] PLATFORM (ARCH = hostarch, BUILD_DESCR is detected automatically)
osc build [OPTS] ARCH (PLATFORM = build_platform (config option), BUILD_DESCR is detected automatically)
osc build [OPTS] BUILD_DESCR (PLATFORM = build_platform (config option), ARCH = hostarch)
osc build [OPTS] (PLATFORM = build_platform (config option), ARCH = hostarch, BUILD_DESCR is detected automatically)
osc build [OPTS] REPOSITORY ARCH BUILD_DESCR
osc build [OPTS] REPOSITORY (ARCH = hostarch, BUILD_DESCR is detected automatically)
osc build [OPTS] ARCH (REPOSITORY = build_repository (config option), BUILD_DESCR is detected automatically)
osc build [OPTS] BUILD_DESCR (REPOSITORY = build_repository (config option), ARCH = hostarch)
osc build [OPTS] (REPOSITORY = build_repository (config option), ARCH = hostarch, BUILD_DESCR is detected automatically)
# Note:
# Configuration can be overridden by envvars, e.g.
@ -2548,7 +2549,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if len(args) > 3:
raise oscerr.WrongArgs('Too many arguments')
arg_arch = arg_platform = arg_descr = None
arg_arch = arg_repository = arg_descr = None
if len(args) < 3:
for arg in args:
if arg.endswith('.spec') or arg.endswith('.dsc'):
@ -2557,36 +2558,36 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if arg in osc.build.can_also_build.get(osc.build.hostarch, []) or \
arg in osc.build.hostarch:
arg_arch = arg
elif not arg_platform:
arg_platform = arg
elif not arg_repository:
arg_repository = arg
else:
raise oscerr.WrongArgs('unexpected argument: \'%s\'' % arg)
else:
arg_platform, arg_arch, arg_descr = args
arg_repository, arg_arch, arg_descr = args
arg_arch = arg_arch or osc.build.hostarch
platforms = get_platforms_of_project( \
repositories = get_repositories_of_project( \
store_read_apiurl('.'), \
opts.alternative_project or store_read_project('.'))
if not arg_platform:
if not arg_repository:
if len(platforms) == 0:
arg_platform = conf.config['build_platform']
if len(repositories) == 0:
arg_repository = conf.config['build_repository']
else:
# Use a default value from config, but just even if it's available
# unless try standard, or openSUSE_Factory
for platform in (conf.config['build_platform'], 'standard', 'openSUSE_Factory'):
if platform in platforms:
arg_platform = platform
for repository in (conf.config['build_repository'], 'standard', 'openSUSE_Factory'):
if repository in repositories:
arg_repository = repository
break
arg_platform = arg_platform or platforms[len(platforms)-1]
arg_repository = arg_repository or repositories[len(repositories)-1]
if not arg_platform in platforms:
raise oscerr.WrongArgs('%s is not a valid platform, use one of: %s' % (arg_platform, ", ".join(platforms)))
if not arg_repository in repositories:
raise oscerr.WrongArgs('%s is not a valid repository, use one of: %s' % (arg_repository, ", ".join(repositories)))
# check for source services
if os.listdir('.').count("_service"):
@ -2608,7 +2609,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
pass
raise oscerr.WrongArgs(msg)
args = (arg_platform, arg_arch, arg_descr)
args = (arg_repository, arg_arch, arg_descr)
if opts.prefer_pkgs:
for d in opts.prefer_pkgs:
@ -2621,7 +2622,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print >> sys.stderr, 'Preferred save location \'%s\' is not a directory' % opts.keep_pkgs
return 1
print 'Building %s for %s/%s' % (arg_descr, arg_platform, arg_arch)
print 'Building %s for %s/%s' % (arg_descr, arg_repository, arg_arch)
return osc.build.main(opts, args)
@ -2629,34 +2630,47 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.option('', '--csv', action='store_true',
help='generate output in CSV (separated by |)')
@cmdln.alias('buildhist')
def do_buildhistory(self, subcmd, opts, platform, arch):
def do_buildhistory(self, subcmd, opts, *args):
"""${cmd_name}: Shows the build history of a package
The arguments PLATFORM and ARCH can be taken from the first two columns
The arguments REPOSITORY and ARCH can be taken from the first two columns
of the 'osc repos' output.
${cmd_usage}
usage:
osc buildhist REPOSITORY ARCHITECTURE
osc buildhist PROJECT PACKAGE REPOSITORY ARCHITECTURE
${cmd_option_list}
"""
wd = os.curdir
package = store_read_package(wd)
project = store_read_project(wd)
apiurl = store_read_apiurl(wd)
if len(args) == 4:
apiurl = conf.config['apiurl']
project = args[0]
package = args[1]
repository = args[2]
arch = args[3]
elif len(args) == 2:
wd = os.curdir
package = store_read_package(wd)
project = store_read_project(wd)
repository = args[0]
arch = args[1]
apiurl = store_read_apiurl(wd)
else:
raise oscerr.WrongArgs('Wrong number of arguments')
format = 'text'
if opts.csv:
format = 'csv'
print '\n'.join(get_buildhistory(apiurl, project, package, platform, arch, format))
print '\n'.join(get_buildhistory(apiurl, project, package, repository, arch, format))
@cmdln.option('', '--csv', action='store_true',
help='generate output in CSV (separated by |)')
@cmdln.alias('jobhist')
def do_jobhistory(self, subcmd, opts, platform, arch):
def do_jobhistory(self, subcmd, opts, repository, arch):
"""${cmd_name}: Shows the job history of a project
The arguments PLATFORM and ARCH can be taken from the first two columns
The arguments REPOSITORY and ARCH can be taken from the first two columns
of the 'osc repos' output.
${cmd_usage}
@ -2676,7 +2690,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if opts.csv:
format = 'csv'
print_jobhistory(apiurl, project, package, platform, arch, format)
print_jobhistory(apiurl, project, package, repository, arch, format)
@cmdln.hide(1)
def do_rlog(self, subcmd, opts, *args):
@ -2744,11 +2758,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
Note the --failed option, which can be used to rebuild all failed
packages.
The arguments PLATFORM and ARCH can be taken from the first two columns
The arguments REPOSITORY and ARCH can be taken from the first two columns
of the 'osc repos' output.
usage:
osc rebuild PROJECT [PACKAGE [PLATFORM [ARCH]]]
osc rebuild PROJECT [PACKAGE [REPOSITORY [ARCH]]]
${cmd_option_list}
"""

View File

@ -83,8 +83,8 @@ DEFAULTS = { 'apiurl': 'https://api.opensuse.org',
'do_package_tracking': '1',
# default for osc build
'extra-pkgs': 'vim gdb strace',
# default platform
'build_platform': 'openSUSE_Factory',
# default repository
'build_repository': 'openSUSE_Factory',
# default project for branch or bco
'getpac_default_project': 'openSUSE:Factory',
# alternate filesystem layout: have multiple subdirs, where colons were.
@ -137,7 +137,7 @@ apiurl = %(apiurl)s
#extra-pkgs = vim gdb strace
# build platform is used if the platform argument is omitted to osc build
#build_platform = %(build_platform)s
#build_repository = %(build_repository)s
# default project for getpac or bco
#getpac_default_project = %(getpac_default_project)s
@ -464,6 +464,8 @@ def get_config(override_conffile = None,
if config.has_key('apisrv') or config.has_key('scheme'):
print >>sys.stderr, 'Warning: Use of the \'scheme\' or \'apisrv\' in ~/.oscrc is deprecated!\n' \
'Warning: See README for migration details.'
if config.has_key('build_platform') and not config.has_key('build_repository'):
config['build_repository'] = config['build_platform']
for i in boolean_opts:
try:

View File

@ -3106,7 +3106,11 @@ def delete_files(apiurl, prj, pac, files):
u = makeurl(apiurl, ['source', prj, pac, file], query={'comment': 'removed %s' % (file, )})
http_DELETE(u)
# old compat lib call
def get_platforms(apiurl):
return get_repositories(apiurl)
def get_repositories(apiurl):
f = http_GET(makeurl(apiurl, ['platform']))
tree = ET.parse(f)
r = [ node.get('name') for node in tree.getroot() ]
@ -3114,7 +3118,11 @@ def get_platforms(apiurl):
return r
# old compat lib call
def get_platforms_of_project(apiurl, prj):
return get_repositories_of_project(apiurl, prj)
def get_repositories_of_project(apiurl, prj):
f = show_project_meta(apiurl, prj)
tree = ET.parse(StringIO(''.join(f)))
@ -3338,26 +3346,26 @@ def streamfile(url, http_meth = http_GET, bufsize=8192):
f.close()
def print_buildlog(apiurl, prj, package, platform, arch, offset = 0):
def print_buildlog(apiurl, prj, package, repository, arch, offset = 0):
"""prints out the buildlog on stdout"""
query = {'nostream' : '1', 'start' : '%s' % offset}
while True:
query['start'] = offset
start_offset = offset
u = makeurl(apiurl, ['build', prj, platform, arch, package, '_log'], query=query)
u = makeurl(apiurl, ['build', prj, repository, arch, package, '_log'], query=query)
for data in streamfile(u):
offset += len(data)
sys.stdout.write(data)
if start_offset == offset:
break
def get_buildinfo(apiurl, prj, package, platform, arch, specfile=None, addlist=None):
def get_buildinfo(apiurl, prj, package, repository, arch, specfile=None, addlist=None):
query = []
if addlist:
for i in addlist:
query.append('add=%s' % quote_plus(i))
u = makeurl(apiurl, ['build', prj, platform, arch, package, '_buildinfo'], query=query)
u = makeurl(apiurl, ['build', prj, repository, arch, package, '_buildinfo'], query=query)
if specfile:
f = http_POST(u, data=specfile)
@ -3366,15 +3374,15 @@ def get_buildinfo(apiurl, prj, package, platform, arch, specfile=None, addlist=N
return f.read()
def get_buildconfig(apiurl, prj, package, platform, arch):
u = makeurl(apiurl, ['build', prj, platform, '_buildconfig'])
def get_buildconfig(apiurl, prj, package, repository, arch):
u = makeurl(apiurl, ['build', prj, repository, '_buildconfig'])
f = http_GET(u)
return f.read()
def get_buildhistory(apiurl, prj, package, platform, arch, format = 'text'):
def get_buildhistory(apiurl, prj, package, repository, arch, format = 'text'):
import time
u = makeurl(apiurl, ['build', prj, platform, arch, package, '_history'])
u = makeurl(apiurl, ['build', prj, repository, arch, package, '_history'])
f = http_GET(u)
root = ET.parse(f).getroot()
@ -3397,12 +3405,12 @@ def get_buildhistory(apiurl, prj, package, platform, arch, format = 'text'):
return r
def print_jobhistory(apiurl, prj, current_package, platform, arch, format = 'text'):
def print_jobhistory(apiurl, prj, current_package, repository, arch, format = 'text'):
import time
if current_package:
u = makeurl(apiurl, ['build', prj, platform, arch, '_jobhistory'], "package=%s" % (current_package))
u = makeurl(apiurl, ['build', prj, repository, arch, '_jobhistory'], "package=%s" % (current_package))
else:
u = makeurl(apiurl, ['build', prj, platform, arch, '_jobhistory'])
u = makeurl(apiurl, ['build', prj, repository, arch, '_jobhistory'])
f = http_GET(u)
root = ET.parse(f).getroot()