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

use list instead of string for command

now arguments with spaces should also work
This commit is contained in:
Ludwig Nussel 2010-12-07 16:07:20 +01:00
parent 820595bb20
commit 5376580652
2 changed files with 38 additions and 44 deletions

View File

@ -385,9 +385,9 @@ def main(apiurl, opts, argv):
if opts.root: if opts.root:
build_root = opts.root build_root = opts.root
if opts.jobs: if opts.jobs:
buildargs.append('--jobs %s' % opts.jobs) buildargs.append('--jobs=%s' % opts.jobs)
elif config['build-jobs'] > 1: elif config['build-jobs'] > 1:
buildargs.append('--jobs %s' % config['build-jobs']) buildargs.append('--jobs=%s' % config['build-jobs'])
if opts.icecream or config['icecream'] != '0': if opts.icecream or config['icecream'] != '0':
if opts.icecream: if opts.icecream:
num = opts.icecream num = opts.icecream
@ -395,7 +395,7 @@ def main(apiurl, opts, argv):
num = config['icecream'] num = config['icecream']
if int(num) > 0: if int(num) > 0:
buildargs.append('--icecream %s' % num) buildargs.append('--icecream=%s' % num)
xp.append('icecream') xp.append('icecream')
xp.append('gcc-c++') xp.append('gcc-c++')
if opts.ccache: if opts.ccache:
@ -409,13 +409,12 @@ def main(apiurl, opts, argv):
buildargs.append('--debug') buildargs.append('--debug')
if opts._with: if opts._with:
for o in opts._with: for o in opts._with:
buildargs.append('--with %s' % o) buildargs.append('--with=%s' % o)
if opts.without: if opts.without:
for o in opts.without: for o in opts.without:
buildargs.append('--without %s' % o) buildargs.append('--without=%s' % o)
# FIXME: quoting if opts.define:
# if opts.define: buildargs.append('--define=%s' % opts.define)
# buildargs.append('--define "%s"' % opts.define)
if config['build-uid']: if config['build-uid']:
build_uid = config['build-uid'] build_uid = config['build-uid']
if opts.build_uid: if opts.build_uid:
@ -423,9 +422,9 @@ def main(apiurl, opts, argv):
if build_uid: if build_uid:
buildidre = re.compile('^[0-9]{1,5}:[0-9]{1,5}$') buildidre = re.compile('^[0-9]{1,5}:[0-9]{1,5}$')
if build_uid == 'caller': if build_uid == 'caller':
buildargs.append('--uid %s:%s' % (os.getuid(), os.getgid())) buildargs.append('--uid=%s:%s' % (os.getuid(), os.getgid()))
elif buildidre.match(build_uid): elif buildidre.match(build_uid):
buildargs.append('--uid %s' % build_uid) buildargs.append('--uid=%s' % build_uid)
else: else:
print >>sys.stderr, 'Error: build-uid arg must be 2 colon separated numerics: "uid:gid" or "caller"' print >>sys.stderr, 'Error: build-uid arg must be 2 colon separated numerics: "uid:gid" or "caller"'
return 1 return 1
@ -500,7 +499,7 @@ def main(apiurl, opts, argv):
build_descr_data = cpio.get() build_descr_data = cpio.get()
# special handling for overlay and rsync-src/dest # special handling for overlay and rsync-src/dest
specialcmdopts = '' specialcmdopts = []
if opts.rsyncsrc or opts.rsyncdest : if opts.rsyncsrc or opts.rsyncdest :
if not opts.rsyncsrc or not opts.rsyncdest: if not opts.rsyncsrc or not opts.rsyncdest:
raise oscerr.WrongOptions('When using --rsync-{src,dest} both parameters have to be specified.') raise oscerr.WrongOptions('When using --rsync-{src,dest} both parameters have to be specified.')
@ -511,12 +510,12 @@ def main(apiurl, opts, argv):
myrsyncdest = os.path.expandvars(opts.rsyncdest) myrsyncdest = os.path.expandvars(opts.rsyncdest)
if not os.path.isabs(myrsyncdest): if not os.path.isabs(myrsyncdest):
raise oscerr.WrongOptions('--rsync-dest %s is no absolute path (starting with \'/\')!' % opts.rsyncdest) raise oscerr.WrongOptions('--rsync-dest %s is no absolute path (starting with \'/\')!' % opts.rsyncdest)
specialcmdopts = '--rsync-src="%s" --rsync-dest="%s"' % (myrsyncsrc, myrsyncdest) specialcmdopts = ['--rsync-src='+myrsyncsrc, '--rsync-dest='+myrsyncdest]
if opts.overlay: if opts.overlay:
myoverlay = os.path.abspath(os.path.expanduser(os.path.expandvars(opts.overlay))) myoverlay = os.path.abspath(os.path.expanduser(os.path.expandvars(opts.overlay)))
if not os.path.isdir(myoverlay): if not os.path.isdir(myoverlay):
raise oscerr.WrongOptions('--overlay %s is no valid directory!' % opts.overlay) raise oscerr.WrongOptions('--overlay %s is no valid directory!' % opts.overlay)
specialcmdopts += '--overlay="%s"' % myoverlay specialcmdopts += ['--overlay='+myoverlay]
bi_file = None bi_file = None
bc_file = None bc_file = None
@ -601,7 +600,7 @@ def main(apiurl, opts, argv):
bi.release = opts.release bi.release = opts.release
if bi.release: if bi.release:
buildargs.append('--release %s' % bi.release) buildargs.append('--release=%s' % bi.release)
# real arch of this machine # real arch of this machine
# vs. # vs.
@ -720,7 +719,7 @@ def main(apiurl, opts, argv):
progress_meter = True) progress_meter = True)
if old_pkg_dir != None: if old_pkg_dir != None:
buildargs.append('--oldpackages %s' % old_pkg_dir) buildargs.append('--oldpackages=%s' % old_pkg_dir)
# Make packages from buildinfo available as repos for kiwi # Make packages from buildinfo available as repos for kiwi
if build_type == 'kiwi': if build_type == 'kiwi':
@ -789,7 +788,7 @@ def main(apiurl, opts, argv):
rpmlist_file.flush() rpmlist_file.flush()
subst = { 'repo': repo, 'arch': arch, 'project' : prj, 'package' : pacname } subst = { 'repo': repo, 'arch': arch, 'project' : prj, 'package' : pacname }
vm_options = '' vm_options = []
# XXX check if build-device present # XXX check if build-device present
my_build_device = '' my_build_device = ''
if config['build-device']: if config['build-device']:
@ -807,11 +806,11 @@ def main(apiurl, opts, argv):
else: else:
my_build_swap = build_root + '/swap' my_build_swap = build_root + '/swap'
vm_options = '--vm-type=%s'%vm_type vm_options = [ '--vm-type=%s'%vm_type ]
if vm_type != 'lxc': if vm_type != 'lxc':
vm_options += ' --vm-disk=' + my_build_device vm_options += [ '--vm-disk=' + my_build_device ]
vm_options += ' --vm-swap=' + my_build_swap vm_options += [ '--vm-swap=' + my_build_swap ]
vm_options += ' --logfile=%s/.build.log' % build_root vm_options += [ '--logfile=%s/.build.log' % build_root ]
if vm_type == 'kvm': if vm_type == 'kvm':
if os.access(build_root, os.W_OK) and os.access('/dev/kvm', os.W_OK): if os.access(build_root, os.W_OK) and os.access('/dev/kvm', os.W_OK):
# so let's hope there's also an fstab entry # so let's hope there's also an fstab entry
@ -819,49 +818,45 @@ def main(apiurl, opts, argv):
build_root += '/.mount' build_root += '/.mount'
if config['build-memory']: if config['build-memory']:
vm_options += ' --memory ' + config['build-memory'] vm_options += [ '--memory=' + config['build-memory'] ]
if config['build-vmdisk-rootsize']: if config['build-vmdisk-rootsize']:
vm_options += ' --vmdisk-rootsize ' + config['build-vmdisk-rootsize'] vm_options += [ '--vmdisk-rootsize=' + config['build-vmdisk-rootsize'] ]
if config['build-vmdisk-swapsize']: if config['build-vmdisk-swapsize']:
vm_options += ' --vmdisk-swapsize ' + config['build-vmdisk-swapsize'] vm_options += [ '--vmdisk-swapsize=' + config['build-vmdisk-swapsize'] ]
if opts.preload: if opts.preload:
print "Preload done for selected repo/arch." print "Preload done for selected repo/arch."
sys.exit(0) sys.exit(0)
print 'Running build' print 'Running build'
cmd = '"%s" --root="%s" --rpmlist="%s" --dist="%s" %s --arch=%s %s %s "%s"' \ cmd = [ config['build-cmd'], '--root='+build_root,
% (config['build-cmd'], '--rpmlist='+rpmlist_filename,
build_root, '--dist='+bc_filename,
rpmlist_filename, '--arch='+bi.buildarch ]
bc_filename, cmd += specialcmdopts + vm_options + buildargs
specialcmdopts, cmd += [ build_descr ]
bi.buildarch,
vm_options,
' '.join(buildargs),
build_descr)
if need_root: if need_root:
if config['su-wrapper'].startswith('su '): sucmd = config['su-wrapper'].split()
tmpl = '%s \'%s\'' if sucmd[0] == 'su':
cmd = sucmd + ['-s', cmd[0], 'root', '--' ] + cmd[1:]
else: else:
tmpl = '%s %s' cmd = sucmd + cmd
cmd = tmpl % (config['su-wrapper'], cmd)
# change personality, if needed # change personality, if needed
if hostarch != bi.buildarch: if hostarch != bi.buildarch and bi.buildarch in change_personality:
cmd = (change_personality.get(bi.buildarch, '') + ' ' + cmd).strip() cmd = [ change_personality[bi.buildarch] ] + cmd;
print cmd print cmd
try: try:
rc = subprocess.call(cmd, shell=True) rc = subprocess.call(cmd)
if rc: if rc:
print print
print 'The buildroot was:', build_root print 'The buildroot was:', build_root
sys.exit(rc) sys.exit(rc)
except KeyboardInterrupt, i: except KeyboardInterrupt, i:
print "keyboard interrupt, killing build ..." print "keyboard interrupt, killing build ..."
subprocess.call(cmd + " --kill", shell=True) subprocess.call(cmd + ["--kill"])
raise i raise i
pacdir = os.path.join(build_root, '.build.packages') pacdir = os.path.join(build_root, '.build.packages')

View File

@ -4147,9 +4147,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='enable feature X for build') help='enable feature X for build')
@cmdln.option('--without', metavar='X', action='append', @cmdln.option('--without', metavar='X', action='append',
help='disable feature X for build') help='disable feature X for build')
# will not work as build.py does not support proper quoting @cmdln.option('--define', metavar='\'X Y\'', action='append',
# @cmdln.option('--define', metavar='\'X Y\'', action='append', help='define macro X with value Y')
# help='define macro X with value Y')
@cmdln.option('--userootforbuild', action='store_true', @cmdln.option('--userootforbuild', action='store_true',
help='Run build as root. The default is to build as ' help='Run build as root. The default is to build as '
'unprivileged user. Note that a line "# norootforbuild" ' 'unprivileged user. Note that a line "# norootforbuild" '