1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-12 16:56:15 +01:00

allow to run build script as user

works only with kvm atm, we should maybe point the user to it in that
case?

Requires: https://github.com/openSUSE/obs-build/pull/678/files
This commit is contained in:
Adrian Schröter 2021-03-19 12:51:56 +01:00
parent 2bc186d0ea
commit 4907982d42
3 changed files with 17 additions and 12 deletions

1
NEWS
View File

@ -4,6 +4,7 @@
- add build --stage flag. Useful for example for fixing file lists and just
running the install section to see the result of it (use --stage=i=).
Check the help for more details.
- allow to run build script as non-root, by setting su-wrapper empty
0.172.0
- support --lastsucceeded/--last-succeeded in "osc buildlog", "osc

View File

@ -552,12 +552,13 @@ def run_build(opts, *args):
cmd += args
sucmd = os.environ.get('OSC_SU_WRAPPER', config['su-wrapper']).split()
if sucmd[0] == 'su':
if sucmd[-1] == '-c':
sucmd.pop()
cmd = sucmd + ['-s', cmd[0], 'root', '--'] + cmd[1:]
else:
cmd = sucmd + cmd
if sucmd:
if sucmd[0] == 'su':
if sucmd[-1] == '-c':
sucmd.pop()
cmd = sucmd + ['-s', cmd[0], 'root', '--'] + cmd[1:]
else:
cmd = sucmd + cmd
if not opts.userootforbuild:
cmd.append('--norootforbuild')
return run_external(cmd[0], *cmd[1:])
@ -1341,12 +1342,13 @@ def main(apiurl, opts, argv):
if need_root:
sucmd = config['su-wrapper'].split()
if sucmd[0] == 'su':
if sucmd[-1] == '-c':
sucmd.pop()
cmd = sucmd + ['-s', cmd[0], 'root', '--' ] + cmd[1:]
else:
cmd = sucmd + cmd
if sucmd:
if sucmd[0] == 'su':
if sucmd[-1] == '-c':
sucmd.pop()
cmd = sucmd + ['-s', cmd[0], 'root', '--' ] + cmd[1:]
else:
cmd = sucmd + cmd
# change personality, if needed
if hostarch != bi.buildarch and bi.buildarch in change_personality:

View File

@ -219,6 +219,8 @@ apiurl = %(apiurl)s
# Wrapper to call build as root (sudo, su -, ...)
#su-wrapper = %(su-wrapper)s
# set it empty to run build script as user (works only with KVM atm):
#su-wrapper =
# rootdir to setup the chroot environment
# can contain %%(repo)s, %%(arch)s, %%(project)s, %%(package)s and %%(apihost)s (apihost is the hostname