diff --git a/osc/build.py b/osc/build.py index bc6528b7..7280c72e 100644 --- a/osc/build.py +++ b/osc/build.py @@ -20,7 +20,7 @@ from . import conf from . import connection from . import core from . import oscerr -from .core import get_buildinfo, store_read_project, store_read_package, meta_exists, quote_plus, get_buildconfig, is_package_dir, dgst +from .core import get_buildinfo, meta_exists, quote_plus, get_buildconfig, dgst from .core import get_binarylist, get_binary_file, run_external, return_external, raw_input from .fetch import Fetcher, OscFileGrabber, verify_pacs from .meter import create_text_meter @@ -595,12 +595,13 @@ def get_kiwipath_from_buildinfo(bi, prj, repo): return kiwipath -def calculate_prj_pac(opts, descr): - project = opts.alternative_project or store_read_project('.') +def calculate_prj_pac(store, opts, descr): + project = opts.alternative_project or store.project if opts.local_package: package = os.path.splitext(os.path.basename(descr))[0] else: - package = store_read_package('.') + store.assert_is_package() + package = store.package return project, package @@ -639,7 +640,7 @@ def run_build(opts, *args): return run_external(cmd[0], *cmd[1:]) -def main(apiurl, opts, argv): +def main(apiurl, store, opts, argv): repo = argv[0] arch = argv[1] @@ -768,11 +769,11 @@ def main(apiurl, opts, argv): prj = opts.alternative_project pac = '_repository' else: - prj = store_read_project(os.curdir) + prj = store.project if opts.local_package: pac = '_repository' else: - pac = store_read_package(os.curdir) + pac = store.package if opts.multibuild_package: buildargs.append('--buildflavor=%s' % opts.multibuild_package) pac = pac + ":" + opts.multibuild_package @@ -797,7 +798,7 @@ def main(apiurl, opts, argv): if pacname == '_repository': if not opts.local_package: try: - pacname = store_read_package(os.curdir) + pacname = store.package except oscerr.NoWorkingCopy: opts.local_package = True if opts.local_package: @@ -834,7 +835,7 @@ def main(apiurl, opts, argv): bc_file = None bi_filename = '_buildinfo-%s-%s.xml' % (repo, arch) bc_filename = '_buildconfig-%s-%s' % (repo, arch) - if is_package_dir('.') and os.access(core.store, os.W_OK): + if store.is_package and os.access(core.store, os.W_OK): bi_filename = os.path.join(os.getcwd(), core.store, bi_filename) bc_filename = os.path.join(os.getcwd(), core.store, bc_filename) elif not os.access('.', os.W_OK): @@ -859,7 +860,7 @@ def main(apiurl, opts, argv): if opts.noinit: buildargs.append('--noinit') - if not is_package_dir('.'): + if not store.is_package: opts.noservice = True # check for source services @@ -1481,8 +1482,8 @@ def main(apiurl, opts, argv): cmd = [change_personality[bi.buildarch]] + cmd # record our settings for later builds - if is_package_dir(os.curdir): - core.store_write_last_buildroot(os.curdir, repo, arch, vm_type) + if store.is_package: + store.last_buildroot = repo, arch, vm_type try: rc = run_external(cmd[0], *cmd[1:]) diff --git a/osc/commandline.py b/osc/commandline.py index df103abb..906b4751 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -7199,25 +7199,17 @@ Please submit there instead, or use --nodevelproject to force direct submission. if len(args) > 3: raise oscerr.WrongArgs('Too many arguments') - project = None - try: - project = store_read_project(Path.cwd()) - if project == opts.alternative_project: - opts.alternative_project = None - except oscerr.NoWorkingCopy: - # This may be a project managed entirely via git? - if os.path.isdir(Path.cwd().parent / '.osc') and os.path.isdir(Path.cwd().parent / '.git'): - project = store_read_project(Path.cwd()) - opts.alternative_project = project - pass + store = osc_store.Store(Path.cwd()) + store.assert_is_package() - if len(args) == 0 and is_package_dir(Path.cwd()): + if opts.alternative_project == store.project: + opts.alternative_project = None + + if len(args) == 0 and store.is_package and store.last_buildroot: # build env not specified, just read from last build attempt - lastbuildroot = store_read_last_buildroot(Path.cwd()) - if lastbuildroot: - args = [lastbuildroot[0], lastbuildroot[1]] - if not opts.vm_type: - opts.vm_type = lastbuildroot[2] + args = [store.last_buildroot[0], store.last_buildroot[1]] + if not opts.vm_type: + opts.vm_type = store.last_buildroot[2] vm_chroot = opts.vm_type or conf.config['build-type'] if (subcmd in ('shell', 'chroot') or opts.shell or opts.wipe) and not vm_chroot: @@ -7226,7 +7218,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. else: args = self.parse_repoarchdescr(args, opts.noinit or opts.offline, opts.alternative_project, False, opts.vm_type, opts.multibuild_package) repo, arch, build_descr = args - prj, pac = osc_build.calculate_prj_pac(opts, build_descr) + prj, pac = osc_build.calculate_prj_pac(store, opts, build_descr) apihost = urlsplit(self.get_api_url())[1] build_root = osc_build.calculate_build_root(apihost, prj, pac, repo, arch) @@ -7250,12 +7242,12 @@ Please submit there instead, or use --nodevelproject to force direct submission. if not opts.local_package: try: - package = store_read_package(Path.cwd()) prj = Project(os.pardir, getPackageList=False, wc_check=False) - if prj.status(package) == 'A': + if prj.status(store.package) == "A": # a package with state 'A' most likely does not exist on # the server - hence, treat it as a local package opts.local_package = True + print("INFO: Building the package as a local package.", file=sys.stderr) except oscerr.NoWorkingCopy: pass @@ -7284,7 +7276,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. print('Building %s for %s/%s' % (args[2], args[0], args[1])) if not opts.host: - return osc_build.main(self.get_api_url(), opts, args) + return osc_build.main(self.get_api_url(), store, opts, args) else: return self._do_rbuild(subcmd, opts, *args)