From b329b748162899d6ed837b62efc9d3f14567b843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Wed, 4 Dec 2019 09:45:17 +0100 Subject: [PATCH] build environement parameter caching repository, architecture and vm_type from last build is automatically reused if not specified otherwise. --- NEWS | 11 +++++++---- osc/build.py | 5 ++++- osc/commandline.py | 11 ++++++++++- osc/core.py | 16 +++++++++++++++- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 1f3f2a75..869b25d0 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,12 @@ 0.167 - osc shell/chroot/wipe is now handled via build script (working for chroot and KVM only atm) - - osc build --vm-type=qemu support for cross architecture builds - - osc build is reading debug packages from prjconf now - (extra-pkgs definition is therefore by default empty) - - osc build --vm-disk-size= switch support + - osc build/shell features: + * --vm-type=qemu support for cross architecture builds + * additional debug packages are read from build config now + (extra-pkgs definition is therefore by default empty now) + * --vm-disk-size= switch supported (has only an effect on clean builds) + * repository, architecture and vm_type from last build is automatically + reused if not specified otherwise. 0.166.2 - Don't enforce password reuse (boo#1156501) diff --git a/osc/build.py b/osc/build.py index 6d991a2b..75fd9777 100644 --- a/osc/build.py +++ b/osc/build.py @@ -705,7 +705,7 @@ def main(apiurl, opts, argv): # check for source services if not opts.offline and not opts.noservice: - p = Package('.') + p = osc.core.Package(os.curdir) r = p.run_source_services(verbose=True) if r: raise oscerr.ServiceRuntimeError('Source service run failed!') @@ -1275,6 +1275,9 @@ def main(apiurl, opts, argv): if hostarch != bi.buildarch and bi.buildarch in change_personality: cmd = [ change_personality[bi.buildarch] ] + cmd + # record our settings for later builds + osc.core.store_write_last_buildroot(os.curdir, repo, arch, vm_type) + try: rc = run_external(cmd[0], *cmd[1:]) if rc: diff --git a/osc/commandline.py b/osc/commandline.py index 6c38e5c1..04704b81 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -6115,7 +6115,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. # it seems to be an architecture in general arg_arch = arg if not (arg == osc.build.hostarch or arg in osc.build.can_also_build.get(osc.build.hostarch, [])): - print("WARNING: native compile is not possible, an emulator must be configured!") + if not (vm_type == 'qemu' or vm_type == 'emulator'): + print("WARNING: native compile is not possible, a emulator via binfmt misc handler must be configured!") elif not arg_repository: arg_repository = arg else: @@ -6439,6 +6440,14 @@ Please submit there instead, or use --nodevelproject to force direct submission. if project == opts.alternative_project: opts.alternative_project = None + if len(args) == 0: + # build env not specified, just read from last build attempt + lastbuildroot = store_read_last_buildroot(os.curdir) + if lastbuildroot: + args = [ lastbuildroot[0], lastbuildroot[1] ] + if not opts.vm_type: + opts.vm_type = lastbuildroot[2] + args = self.parse_repoarchdescr(args, opts.noinit or opts.offline, opts.alternative_project, False, opts.vm_type, opts.multibuild_package) if not opts.local_package: diff --git a/osc/core.py b/osc/core.py index b1289e48..361bae5e 100644 --- a/osc/core.py +++ b/osc/core.py @@ -1140,7 +1140,7 @@ class Package: REQ_STOREFILES = ('_project', '_package', '_apiurl', '_files', '_osclib_version') OPT_STOREFILES = ('_to_be_added', '_to_be_deleted', '_in_conflict', '_in_update', '_in_commit', '_meta', '_meta_mode', '_frozenlink', '_pulled', '_linkrepair', - '_size_limit', '_commit_msg') + '_size_limit', '_commit_msg', '_last_buildroot') def __init__(self, workingdir, progress_obj=None, size_limit=None, wc_check=True): global store @@ -6508,6 +6508,17 @@ def store_read_apiurl(dir, defaulturl=True): apiurl = conf.config['apiurl'] return apiurl +def store_read_last_buildroot(dir): + global store + + fname = os.path.join(dir, store, '_last_buildroot') + if os.path.exists(fname): + lines = open(fname).read().splitlines() + if len(lines) == 3: + return lines + + return + def store_write_string(dir, file, string, subdir=''): global store @@ -6532,6 +6543,9 @@ def store_write_project(dir, project): def store_write_apiurl(dir, apiurl): store_write_string(dir, '_apiurl', apiurl + '\n') +def store_write_last_buildroot(dir, repo, arch, vm_type): + store_write_string(dir, '_last_buildroot', repo + '\n' + arch + '\n' + vm_type + '\n') + def store_unlink_file(dir, file): global store