mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-03 18:16:17 +01:00
Merge pull request #1369 from dmach/build-store-object
Change osc.build module to use 'store' object instead of calling core.store_*() functions
This commit is contained in:
commit
87d1c489f2
25
osc/build.py
25
osc/build.py
@ -20,7 +20,7 @@ from . import conf
|
|||||||
from . import connection
|
from . import connection
|
||||||
from . import core
|
from . import core
|
||||||
from . import oscerr
|
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 .core import get_binarylist, get_binary_file, run_external, return_external, raw_input
|
||||||
from .fetch import Fetcher, OscFileGrabber, verify_pacs
|
from .fetch import Fetcher, OscFileGrabber, verify_pacs
|
||||||
from .meter import create_text_meter
|
from .meter import create_text_meter
|
||||||
@ -595,12 +595,13 @@ def get_kiwipath_from_buildinfo(bi, prj, repo):
|
|||||||
return kiwipath
|
return kiwipath
|
||||||
|
|
||||||
|
|
||||||
def calculate_prj_pac(opts, descr):
|
def calculate_prj_pac(store, opts, descr):
|
||||||
project = opts.alternative_project or store_read_project('.')
|
project = opts.alternative_project or store.project
|
||||||
if opts.local_package:
|
if opts.local_package:
|
||||||
package = os.path.splitext(os.path.basename(descr))[0]
|
package = os.path.splitext(os.path.basename(descr))[0]
|
||||||
else:
|
else:
|
||||||
package = store_read_package('.')
|
store.assert_is_package()
|
||||||
|
package = store.package
|
||||||
return project, package
|
return project, package
|
||||||
|
|
||||||
|
|
||||||
@ -639,7 +640,7 @@ def run_build(opts, *args):
|
|||||||
return run_external(cmd[0], *cmd[1:])
|
return run_external(cmd[0], *cmd[1:])
|
||||||
|
|
||||||
|
|
||||||
def main(apiurl, opts, argv):
|
def main(apiurl, store, opts, argv):
|
||||||
|
|
||||||
repo = argv[0]
|
repo = argv[0]
|
||||||
arch = argv[1]
|
arch = argv[1]
|
||||||
@ -768,11 +769,11 @@ def main(apiurl, opts, argv):
|
|||||||
prj = opts.alternative_project
|
prj = opts.alternative_project
|
||||||
pac = '_repository'
|
pac = '_repository'
|
||||||
else:
|
else:
|
||||||
prj = store_read_project(os.curdir)
|
prj = store.project
|
||||||
if opts.local_package:
|
if opts.local_package:
|
||||||
pac = '_repository'
|
pac = '_repository'
|
||||||
else:
|
else:
|
||||||
pac = store_read_package(os.curdir)
|
pac = store.package
|
||||||
if opts.multibuild_package:
|
if opts.multibuild_package:
|
||||||
buildargs.append('--buildflavor=%s' % opts.multibuild_package)
|
buildargs.append('--buildflavor=%s' % opts.multibuild_package)
|
||||||
pac = pac + ":" + opts.multibuild_package
|
pac = pac + ":" + opts.multibuild_package
|
||||||
@ -797,7 +798,7 @@ def main(apiurl, opts, argv):
|
|||||||
if pacname == '_repository':
|
if pacname == '_repository':
|
||||||
if not opts.local_package:
|
if not opts.local_package:
|
||||||
try:
|
try:
|
||||||
pacname = store_read_package(os.curdir)
|
pacname = store.package
|
||||||
except oscerr.NoWorkingCopy:
|
except oscerr.NoWorkingCopy:
|
||||||
opts.local_package = True
|
opts.local_package = True
|
||||||
if opts.local_package:
|
if opts.local_package:
|
||||||
@ -834,7 +835,7 @@ def main(apiurl, opts, argv):
|
|||||||
bc_file = None
|
bc_file = None
|
||||||
bi_filename = '_buildinfo-%s-%s.xml' % (repo, arch)
|
bi_filename = '_buildinfo-%s-%s.xml' % (repo, arch)
|
||||||
bc_filename = '_buildconfig-%s-%s' % (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)
|
bi_filename = os.path.join(os.getcwd(), core.store, bi_filename)
|
||||||
bc_filename = os.path.join(os.getcwd(), core.store, bc_filename)
|
bc_filename = os.path.join(os.getcwd(), core.store, bc_filename)
|
||||||
elif not os.access('.', os.W_OK):
|
elif not os.access('.', os.W_OK):
|
||||||
@ -859,7 +860,7 @@ def main(apiurl, opts, argv):
|
|||||||
if opts.noinit:
|
if opts.noinit:
|
||||||
buildargs.append('--noinit')
|
buildargs.append('--noinit')
|
||||||
|
|
||||||
if not is_package_dir('.'):
|
if not store.is_package:
|
||||||
opts.noservice = True
|
opts.noservice = True
|
||||||
|
|
||||||
# check for source services
|
# check for source services
|
||||||
@ -1481,8 +1482,8 @@ def main(apiurl, opts, argv):
|
|||||||
cmd = [change_personality[bi.buildarch]] + cmd
|
cmd = [change_personality[bi.buildarch]] + cmd
|
||||||
|
|
||||||
# record our settings for later builds
|
# record our settings for later builds
|
||||||
if is_package_dir(os.curdir):
|
if store.is_package:
|
||||||
core.store_write_last_buildroot(os.curdir, repo, arch, vm_type)
|
store.last_buildroot = repo, arch, vm_type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rc = run_external(cmd[0], *cmd[1:])
|
rc = run_external(cmd[0], *cmd[1:])
|
||||||
|
@ -7197,25 +7197,17 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
if len(args) > 3:
|
if len(args) > 3:
|
||||||
raise oscerr.WrongArgs('Too many arguments')
|
raise oscerr.WrongArgs('Too many arguments')
|
||||||
|
|
||||||
project = None
|
store = osc_store.Store(Path.cwd())
|
||||||
try:
|
store.assert_is_package()
|
||||||
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
|
|
||||||
|
|
||||||
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
|
# build env not specified, just read from last build attempt
|
||||||
lastbuildroot = store_read_last_buildroot(Path.cwd())
|
args = [store.last_buildroot[0], store.last_buildroot[1]]
|
||||||
if lastbuildroot:
|
if not opts.vm_type:
|
||||||
args = [lastbuildroot[0], lastbuildroot[1]]
|
opts.vm_type = store.last_buildroot[2]
|
||||||
if not opts.vm_type:
|
|
||||||
opts.vm_type = lastbuildroot[2]
|
|
||||||
|
|
||||||
vm_chroot = opts.vm_type or conf.config['build-type']
|
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:
|
if (subcmd in ('shell', 'chroot') or opts.shell or opts.wipe) and not vm_chroot:
|
||||||
@ -7224,7 +7216,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
else:
|
else:
|
||||||
args = self.parse_repoarchdescr(args, opts.noinit or opts.offline, opts.alternative_project, False, opts.vm_type, opts.multibuild_package)
|
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
|
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]
|
apihost = urlsplit(self.get_api_url())[1]
|
||||||
build_root = osc_build.calculate_build_root(apihost, prj, pac, repo,
|
build_root = osc_build.calculate_build_root(apihost, prj, pac, repo,
|
||||||
arch)
|
arch)
|
||||||
@ -7248,12 +7240,12 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
|
|
||||||
if not opts.local_package:
|
if not opts.local_package:
|
||||||
try:
|
try:
|
||||||
package = store_read_package(Path.cwd())
|
|
||||||
prj = Project(os.pardir, getPackageList=False, wc_check=False)
|
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
|
# a package with state 'A' most likely does not exist on
|
||||||
# the server - hence, treat it as a local package
|
# the server - hence, treat it as a local package
|
||||||
opts.local_package = True
|
opts.local_package = True
|
||||||
|
print("INFO: Building the package as a local package.", file=sys.stderr)
|
||||||
except oscerr.NoWorkingCopy:
|
except oscerr.NoWorkingCopy:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -7282,7 +7274,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
|
|
||||||
print('Building %s for %s/%s' % (args[2], args[0], args[1]))
|
print('Building %s for %s/%s' % (args[2], args[0], args[1]))
|
||||||
if not opts.host:
|
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:
|
else:
|
||||||
return self._do_rbuild(subcmd, opts, *args)
|
return self._do_rbuild(subcmd, opts, *args)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user