Skip to content

Commit 799b45a

Browse files
committed
Fix osc build --local-package
Check if opts.local_package is set before attempting to read content of the local package store or access data obtained from it. This fixes issue openSUSE#1612. Signed-off-by: Egbert Eich <[email protected]>
1 parent 9d76d1d commit 799b45a

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

osc/build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ def main(apiurl, store, opts, argv):
925925
bc_file = None
926926
bi_filename = '_buildinfo-%s-%s.xml' % (repo, arch)
927927
bc_filename = '_buildconfig-%s-%s' % (repo, arch)
928-
if store.is_package and os.access(core.store, os.W_OK):
928+
if not opts.local_package and store.is_package and os.access(core.store, os.W_OK):
929929
bi_filename = os.path.join(os.getcwd(), core.store, bi_filename)
930930
bc_filename = os.path.join(os.getcwd(), core.store, bc_filename)
931931
elif not os.access('.', os.W_OK):
@@ -950,7 +950,7 @@ def main(apiurl, store, opts, argv):
950950
if opts.noinit:
951951
buildargs.append('--noinit')
952952

953-
if not store.is_package:
953+
if opts.local_package or not store.is_package:
954954
opts.skip_local_service_run = True
955955

956956
# check for source services
@@ -1551,7 +1551,7 @@ def __str__(self):
15511551
cmd = [change_personality[bi.buildarch]] + cmd
15521552

15531553
# record our settings for later builds
1554-
if store.is_package:
1554+
if not opts.local_package and store.is_package:
15551555
store.last_buildroot = repo, arch, vm_type
15561556

15571557
try:

osc/commandline.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7388,22 +7388,28 @@ def do_build(self, subcmd, opts, *args):
73887388
if len(args) > 3:
73897389
raise oscerr.WrongArgs('Too many arguments')
73907390

7391-
store = osc_store.get_store(Path.cwd(), print_warnings=True)
7392-
store.assert_is_package()
7391+
if not opts.local_package:
7392+
store = osc_store.get_store(Path.cwd(), print_warnings=True)
7393+
store.assert_is_package()
73937394

7394-
try:
7395-
if opts.alternative_project and opts.alternative_project == store.project:
7396-
opts.alternative_project = None
7397-
except RuntimeError:
7395+
try:
7396+
if opts.alternative_project and opts.alternative_project == store.project:
7397+
opts.alternative_project = None
7398+
except RuntimeError:
73987399
# ignore the following exception: Couldn't map git branch '<BRANCH>' to a project
7399-
pass
7400+
pass
7401+
else:
7402+
try:
7403+
store = osc_store.get_store(os.path.dirname(Path.cwd()), print_warnings=True)
7404+
except oscerr.NoWorkingCopy:
7405+
store = None
74007406

74017407
# HACK: avoid calling some underlying store_*() functions from parse_repoarchdescr() method
74027408
# We'll fix parse_repoarchdescr() later because it requires a larger change
74037409
if not opts.alternative_project and isinstance(store, git_scm.GitStore):
74047410
opts.alternative_project = store.project
74057411

7406-
if len(args) == 0 and store.is_package and store.last_buildroot:
7412+
if len(args) == 0 and store and store.is_package and store.last_buildroot:
74077413
# build env not specified, just read from last build attempt
74087414
args = [store.last_buildroot[0], store.last_buildroot[1]]
74097415
if not opts.vm_type:

0 commit comments

Comments
 (0)