1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-27 23:16:14 +01:00

- cleanups + cosmetic changes

This commit is contained in:
Marcus Huewe 2010-01-09 14:25:41 +01:00
parent 5a7346858a
commit 5c8ee534a9
2 changed files with 40 additions and 63 deletions

View File

@ -281,11 +281,14 @@ def main(opts, argv):
xp = [] xp = []
build_root = None build_root = None
build_descr = os.path.abspath(build_descr)
build_type = os.path.splitext(build_descr)[1][1:] build_type = os.path.splitext(build_descr)[1][1:]
if build_type not in ['spec', 'dsc', 'kiwi']: if build_type not in ['spec', 'dsc', 'kiwi']:
raise oscerr.WrongArgs( raise oscerr.WrongArgs(
"Unknown build type: '%s'. Build description should end in .spec, .dsc or .kiwi." \ 'Unknown build type: \'%s\'. Build description should end in .spec, .dsc or .kiwi.' \
% build_type) % build_type)
if not os.path.isfile(build_descr):
raise oscerr.WrongArgs('Error: build description file named \'%s\' does not exist.' % build_descr)
buildargs = [] buildargs = []
if not opts.userootforbuild: if not opts.userootforbuild:
@ -341,11 +344,6 @@ def main(opts, argv):
pac = store_read_package(os.curdir) pac = store_read_package(os.curdir)
apiurl = store_read_apiurl(os.curdir) apiurl = store_read_apiurl(os.curdir)
build_descr = os.path.abspath(build_descr)
if not os.path.exists(build_descr):
print >>sys.stderr, 'Error: build description named \'%s\' does not exist.' % build_descr
return 1
# make it possible to override configuration of the rc file # make it possible to override configuration of the rc file
for var in ['OSC_PACKAGECACHEDIR', 'OSC_SU_WRAPPER', 'OSC_BUILD_ROOT']: for var in ['OSC_PACKAGECACHEDIR', 'OSC_SU_WRAPPER', 'OSC_BUILD_ROOT']:
val = os.getenv(var) val = os.getenv(var)
@ -396,6 +394,25 @@ def main(opts, argv):
cpio.add(os.path.basename(build_descr), build_descr_data) cpio.add(os.path.basename(build_descr), build_descr_data)
build_descr_data = cpio.get() build_descr_data = cpio.get()
# special handling for overlay and rsync-src/dest
specialcmdopts = ''
if opts.rsyncsrc or opts.rsyncdest :
if not opts.rsyncsrc or not opts.rsyncdest:
raise oscerr.WrongOptions('When using --rsync-{src,dest} both parameters have to be specified.')
myrsyncsrc = os.path.abspath(os.path.expanduser(os.path.expandvars(opts.rsyncsrc)))
if not os.path.isdir(myrsyncsrc):
raise oscerr.WrongOptions('--rsync-src %s is no valid directory!' % opts.rsyncsrc)
# can't check destination - its in the target chroot ;) - but we can check for sanity
myrsyncdest = os.path.expandvars(opts.rsyncdest)
if not os.path.isabs(myrsyncdest):
raise oscerr.WrongOptions('--rsync-dest %s is no absolute path (starting with \'/\')!' % opts.rsyncdest)
specialcmdopts = '--rsync-src="%s" --rsync-dest="%s"' % (myrsyncsrc, myrsyncdest)
if opts.overlay:
myoverlay = os.path.abspath(os.path.expanduser(os.path.expandvars(opts.overlay)))
if not os.path.isdir(myoverlay):
raise oscerr.WrongOptions('--overlay %s is no valid directory!' % opts.overlay)
specialcmdopts += '--overlay="%s"' % myoverlay
bi_file = None bi_file = None
bc_file = None bc_file = None
bi_filename = '_buildinfo-%s-%s.xml' % (repo, arch) bi_filename = '_buildinfo-%s-%s.xml' % (repo, arch)
@ -412,12 +429,10 @@ def main(opts, argv):
try: try:
if opts.noinit: if opts.noinit:
if not os.path.isfile(bi_filename): if not os.path.isfile(bi_filename):
print >>sys.stderr, '--noinit is not possible, no local buildinfo file' raise oscerr.WrongOptions('--noinit is not possible, no local buildinfo file')
sys.exit(1)
print 'Use local \'%s\' file as buildinfo' % bi_filename print 'Use local \'%s\' file as buildinfo' % bi_filename
if not os.path.isfile(bc_filename): if not os.path.isfile(bc_filename):
print >>sys.stderr, '--noinit is not possible, no local buildconfig file' raise oscerr.WrongOptions('--noinit is not possible, no local buildconfig file')
sys.exit(1)
print 'Use local \'%s\' file as buildconfig' % bc_filename print 'Use local \'%s\' file as buildconfig' % bc_filename
else: else:
print 'Getting buildinfo from server and store to %s' % bi_filename print 'Getting buildinfo from server and store to %s' % bi_filename
@ -580,51 +595,20 @@ def main(opts, argv):
rpmlist_file.writelines(rpmlist) rpmlist_file.writelines(rpmlist)
rpmlist_file.flush() rpmlist_file.flush()
vm_options="" vm_options = ''
if config['build-device'] and config['build-memory'] and config['build-type']: if config['build-device'] and config['build-memory'] and config['build-type']:
if config['build-type'] == "kvm": if config['build-type'] == 'kvm':
vm_options="--kvm " + config['build-device'] vm_options = '--kvm ' + config['build-device']
elif config['build-type'] == "xen": elif config['build-type'] == 'xen':
vm_options="--xen " + config['build-device'] vm_options = '--xen ' + config['build-device']
else: else:
print "ERROR: unknown VM is set ! (" + config['build-type'] + ")" raise oscerr.WrongArgs('ERROR: unknown VM is set ! ("%s")' % config['build-type'])
sys.exit(1)
if config['build-swap']: if config['build-swap']:
vm_options+=" --swap " + config['build-swap'] vm_options += ' --swap ' + config['build-swap']
if config['build-memory']: if config['build-memory']:
vm_options+=" --memory " + config['build-memory'] vm_options += ' --memory ' + config['build-memory']
print 'Running build' print 'Running build'
# special handling for overlay and rsync-src/dest
specialcmdopts = " "
if opts.rsyncsrc or opts.rsyncdest :
if not opts.rsyncsrc or not opts.rsyncdest:
print "When using --rsync-{src,dest} both parameters have to be specified."
sys.exit(1)
myrsyncsrc = os.path.expanduser(os.path.expandvars(opts.rsyncsrc))
myrsyncdest = ""
if os.path.isdir(myrsyncsrc):
myrsyncsrc = os.path.abspath(myrsyncsrc)
else:
print "--rsync-src " + str(opts.rsyncsrc) + " is no valid directory!"
sys.exit(1)
# can't check destination - its in the target chroot ;) - but we can check for sanity
if not opts.rsyncdest.startswith("/"):
print "--rsync-dest " + str(opts.rsyncsrc) + " is no absolute path (starting with '/')!"
sys.exit(1)
myrsyncdest = os.path.expandvars(opts.rsyncdest)
specialcmdopts += '--rsync-src="%s" --rsync-dest="%s"' \
% (myrsyncsrc,
myrsyncdest)
if opts.overlay:
myoverlay = os.path.expanduser(os.path.expandvars(opts.overlay))
if not os.path.isdir(myoverlay):
print "--overlay " + str(opts.overlay) + " is no valid directory!"
sys.exit(1)
myoverlay = os.path.abspath(myoverlay)
specialcmdopts += '--overlay="%s"' \
% (myoverlay)
cmd = '"%s" --root="%s" --rpmlist="%s" --dist="%s" %s --arch=%s %s "%s" %s' \ cmd = '"%s" --root="%s" --rpmlist="%s" --dist="%s" %s --arch=%s %s "%s" %s' \
% (config['build-cmd'], % (config['build-cmd'],
build_root, build_root,

View File

@ -1313,8 +1313,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
dst_package = src_package dst_package = src_package
if src_project == dst_project and src_package == dst_package: if src_project == dst_project and src_package == dst_package:
print >>sys.stderr, 'Error: source and destination are the same.' raise oscerr.WrongArgs('Error: source and destination are the same.')
return 1
if src_project == dst_project and not opts.cicount: if src_project == dst_project and not opts.cicount:
# in this case, the user usually wants to build different spec # in this case, the user usually wants to build different spec
@ -1368,16 +1367,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
dst_package = src_package dst_package = src_package
if src_project == dst_project and src_package == dst_package: if src_project == dst_project and src_package == dst_package:
print >>sys.stderr, 'Error: source and destination are the same.' raise oscerr.WrongArgs('Error: source and destination are the same.')
return 1
repo_map = {} repo_map = {}
if opts.map_repo: if opts.map_repo:
for pair in opts.map_repo.split(','): for pair in opts.map_repo.split(','):
src_tgt = pair.split('=') src_tgt = pair.split('=')
if len(src_tgt) != 2: if len(src_tgt) != 2:
print >>sys.stderr, 'map "%s" must be SRC=TARGET[,SRC=TARGET]' % opts.map_repo raise oscerr.WrongOptions('map "%s" must be SRC=TARGET[,SRC=TARGET]' % opts.map_repo)
return 1
repo_map[src_tgt[0]] = src_tgt[1] repo_map[src_tgt[0]] = src_tgt[1]
aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map, opts.disable_publish) aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map, opts.disable_publish)
@ -3158,13 +3155,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if opts.prefer_pkgs: if opts.prefer_pkgs:
for d in opts.prefer_pkgs: for d in opts.prefer_pkgs:
if not os.path.isdir(d): if not os.path.isdir(d):
print >> sys.stderr, 'Preferred package location \'%s\' is not a directory' % d raise oscerr.WrongOptions('Preferred package location \'%s\' is not a directory' % d)
return 1
if opts.keep_pkgs: if opts.keep_pkgs and not os.path.isdir(opts.keep_pkgs):
if not os.path.isdir(opts.keep_pkgs): raise oscerr.WrongOptions('Preferred save location \'%s\' is not a directory' % opts.keep_pkgs)
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_repository, arg_arch) print 'Building %s for %s/%s' % (arg_descr, arg_repository, arg_arch)
return osc.build.main(opts, args) return osc.build.main(opts, args)
@ -3452,8 +3446,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
codes.append(None) codes.append(None)
if len(codes) == 0: if len(codes) == 0:
print 'No option has been provided. If you want to delete all binaries, use --all option.' raise oscerr.WrongOptions('No option has been provided. If you want to delete all binaries, use --all option.')
return 1
# make a new request for each code= parameter # make a new request for each code= parameter
for code in codes: for code in codes: