From 08979fb0ebdf884db8cc63e0d00f2c4cc76dfe11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Thu, 25 Mar 2021 13:37:49 +0100 Subject: [PATCH] do not use preinstallimages when building as non-root it can not work and build script will direct complain in future --- osc/build.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/osc/build.py b/osc/build.py index 55a69a4a..0986a6a8 100644 --- a/osc/build.py +++ b/osc/build.py @@ -547,10 +547,12 @@ def calculate_build_root(apihost, prj, pac, repo, arch): % {'repo': repo, 'arch': arch, 'project': prj, 'package': pac, 'apihost': apihost} return buildroot -def run_build(opts, *args): - cmd = [config['build-cmd']] - cmd += args +def build_as_user(): + if os.environ.get('OSC_SU_WRAPPER', config['su-wrapper']).split(): + return False + return True +def su_wrapper(cmd): sucmd = os.environ.get('OSC_SU_WRAPPER', config['su-wrapper']).split() if sucmd: if sucmd[0] == 'su': @@ -559,6 +561,14 @@ def run_build(opts, *args): cmd = sucmd + ['-s', cmd[0], 'root', '--'] + cmd[1:] else: cmd = sucmd + cmd + return cmd + +def run_build(opts, *args): + cmd = [config['build-cmd']] + cmd += args + + cmd = su_wrapper(cmd) + if not opts.userootforbuild: cmd.append('--norootforbuild') return run_external(cmd[0], *cmd[1:]) @@ -1007,6 +1017,9 @@ def main(apiurl, opts, argv): imagefile = '' imagesource = '' imagebins = [] + if build_as_user(): + # preinstallimage extraction will fail + bi.preinstallimage = None if (not config['no_preinstallimage'] and not opts.nopreinstallimage and bi.preinstallimage and not opts.noinit and @@ -1336,14 +1349,7 @@ def main(apiurl, opts, argv): cmd += specialcmdopts + vm_options + buildargs cmd += [ build_descr ] - sucmd = config['su-wrapper'].split() - if sucmd: - if sucmd[0] == 'su': - if sucmd[-1] == '-c': - sucmd.pop() - cmd = sucmd + ['-s', cmd[0], 'root', '--' ] + cmd[1:] - else: - cmd = sucmd + cmd + cmd = su_wrapper(cmd) # change personality, if needed if hostarch != bi.buildarch and bi.buildarch in change_personality: