From c06b794ddf6e48c8a02db0d10e424fd4b2286e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Thu, 11 Feb 2021 10:58:40 +0100 Subject: [PATCH] support osc build --shell-after-fail from build script --- NEWS | 1 + osc/build.py | 6 ++++++ osc/commandline.py | 5 ++++- osc/conf.py | 6 +++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 366c05d0..3b9b2495 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ 0.173.0 - add showlinked command to show all references of packages linking to a given one + - add build --shell-after-build flag. It can also be set via .oscrc. 0.172.0 - support --lastsucceeded/--last-succeeded in "osc buildlog", "osc diff --git a/osc/build.py b/osc/build.py index 9b040a9c..e26c7a7a 100644 --- a/osc/build.py +++ b/osc/build.py @@ -571,6 +571,7 @@ def main(apiurl, opts, argv): build_root = None cache_dir = None build_uid = '' + build_shell_after_fail = config['build-shell-after-fail'] vm_memory = config['build-memory'] vm_disk_size = config['build-vmdisk-rootsize'] vm_type = config['build-type'] @@ -665,6 +666,8 @@ def main(apiurl, opts, argv): else: print('Error: build-uid arg must be 2 colon separated numerics: "uid:gid" or "caller"', file=sys.stderr) return 1 + if opts.shell_after_fail: + build_shell_after_fail = opts.shell_after_fail if opts.vm_memory: vm_memory = opts.vm_memory if opts.vm_disk_size: @@ -740,6 +743,9 @@ def main(apiurl, opts, argv): if opts.shell: buildargs.append("--shell") + if build_shell_after_fail: + buildargs.append("--shell-after-fail") + if opts.shell_cmd: buildargs.append("--shell-cmd") buildargs.append(opts.shell_cmd) diff --git a/osc/commandline.py b/osc/commandline.py index 162de1eb..e05d4d34 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -771,7 +771,7 @@ class Osc(cmdln.Cmdln): @cmdln.option('-d', '--delete', metavar='TOKENID', help='Delete a token') @cmdln.option('-o', '--operation', metavar='OPERATION', - help='Default is "runservice", but "release" or "rebuild" can also be used') + help='Default is "runservice", but "branch", "release" or "rebuild" can also be used') @cmdln.option('-t', '--trigger', metavar='TOKENSTRING', help='Trigger the action of a token') def do_token(self, subcmd, opts, *args): @@ -6512,6 +6512,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. help=SUPPRESS_HELP) @cmdln.option('--shell', action='store_true', help=SUPPRESS_HELP) + @cmdln.option('--shell-after-fail', action='store_true', + help="run a shell if the build tool fails") @cmdln.option('--shell-cmd', metavar='COMMAND', help='run specified command instead of bash') @cmdln.option('-f', '--force', action='store_true', @@ -6571,6 +6573,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. --noinit # for faster run --shell-cmd=COMMAND + --shell-after-fail --extra-pkgs=PACKAGE # install additional packages To clean up the build environment run diff --git a/osc/conf.py b/osc/conf.py index d0cf6869..22a616d2 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -108,6 +108,7 @@ DEFAULTS = {'apiurl': 'https://api.opensuse.org', 'build-uid': '', # use the default provided by build 'build-device': '', # required for VM builds 'build-memory': '', # required for VM builds + 'build-shell-after-fail': '0', # optional for VM builds 'build-swap': '', # optional for VM builds 'build-vmdisk-rootsize': '', # optional for VM builds 'build-vmdisk-swapsize': '', # optional for VM builds @@ -201,7 +202,7 @@ boolean_opts = ['debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'tr 'checkout_no_colon', 'checkout_rooted', 'check_for_request_on_action', 'linkcontrol', 'show_download_progress', 'request_show_interactive', 'request_show_source_buildstatus', 'review_inherit_group', 'use_keyring', 'gnome_keyring', 'no_verify', 'builtin_signature_check', 'http_full_debug', 'include_request_from_project', 'local_service_run', 'buildlog_strip_time', 'no_preinstallimage', - 'status_mtime_heuristic', 'print_web_links', 'ccache'] + 'status_mtime_heuristic', 'print_web_links', 'ccache', 'build-shell-after-fail'] integer_opts = ['build-jobs'] api_host_options = ['user', 'pass', 'passx', 'aliases', 'http_headers', 'realname', 'email', 'sslcertck', 'cafile', 'capath', 'trusted_prj'] @@ -238,6 +239,9 @@ apiurl = %(apiurl)s # lxc - lxc build #build-type = +# Execute always a shell prompt on build failure inside of the build environment +#build-shell-after-fail = 1 + # build-device is the disk-image file to use as root for VM builds # e.g. /var/tmp/FILE.root #build-device = /var/tmp/FILE.root